/bonsai:splitfrom bonsai
Moves CLAUDE.md rules to the load scope of the sessions they govern (nested files, path-scoped rules, or root). Run after an audit, or when a resident file carries rules that bind one area.
Ships in bonsai. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Judge every rule of every in-scope CLAUDE.md against one question: which sessions does this rule govern? A resident rule that governs one subtree taxes every other session for nothing, and a scoped rule that governs the whole project is missing from most sessions that need it. The goal is placement: every rule loads in the sessions it governs, and in no others.
Throughout, "demote" and "promote" mean recording a verdict in the report. No file changes before approval, no exceptions.
This skill decides where rules live. Whether they live is /bonsai:audit's call: leave a rule that looks cuttable where it is and refer it to the audit. Run split after an audit, so placement work is spent only on lines that earned their keep.
Default scope is the current project tree. Writes only ever land in the project's CLAUDE.md files and .claude/rules/ files, plus the one-line pointer for another agent in the root AGENTS.md (step 3). User-level and ancestor-directory files are out of scope in both directions: they load in every project, so no in-project placement can host their content.
Placing lines an audit would cut wastes the pass, and its probes are the costly part. So after the inventory, and before any grep or probe, check whether the audit is obviously due. It is when both hold:
~/.claude/bonsai/runs/<key>/ holds no finished audit run (${CLAUDE_PLUGIN_ROOT}/references/rounds.md, "Continue a run"), or a resident file changed after it: a commit since its date (git log --since=<its date> -- <file>) or an uncommitted change (git status --porcelain -- <file>). <key> is the repository key from ${CLAUDE_PLUGIN_ROOT}/references/intake-entry.md.When both hold, stop and ask one AskUserQuestion that names the numbers: "CLAUDE.md is est. 14.2k tokens, unaudited since 40 commits, and one section holds 54% of it." Add the probe history when it predicts the result: the session reads through the shell, and an earlier split run in that harness mode (~/.claude/bonsai/runs/*/*/split-*.json, its context.harness_mode) kept every candidate it probed. Say so in one line: demotions here are unlikely to pass, so the probes would mostly confirm the file stays as it is. Offer two options:
A --headless run asks nothing: it continues and opens the PR body with the recommendation. Record the check in the run file as audit_first, with both signals and the answer, and the harness mode the session reads in as context.harness_mode, so a later run can read the probe history.
Placement chooses among the load classes in ${CLAUDE_PLUGIN_ROOT}/references/load-model.md: always resident, nested CLAUDE.md, or path-scoped rule. Read it before the pass, with the ladder in ${CLAUDE_PLUGIN_ROOT}/references/delivery.md, where these classes are R4 and R7. Read the repository's agents setting (${CLAUDE_PLUGIN_ROOT}/references/decision-memory.md) too, and when it is missing ask once, as /bonsai:audit does, and store the answer. Every demotion verdict hangs on the triggers it describes: a scoped file loads on a file-tool touch or a plain shell read, and on nothing else.
Check each rule against this list before measuring its scope. A match stays resident whatever the measurements say.
${CLAUDE_PLUGIN_ROOT}/references/load-model.md defines them narrowly. This holds even when every file the rule names lives in one directory: the grep says demote, this list says stay. A convention phrased with "never" goes through the normal pass.List each in-scope file with its load class and est. token cost (label every figure "est."). Include .claude/rules/*.md files with their paths globs resolved against the tree.
For each rule in an always-resident file, grep the first-party paths the rule binds: the files where following or violating it is possible. Use the subjects the rule itself names (a class, a directory, an extension, an API). Report the paths found, and let them decide the shape:
<subdir>/CLAUDE.md.The grep is the verdict on shape. The author's sense of where a rule "belongs" is not evidence.
A demotion only works if the scoped file is loaded by the time the rule matters. Name the mistake the rule prevents, then classify the action that commits it:
${CLAUDE_PLUGIN_ROOT}/references/load-model.md), so a session that writes the first file without the rule sees it before its next step and corrects that file. When the agents setting names an agent that reads only the root file (${CLAUDE_PLUGIN_ROOT}/references/load-model.md, "Other agents"), the demotion leaves a one-line pointer where that agent reads it: in CLAUDE.md when the root AGENTS.md is a symlink to it, else in the root AGENTS.md. With no root AGENTS.md, the pointer is a call. A rule that also governs files a generator or a shell command writes takes the next check for that workflow.sed -i, git mv, running a command): nothing loads. For these rules no verdict exists until a load-path probe runs, as ${CLAUDE_PLUGIN_ROOT}/references/probe.md prescribes: one fresh low-effort agent gets the task that would commit the mistake, in the real repo, without mention of the rule. The scoped file loads before the mistake: demote. It acts first, or reads only in shapes that load nothing: the rule stays resident. Run the probe in the harness mode the team works in: a mode that reads through the shell loads a scoped file only on plain reads, and a demotion probed in another mode is untested for it. The author guessing whether sessions read first is the same simulation the probe replaces. A rule in an always-resident file never probes clean, since every subagent inherits it (${CLAUDE_PLUGIN_ROOT}/references/probe.md): it stays resident, recorded as unresolved.For each rule already in a scoped file, run step 2's grep from that file's viewpoint. Governed paths outside the file's subtree or globs mean the rule outgrew its home: promote it to the smallest target that covers every governed path (a wider glob, an ancestor directory's CLAUDE.md, or root). Promotions pass through "Never demote" in reverse trivially: widening a rule's audience is always load-safe.
Flag orphans while there: a nested CLAUDE.md whose directory no longer holds first-party files, or a path-scoped rule whose globs match nothing. Deletion verdicts belong to /bonsai:audit, so record orphans as flags.
Read ${CLAUDE_PLUGIN_ROOT}/references/decision-memory.md before routing, then pick the delivery as ${CLAUDE_PLUGIN_ROOT}/references/decision-artifact.md prescribes under "Delivery". For the page, build it with the renderer that reference names. Each demotion or promotion is one move change, with destination scoped-file or root: an edit that removes the rule from its source and an edit that inserts it in the destination, with the governed paths and the load-path result as evidence. Route it:
${CLAUDE_PLUGIN_ROOT}/references/probe.md) on that edit. A drift makes it a call.kept, with the reason. Flags and skill candidates: questions or kept items.Present each round in full before editing anything, in rounds as ${CLAUDE_PLUGIN_ROOT}/references/rounds.md prescribes. Per rule: the verdict (demote, promote, keep, flag), the destination, and the evidence (governed paths, load-path result). Only edit after approval, and apply as ${CLAUDE_PLUGIN_ROOT}/references/rounds.md prescribes: one commit per destination file. Close with est. resident tokens per session before and after, listing separately what every session pays and what only in-scope sessions pay.
After applying, verify that each scoped file the edits created or re-globbed actually loads: one marker probe per created or changed glob, run as ${CLAUDE_PLUGIN_ROOT}/references/probe.md prescribes. A valid glob loads the rule and hides a malformed neighbor, so one file never vouches for the globs that did not select it. The phrase comes back: the glob fires. NONE twice: the placement is broken, and the move reverts until the globs are fixed.
A moved rule keeps its exact text. The only permitted edit is deleting a scope qualifier the destination now expresses: "In tests/, never use RefreshDatabase" becomes "Never use RefreshDatabase" inside tests/CLAUDE.md. Phrasing improvements belong to /bonsai:audit.
A demotion leaves nothing behind. The scoped file loads automatically, so a pointer at root would rebuild the cost the move removed. The one exception is a repository whose agents setting names an agent that reads only the root file: there the demotion leaves the one-line pointer step 3 places. A promotion retargets or removes the pointer that named the rule's old home, and keeps any pointer other rules still need. Create the destination file if it is missing, and append under a heading that matches its existing structure.
Content shaped as a procedure (a numbered workflow, a deploy guide, a checklist walked start to finish) belongs in a skill body. Flag it with a proposed skill name and the placement the skill rung of ${CLAUDE_PLUGIN_ROOT}/references/delivery.md gives it from the files the procedure touches, and stop there. Writing skills is a different job with its own standards.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
6 skills in this plugin
/auditPrunes CLAUDE.md files to the lines a fresh session cannot derive, every cut backed by evidence. Run when the files have grown without review./bakeConverts CLAUDE.md rules and recurring review findings into automated checks, and removes the prose once a check holds the rule. Run once enough rules have accumulated to be worth automating./feedTurns recurring corrections (conversation, intake entries, recent commits) into CLAUDE.md rules. Run after a working session or a review round./guardTurns review findings into guardrails, one pull request per check, cut from the default branch. Run with PR numbers or URLs after a review round, or once over every PR of a finished run, while the PRs are open or after they merged. A follow-up pass over review threads hands its PRs here before replying. Opens pull requests and replies on review threads./intakeRecords pull request review threads as local evidence for feed and bake. Run after a review round with the PR number or URL, or with `--search` over a reviewer's past PRs to start from history, `--export` to share candidates through the repo. Never commits, never touches the threads.npx claudepluginhub publicala/claude-plugins --plugin bonsai