grimoire
AGENTS.md15 starsChanged 17 days agoApache-2.0View on GitHub
Single project-context file for every AI agent working in this repo — Claude Code, Codex CLI, and any other AGENTS.md-aware tool. Edit this file, never CLAUDE.md. CLAUDE.md is a one-line pointer that imports this one, so a second copy would only drift. The same goes for anything it links: fix the source file, not a restatement of it. Lines beginning @ are Claude Code file imports and are expanded into context automatically; other agents should open those paths directly. Grimoire…
- Reads credentials
- Deletes or force-pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,700 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 repository45 other files it gives its agents.
- .agents/research/hooks_vendor_reports/claude.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- code-docs-cleanupSkill
- docs-instrumentSkill
- docs-planSkill
- docs-reviewSkill
- hex-architectSkill
- hex-coreSkill
- hex-discussSkill
- hex-executeSkill
- hex-finalizeSkill
- hex-initSkill
- hex-loopSkill
- hex-planSkill
- hex-retroSkill
- hex-reviewSkill
- nox-reviewSkill
- bugfixSkill
- builderSkill
- changelogSkill
- code-checkSkill
- code-docs-cleanupSkill
- commitSkill
- docs-instrumentSkill
- docs-planSkill
- docs-reviewSkill
- docsSkill
- finalizeSkill
- hex-architectSkill
- hex-coreSkill
- hex-discussSkill
- hex-executeSkill
- hex-finalizeSkill
- hex-initSkill
- hex-loopSkill
- hex-planSkill
- hex-retroSkill
- hex-reviewSkill
- meta-maintain-configSkill
- meta-validate-contextSkill
- nextSkill
- nox-reviewSkill
- qa-engineerSkill
- security-auditorSkill
- upstream-refreshSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
15 rules. About 1 is common, 9 are distinctive, and 5 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈9
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
- Distinctive: line 37
Before planning, research, or an architectural decision, scan "By concern" in the catalog below.
- Very specific: line 65
Always run
task verifyafter implementation is done: Always run cargo fmt before commit. - Distinctive: line 126
Follow them and everything else follows.
- Distinctive: line 130
Read before write. Grep before create.
- Distinctive: line 136
Write tests for the use case first.
- Common: line 141
No secrets in code. Validate all external input.
- Very specific: line 151
Check .claude/skills/ before ad-hoc generation.
- Distinctive: line 166
When you get user feedback or corrections, evaluate whether the insight should persist as an AI config update (rules, skills, agents).
- Distinctive: line 172
Treat every schema, layout, and renderer change with high caution.
- Very specific: line 193
Commits: Use Conventional Commits (e.g., feat:, fix:, refactor:, ci:, chore:).
- Very specific: line 198
Landing a feature: When a feature is done, run /finalize to clean branch history into a sequence of Conventional Commits ready to …
- Distinctive: line 231
Every task starts with workflow-intent.md — classify work (feature, bug fix, refactoring), check GitHub for related issues/PRs, then follow …
- Distinctive: line 241
When a cross-model reviewer is delegated an adversarial pass (hex's adversary gate, or a direct hand-off to another model):
- Distinctive: line 278
All changes must be committed locally on a feature branch.
- Very specific: line 280
Run task verify after any implementation change.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 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
AGENTS.md
Single project-context file for every AI agent working in this repo —
Claude Code, Codex CLI, and any other AGENTS.md-aware tool.
Edit this file, never
CLAUDE.md.CLAUDE.mdis a one-line pointer that imports this one, so a second copy would only drift. The same goes for anything it links: fix the source file, not a restatement of it.
Lines beginning @ are Claude Code file imports and are expanded into
context automatically; other agents should open those paths directly.
What is Grimoire
Grimoire is a package manager for AI-agent config — a CLI to install,
maintain, and publish AI-agent configuration (skills, rules, prompts)
distributed through standard OCI registries. The binary is named grim;
the Rust crate/package is grimoire. Shipping: full CLI (20 subcommands),
OCI registry pipeline, catalog publishing, MCP server, TUI, experimental
hooks. A cargo workspace (see Architecture), subsystem modules under src/, no stable library API — the binary is the only consumer.
Status: stabilizing — preparing 1.0.0. Released surfaces (CLI, JSON output, schemas, layouts, OCI pipeline, catalog publishing) are frozen contracts: breaking changes are prohibited — evolution is additive-only (Principle 9). Treat docs as contracts, flag drift when you find it.
Project Identity
Product vision, target users, positioning, related repos, comparable tools
and research keywords → product-context.md.
Consult when reasoning about project direction, scope trade-offs, ADR
motivation, or research framing. Canonical — keep current (update protocol
at the bottom of that file).
Rule Catalog
Before planning, research, or an architectural decision, scan "By concern" in the catalog below. Path-glob rules fire only when a matching file is already open; the catalog covers everything before that.
@.claude/rules.md
Build & Development Commands
Task runner: task (Taskfile v3) is the
primary runner. Always check task --list before inventing ad-hoc
commands. Taskfiles are tree-structured: root (taskfile.yml), subsystem
dirs (test/, .claude/), taskfiles/*.taskfile.yml for cross-cutting.
Key workflows:
task # fast check (format + clippy + cargo check)
task verify # full quality gate (lint, then build + tests)
task --force verify # bypass caching — run everything
task rust:verify # Rust-only gate
task shell:verify # shell-only gate (shellcheck + shfmt)
task claude:tests # AI config structural tests
task docs:check # docs site gate — needs Node 24; task verify does not
task upstream:stale # warn-only upstream staleness reportCargo commands (for finer control): cargo check, cargo build
--release (binary grim), cargo fmt, cargo clippy, cargo test.
Always run task verify after implementation is done. Always run
cargo fmt before commit. Subsystem verify tasks (rust:verify,
shell:verify, claude:verify) are AI dev-loop gates — run the subsystem
gate for the code changed; full task verify is the final gate before
commit. Conventions →
subsystem-taskfiles.md.
Architecture
Layout: a cargo workspace — one binary crate (grimoire, binary grim,
source under src/) plus two hook crates (crates/grimoire-hook-core,
crates/grim-hook). No lib/CLI split of the main crate. Tests under test/. Rust edition 2024.
Read the matching subsystem rule before working on code in that area — each carries invariants and design decisions not obvious from the code. Claude Code auto-loads them on path match; other agents open them by hand.
| Path | Subsystem rule |
src/**, crates/** | subsystem-file-structure.md, subsystem-cli.md, subsystem-cli-api.md, subsystem-cli-commands.md |
test/** (pytest, fixtures) | subsystem-tests.md |
.github/workflows/** | subsystem-ci.md |
taskfile.yml, taskfiles/** | subsystem-taskfiles.md |
Beyond the path map, two rules carry weight on any change:
arch-principles.md (design
principles, boundaries, glossary) and quality-core.md (SOLID/DRY/YAGNI,
Block/Warn/Suggest severity tiers, refactoring discipline). Shareable,
project-independent quality guidance lives in .claude/rules/quality-*.md
— load the one matching the language you are editing (quality-rust.md,
quality-python.md, quality-bash.md), and quality-security.md (attack
surfaces, OWASP/STRIDE checklist) before any security review.
Environment Variables
| Variable | Purpose | Default |
GRIM_HOME | Root data directory (content store, catalog, global config, global-scope install state at $GRIM_HOME/state/global.json). Project-scope install state lives at <workspace>/.grimoire/state.json. Global-scope client output lands in vendor-native dirs — see subsystem-file-structure.md. Hook arming lives here too ($GRIM_HOME/hooks/: the dispatch table, the generated launcher, the root-key map, and the per-workspace consent records under consent/) and it is load-bearing, not incidental: a relative GRIM_HOME, or one nested inside the workspace, makes an armable file repo-resident and grim therefore refuses to arm rather than warning — causes grim-home-relative / grim-home-in-workspace | ~/.grimoire |
GRIM_DEFAULT_REGISTRY | Default registry for short-id resolution and the single-registry fallback when no [[registries]] is configured. Does not collapse or restrict the multi-registry browse set — [[registries]] is authoritative for browsing even when this is set; only the --registry flag collapses browse to one registry. Short-id precedence: --registry flag > GRIM_DEFAULT_REGISTRY > project default_registry > global default_registry > built-in fallback ghcr.io/grimoire-rs (browse fallback: the public index https://index.grimoire.rs) | (unset) |
GRIM_INSECURE_REGISTRIES | Comma-separated host[:port] list contacted over plain HTTP instead of HTTPS, matched exactly. Unions with the always-on loopback forms (localhost, 127.0.0.1, bare and on port 5000) and with every [[registries]] entry declaring insecure = true — nothing removes a host from the set, and --registry never narrows it. Covers hosts no entry declares; it does not widen where grim login may send a credential | (unset) |
GRIM_OFFLINE | Disable all network access (cache-only; default is always-fresh online resolution) | false |
GRIM_TELEMETRY, GRIM_TELEMETRY_REPOSITORY | Opt-in OTLP usage telemetry, truthy-gated (1|true|yes|on). GRIM_TELEMETRY arms it; unarmed, grim makes no telemetry call and writes no $GRIM_HOME/telemetry/ file even with OTEL_* set, and an endpoint variable (OTEL_EXPORTER_OTLP_[LOGS_]ENDPOINT) is still required — there is no default endpoint. OTEL_SDK_DISABLED, DO_NOT_TRACK and offline mode disarm it; the grim-hook launcher carries no telemetry code. GRIM_TELEMETRY_REPOSITORY additionally adds the redacted origin remote as vcs.* (project scope only, never a $HOME repository). Both Unstable until 1.0. Contract: docs/src/content/docs/telemetry.md | (unset) |
GRIM_ANNOUNCE_TOKEN | Forge API token for grim publish --announce (PR/MR creation, owner-id lookup); always wins over CI-conventional tokens (GH_TOKEN/GITHUB_TOKEN, GITLAB_TOKEN), which apply only when the CI server host matches the announce target host. Never logged. Separately, CI_JOB_TOKEN is checked for presence only on a host-matched GitLab CI: it enables a fallback git-transport credential for the announce push (value never read into grim, never used for the MR API) | (unset) |
GRIM_RATE_TOKEN | Forge API token for grim rate, first rung of its own credential ladder (env → host-matched CI token → gh/glab stored credential → refuse with 80). Deliberately not the announce token: narrower scope, separate rotation. Never logged. Host-agnostic, so it is gated: against a host the index declared (providers.rating_host) it must be paired with --token-host <host> or the run exits 80 before the credential is read — same rule as --token-stdin, and the reason the two host-matched rungs need no gate. The rating host itself now comes from the index, not from the environment (adr_index_declared_rating_host.md) | (unset) |
DOCKER_CONFIG | Directory holding the docker-compatible config.json read/written by grim login/logout (and the credential read path) | ~/.docker |
OPENCODE_CONFIG | OpenCode config file that grim edits for global-scope rule registration (vendor variable, honored read/write). When unset, grim falls back to $XDG_CONFIG_HOME/opencode/opencode.json (or ~/.config/opencode/opencode.json if XDG_CONFIG_HOME is also unset). Config-file-only — no effect on skill/agent paths | (unset) |
CLAUDE_CONFIG_DIR, COPILOT_HOME, OPENCODE_CONFIG_DIR, CODEX_HOME, KIRO_HOME, QODER_CONFIG_DIR, GEMINI_CLI_HOME, JUNIE_HOME, OPENCLAW_STATE_DIR, OPENCLAW_HOME | Vendor config-dir overrides (honored read-only). Global-scope installs follow them: CLAUDE_CONFIG_DIR replaces ~/.claude (skills, rules, and agents), relocates the global MCP registration file to $CLAUDE_CONFIG_DIR/.claude.json, and relocates the settings.json grim writes for a support-dir rule's claudeMdExcludes registration — and it is the one variable grim also reads from the client's own files: the env block of Claude's managed settings (managed-settings.json + managed-settings.d/*.json) wins, then the user settings.json in the shell-resolved root, then the shell export (Claude's documented order; project/local settings cannot set it since 2.1.251; non-absolute or .. values ignored), COPILOT_HOME replaces ~/.copilot (skills, rules, agents; set elsewhere, Copilot stops reading ~/.agents/skills), OPENCODE_CONFIG_DIR is the preferred install target over the XDG default for OpenCode skills and agents (additive — OpenCode scans both), CODEX_HOME replaces ~/.codex for Codex agents and the MCP config.toml (Codex skills follow the cross-vendor $HOME/.agents/skills standard, NOT relocated by it), KIRO_HOME replaces ~/.kiro outright, no .kiro segment appended (skills, steering/ rules, settings/mcp.json; grim follows the Kiro CLI — the IDE ignores it upstream), QODER_CONFIG_DIR replaces ~/.qoder the same way (skills, rules, agents, settings.json), and so does JUNIE_HOME for ~/.junie (skills, agents, mcp/mcp.json). OPENCLAW_STATE_DIR names OpenClaw's root itself and wins over OPENCLAW_HOME, which replaces the home directory ($OPENCLAW_HOME/.openclaw, the GEMINI_CLI_HOME shape). GEMINI_CLI_HOME is the opposite shape: it replaces the home directory, so Gemini's root is $GEMINI_CLI_HOME/.gemini — segment still appended — relocating Gemini agents and settings.json, but never the shared $HOME/.agents/skills pool. They also drive global-scope client detection — a client counts as present when its (possibly overridden) native root exists. Details → subsystem-file-structure.md; upstream-verified dates: watchlist › Config roots and env vars | (unset) |
CLINE_MCP_SETTINGS_PATH, CLINE_DATA_DIR, CLINE_DIR | Cline vendor overrides, honored read-only for Cline's global MCP settings file only, in upstream order: the file path outright, else $CLINE_DATA_DIR/settings/cline_mcp_settings.json, else $CLINE_DIR/data/settings/…. Cline skills stay at ~/.cline/skills (the VS Code extension ignores CLINE_DIR). A file they move outside ~/.cline is skipped with a warning and never reported under outputs_pending, so grim install stays unchanged | (unset) |
| (no variable) | Hooks are deliberately unreachable from the environment. Neither the [options.experimental] hooks feature flag nor the workspace consent record ($GRIM_HOME/hooks/consent/<workspace-key>.json) has an env form: there is no GRIM_HOOK_CONSENT, and no variable naming or relocating the record's path. GRIM_ALLOW_HOOKS does not exist either — removed by owner decision 2026-08-17 (commit 24a14bb, withdrawing C-026) and must not be re-added. A repository routinely carries its own environment (.envrc, .mise.toml, devcontainer containerEnv, CI variables:), so an env-settable consent gate would let a repo consent on a cloner's behalf, and an env-settable record path would let it supply a pre-consented file — both CWE-426, both the same defect as the withdrawn committed-registration shape. The only per-invocation answers are the --trust-hooks / --no-trust-hooks flag pair on install/update/add, which cannot be set by a file — which is why the pair is allowed to outrank the record in both directions (owner decision 2026-08-28). Do not "helpfully" add a row here | n/a |
First-Party Catalog
catalog/ holds grim-publishable packages (skills grim-usage,
ai-config-authoring, grim-authoring; bundle grim-essentials; mcp grim;
hooks command-guard, tool-call-logger). CLI (src/command/**) or
docs-page changes need a drift review of these skills
(catalog/README.md). Hooks remind; task catalog:verify gates CI.
Core Principles
Nine principles distill every rule, skill, and standard in the framework. Follow them and everything else follows.
1. Understand First
Read before write. Grep before create. Never modify code not read — before changing a function, grep all callers. Check what exists before building new.
2. Prove It Works
Write tests for the use case first. Run them before commit. Every bug fix gets a regression test. All quality gates must pass.
3. Keep It Safe
No secrets in code. Validate all external input. Least privilege everywhere. Flag vulnerabilities immediately.
4. Keep It Simple
Small functions, single responsibility. No premature abstraction. Delete dead code. Comments explain why, never what.
5. Don't Repeat Yourself
Check .claude/skills/ before ad-hoc generation. Follow existing patterns.
Single source of truth for logic. Extract only when duplication is real.
6. Ship It
Work on a branch, never main. Commit iteratively. Never push to remote — the human decides when to push. Push triggers CI, real cost.
7. Leave a Trail
Planning artifacts go under ./.agents/. Document architectural
decisions in ADRs. Name things so the next person understands.
8. Learn and Adapt
When you get user feedback or corrections, evaluate whether the insight should persist as an AI config update (rules, skills, agents).
9. Preserve Compatibility
Stabilization freeze on the road to 1.0.0: breaking changes are prohibited — do not propose, implement, or merge one.
Treat every schema, layout, and renderer change with high caution.
Schema evolution is additive-only (new fields optional + default; enum literals added, never removed).
Layout moves ship automatic state migration, an old-path reaper, and an upgrade fixture; renderer changes prove self-heal (re-materialize leaves status not-modified). Contract: docs/src/content/docs/stability.md, adr_render_layout_stability.md.
Tech Stack
Golden-path technology choices — no deviations →
product-tech-strategy.md.
(A frontmatter-less rule: Claude Code already loads it every session, so it
is linked here rather than @-imported a second time.)
Workflow
Worktrees: grimoire is the primary checkout (main). Feature work
happens in ad hoc worktrees — human ones as siblings ../grimoire-wt-<topic>
on a matching <type>/<topic> branch (e.g. ../grimoire-wt-status-check on
feat/status-check), agent-spawned ones under
.agents/worktrees/<topic> (gitignored). Created and torn down per task,
not a fixed roster; whoever creates one removes it. git worktree list
shows what is currently checked out.
Commits: Use Conventional Commits
(e.g., feat:, fix:, refactor:, ci:, chore:). Scopes optional. No
Co-Authored-By trailers. Use chore: for AI settings, skills, agent
context files, and tooling that should not appear in the changelog.
Landing a feature: When a feature is done, run /finalize to clean
branch history into a sequence of Conventional Commits ready to
fast-forward onto main. Two-phase model (/commit during dev,
/finalize before landing) →
workflow-git.md.
Planning flow: ADR → Design Spec → Plan → Implementation. Planning docs
are committed under ./.agents/: adr/, specs/, plans/ (incl.
bugfix_plan_*, meta-plan_*; landed pre-protocol ones in
plans/archive/), research/, one-off records at the root. Templates in
./.claude/templates/artifacts/.
Skills & Personas
Multi-agent orchestration is the hex bundle, installed at user level
(not in this repo): /hex-plan, /hex-execute, /hex-review,
/hex-architect, /hex-init. They read swarm memory from
.agents/memory/hex.md — pointers, the model matrix, always-on review
perspectives, and the cross-model adversary.
<!-- hex:start -->Swarm memory: .agents/memory/hex.md (pointers + preferences). Commands: /hex-init, /hex-plan, /hex-execute, /hex-review, /hex-architect.
<!-- hex:end -->Project-local skills in .claude/skills/ cover solo work and this repo's
own conventions: /builder, /qa-engineer, /security-auditor,
/code-check, /bugfix, /docs, /commit, /finalize, /next,
/meta-maintain-config, /meta-validate-context. Full map → "Skills by
task topic" in .claude/rules.md. Check
.claude/skills/ before ad-hoc generation.
Starting Work
Every task starts with workflow-intent.md — classify work (feature, bug fix, refactoring), check GitHub for related issues/PRs, then follow the appropriate workflow. Also: workflow-feature.md, workflow-bugfix.md, workflow-refactor.md.
Adversarial Review Guidance
When a cross-model reviewer is delegated an adversarial pass (hex's adversary gate, or a direct hand-off to another model):
- Load this file and the subsystem rules for the touched paths before flagging anything — the author was likely working against them.
- Challenge design choices, not style.
cargo fmthandles formatting; question whether the approach is right, what assumptions it depends on, and where it fails under real-world conditions. - Do not critique load-bearing conventions stated here or in
product-tech-strategy.md(Tokio, Rust 2024, OCI-backed storage, never-push-to-remote, commit format). They are decisions, not invitations. - Return findings with concrete file paths and line numbers, grouped
by severity (Block / Warn / Suggest — definitions in
.claude/rules/quality-core.md).
General Agent Safety (applies to any external agent)
Non-interactive shell commands
cp, mv, rm may be aliased to -i on some systems, which hangs an
agent waiting for y/n. Always use non-interactive flags:
cp -f source dest # NOT: cp source dest
mv -f source dest # NOT: mv source dest
rm -f file # NOT: rm file
rm -rf directory # NOT: rm -r directoryAlso: scp -o BatchMode=yes, ssh -o BatchMode=yes, apt-get -y, HOMEBREW_NO_AUTO_UPDATE=1 brew ….
Session hygiene
- Never push to remote — the human decides when to push (CI has real cost).
- All changes must be committed locally on a feature branch.
- Never commit directly to
main. - Run
task verifyafter any implementation change.
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.

