Relationships
#3346 repo init --tool claude writes a CLAUDE.md that shadows an existing AGENTS.md
Opened by elem103 · 10/13/2026· Shipped 10/13/2026
Summary
swamp init / swamp repo init with --tool claude (also the default when --tool is omitted) always scaffolds and maintains a root CLAUDE.md. The built-in claude tool config hard-codes instructionsFile: "CLAUDE.md". Now that Claude Code reads AGENTS.md natively, this creates a duplicate instructions file and — worse — causes Claude Code to ignore the repository's existing AGENTS.md.
Environment
- swamp
20261013.032621.0-sha.fc312a85(macOS arm64)
Steps to reproduce
mkdir demo && cd demo && git init- Create an
AGENTS.md(repository already standardised on the shared standard) swamp init --tool claude --no-vaultls-> aCLAUDE.mdis created alongsideAGENTS.md
Current behaviour
- Built-in
claudetool config:skillsDir: ".claude/skills",instructionsFile: "CLAUDE.md",instructionsMode: "shared". - Verified: in an empty git repo,
swamp init --tool claude --no-vaultcreatesCLAUDE.md(6113 bytes, carrying the<!-- BEGIN swamp managed section -->marker). claudeis the default tool when--toolis omitted.- This is inconsistent with the other agent built-ins (
amp,opencode,codex,copilot,pi,antigravity), which all useAGENTS.md.
Expected behaviour
For a repository that already has an AGENTS.md, --tool claude should use that existing AGENTS.md (or require explicit opt-in) instead of unconditionally creating a duplicate CLAUDE.md.
Impact
Per Anthropic's Claude Code memory docs (https://code.claude.com/docs/en/memory#agents-md), Claude Code reads AGENTS.md as project instructions when there is no CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md in the working directory or above it (requires Claude Code v2.1.277 or later). When a CLAUDE.md IS present, Claude Code reads CLAUDE.md only and does not read AGENTS.md. So swamp's claude scaffolding causes the repository's canonical AGENTS.md to be ignored by Claude, and leaves a second instructions file that can drift out of sync.
Why this is a bug rather than a feature
The claude tool's purpose is to give the agent the project rules. Now that Claude Code natively reads the shared AGENTS.md, unconditionally emitting CLAUDE.md produces an incorrect result (a duplicate that shadows the canonical file) rather than adding a missing capability. This matches earlier init/upgrade tool bugs: #1754 (repo init/upgrade --tool kiro references the wrong skills path) and #3322 (repo init --help omits built-in tools).
Proposed fix
- Prefer an existing
AGENTS.mdfor the built-inclaudetool (shared instructions mode); fall back toCLAUDE.mdonly when noAGENTS.mdexists. - Optionally add an explicit override, e.g.
swamp init --tool claude --instructions-file AGENTS.md. - Make
swamp repo upgrade/swamp updateidempotent so it does not (re)createCLAUDE.mdin repositories that have adoptedAGENTS.md.
Workarounds
There is no CLI option to make the built-in claude tool target AGENTS.md: swamp init exposes no instructionsFile option, and a custom tool cannot shadow the built-in because validateCustomToolName rejects names that collide with built-ins (claude). The following workarounds were verified against swamp 20261013.032621.0-sha.fc312a85.
swamp repo upgrade behaviour (important for any workaround)
- If
CLAUDE.mdis missing whileclaudeis enrolled,swamp repo upgraderecreates it (fresh 6113-byte managed section). DeletingCLAUDE.mdis therefore not durable on its own. - Content placed outside the
<!-- BEGIN/END swamp managed section -->markers is preserved acrossswamp repo upgrade(reported asInstructions: unchanged). swamp repo upgrade --tool <tool>replaces the enrolled tool list. Dropping a tool warns that its files (e.g..claude/,.agents/skills/) are left behind and must be removed by hand.
Options
- Keep
--tool claudeand append@AGENTS.mdtoCLAUDE.md, after the managed block. Claude readsCLAUDE.mdand importsAGENTS.md; survivesswamp repo upgrade. (Duplicates swamp rules if the repo'sAGENTS.mdalso carries a swamp managed section.) - Have Claude read both files via the Project instructions setting (
claude-md-and-agents-md) — no file edits needed. - Delete
CLAUDE.md(stopgap). Claude falls back toAGENTS.md, but the nextswamp repo upgraderecreates the file. - Stop enrolling
claude(swamp repo upgrade --tool opencode, etc.) and deleteCLAUDE.md. Durable, but theAGENTS.md-based tools sync skills to.agents/skills, which Claude Code does not read, so a custom tool (skillsDir.claude/skills, instructionsFileAGENTS.md) would be needed to keep swamp skills working.
References
- Anthropic, "How Claude remembers your project" — AGENTS.md resolution table and the v2.1.277 requirement: https://code.claude.com/docs/en/memory#agents-md
- Same doc, "When AGENTS.md support is unavailable": https://code.claude.com/docs/en/memory#when-agents-md-support-is-unavailable
- Same doc, troubleshooting "My AGENTS.md isn't loading": https://code.claude.com/docs/en/memory#my-agentsmd-isnt-loading
Notes
Reading AGENTS.md requires Claude Code v2.1.277 or later. Before v2.1.281, some sessions — notably those on Amazon Bedrock or with telemetry disabled — read CLAUDE.md files only (https://code.claude.com/docs/en/memory#when-agents-md-support-is-unavailable); the documented remedy there is to update Claude Code, or to import AGENTS.md from a CLAUDE.md. Any fix should preserve a supported path for those environments.
Shipped
Click a lifecycle step above to view its details.
stack72 commented 10/13/2026, 3:26:50 PM
Thanks @elem103 for reporting this! We shipped: swamp init and repo upgrade with the claude tool stop shadowing an existing AGENTS.md. When the repo has an AGENTS.md with its own content and no CLAUDE.md, swamp writes its Claude rules to .claude/rules/swamp.md, which Claude Code loads alongside AGENTS.md on current versions and which older clients (2.0.64+) still load. Repos that already have swamp's section in a CLAUDE.md that holds nothing else get an @AGENTS.md import inside the managed section. Every other repo shape keeps today's output byte for byte, and the choice is sticky so upgrades never flip targets.. The fix has been merged and a release is on its way. We appreciate your contribution to swamp.
Sign in to post a ripple.