{"id":"2e119814-d605-4a04-a7e5-c3cf375163bf","shortId":"YWzGum","kind":"skill","title":"ipc","tagline":"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.","description":"# IPC (Inter-Process Communication)\n\n## Scope\n\n- Shared memory regions (POSIX `shm_open` + `mmap`, Windows `CreateFileMapping`).\n- Lock-free ring buffers (SPSC, MPMC).\n- Platform-specific synchronization (futex, ulock, Win32 Event).\n- Notification mechanisms (eventfd, pipe, kqueue).\n- Async ring integration with Tokio.\n- Buffer pools and zero-copy data transfer.\n\n<workflow>\n\n## Shared Memory Regions\n\n### ShmRegion Pattern\n\n<example>\n\n```rust\npub struct ShmRegion {\n    ptr: *mut u8,\n    len: usize,\n    fd: OwnedFd,  // RAII: closes on drop\n}\n\nimpl ShmRegion {\n    pub fn create(name: &str, size: usize) -> Result<Self, IpcError> {\n        // SAFETY: shm_open + ftruncate + mmap is the standard POSIX pattern.\n        // We own the fd exclusively and unlink after mapping.\n        unsafe {\n            let fd = shm_open(name, O_CREAT | O_RDWR, 0o600)?;\n            ftruncate(fd, size as libc::off_t)?;\n            let ptr = mmap(\n                std::ptr::null_mut(),\n                size,\n                PROT_READ | PROT_WRITE,\n                MAP_SHARED,\n                fd,\n                0,\n            )?;\n            shm_unlink(name)?;  // Unlink immediately — fd keeps it alive\n            Ok(Self { ptr: ptr.cast(), len: size, fd: OwnedFd(fd) })\n        }\n    }\n\n    pub fn as_slice(&self) -> &[u8] {\n        // SAFETY: ptr is valid for len bytes and region outlives self\n        unsafe { std::slice::from_raw_parts(self.ptr, self.len) }\n    }\n}\n\nimpl Drop for ShmRegion {\n    fn drop(&mut self) {\n        // SAFETY: We own this mapping exclusively\n        unsafe { munmap(self.ptr.cast(), self.len) };\n        // fd closed by OwnedFd::drop\n    }\n}\n```\n\n</example>\n\n<guardrails>\n## Guardrails\n\n- **Always unlink shared memory immediately** -- Use `shm_unlink` as soon as the memory is mapped to ensure it is correctly cleaned up by the OS when the process exits.\n- **Use RAII for all resources** -- Wrap pointers, file descriptors, and mapping handles in structs that implement `Drop` to prevent resource leaks on crash or error.\n- **Align to page boundaries** -- Shared memory region sizes should always be a multiple of the system page size (typically 4096 bytes) for optimal mapping.\n- **Capacity must be a power of two** -- For ring buffers, this allows for fast indexing using bitwise AND instead of expensive modulo operations.\n- **Align headers to cache lines (64 bytes)** -- This prevents false sharing between producers and consumers on different CPU cores.\n</guardrails>\n\n<validation>\n## Validation Checkpoint\n\n- [ ] Shared memory is unlinked immediately after mapping\n- [ ] RAII cleanup logic is implemented in `Drop` for all resources\n- [ ] Ring buffer capacity is a power of two\n- [ ] Headers are cache-line aligned (64 bytes) with explicit padding\n- [ ] Bounds checks are performed on all reads and writes from shared memory\n- [ ] Atomic memory ordering is correctly applied (`Acquire`/`Release`)\n</validation>","tags":["ipc","flow","cofin","agent-skills","ai-agents","beads","claude-code","codex","cursor","developer-tools","gemini-cli","opencode"],"capabilities":["skill","source-cofin","skill-ipc","topic-agent-skills","topic-ai-agents","topic-beads","topic-claude-code","topic-codex","topic-cursor","topic-developer-tools","topic-gemini-cli","topic-opencode","topic-plugin","topic-slash-commands","topic-spec-driven-development"],"categories":["flow"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/cofin/flow/ipc","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add cofin/flow","source_repo":"https://github.com/cofin/flow","install_from":"skills.sh"}},"qualityScore":"0.455","qualityRationale":"deterministic score 0.46 from registry signals: · indexed on github topic:agent-skills · 11 github stars · SKILL.md body (2,938 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T19:07:37.725Z","embedding":null,"createdAt":"2026-04-23T13:03:59.898Z","updatedAt":"2026-05-18T19:07:37.725Z","lastSeenAt":"2026-05-18T19:07:37.725Z","tsv":"'0':161 '0o600':138 '4096':302 '64':335,382 'acquir':405 'align':283,330,381 'aliv':170 'allow':318 'alway':229,292 'appli':404 'async':64 'atom':399 'bitwis':323 'bound':387 'boundari':286 'buffer':16,48,69,316,369 'byte':192,303,336,383 'cach':333,379 'cache-lin':378 'capac':307,370 'check':388 'checkpoint':350 'clean':249 'cleanup':359 'close':94,224 'communic':8,33 'consum':344 'copi':19,74 'core':348 'correct':248,403 'cpu':347 'crash':280 'creat':101,135 'createfilemap':43 'data':20,75 'descriptor':266 'differ':346 'drop':96,206,210,227,274,364 'ensur':245 'error':282 'event':58 'eventfd':61 'exclus':123,218 'exit':257 'expens':327 'explicit':385 'fals':339 'fast':320 'fd':91,122,130,140,160,167,177,179,223 'file':265 'fn':100,181,209 'free':46 'ftruncat':112,139 'futex':55 'guardrail':228 'handl':269 'header':331,376 'immedi':166,233,355 'impl':97,205 'implement':4,273,362 'index':321 'instead':325 'integr':66 'inter':6,31 'inter-process':5,30 'ipc':1,29 'ipcerror':108 'keep':168 'kqueue':63 'leak':278 'len':89,175,191 'let':129,146 'libc':143 'line':334,380 'lock':45 'lock-fre':44 'logic':360 'map':127,158,217,243,268,306,357 'mechan':28,60 'memori':10,36,78,232,241,288,352,398,400 'mmap':41,113,148 'modulo':328 'mpmc':14,50 'multipl':295 'munmap':220 'must':308 'mut':87,152,211 'name':102,133,164 'notif':27,59 'null':151 'o':134,136 'ok':171 'open':40,111,132 'oper':329 'optim':305 'order':401 'os':253 'outliv':195 'ownedfd':92,178,226 'pad':386 'page':285,299 'part':202 'pattern':81,118 'perform':390 'pipe':62 'platform':22,52 'platform-specif':51 'pointer':264 'pool':70 'posix':38,117 'power':311,373 'prevent':276,338 'primit':24 'process':7,26,32,256 'produc':342 'prot':154,156 'ptr':86,147,150,173,187 'ptr.cast':174 'pub':83,99,180 'raii':93,259,358 'raw':201 'rdwr':137 'read':155,393 'region':11,37,79,194,289 'releas':406 'resourc':262,277,367 'result':106 'ring':15,47,65,315,368 'rust':82 'safeti':109,186,213 'scope':34 'self':107,172,184,196,212 'self.len':204,222 'self.ptr':203 'self.ptr.cast':221 'share':9,35,77,159,231,287,340,351,397 'shm':39,110,131,162,235 'shmregion':80,85,98,208 'size':104,141,153,176,290,300 'skill' 'skill-ipc' 'slice':183,199 'soon':238 'source-cofin' 'specif':53 'spsc':12,49 'standard':116 'std':149,198 'str':103 'struct':84,271 'synchron':23,54 'system':298 'tokio':68 'topic-agent-skills' 'topic-ai-agents' 'topic-beads' 'topic-claude-code' 'topic-codex' 'topic-cursor' 'topic-developer-tools' 'topic-gemini-cli' 'topic-opencode' 'topic-plugin' 'topic-slash-commands' 'topic-spec-driven-development' 'transfer':21,76 'two':313,375 'typic':301 'u8':88,185 'ulock':56 'unlink':125,163,165,230,236,354 'unsaf':128,197,219 'use':2,234,258,322 'usiz':90,105 'valid':189,349 'win32':57 'window':42 'wrap':263 'write':157,395 'zero':18,73 'zero-copi':17,72","prices":[{"id":"812ba668-e877-4836-bea2-7eef15b05625","listingId":"2e119814-d605-4a04-a7e5-c3cf375163bf","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"cofin","category":"flow","install_from":"skills.sh"},"createdAt":"2026-04-23T13:03:59.898Z"}],"sources":[{"listingId":"2e119814-d605-4a04-a7e5-c3cf375163bf","source":"github","sourceId":"cofin/flow/ipc","sourceUrl":"https://github.com/cofin/flow/tree/main/skills/ipc","isPrimary":false,"firstSeenAt":"2026-04-23T13:03:59.898Z","lastSeenAt":"2026-05-18T19:07:37.725Z"}],"details":{"listingId":"2e119814-d605-4a04-a7e5-c3cf375163bf","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"cofin","slug":"ipc","github":{"repo":"cofin/flow","stars":11,"topics":["agent-skills","ai-agents","beads","claude-code","codex","context-driven-development","cursor","developer-tools","gemini-cli","opencode","plugin","slash-commands","spec-driven-development","subagents","tdd","workflow"],"license":"apache-2.0","html_url":"https://github.com/cofin/flow","pushed_at":"2026-04-27T19:07:26Z","description":"Context-Driven Development toolkit for AI agents — spec-first planning, TDD workflow, and Beads integration.","skill_md_sha":"1546565dd6cdc561910ad57548efd0608c376d86","skill_md_path":"skills/ipc/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/cofin/flow/tree/main/skills/ipc"},"layout":"multi","source":"github","category":"flow","frontmatter":{"name":"ipc","description":"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."},"skills_sh_url":"https://skills.sh/cofin/flow/ipc"},"updatedAt":"2026-05-18T19:07:37.725Z"}}