add-ffi-binding
Skill1 starsChanged 12 days agoApache-2.0View on GitHub
Use whenever adding or changing OS bindings (libc, X11, Objective-C/AppKit/CoreGraphics, Win32, ConPTY). Declares items in tidepool-sys with layout assertions and source citations, then wraps them safely in tidepool-platform.
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-managed-toolSkill
- evaluate-dependencySkill
- next-taskSkill
- record-decisionSkill
- verifySkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
If the header isn't available in this session, use the official documentation and mark the values "verify on <OS>".
- Very specific: line 55
Document ownership (who frees what, with which call) and main-thread-only requirements.
- Very specific: line 68
Ask security-reviewer to review.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Add an FFI binding
Request: $ARGUMENTS
We use no binding crates (ADR-0001), so correctness depends on following this procedure exactly. Nadir (same owner) uses the same procedure; check whether it already declares what you need and port it with a note.
1. Scope it
- List the exact functions, types, constants or selectors the feature calls. Declare nothing else.
- For each item, find the authoritative source:
- Linux: glibc headers (
/usr/include/*.h,sys/*.h), X11 headers (/usr/include/X11/*.h), kernel uapi headers (linux/inotify.h) - macOS: SDK framework headers or Apple's developer documentation
- Windows: Windows SDK headers (
um/*.h) or Microsoft Learn
- Linux: glibc headers (
- If the header isn't available in this session, use the official
documentation and mark the values "verify on
<OS>".
2. Declare in tidepool-sys
- File:
crates/sys/src/<os>/<module>.rs. Every item carries a doc comment or a// source:comment naming the header and declaration. - Functions:
unsafe extern "system" { ... }for Win32,unsafe extern "C" { ... }elsewhere. Libraries wedlopen(libX11) use thedynlib!macro, which reports every missing symbol by name. - Types:
#[repr(C)], fields in header order with exact widths (longisi64on LP64 Linux and macOS,i32on Windows; objcBOOLisboolon arm64,i8on x86_64). - Layout assertions for every struct, with numbers from the header or docs
(never from the Rust struct you just wrote):
Gate per target withconst _: () = assert!(core::mem::size_of::<XEvent>() == 192); const _: () = assert!(core::mem::align_of::<XEvent>() == 8); const _: () = assert!(core::mem::offset_of!(XKeyEvent, keycode) == 84);#[cfg(...)]when values differ. - Constants: the header's type and spelling (hex stays hex).
- Objective-C: cache selectors once; every
msg_send!spells the full signature;_stretfor big struct returns on x86_64; runtime-created classes list ivars and methods with type encodings in one place.
3. Wrap safely in tidepool-platform
- Safe API: owned RAII types for handles,
&str/&Pathinstead of raw strings, our error enums instead of codes. - One unsafe operation per block, each preceded by
// SAFETY:. - Document ownership (who frees what, with which call) and main-thread-only
requirements; make main-thread types
!Send. - Convert every failure path into an error with context.
4. Test
- Layout assertions compile on the OS they target: say which OS builds you actually ran.
- Unit tests for wrapper logic that doesn't need the OS (key mapping tables, string conversion).
- Behavior tests under Xvfb on Linux where a display is needed.
- Run
cargo xtask unsafe-auditandcargo clippy -p <crate> --all-targets -- -D warnings. - Ask
security-reviewerto review.
5. Report
- Each declared item and its source.
- Which layout assertions compiled on which OS in this session.
- Which items still need verification on another OS (also add a
⏳note to the roadmap task).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

