writing-rust
Skill2 starsChanged 4 months agoMITView on GitHub
Write, test, review, or debug Rust code. Focuses on current toolchain verification, type-driven completeness, ownership at FFI boundaries, and Nix-controlled builds.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- xmtp/libxmtptheir own version, first seen Oct 17, 2026
- weaverbase/skillstheir own version, first seen Oct 13, 2026
- Chogos/claude-skillstheir own version, first seen Mar 9, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- xmtp/libxmtp★ 130same name
- Chogos/claude-skills★ 1same name
- weaverbase/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository34 other files it gives its agents.
- capture-collaboration-evidenceSkill
- clarify-before-buildingSkill
- cross-platform-project-build-archSkill
- deep-code-reviewSkill
- dispatchSkill
- erect-agent-stackSkill
- fix-zig-deps-hashSkill
- gather-project-intentionsSkill
- handoffSkill
- hulk-bug-handoffSkill
- i18nSkill
- llvm-guided-optimizationSkill
- mechatron-ciSkill
- memoriesSkill
- mficSkill
- multi-implementation-contractsSkill
- no-ai-slopSkill
- onboardSkill
- performance-profilingSkill
- planning-workSkill
- scaffold-zig-projectSkill
- ship-itSkill
- test-isolationSkill
- universal-app-frontendSkill
- upgrading-zig-16-to-17Skill
- walking-decisionsSkill
- writing-bendSkill
- writing-elmSkill
- writing-leanSkill
- writing-nixSkill
- writing-rocSkill
- writing-webassemblySkill
- writing-zigSkill
- zig-microbenchmarksSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. 0 are common, 6 are distinctive, and 9 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
6
Distinctive
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Use the project's pinned toolchain and dependencies.
- Distinctive: line 15
When stamping build identity, follow the shared build revision rule.
- Very specific: line 20
Prefer closed enums and exhaustive match expressions for finite domain variants.
- Distinctive: line 22
Use one authoritative typed model to derive or serialize each external representation.
- Very specific: line 49
Keep lifetimes local and simple.
- Very specific: line 50
Use Result for recoverable failures and preserve useful error context.
- Very specific: line 53
Do not make code compile by cloning whole collections, wrapping every resource in Arc<Mutex<_>>, or replacing error handling with …
- Distinctive: line 59
Read ownership, concurrency and panic traps when introducing shared state, database access, borrowing workarounds or lint policy.
- Very specific: line 72
Treat unsafe as a last resort that must earn its place with evidence.
- Distinctive: line 87
When a public ABI has CLI consumers or interchangeable core implementations, use multi-implementation-contracts to make acceptance …
- Very specific: line 100
Use cargo fmt --check, Clippy where configured, and focused Rust tests through the project test path.
- Very specific: line 116
Never static glibc: do not use -C target-feature=+crt-static on the gnu target.
- Distinctive: line 130
Archives: every C or Zig archive the program links must be built for the same libc.
- Very specific: line 158
Before adding or changing a dependency, follow writing-nix and its dependency-portability reference.
- Distinctive: line 167
When a repeated Rust-specific mistake exposes a gap, make a small evidence-based update to this skill with the Rust version and a minimal …
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Writing Rust
Use the project's pinned toolchain and dependencies. Read its intent, Rust
version, Cargo features, and Nix derivations before changing the build. Run
nix build as the canonical build and the project's complete ./test entry
point for verification. cargo check and focused tests are useful diagnostics
inside the declared Nix environment; they do not replace the project build
contract.
When stamping build identity, follow the shared build revision rule.
Encode completeness in types
Prefer closed enums and exhaustive match expressions for finite domain
variants. Avoid wildcard arms when a newly added variant should force review.
Use one authoritative typed model to derive or serialize each external
representation. For event logs, for example, let the event enum and typed
fields drive internal handling, NDJSON serialization and human-readable output;
make missing representations compile-time failures where practical. Keep
serialization formats explicitly versioned when they are persisted or shared.
The compiler only checks paths represented in the type system. It does not prove runtime data is valid, a serializer includes every semantically required field, or all event variants are exercised. Add independent contract tests for round trips, schema shape and output behavior. Avoid hand-maintained tuple layouts or parallel string-key maps when a typed struct or enum can make omission visible.
Generating Rust with Lua
Lua long strings delimited by [[ and ]] end at the first ]], which can
occur in Rust indexing or array syntax. Use a matching long-bracket delimiter
whose closing sequence does not appear in the source: [=[...]=], then
[==[...]==] or more equals signs as needed. Check the complete payload; the
one-equals form is not universally safe. A long string also discards one
newline immediately after its opener and normalizes line endings. If exact
bytes matter, read the source as data or use byte-preserving escapes instead.
Ownership and effects
Make ownership and borrowing explicit at API boundaries. Prefer slices for
borrowed input and return owned values only when the caller needs ownership.
Keep lifetimes local and simple; do not add lifetime parameters speculatively.
Use Result for recoverable failures and preserve useful error context. Avoid
panics for malformed input or expected environmental failures.
Do not make code compile by cloning whole collections, wrapping every resource
in Arc<Mutex<_>>, or replacing error handling with unwrap/expect. Choose
the owner, data access boundary and failure behavior first. For new clones and
shared mutable state, check copied volume/frequency, lock scope/contention and
consistency; record the reason where the choice is non-obvious. Prefer the
simplest design that meets those requirements, without speculative frameworks.
Read ownership, concurrency and panic traps
when introducing shared state, database access, borrowing workarounds or lint
policy. These are review triggers, not blanket bans on legitimate Rust tools.
At C FFI boundaries, arbitrary bytes are (pointer, length), never assumed to
be NUL-terminated. Specify who allocates and frees each buffer, whether pointers
may be retained, and how errors cross the ABI. Do not unwind Rust panics across
C ABI boundaries. Catch or translate panics at the exported boundary where the
ABI contract requires containment; C++ exceptions and Zig panics also need
explicit boundary handling.
Unsafe code
Treat unsafe as a last resort that must earn its place with evidence. Add it
only for a measured performance win the owner accepts, or for an operation with
no safe equivalent (FFI, intrinsics). For performance, never write the unsafe
version first: write and benchmark a safe version, then an unsafe one with the
same harness, choose on the numbers, and keep the loser alive with both
measurements and the compromise explained: preferably compiled behind a
non-default Cargo feature with both paths under test, otherwise commented out
and intact. Cargo features are also the tool when an application needs to
choose per build how much unsafe to lean on. Crates that need
no unsafe declare #![forbid(unsafe_code)]; crates that do confine it with a
crate-level deny and module-level allow, with a // SAFETY: comment on
every block. Read unsafe Rust before adding or
keeping any unsafe, and report each addition to the owner. Its
scripts/unsafe-advisory-hook warns agents when an edit adds unsafe.
When a public ABI has CLI consumers or interchangeable core implementations, use multi-implementation-contracts to make acceptance consumers link only the packaged ABI. Same-crate CLI tests can stay green while the exported interface becomes unusable.
Performance and verification
During implementation, ask whether each function is on a hot path. Once a hot
path first works correctly, declare an optimistic expected complexity and add
an enforced ./big_o case. Use the shared performance-profiling skill; the
Rust big_o crate can infer from measurements and check model bounds, but it
does not discover or require declarations by itself.
Use cargo fmt --check, Clippy where configured, and focused Rust tests through
the project test path. Keep tests isolated and fast. A compile success is not
behavioral verification. Use property, differential, and exhaustive finite
domain checks where the contract supports them.
Linux libc and dead code
Each project uses one libc for all of its Linux builds. Static musl is the default; dynamic glibc is for programs that must load host GPU, display or audio libraries (GUI and GPU applications). Neither may depend on a Nix store path. The policy and its blocking gate live in writing-nix's runtime-independence gate. The musl items below were verified with rustc 1.97.0:
- Static musl: build with
pkgs.pkgsStatic.rustPlatform.buildRustPackage, which uses a cached cross rustc for the musl target and links statically. - Never static glibc: do not use
-C target-feature=+crt-staticon the gnu target. The standard library reachesgetaddrinfo(std::net) andgetpwuid_r(std::env::home_dir), which a static glibc still resolves through shared libraries at run time. Under Nix's linker wrapper the link failed outright ("DSO missing from command line"). - glibc: a Nix-built gnu binary names the store's loader and glibc, and references the newest glibc symbol versions. A standalone artifact needs the standard interpreter path, no store RUNPATH, and a declared glibc floor that the writing-nix gate checks.
- The standard library supports glibc 2.17 and later, and it probes newer
functions through weak references. Those references still record a hard
version requirement. A rustc 1.97 build against glibc 2.42 required
GLIBC_2.39because ofpidfd_spawnp. A lower floor therefore needs linking against an older glibc, not just avoiding new APIs. - Archives: every C or Zig archive the program links must be built for the same libc.
- Rust staticlibs: each one carries its own standard library, so a Rust program cannot link another Rust staticlib. That pairing needs a shared library, which only test-only artifacts may use.
- Dead-code elimination: rustc emits a section per function and passes
--gc-sectionsfor executables. In the release profile, setlto = true(fat) andcodegen-units = 1so cross-crate dead code is removed too.opt-level = "s"or"z"trades speed for size; adopt it only on measurement.panic = "abort"shrinks binaries further but changes how panics are contained at FFI boundaries, so treat it as a contract decision. - Strip debug information (Nix's fixup phase does by default; otherwise set
strip = "debuginfo"). Keep the symbol table when tests inspect it withnm.
Dependency and toolchain policy
Rust 1.100.0 was released on 2026-11-12. When assessing that upgrade, read the 1.100 upgrade reference for inference and Cargo layout changes. This records a verified release, not a requirement to use the newest compiler. Check the current official release notes again for later work.
Distinguish the compiler selected by the Nix derivation from Cargo's
rust-version minimum supported Rust version (MSRV). Updating one does not
automatically update the other. Keep rustc, Cargo, Clippy, rustfmt and required
target standard libraries consistent through the declared Nix toolchain;
check native and cross-build routes for separate older compiler selections.
Before adding or changing a dependency, follow
writing-nix and its
dependency-portability reference.
That reference defines the Rust/Cargo and Nix source model, lock/vendor hashes,
private sources, source staging and clean-build proof. Never commit absolute
machine paths, local file URLs, undeclared sibling checkouts, or an implicit
host Cargo cache dependency. Verify a clean, source-bounded nix build; a warm
local target directory or devShell-only build does not prove CI portability.
When a repeated Rust-specific mistake exposes a gap, make a small evidence-based update to this skill with the Rust version and a minimal reproduction. Do not copy project-specific workarounds or speculate about future compiler behavior.
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.

