Recommended Repository Layout
your-repo/
βββ AGENTS.md # canonical, cross-tool: conventions, commands, guardrails
βββ CLAUDE.md # Claude-Code-only additions (compaction guidance, subagent routing)
βββ GEMINI.md # Antigravity-only overrides (kept thin)
βββ .codex/agents/ # Codex subagent definitions (model/sandbox per role)
βββ .antigravity/agents/ # Antigravity subagent YAML definitions
βββ .claude/skills/ # Claude Code skills (progressive disclosure)
βββ .cursor/
β βββ rules/
β β βββ 000-project.mdc # thin, always-apply, points back to AGENTS.md
β β βββ 200-high-risk-paths.mdc # scoped, glob-matched, loads only near risky code
β βββ agents/ # Cursor subagent personas (review/verify/test)
β βββ skills/ # Cursor skills (or point at .claude/skills/)
βββ playbooks/
βββ dependency-upgrade.devin.md # general SDLC: incremental dep upgrades, PR per risk group
βββ hugo-docs-check.devin.md # narrower example: docs build + link check
AGENTS.md is the only file all five tools read natively or near-natively. Everything else exists purely to hold one tool’s extra, tool-specific capability β none of it should restate what’s already in AGENTS.md. That’s the drift-prevention mechanism: one canonical file for shared rules, thin or scoped tool-specific files layered on top.
Concrete File Examples
AGENTS.md - Canonical Cross-Tool Rules
# AGENTS.md β Canonical Project Rules
<!--
Single source of truth, read natively (or near-natively) by Claude Code,
Codex CLI, Antigravity CLI, and Devin CLI.
Keep this file lean: every line here loads into every agent's context,
every session, regardless of task. Anything task-specific, infrequently
needed, or only relevant to one tool belongs in a Skill, a Playbook, or
a tool-specific override file (CLAUDE.md, GEMINI.md) β not here.
-->
## Stack
- [Language/framework β e.g. TypeScript, Next.js 15 App Router]
- [Database / ORM]
- [Package manager] β state it explicitly; agents default to whichever is
most common in training data if you don't.
## Commands
Run these before considering any task complete:
```bash
[lint command]
[test command]
[typecheck command]
Conventions
- One responsibility per function/class/file. If a file exceeds roughly [300] lines or a function exceeds roughly [40] lines, split it before adding more β don’t append.
- Keep dependency fan-out low: depend on an interface/abstraction rather than a concrete deep chain, so a small change doesn’t require pulling a wide dependency graph into context to verify.
- [Naming conventions, export style, etc.]
- Never modify files in [/legacy/ or other frozen paths].
Skills
See .claude/skills/, .codex/ skill config, .gemini/config/skills/
(or wherever each tool discovers them) for task-specific instructions β
deployment, migrations, code review, release notes. This file intentionally
does not duplicate skill content; it only points at where to find it.
Guardrails
- Never force-push or rewrite shared git history without explicit confirmation.
- Never commit secrets, credentials, or
.envfiles. - Ask before running destructive database operations.
- Stop and report on the first build/test failure rather than attempting speculative fixes.
### CLAUDE.md - Claude Code Specific Additions
```markdown
# CLAUDE.md β Claude Code Additions
<!--
Shared conventions, commands, and guardrails live in AGENTS.md β Claude
Code reads that file too. This file holds only what's specific to how
Claude Code itself operates a session.
-->
See `AGENTS.md` for project conventions, commands, and guardrails.
## Compaction guidance
When compacting (`/compact`), preserve:
- Any failing test output and the diff that produced it
- Open TODOs and unresolved questions from the user
- The current task's acceptance criteria
Discard exploratory file reads that didn't lead to a change.
## Subagent routing
- Default subagent model: Haiku β for test runs, log triage, and doc
lookups.
- Escalate to Sonnet only when the subagent's task requires code
generation, not just retrieval or summarization.
- Reserve Opus for the primary session on architecture-level decisions.
## Session hygiene
- Before starting an unrelated task, prefer `/clear` over letting stale
context linger through auto-compact.
- Flag any MCP server unused for two or more weeks for removal from this
project's config β it still costs prefix tokens every turn even if
nothing calls it.
## Effort
- Default to a lower `/effort` setting for routine edits; only raise it
for multi-file refactors or architecture-level reasoning.
Key Pattern: Notice how CLAUDE.md starts with a pointer to AGENTS.md and only contains Claude-specific operational details (compaction, subagent routing, session hygiene). This avoids duplication while providing tool-specific guidance.
Tool-Specific File Examples
The previous sections contain detailed examples for:
- Cursor .mdc rules: See Part V for
000-project.mdcand200-high-risk-paths.mdcexamples - Devin Playbooks: See Part IV for
dependency-upgrade.devin.mdexample - Subagent configurations: Each tool’s section contains configuration patterns
File Purpose Summary
| File | Purpose | Tool(s) | Loading Behavior |
|---|---|---|---|
AGENTS.md | Canonical cross-tool rules | All 5 tools | Always loaded (except Cursor scoped) |
CLAUDE.md | Claude-specific additions | Claude Code | Always loaded |
GEMINI.md | Antigravity-specific overrides | Antigravity CLI | Always loaded |
.codex/agents/*.toml | Codex subagent definitions | Codex CLI | Per-subagent configuration |
.antigravity/agents/*.yaml | Antigravity subagent definitions | Antigravity CLI | Per-subagent configuration |
.claude/skills/ | Claude Code skills | Claude Code | Load on match |
.cursor/rules/*.mdc | Cursor scoped rules | Cursor | Glob-based activation |
.cursor/agents/*.md | Cursor subagent personas | Cursor | Per-subagent configuration |
.cursor/skills/ | Cursor skills | Cursor | Load on match |
playbooks/*.devin.md | Devin workflows | Devin CLI | Load on invocation |
Setup Checklist
Initial Setup
Write
AGENTS.mdfirst: Conventions, build/test/lint commands, guardrails, a pointer to your skills index. Keep it lean β strip anything that reads like an auto-generated architecture overview or README duplication; agents can already read the README and discover file-level detail themselves.Add
CLAUDE.mdwith Claude-specific additions only, plus a one-line pointer toAGENTS.md. Don’t duplicate content that belongs in the shared file.Add
GEMINI.mdwith Antigravity-only overrides; confirm it isn’t also being loaded by a separate Gemini CLI install on the same machine (both write to~/.gemini/GEMINI.md).Confirm Devin’s
read_config_fromsetting (~/.config/devin/config.json) hasagents_standard: trueso it’s actually reading yourAGENTS.md.
Skills and Playbooks
Move any repeatable multi-step workflow into a Skill (Claude/Codex/Antigravity/Cursor) or a Playbook (Devin) instead of a paragraph in a Rules file. This is the primary mechanism for reducing token overhead through progressive disclosure.
In Cursor specifically, split any always-apply rule that’s grown past a screen or two into scoped
.mdcrules with realglobsβ an always-apply rule that’s really only relevant tosrc/api/**is paying the always-loaded tax for no reason.
Model Configuration
- Set per-subagent model tiers in each tool’s subagent config β not just the primary session model. Reserve expensive models (Opus, GPT-4, etc.) for high-value tasks, use cheaper models for routine operations.
Maintenance
Re-audit all five tools’ config quarterly. The biggest silent cost driver in these files isn’t any single bad line β it’s accumulated, never-pruned instructions nobody remembers adding.
Monitor for rule drift: Ensure tool-specific files don’t gradually accumulate content that belongs in
AGENTS.md. The shared file should remain the single source of truth for cross-tool rules.
Common Pitfalls
Path Conflicts
- Gemini CLI + Antigravity CLI: Both write to
~/.gemini/GEMINI.md, causing silent context pollution. Separate deliberately using~/.gemini/AGENTS.mdfor shared rules.
Duplication
- Copying content between
AGENTS.mdand tool-specific files: Defeats the purpose of having a shared canonical file. ReferenceAGENTS.mdfrom tool-specific files instead of duplicating.
Always-Loaded Bloat
- Over-sized always-apply rules: Especially problematic in Cursor where scoped rules are the native primitive. Split large always-apply rules into glob-matched scoped rules.
Missing Progressive Disclosure
- Putting task-specific instructions in always-loaded files: Move these to Skills or Playbooks that load on-demand instead.
Assumed Parity
- Assuming
AGENTS.mdparity across tools: Claude Code only gainedAGENTS.mdsupport in spring 2026 and still treatsCLAUDE.mdas richer for Claude-specific features. Don’t assume full parity.
Key Takeaways
One Canonical Source:
AGENTS.mdis the single source of truth for cross-tool rules. Everything else should reference it, not duplicate it.Progressive Disclosure: Use Skills, Playbooks, and scoped rules to load instructions only when relevant. This is the primary token optimization mechanism.
Tool-Specific Layers: Each tool has unique capabilities (Cursor’s scoped rules, Devin’s Playbooks, etc.). Leverage these rather than fighting against them.
Regular Maintenance: Token optimization isn’t set-and-forget. Quarterly audits prevent the accumulation of redundant instructions.
Model Tier Strategy: Per-subagent model routing is as important as file organization. Reserve expensive models for high-value tasks.
The concrete examples provided in this guide (AGENTS.md, CLAUDE.md, Cursor .mdc rules, Devin Playbooks) demonstrate these principles in action. Adapt them to your project’s specific needs while maintaining the core discipline: small always-loaded rules, large on-demand instructions.