bd-detox
Skill4 starsChanged 3 months agoMITView on GitHub
Remove the anti-MEMORY.md clause from a project that already ran vanilla `bd init`, on the paths that actually reach Claude Code — the CLAUDE.md `BEADS INTEGRATION` block and bd's runtime `bd prime` output. Idempotent. Invoke as `/ticket-flow:bd-detox` (default: strip the clause, append the Coexistence Policy to CLAUDE.md, install the prime override) or `/ticket-flow:bd-detox --skip-agents` (delete AGENTS.md and the BEADS INTEGRATION block entirely).
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 64
No contamination detected and PRIME.md in place → script reports "✓ already clean" and exits 0
- Very specific: line 80
.beads/PRIME.mdwritten by hand: never overwritten. If it predates this skill it may be a bare mute file — check that it still carries …
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill 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
/ticket-flow:bd-detox — Memory-clause cleanup for existing beads projects
Args:
- (none) — coexistence mode: remove the anti-MEMORY line from
CLAUDE.mdandAGENTS.md, append the Memory Coexistence Policy to CLAUDE.md (and to AGENTS.md when it exists), install the.beads/PRIME.mdoverride. Equivalent end-state to a fresh/ticket-flow:init --mode=beads(default mode). --skip-agents— purge mode: deleteAGENTS.mdentirely, strip theBEADS INTEGRATIONblock fromCLAUDE.md. Equivalent end-state to a fresh/ticket-flow:init --mode=beads --skip-agents. Recommended for tf users on the Auto-Memory + CLAUDE.md stack.--no-prime— leavebd primealone; skip the.beads/PRIME.mdoverride.--dry-run— show the planned changes without writing.
What it does
/ticket-flow:init --mode=beads only handles fresh beads projects (it scaffolds with tf's custom agents-template). Projects that already ran vanilla bd init have the anti-MEMORY clause baked into AGENTS.md plus a BEADS INTEGRATION block in CLAUDE.md, and bd re-emits the same guidance at runtime through bd prime. This skill is the after-the-fact cleanup.
Which file actually reaches Claude Code
Claude Code does not read AGENTS.md. Its memory files are CLAUDE.md and .claude/rules/ (memory docs). That reorders the whole cleanup:
| Surface | Reaches Claude Code | Handled by |
CLAUDE.md → BEADS INTEGRATION block | yes — this is the effective contamination | clause stripped + Coexistence Policy appended (coexistence) / whole block removed (purge) |
bd prime output (SessionStart and PreCompact hooks) | yes — injected at runtime | .beads/PRIME.md override |
AGENTS.md | no | cleaned anyway, for other agents (Codex, Cursor, Amp, …) |
The earlier version of this skill appended the Memory Coexistence Policy only to AGENTS.md — i.e. the countermeasure landed in the file this harness never reads, while the contaminating block stayed in the one it does. Coexistence mode now appends the policy to CLAUDE.md.
bd prime is mutable — the old caveat is wrong
Earlier versions of this skill claimed "bd prime's output is hardcoded in the bd binary, no known mute flag". That is not true since bd 0.44.0: if .beads/PRIME.md exists, bd prime returns that file and skips every built-in section (prime.go:116 returns before any default output; measured on a real project: 4877 bytes of stock output → 57 bytes of override). The skill installs the override from skills/bd-detox/templates/PRIME.md via skills/bd-detox/install-prime.sh, and never overwrites an existing PRIME.md.
Two pitfalls that come with the override — both by design, both your problem now:
- It also replaces the
PreCompactoutput, not just SessionStart. Whatever a session needs in order to resume after a compaction has to be insidePRIME.md, or it is gone at the worst possible moment. The shipped template therefore carries the state-recovery commands (bd ready,bd list --status=in_progress,bd show <id>), not just a mute line. - On bd < 1.2.2 the override hides persistent memories. Confirmed on bd 1.0.4:
bd rememberentries stop appearing in the prime output oncePRIME.mdexists. Fixed from bd 1.2.2 on. On an older bd, either upgrade or restate the critical memories insidePRIME.md.
Steps
The skill delegates to skills/bd-detox/bd-detox.sh. The script:
- Preflight — current dir is a git repo (
git rev-parse --git-dir) and contains.beads/. If not, abort with hint (bd-detox is for existing beads projects; use /ticket-flow:init --mode=beads for fresh ones). - Detect contamination — grep
CLAUDE.md(the effective path) andAGENTS.mdfor the marker stringsdo NOT use MEMORY.mdandBEADS INTEGRATION; check whether.beads/PRIME.mdis missing. - Plan — print a summary of what will be changed, labelled by whether the file reaches Claude Code. In
--dry-run, exit here. - Apply:
- Coexistence mode:
- Strip the contaminating lines from
CLAUDE.md, keep the rest of theBEADS INTEGRATIONblock (it holds a useful command quick-ref), and append the Memory Coexistence Policy from the plugin template. - Strip the same lines from
AGENTS.mdand append the policy there too — for the agents that do read it.
- Strip the contaminating lines from
- Purge mode (
--skip-agents):- Strip the whole
BEADS INTEGRATIONblock fromCLAUDE.md. - Delete
AGENTS.md.
- Strip the whole
- Both modes (unless
--no-prime): install.beads/PRIME.md.
- Coexistence mode:
- Verify — re-grep both files for the marker strings; if any remain, warn and list them.
- Report — confirm changes and restate the two
PRIME.mdpitfalls.
Skill-side retrofit step (after the script) — set the beads role: git config beads.role maintainer. Newer /ticket-flow:init sets this at scaffold time; projects initialized before that print warning: beads.role not configured (GH#2950) (two noise lines) on every bd call. Setting is idempotent — no need to check first.
Idempotency
Re-running on an already-detoxed project is a no-op:
- No contamination detected and
PRIME.mdin place → script reports "✓ already clean" and exits 0 - Coexistence Policy already appended → not re-appended (grep marker first)
.beads/PRIME.mdalready present → left untouched, including hand-tuned content
When NOT to run
- Fresh project without
.beads/→ use/ticket-flow:init --mode=beadsinstead - Project where you want bd's stock guidance (team setting) → leave as-is
- Project on bd < 1.2.2 that leans on
bd rememberoutput in prime → run with--no-prime, or upgrade bd first - Mid-flow worktree → finish the flow first, then detox on main
Edge cases
AGENTS.mdwas hand-edited beyond recognition: the line-strip might miss it. Script warns and asks for manual review. Low stakes — Claude Code never reads it.CLAUDE.mdBEADS INTEGRATION block was reformatted: matched by its header marker, not exact text. If the marker is missing, the block is reported as not found — manual cleanup needed.- Custom-template-style AGENTS.md (already detoxed via init custom template): script detects the Memory Coexistence Policy section and treats the file as clean.
.beads/PRIME.mdwritten by hand: never overwritten. If it predates this skill it may be a bare mute file — check that it still carries what a post-compaction session needs.- No
.beads/: script aborts — there's nothing for bd-detox to clean.
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.

