agentleFS
DankosikDankosik/cargo-modernize/.agents/skills/rust-errors/SKILL.md

rust-errors

Skill0 starsChanged 4 days agoApache-2.0View on GitHub

Failure semantics. Use when defining Rust errors, failure mappings, exit codes, degradation, or fallible completion.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Rust Errors

Failure semantics. Trace failure from the operation that observes it to the consumer that acts on it, separating rejected inputs, partial effects, uncertain outcomes, and post-commit cleanup failures so each boundary can stop, degrade, retry, or continue accurately.

Consumer-driven types. Expose typed variants where callers branch on recovery, while letting report-and-exit boundaries use contextual errors. Implement std::error::Error, Display, and Debug (via thiserror) on public library error types, preserving upstream #[source] causes and adding variants only for real consumers.

Context and redaction. Attach safe resource identifiers or input positions at the failing operation, verify what the boundary renderer actually emits from the source() chain, keep messages lowercase and free of trailing punctuation, redact secrets across every nested cause, and preserve failure precedence and all-or-nothing guarantees.

Conversions and retries. Implement From for context-free canonical conversions and use map_err where operation context disambiguates the failure; match structured variants rather than formatted strings. Require safe effect and idempotency identity before retrying timeouts or broken connections, log ignored cleanup failures only under an explicit best-effort policy, and represent help or early clean exits as normal Ok outcomes.

Fallible completion and panics. Expose an explicit observed close or flush method whenever resource completion can fail or await, reserving Drop for infallible non-blocking release and keeping primary outcomes distinct from cleanup errors. Use catch_unwind solely as task-boundary defense in depth, observe spawned-task failures via their supervisor, and re-establish or quarantine any multi-step invariant a panic could leave partial before exposing shared state.

Project boundaries. Keep per-file parser or detector failures (including panics caught by the scan worker's catch_unwind) contained to that file and accounted in the run summary rather than aborting the workspace scan; keep --fix transactional so a failed cargo check rolls edits back; and map outcomes to process exit status only in crates/cargo-modernize/src/main.rs, where --check findings and real errors stay distinguishable. Test these mappings behaviorally rather than boilerplate variants.

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.