/koopa:koopa-maintain-claude-configfrom koopa
Guides maintaining Claude Code configuration (CLAUDE.md, rules, hooks, skills) with progressive disclosure, the 200-line rule, and decision trees for where new rules belong.
Ships in koopa. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Configuration that loads unconditionally on every session costs tokens every time, whether relevant or not. The goal is to keep always-loaded content minimal and push everything else to mechanisms that load only when needed.
| Mechanism | Loads When | Token Cost | Use For |
|---|---|---|---|
CLAUDE.md / rules/*.md (no frontmatter) | Every session | Always | Universally-applicable standing facts only |
rules/*.md with paths: frontmatter | Matching file opened | Conditional | Language/directory-specific conventions |
| Skills | Explicitly invoked | Description only (body on demand) | Reference content, procedures, domain knowledge |
Hooks (settings.json) | Tool event fires | None | Hard behavioral enforcement |
Anthropic's official guidance: keep every always-loaded file under 200 lines. Longer files cause Claude to ignore rules, important instructions get lost in the noise. This is qualitative degradation, not just a capacity problem; it begins before the context window fills.
@path imports do NOT help. @file references in CLAUDE.md still load the
imported content unconditionally at session start. Only paths: frontmatter and
skills actually reduce token spend.
Ask these questions in order:
Must this always run, regardless of whether Claude agrees? → Hook
(PreToolUse to block, PostToolUse to enforce after). Rules in prose have
no compliance guarantee; hooks are deterministic.
Does this only apply when working in a specific language or directory? →
rules/*.md file with paths: frontmatter. Example:
---
paths:
- "**/*.py"
- "**/pyproject.toml"
---
Is this reference content, a procedure, or domain knowledge? → Skill. Skill descriptions stay in context; the full body loads only when invoked.
Does this genuinely apply to every session in every project? → Keep it in
CLAUDE.md or an unconditional rules/*.md file. Be ruthless, if Claude
already does it correctly without the instruction, delete it.
Every skill's description: key must use the folded-strip block scalar:
description: >-
One or more lines of prose describing what the skill covers and when to use it.
Never plain > and never an inline scalar. Related constraints
(Claude Code itself has no such limit, but a skill tree shared across tools must
satisfy every reader):
MAX_DESCRIPTION_LEN=1024, and
Copilot CLI enforces it too. An over-cap skill gets dropped by whichever CLI
reads it (Copilot CLI's current behavior is a per-skill drop with a "N skill(s)
failed to load" banner, not the whole-directory failure earlier Copilot versions
had). >- makes parsed length equal raw length; plain > folds in a trailing
newline, silently spending 1 char of the budget for nothing.key: value patterns inside the description body. A naive
non-block-scalar extractor can misread a colon-space as a nested YAML mapping.
A correctly-formed >- block scalar sidesteps this: ordinary prose colons
("Use when: X, Y, or Z") are safe once the block-scalar form is used.test_plugin_skills.py caps the plugin's index at 5,000 chars
and koopa's repo-local .agents/skills at 20,000; koopa app claude audit-tokens reports the index for any tree.<server> MCP server's <tool> tool"
and describe actions ("ask the user", "track the steps in a file"), not one
harness's own names (mcp__server__tool, AskUserQuestion, TodoWrite,
ExitPlanMode). Skills about a harness's own configuration are exempt;
test_plugin_skills.py enforces the rest.Verify any skill tree with the validator (checks frontmatter shape, length, naming, and the trigger phrase, not prose):
koopa develop check-skills # koopa's own default skill trees
koopa develop check-skills <path/to/skills/dir> # any other tree, e.g. a work repo
Point it at a source tree (a repo's own .agents/skills), not at a deployed
directory shared by several trees (for example ~/.agents/skills): the
prefix check infers each root's shared prefix by majority, so a minority
tree's skills would be flagged as outliers there.
.agents/skills conventionThe Agent Skills format is an open standard (originally from Anthropic,
spec at agentskills.io) that Codex CLI, Gemini CLI, and Copilot CLI all read
directly, same SKILL.md files, no format changes needed beyond the frontmatter
rules above. .agents/skills (and .agents/rules for path-scoped rules) is the
canonical, real directory; nothing is named after one vendor's own discovery
path. .claude/skills and .claude/rules are symlink aliases onto it, kept only
because Claude Code has no native .agents/ path of its own:
| Tool | Native path(s) | Reads .agents/skills? |
|---|---|---|
| Claude Code | .claude/skills/, ~/.claude/skills/ | No: reached only via the .claude/skills -> .agents/skills symlink |
| Codex CLI | .codex/skills/ (walking up to repo root), ~/.codex/skills/ | Yes |
| Gemini CLI | .gemini/skills/, ~/.gemini/skills/ | Yes: wins over .gemini/skills at the same tier |
| Copilot CLI | .github/skills/, .claude/skills/, ~/.copilot/skills/ | Yes |
Antigravity CLI (agy) | Unconfirmed: no public doc page found; changelog confirms native skill support exists | Unconfirmed: no evidence either way |
.agents/{skills,rules} are the real directories, both in a project repo
(git-tracked, e.g. this koopa checkout's own .agents/skills -> ... adapter
pattern) and user-global (~/.agents/{skills,rules}, chezmoi-managed, source
dot_agents/{skills,rules}/). .claude/{skills,rules} are symlink aliases onto
them: ../.agents/skills and ../.agents/rules in a repo, and chezmoi
dot_claude/symlink_skills / dot_claude/symlink_rules globally. So Codex,
Gemini CLI, Copilot CLI, and Claude Code (via the alias) all read one tree with
zero duplication. Antigravity is an accepted gap, not a pending task: its config
root is ~/.gemini/config/, not ~/.gemini/skills/, and confirming its exact
skill-discovery path requires an authenticated agy session, this machine has
no Antigravity login, so the path stays unverified here. Re-check only if
Antigravity auth becomes available.
A paths:-scoped rule matching **/*.sh silently covers zero chezmoi shell sources: they
are named dot_zprofile-work.tmpl, dot_bashrc-work, install, with no .sh suffix.
dotfiles-shell.md carried the correct 4-space rule for months while every file it mattered
for went unmatched. A rule that never fires looks identical to a rule that does not exist.
git ls-files output before trusting it..editorconfig (declarative, editor-visible), not prose alone..editorconfig section glob matches on basename for a bare pattern, so extension-less
files need explicit brace lists ({install,dot_profile*,...})..editorconfig must omit root=true to override one property while inheriting
the rest from a parent./init on a new project to generate a starter CLAUDE.md.IMPORTANT / YOU MUST emphasis for genuinely critical rules;
overuse dilutes signal.When reviewing a rules file, apply each instruction to this filter:
paths: frontmatterHooks live in settings.json under "hooks". They fire deterministically
regardless of what Claude decides.
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{
"type": "command",
"command": "bash ~/.agents/hooks/guard-installs.sh"
}]
}
]
}
}
A blocking hook should exit with code 2 and write a JSON decision:
echo '{"decision": "block", "reason": "Install commands are not allowed. Surface the command and let the user run it."}' >&2
exit 2
koopa app claude audit-tokensThe command reports approximate token cost for always-loaded Claude config.
Token estimate: len(text) // 3 (chars, not bytes), calibrated against a live
/context reading; the common // 4 English-prose figure undercounts Markdown
with arrows, dashes, and code.
Flags:
--scope {all,global,project}: default all; scan global ~/.claude/, the
current project's .claude/, or both. Project root is auto-discovered by walking
up from CWD looking for a .claude/ or .agents/ subdir, or .git/.--project-dir PATH: explicit project root, skips CWD discovery.--max-tokens N: exit 1 if combined always-loaded tokens exceed N.What "always-loaded" means: CLAUDE.md + all rules/**/*.md files without
paths: frontmatter. Path-scoped files are reported separately but excluded from
the gated total. Rules are read from the canonical .agents/rules first, then from
the .claude/rules alias (a symlink to it). Each file appears once, under its
.agents/rules/... path.
The combined all output is the true per-session token cost before the first prompt.
Use --scope global to see only the global tree (~/.claude/CLAUDE.md plus the
rules under ~/.agents/rules), or --scope project for only the current project.
Each tree also gets two notes, printed only when they apply and never counted toward
--max-tokens: its skill index (every skill's name plus description under
.agents/skills and .claude/skills, symlinks counted once), and the rules that
Copilot loads twice (a rule in .agents/rules with a same-stem generated copy in
.github/instructions, or ~/.copilot/instructions for the global tree).
When a project lessons file (<prefix>-lessons.md, or lessons.md if the
repo does not prefix its rules) exceeds ~200 lines, apply this triage to
each lesson:
## Gotchas section (or a similarly named topical
heading, matching that skill's own convention). Replace the lessons-file
entry with a 1-line pointer: - **Title**: see the \skill-name` skill.`Do not keep a skills index or a path-scoped-rules index table in an
always-loaded file. Claude Code already lists every skill's description, and
it already loads a paths:-scoped rule on its own when a matching file
opens, so an index in CLAUDE.md or the lessons file only repeats what the
tool itself already surfaces, at always-loaded token cost.
This pattern routinely achieves 70-80% token reduction on a bloated lessons file while preserving all knowledge in skill files that load on-demand.
Token targets:
koopa app claude audit-tokens --scope global for the current figure.lessons.md: ≤200 lines / ≤3,000 tokenskoopa app claude audit-tokens --max-tokens 10000.Hook: never-install enforcement: ~/.agents/hooks/guard-installs.sh. Done.
Path-scope dotfiles-python.md: paths: ["**/*.py", "**/pyproject.toml"]. Done.
Path-scope environment-specific rules: GHA, IaC, cloud-platform rules path-scoped to their relevant file patterns. Done.
Migrate bulky lessons-file entries to skills: apply the triage pattern above whenever a project lessons file exceeds 200 lines.
Migrate dotfiles-workflow.md to a skill: it was entirely procedure and
reference, never a hard behavioral constraint. Now a ~10-line stub with a
pointer to the koopa-workflow-guidance skill. Done.
dotfiles-coding.md, dotfiles-thinking.md, dotfiles-security.md:
apply the test, "would removing this instruction change Claude's behavior?"
Delete where the answer is no.paths:-scoped rules: language/framework/project-type conventionsThis config spans two chezmoi trees. The public koopa tree cedes ownership of
settings.json (and .npmrc, pip.conf) to the work tree when the generic
~/.config/koopa/dotfiles-work symlink exists:
{{- if stat (joinPath .chezmoi.homeDir ".config" "koopa" "dotfiles-work") }}
.claude/settings.json
.config/pip/pip.conf
.npmrc
{{- end }}
Rules for extending this:
dotfiles-work (generic symlink name), never the actual
private repo name. This keeps the public repo free of private identifiers.guard-installs.sh) live in koopa and are deployed everywhere;
both settings files merely reference them by path.Every file this tree deploys into ~/.agents/rules/ or ~/.agents/skills/
(aliased as ~/.claude/rules/ / ~/.claude/skills/) must carry a prefix that
names the tree that owns it. The prefix stops two trees from silently writing
to the same bare filename.
| Layer | Location | Owner | Prefix |
|---|---|---|---|
| User-global, public | ~/.agents/{rules,skills}/ (aliased as ~/.claude/{rules,skills}/) | this public dotfiles tree (main tree) | dotfiles- |
| User-global, other private/work trees | same directories | that tree's own install | its own distinct prefix (not dotfiles-) |
| Project | <repo>/.agents/{rules,skills}/ (aliased as <repo>/.claude/{rules,skills}/) | that repo | <repo-name>-, e.g. koopa- |
| Project lessons file | <repo>/.agents/rules/<repo-name>-lessons.md, or lessons.md if the repo does not prefix its rules | that repo | the repo's own prefix, if it has one |
| Local, unmanaged | any unprefixed name under ~/.agents/ | the user, not any managed tree | none |
The invariant: a managed tree must only ever deploy files whose name carries
its own prefix into ~/.agents/rules/ or ~/.agents/skills/. This is what keeps
two trees, or a tree and the user, from silently colliding on the same bare
filename.
This tree's prefix is dotfiles-, not something like personal-, because the
prefix names the tree or repo that owns and deploys the file. This tree is the
shared public dotfiles repo, not a personal one, so dotfiles- is correct where
personal- would not be.
.chezmoiremove may list an unprefixed legacy filename only for a one-time
migration off an old, no-longer-prefixed name. It is never an ongoing pattern:
remove the entry once the migration lands.
koopa-claude-permissions: protected paths, permission modes, allow/ask/deny
precedence, PreToolUse permissionDecision contract, and the carve-out hook
for .claude/ writes. Use when debugging unexpected permission prompts.This user's configuration lives in chezmoi at:
~/.local/share/koopa/opt/dotfiles/chezmoi/dot_claude/
(or equivalently ~/.config/koopa/dotfiles/chezmoi/dot_claude/).
Hook scripts are the exception: they live in chezmoi/dot_agents/hooks/ (public
tree) and the work tree's chezmoi/dot_agents/hooks/, both deploying into one flat
~/.agents/hooks/ directory (~/.claude/hooks is a chezmoi dot_claude/symlink_hooks alias
onto it). settings.json.tmpl and the Copilot hook templates
point at that path.
The deployed targets are ~/.claude/ and ~/.agents/. Always edit the chezmoi
source, not the deployed copy, it will be overwritten on the next chezmoi apply.
After editing, deploy with a targeted apply. Target the real managed path
(~/.agents/...), not the ~/.claude/... alias, ~/.claude/rules and
~/.claude/skills are symlinks, not individually managed targets:
chezmoi apply \
--source=~/.local/share/koopa/opt/dotfiles/chezmoi \
~/.agents/rules/dotfiles-lessons.md # or whichever file changed
Do NOT run koopa configure user dotfiles from inside a long-running agent
session, the session's KOOPA_COLOR_MODE may be stale and will clobber theme
files.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub acidgenomics/koopa --plugin koopa14 skills in this plugin
/koopa-agent-guardsWhat the koopa plugin's agent guard hooks block or ask about, why, and the correct alternative for each. Use when a koopa hook blocked or asked about a command or a file write, when a deny message names a script such as block_uv.py or guard_rm.py, or when the user asks what the koopa plugin guards do and how to configure them./koopa-claude-permissionsClaude Code permission system internals, protected paths, permission modes, allow/ask/deny rule precedence, and the PreToolUse permissionDecision hook contract. Use when debugging unexpected permission prompts, understanding why Edit(.claude/**) or Bash(*) allow rules have no effect on .claude/ writes, reasoning about acceptEdits vs plan vs bypassPermissions mode tradeoffs, a headless claude -p call that hangs with no output, interpreter allow entries (bash, python, sh, xargs) that bypass deny rules, a deny rule that blocks a harmless test command, or a settings.json change that did not deploy on a work host./koopa-cliCommand syntax for koopa, a shell bootloader that installs apps into its own prefix instead of the system package manager. Use when changing koopa's CLI architecture, installing a CLI tool, updating apps, switching koopa branches, recovering from a stale checkout, or listing what koopa manages./koopa-envWhy a tool resolves inside the koopa prefix instead of Homebrew or the system, how to check that, and how koopa activation behaves in non-interactive and agentic sessions. Use when a command resolves to an unexpected binary, when PATH order looks wrong, or when working inside an SSH/CI/agent harness session that needs koopa's tools on PATH, when asking which shell an agent runs, what KOOPA_BUCKET is, when BSD `sed -i` fails on macOS and `gsed` is the fix, or when `timeout` is a missing command on macOS and `gtimeout` is the fix./koopa-ghosttyTroubleshoot Ghostty directory-access failures caused by macOS privacy permissions. Use when Ghostty reports Permission denied, code 13, or cannot list a Documents or cloud-synced directory that other apps can access./koopa-git-history-surgeryRewrite git history safely with git filter-repo. Use when removing secrets or sensitive files from commits, rewriting author/committer emails across history, de-duplicating doubled commits, or any commit-level surgery.Other plugins' skills for the same job