* feat(setup): redirect beads block to AGENTS.md when CLAUDE.md is a stub
When CLAUDE.md is a thin pointer that imports AGENTS.md via the
@-include convention (e.g. "@AGENTS.md" on its own line), bd setup claude
now writes the managed BEADS INTEGRATION block to AGENTS.md instead of
duplicating it in the stub. This supports the shared-authoritative-file
pattern used by repos that keep AGENTS.md as the single source of agent
instructions.
The redirect applies to install, check, and remove operations. If
AGENTS.md does not exist, the fallback behavior (writing to CLAUDE.md)
is preserved.
Agent-Signature: amp-gpt-5.4-2026-03-05-high on behalf of maphew
* fix(setup): strip stale CLAUDE.md beads block when AGENTS.md redirect activates
An older bd could have written a beads-managed block directly into CLAUDE.md
before a project adopted the "@AGENTS.md" import-stub pattern; once the
redirect to AGENTS.md activates, that block became an orphaned duplicate that
neither install nor remove ever cleaned up. installClaude now strips a stale
block from CLAUDE.md when the redirect is active (preserving the rest of the
stub), and removeClaude strips it too, alongside removing the AGENTS.md copy
as before.
Agent-Signature: claude-fable-5-high on behalf of matt wilkie
* fix(setup): gate CLAUDE.md strip on successful AGENTS.md injection; preserve shared AGENTS.md block on remove
Addresses two major findings from PR #4838 review:
- installClaude stripped the stale CLAUDE.md beads block whenever the
AGENTS.md redirect was active, even when installAgents skipped injection
(e.g. AGENTS.md is a symlink). That deleted the only copy of the beads
block without writing a replacement. Gate the strip on
`redirected && !agentsSkipped`.
- removeClaude with the redirect active called removeAgents against
AGENTS.md, deleting the project-authoritative shared beads section that
bd init/other agents' setup created and other agents rely on. Limit the
redirected remove path to stale CLAUDE.md cleanup and leave the shared
AGENTS.md section intact.
Also addresses minor finding: isAgentsImportStub now also accepts the
`@./AGENTS.md` relative-import form, not just `@AGENTS.md`.
Deferred (minor, ambiguous product intent, needs maintainer input rather
than a guess): blank AGENTS.md gets ProfileMinimal on redirect; whether it
should get the full profile instead is a product decision, not a bug fix.
Added regression tests: TestInstallClaudeRedirectSkipsStripWhenAgentsSymlink,
TestRemoveClaudeRedirectPreservesFullProfileSharedBlock; updated
TestRemoveClaudeRedirectsToAgentsMD and
TestRemoveClaudeRedirectCleansStaleClaudeBlock to assert the shared AGENTS.md
block is preserved on remove; added an @./AGENTS.md case to
TestIsAgentsImportStub.
Agent-Signature: claude-fable-5-high on behalf of matt wilkie
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>