rust-error-identity-boundaries
Skill0 starsChanged 39 days agoMITView on GitHub
Use when adding Rust error context or wrappers changes recovery behavior, or when reviewing anyhow and thiserror boundaries for preserved types, causes, and operation details.
In this repository66 other files it gives its agents.
- AGENTS.mdAGENTS.md
- postgres-locking-joinsSkill
- ai-bug-patternsSkill
- compressed-ndjson-boundariesSkill
- http-resume-integritySkill
- linux-io-latency-triageSkill
- macos-disk-space-recoverySkill
- minimal-sufficient-evidenceSkill
- modularize-large-filesSkill
- patch-reproducer-validitySkill
- prompt-cache-boundariesSkill
- proton-drive-selective-backupSkill
- transactional-outbox-deliverySkill
- conventional-commitsSkill
- git-advanced-mergingSkill
- git-bisect-forensicsSkill
- git-data-recoverySkill
- git-hooksSkill
- git-rerereSkill
- git-reset-mechanicsSkill
- git-revisions-syntaxSkill
- git-rewriting-historySkill
- git-submodulesSkill
- git-worktreesSkill
- github-ssh-keysSkill
- npm-publish-ci-pitfallsSkill
- sapling-stacked-pr-workflowSkill
- go-concurrency-patternsSkill
- go-data-idiomsSkill
- go-error-handlingSkill
- go-interfaces-embeddingSkill
- go-pprof-profilingSkill
- marketing-funnel-diagnosisSkill
- marketing-geo-experimentsSkill
- marketing-incrementalitySkill
- marketing-positioning-testsSkill
- python-descriptors-mroSkill
- python-logging-cookbookSkill
- python-scaling-regression-testsSkill
- python-unicode-gotchasSkill
- rust-compile-time-invariantsSkill
- rust-deterministic-concurrency-testsSkill
- rust-regex-search-contractsSkill
- rust-runtime-bug-classesSkill
- rust-tokio-actor-deliverySkill
- rust-tokio-cancellation-safetySkill
- sales-discovery-qualificationSkill
- sales-mutual-action-plansSkill
- sales-pipeline-forecast-calibrationSkill
- sales-value-negotiationSkill
- ai-triage-evaluationSkill
- container-image-patchingSkill
- dependency-artifact-integritySkill
- dnssec-sentinel-diagnosticsSkill
- iam-policy-change-replaySkill
- rbvm-applicabilitySkill
- rbvm-asset-evidenceSkill
- rbvm-guarded-remediationSkill
- rbvm-priority-decisionsSkill
- rbvm-risk-exceptionsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Treat diagnostic text, concrete error identity, and the source chain as separate contracts.
- Very specific: line 16
Use explicit map_err construction when a thiserror wrapper must retain both operation fields and its original source.
- Distinctive: line 20
Test direct typed-context downcasts, domain-wrapper traversal, and the broken stringification alternative.
≈ “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
Rust Error Identity Boundaries
Treat diagnostic text, concrete error identity, and the source chain as separate contracts. An informative message does not prove that callers can still classify the failure.
Preserve the information needed by callers
- Identify the classification contract before changing an error boundary: a domain variant, a typed operation marker, an underlying source kind, or a combination. Do not branch on formatted messages.
- Preserve existing errors with
?,anyhow::Error::new, or an explicit domain wrapper. - Attach operation information using anyhow context. Typed context can classify the operation while ordinary text explains it. Additional context preserves anyhow's existing downcasts. Context values require
Display + Send + Sync + 'static; a marker need not implementstd::error::Error. Usewith_contextfor lazily prepared details. - Select the traversal the contract requires. Inspect a domain error directly, or use
chain()and downcast each cause when classification genuinely depends on a lower-level type. Keep operation context as a separate classification condition when necessary. - Use explicit
map_errconstruction when a thiserror wrapper must retain both operation fields and its original source.
Regression evidence
Test direct typed-context downcasts, domain-wrapper traversal, and the broken stringification alternative. Add unrelated and different-kind failures as negative controls. Change human-readable context without changing the classification. Assert retained fields and source kinds independently of display text.
The original fixture uses synthetic errors with no filesystem or network operations. See provenance and validation limits before running it. Its direct dependencies are version-pinned; compilation and runtime are unverified.
Pitfalls
- Anyhow context downcasts are not arbitrary source-chain searches. Introducing a domain wrapper changes the concrete underlying error; direct downcasts to its source can fail.
- Stringification destroys original types and causes. Later context cannot reconstruct that information.
#[from]implies#[source]but permits only the source field and an optional backtrace, not extra operation fields.#[error(transparent)]forwards Display and source behavior rather than adding a diagnostic layer.
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.

