agentleFS
manav8498manav8498/processfork/.claude/skills/rust-pattern/SKILL.md

rust-pattern

Skill1 starsChanged 6 months agoMITView on GitHub

ProcessFork's Rust idioms — Result propagation, tokio async, tracing instrumentation, error typing.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never unwrap() / expect() outside #[cfg(test)] and examples/.

    line 15
  2. Very specific:

    Use ? everywhere. If you find yourself writing match res { Err(e) => return Err(e.into()), Ok(v) => v }, write res?

    line 16
  3. Very specific:

    Use tokio::task::JoinSet for fan-out/fan-in instead of spawn + await loops.

    line 22
  4. Very specific:

    Every pub symbol gets a doc-comment that compiles as a doctest where meaningful.

    line 37
  5. Very specific:

    Prefer borrowed parameters (&str, &[u8], &Path).

    line 39

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Rust patterns

Errors

  • Library crates: thiserror::Error-derived enum named Error, type alias pub type Result<T> = std::result::Result<T, Error>;. Variants tagged with #[error("…")].
  • Binary crates (pf-cli only): anyhow::Result is acceptable at the command-handler boundary. Internals still use typed errors.
  • Never unwrap() / expect() outside #[cfg(test)] and examples/.
  • Use ? everywhere. If you find yourself writing match res { Err(e) => return Err(e.into()), Ok(v) => v }, write res? instead.

Async

  • tokio multi-thread runtime; #[tokio::main] only in binaries.
  • Use tokio::task::JoinSet for fan-out/fan-in instead of spawn + await loops.
  • tokio::fs for I/O paths in async contexts; std::fs only in clearly- sync contexts.

Tracing

  • use tracing::{debug, info, warn, error, instrument};
  • Annotate every pub async function with #[instrument(skip(self))] or similar (skip large args).
  • Spans MUST carry meaningful field names: tracing::info!(image=%cid, "snapshot complete"). Never log opaque Debug structs at info level.

API surface

  • Every pub symbol gets a doc-comment that compiles as a doctest where meaningful. cargo test --doc runs these in CI.
  • Prefer borrowed parameters (&str, &[u8], &Path); accept impl AsRef<Path> only at the outermost API boundary.
  • Newtype the digest types — never expose raw String for content IDs.

Workspace lints

  • pedantic is on, module_name_repetitions and must_use_candidate are off. Fix every other clippy warning before committing.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.