skills/ipc/SKILL.md
Use when implementing inter-process communication, shared memory regions, SPSC or MPMC ring buffers, zero-copy data transfer, platform synchronization primitives, or process notification mechanisms.
npx skillsauth add cofin/flow ipcInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
shm_open + mmap, Windows CreateFileMapping).pub struct ShmRegion {
ptr: *mut u8,
len: usize,
fd: OwnedFd, // RAII: closes on drop
}
impl ShmRegion {
pub fn create(name: &str, size: usize) -> Result<Self, IpcError> {
// SAFETY: shm_open + ftruncate + mmap is the standard POSIX pattern.
// We own the fd exclusively and unlink after mapping.
unsafe {
let fd = shm_open(name, O_CREAT | O_RDWR, 0o600)?;
ftruncate(fd, size as libc::off_t)?;
let ptr = mmap(
std::ptr::null_mut(),
size,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fd,
0,
)?;
shm_unlink(name)?; // Unlink immediately — fd keeps it alive
Ok(Self { ptr: ptr.cast(), len: size, fd: OwnedFd(fd) })
}
}
pub fn as_slice(&self) -> &[u8] {
// SAFETY: ptr is valid for len bytes and region outlives self
unsafe { std::slice::from_raw_parts(self.ptr, self.len) }
}
}
impl Drop for ShmRegion {
fn drop(&mut self) {
// SAFETY: We own this mapping exclusively
unsafe { munmap(self.ptr.cast(), self.len) };
// fd closed by OwnedFd::drop
}
}
</example>
<guardrails>
## Guardrails
shm_unlink as soon as the memory is mapped to ensure it is correctly cleaned up by the OS when the process exits.Drop to prevent resource leaks on crash or error.Drop for all resourcesAcquire/Release)
</validation>
testing
Use when syncing Beads state to markdown, checking Flow status, refreshing context docs, validating task markers, or reporting ready/blocked Flow work.
testing
Use when initializing Flow in a repo, configuring .agents, installing or checking Beads bd, setting local-only sync policy, or creating first project context files.
data-ai
Use when drafting PRDs, researching, planning, refining, revising, or creating .agents/specs/<flow_id>/spec.md worksheets for Flow.
testing
Use when implementing Flow tasks from Beads or spec.md, claiming ready work, applying TDD, recording task notes, committing, and syncing after task state changes.