rust-2026-template
AGENTS.md11 starsChanged 6 months agoMITView on GitHub
2026 Best Practice Rust Template - This is the single canonical instruction file for all AI agents. Tool-specific files (CLAUDE.md, GEMINI.md, etc.) are thin adapters that point here. The skills index is auto-generated from skill frontmatter. Do not edit the table below manually. Regenerate after adding/modifying skills: Skill symlinks are managed automatically. After cloning, run: CLI-specific directories read from .agents/skills/ via symlinks: - .claude/skills/ → Claude Code - .qwen/skills/ → Qwen Code - .gemini/, .opencode/, .windsurf/ → Read directly The…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository29 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- llms-full.txtllms.txt
- llms.txtllms.txt
- anti-ai-slopSkill
- architecture-diagramSkill
- atomic-commitSkill
- build-rustSkill
- codacySkill
- crates-io-name-checkSkill
- dora-reportSkill
- goap-agentSkill
- harnessSkill
- issue-triageSkill
- lint-rustSkill
- metrics-reporterSkill
- privacy-firstSkill
- release-rustSkill
- reviewing-pull-requestsSkill
- secret-lintSkill
- self-fix-loopSkill
- skill-creatorSkill
- skill-evaluatorSkill
- stacked-prsSkill
- task-decompositionSkill
- test-rustSkill
- tokio-performanceSkill
- triz-analysisSkill
- triz-solverSkill
- verify-actionsSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
18 rules. About 0 are common, 4 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 77
Async: Use tokio when you need a runtime.
- Very specific: line 80
Quality SSOT: Prefer ./scripts/quality-gates.sh before push.
- Very specific: line 86
Safe Loading: Use file.take(limit) and is_file() check before reading.
- Very specific: line 89
Secrets: Never hardcode; use environment variables or .env.
- Very specific: line 90
Template Portability: Never hardcode project name, repo URL, or author across source files.
- Very specific: line 94
Docs: All public items must have /// doc comments.
- Distinctive: line 95
TDD: Add or update tests before implementing logic.
- Very specific: line 96
Snapshots: Treat snapshot changes as behavior changes.
- Very specific: line 97
Search: Always use --exclude-dir=target (and .git) in search commands.
- Very specific: line 98
Context: Run bash scripts/generate-llms-txt.sh after significant arch changes.
- Very specific: line 103
Discover: Read code patterns, module structure, and .agents/ci/ci-summary.md.
- Distinctive: line 105
Test-First: Add or update tests before logic implementation.
- Distinctive: line 106
Implement: Write code adhering to conventions.
- Very specific: line 107
Quality Check: Run ./scripts/quality-gates.sh.
- Distinctive: line 108
Commit: Use conventional commit format.
- Very specific: line 118
After completing any task, write a JSON event file to .agents/events/YYYY/MM/DD/.
- Very specific: line 125
If a release-failure issue is open:
- Very specific: line 126
Create a hotfix/ branch and apply the minimal fix.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md 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
Agent Coding Contract
2026 Best Practice Rust Template - This is the single canonical instruction file for all AI agents. Tool-specific files (
CLAUDE.md,GEMINI.md, etc.) are thin adapters that point here.
Quick Reference
| Task | Command |
| Build | cargo build --workspace |
| Quality | ./scripts/quality-gates.sh |
| Tests | cargo nextest run --workspace |
| Setup | ./scripts/bootstrap.sh |
| Diagnostics | ./scripts/doctor.sh |
Project Structure
.agents/skills/: Executable task knowledge and canonical workflows..agents/skills/harness/: Harness engineering — sensor response protocol and self-correction.crates/: Workspace members (libraries and applications).scripts/: Development, quality, and release automation.plans/adr/: Architecture Decision Records..githooks/: Pre-commit quality enforcement.AGENTS.md: THIS FILE (Canonical Project Contract).
Agent Skills (.agents/skills/)
The skills index is auto-generated from skill frontmatter. Do not edit the table below manually.
Regenerate after adding/modifying skills:
bash scripts/generate-skills-md.sh<!-- AUTO-GENERATED: see .agents/SKILLS.md for full table -->Consult .agents/SKILLS.md for the complete skills index, or read individual skill docs at .agents/skills/<name>/SKILL.md.
Multi-Agent Support
Skill symlinks are managed automatically. After cloning, run:
./scripts/bootstrap.sh # One-command setup
./scripts/doctor.sh # Environment diagnosticsCLI-specific directories read from .agents/skills/ via symlinks:
.claude/skills/→ Claude Code.qwen/skills/→ Qwen Code.gemini/,.opencode/,.windsurf/→ Read directly
Session Bootstrap
The repository includes a SessionStart hook to auto-inject project context at the start of an agent session. This helps agents orient themselves quickly without manual discovery.
- Hook:
hooks/session-start.sh - Config:
docflow.json - Integration: Registered in
.claude/settings.jsonfor Claude.
Cross-Repo Context
Derived repositories should check .agents/context/ for shared conventions and related repository links.
.agents/context/external-repos.json: Links to related repos and their agent context URLs.agents/context/shared-conventions.md: Cross-repo coding conventions (commit format, branch naming, PR requirements)
Merge precedence: Local repo instructions > imported context > template defaults.
Coding Conventions
Rust & Concurrency
- Edition: Rust 2024 (MSRV 1.88). Edition 2024 requires ≥1.85; 1.88 is intentional for broader codespace/toolchain compatibility. Do not bump MSRV unless required by a dependency. https://doc.rust-lang.org/edition-guide/rust-2024/index.html
- Versions:
VERSION/ workspace0.0.0is the adopter app version (start here). Template meta-releases (e.g. v0.3.x) live only in.template/CHANGELOG-TEMPLATE.md— do not sync them intoVERSION. - Safety:
#![forbid(unsafe_code)]at workspace and crate roots. - Errors:
thiserrorfor libraries,anyhowfor binaries. Nounwrap()in libs. - Async: Use
tokiowhen you need a runtime. CLI apps that use async: prefer#[tokio::main(flavor = "current_thread")]. Syncmainis fine when no async is required (sample-app). - Async Safety & Execution: Choose execution models based on workload characteristics: keep short bounded CPU work on Tokio worker threads, offload genuinely blocking operations or long CPU work to
spawn_blockingor dedicated worker pools, default to bounded concurrency/channels for backpressure, and keep lock scopes minimal (never across.await). Reference.agents/skills/tokio-performance/SKILL.mdfor Tokio architecture choices. - Tracing: Minimize CLI tracing metadata (thread IDs/names) unless high-concurrency.
- Quality SSOT: Prefer
./scripts/quality-gates.shbefore push.cargo run -p xtask quality-gatesdelegates to that script. - Verification tiers: Which checks run for each lifecycle trigger (pull request / protected branch / scheduled / release) is configured in
config/xtask.json(tiersmap:pull-request,protected-branch,scheduled,release) — not in workflow YAML. Override per run viaxtask quality run --tier <name>or$XTASK_TIER. Legacy namesfast-prandfull-gate/allare aliases forpull-requestandprotected-branch. - When-changed check selection:
xtask quality run --changed-from <ref>uses declarativewhen_changedglob mappings inconfig/xtask.json(e.g.crates/**/*.rs-> Rust checks,scripts/**/*.sh-> ShellCheck). Usextask quality explain --changed-from <ref>to inspect selected vs skipped checks and matched patterns. Unreadable git state fails closed by selecting all checks and recordingfallback_used: true.
Security & Configuration
- Hardening: Enforce
#[serde(deny_unknown_fields)]on config structs. - Safe Loading: Use
file.take(limit)andis_file()check before reading. - Validation: Sanitize strings (
is_control()) and enforce bounds on numeric fields. - Dependencies: Declare versions in
[workspace.dependencies]with caret ranges (e.g."1"≡^1). Library/template crates should ignoreCargo.lock(rely onCargo.tomlconstraints); binary applications should commit it for reproducible builds. Audit withcargo treeanddeny.toml. Prefer lockfile pins over exact=requirements in manifests. https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html - Secrets: Never hardcode; use environment variables or
.env. - Template Portability: Never hardcode project name, repo URL, or author across source files. All project-specific values must derive from
Cargo.tomlat runtime or be rewriteable viascripts/init-template.sh. Avoid magic number thresholds — define named constants.
Quality & Workflow
- File Size: Max 500 LOC per source file.
- Docs: All public items must have
///doc comments. - TDD: Add or update tests before implementing logic.
- Snapshots: Treat snapshot changes as behavior changes. Inspect them with
cargo insta reviewand accept only intentional, deterministic output changes; never update snapshots just to clear a failing test. - Search: Always use
--exclude-dir=target(and.git) in search commands. - Context: Run
bash scripts/generate-llms-txt.shafter significant arch changes. - Commits: Strictly use lowercase for the subject line (e.g.,
fix(scope): add ...notfix(scope): Add ...). Sentence-case or start-case will fail CI.
Change Workflow
- Discover: Read code patterns, module structure, and
.agents/ci/ci-summary.md. - Plan: Identify affected files and required test coverage.
- Test-First: Add or update tests before logic implementation.
- Implement: Write code adhering to conventions.
- Quality Check: Run
./scripts/quality-gates.sh. - Commit: Use conventional commit format.
Stacked PRs (Optional)
For large features with 3+ distinct concerns, stacked PRs are available via gh stack.
This is OPTIONAL — default to single-PR atomic commits. See .agents/skills/stacked-prs/SKILL.md.
Requires GitHub and gh CLI. Install: gh extension install github/gh-stack
Agentic Metrics Reporting
After completing any task, write a JSON event file to .agents/events/YYYY/MM/DD/.
This event-based pattern is also used for CI benchmarks in benchmarks/events/ to prevent merge conflicts.
See .agents/skills/metrics-reporter/ for the schema and event writing procedures.
Set human_interventions > 0 if a human corrected your code or provided rework instructions.
Release Failures (Priority 1)
If a release-failure issue is open:
- Create a
hotfix/branch and apply the minimal fix. - Open a PR with the
hotfixlabel. - Close the issue with:
Recovered at: <TIMESTAMP>. FDRT: <HOURS>.
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.

