rust-architecture
Skill0 starsChanged 43 days agoMITView on GitHub
Project and system design for Rust. Use when starting a new Rust project or crate (cargo new, scaffolding, "set up a Rust service/CLI/library"), deciding bin vs lib vs workspace, designing crate and module structure or visibility, applying layered/hexagonal (ports and adapters) architecture or dependency injection, structuring an axum/tokio web service (state, errors, graceful shutdown, timeouts, health checks), a clap CLI (exit codes, stdout/stderr, config precedence), or a publishable library (semver, feature flags, MSRV, no_std); for configuration and secrets, tracing/metrics/OpenTelemetry setup, and CI/CD, release (release-plz, cargo-dist) and copy-paste templates (Cargo.toml with workspace lints, clippy.toml, deny.toml, GitHub Actions workflow, rust-toolchain.toml).
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- dawidpereira/rust-skillstheir own version, first seen Mar 22, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- dawidpereira/rust-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 repository4 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- rust-ecosystemSkill
- rust-idiomsSkill
- rust-securitySkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 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.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
ARCH-02: Start with one package; binaries get a thin main.rs over a lib.rs.
- Distinctive: line 30
ARCH-09: No global mutable state: main is the composition root and passes dependencies down.
- Very specific: line 76
Read project-kickoff.md; write the ADR block with the chosen defaults.
- Very specific: line 81
Add CI (ci-cd-release.md) in the first commit, then run cargo clippy --all-targets -- -D warnings and cargo test locally before handing …
≈ “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-architecture
Opinionated defaults for shaping Rust projects. Language-level idioms (errors, async, traits,
testing) live in rust-idioms; crate choices in rust-ecosystem; supply chain and secure coding in
rust-security. Every rule has a stable ID — cite it in reviews and plans.
Core rules
- ARCH-01 Answer the kickoff questions (shape, edition, MSRV, async, errors, config, observability, targets) before scaffolding; state the defaults you picked.
- ARCH-02 Start with one package; binaries get a thin
main.rsover alib.rs. - ARCH-03 / WS-06 Split crates only for separate deployables, reuse, heavy-dependency isolation, enforced dependency direction, or proc-macros — never one crate per layer.
- ARCH-06 Async only for concurrent network IO; sync + rayon for CPU work; never start a runtime inside a library.
- ARCH-09 No global mutable state:
mainis the composition root and passes dependencies down. - WS-02 A virtual workspace manifest must say
resolver = "3". - WS-04 / WS-05 Versions once in
[workspace.dependencies]; lints once in[workspace.lints]with[lints] workspace = truein every member. - MOD-01 / MOD-05 Modules by domain concept; no
utils/helpers/commondumping grounds. - MOD-03 / MOD-04 Private by default,
pub(crate)in binaries,lib.rsre-exports a curated facade. - HEX-01 Concrete types by default; a trait only at an external boundary that needs a second implementation (e.g. a test fake).
- HEX-05 / HEX-07 Inject with generics that stop at the composition root; no DI containers
or service locators;
dyn/enums only for runtime choice. - SVC-04 One
ApiError: IntoResponsemaps domain errors to HTTP; 5xx bodies are generic. - SVC-05 / SVC-06 SIGTERM + Ctrl-C graceful shutdown with cancellation of background tasks; request timeout, body limit and outbound timeouts everywhere.
- CLI-02 / CLI-04
mainreturnsExitCodeand printserror: {err:#}; data to stdout, diagnostics to stderr; neverunwrap()inmain. - LIB-04 Cargo features are strictly additive (
std, neverno-std); test withcargo hack --feature-powerset. - LIB-02 / LIB-05 Semver-check every library PR; libraries never init loggers, read env vars
or call
process::exit. - CFG-01 / CFG-04 One typed, validated
Settingsloaded once at startup; secrets areSecretString; noenv::varoutside the config module. - OBS-01
tracingin every crate; the subscriber is installed only in binaries. - OBS-04 / OBS-06
#[instrument(skip_all, fields(..))]; never log secrets or bodies. - CI-01 / CI-03 CI runs fmt, clippy
-D warnings, test, doc, cargo-deny with--locked;Cargo.lockis committed.
Routing table
| Situation | Read |
| "Start/scaffold/set up a new Rust project"; choosing bin vs lib vs workspace, edition, MSRV, async | references/project-kickoff.md |
Workspace manifests, crates/ layout, shared deps/lints, when to split crates, xtask, build times | references/workspace-layout.md |
Module tree, visibility, pub(crate), re-export facade, god-modules, dependency direction | references/modules-and-boundaries.md |
Ports & adapters, clean/hexagonal architecture, DI, traits vs generics vs dyn, fakes vs mocks | references/layered-hexagonal.md |
| axum/tokio HTTP service: state, handlers, error mapping, graceful shutdown, timeouts, health, DB pool | references/web-services.md |
| clap CLI: structure, exit codes, stdout/stderr, broken pipe, config precedence, progress | references/cli-apps.md |
| Publishable library: API surface, semver, feature flags, docs.rs, MSRV policy, no_std | references/library-design.md |
Config files, env vars, secrets, validation, .env | references/configuration.md |
Logging, spans, #[instrument], log levels, OpenTelemetry, Prometheus metrics | references/observability.md |
| GitHub Actions CI, MSRV/semver/feature jobs, caching, release-plz, cargo-dist, cross-compiling | references/ci-cd-release.md |
Copy-paste workspace/member Cargo.toml with lints, rust-toolchain.toml, rustfmt.toml, clippy.toml, release profile | references/templates.md |
Copy-paste deny.toml, .github/workflows/ci.yml, axum service and clap CLI main.rs skeletons | references/templates-ci-and-skeletons.md |
Workflow for a new project
- Read
project-kickoff.md; write the ADR block with the chosen defaults. - Scaffold manifests from
templates.md, thendeny.toml, CI and the service (TPL-11) or CLI (TPL-12) skeleton fromtemplates-ci-and-skeletons.md. - Lay out modules per
modules-and-boundaries.md; add ports only per HEX-01. - Wire config (
configuration.md) and telemetry (observability.md) inmainbefore features. - Add CI (
ci-cd-release.md) in the first commit, then runcargo clippy --all-targets -- -D warningsandcargo testlocally before handing back.
Versions and live data
Crate versions in these references were verified against crates.io on 2026-09-29 (see each
file's crates: frontmatter). When the rustkb MCP tools are available, prefer them for anything
version-sensitive: crate_info (current versions, features, MSRV), search/get_item (versioned
API docs), check_advisories (RustSec), explain_lint (rustc/clippy lint docs) and
rust_release (what changed in a Rust release). Never write a dependency version from memory.
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.

