repo-cleanup
Audit a repository and its Claude Code setup for wasted tokens, wasted time, and dead weight — then plan and apply fixes under evidence. Use when the user asks why sessions are slow or expensive, wants CLAUDE.md / .claude / skills / agents / MCP trimmed or optimized, wants dead code, unused dependencies, disabled tests or repo bloat found, asks where the tokens went, or says "repo-cleanup", "/repo-cleanup", "audit this repo", "clean up my .claude folder", "reduce context cost". Read-only by default; every finding carries evidence, a confidence level, and what was not verified.
- License 许可
- MIT
- 最近更新
- 2026-10-07
- Stars
- ★ 1
- Forks
- 1
01 前言 Front Matter
- name
- repo-cleanup
- metadata
- { "version": "1.0.0" }
- description
- Audit a repository and its Claude Code setup for wasted tokens, wasted time, and dead weight — then plan and apply fixes under evidence. Use when the user asks why sessions are slow or expensive, wants CLAUDE.md / .claude / skills / agents / MCP trimmed or optimized, wants dead code, unused dependencies, disabled tests or repo bloat found, asks where the tokens went, or says "repo-cleanup", "/repo-cleanup", "audit this repo", "clean up my .claude folder", "reduce context cost". Read-only by default; every finding carries evidence, a confidence level, and what was not verified.
02 资源文件 47
- 参考文档README.md10.0 KB
- 参考文档references/context-budget.md8.5 KB
- 参考文档references/doc-hygiene.md5.9 KB
- 参考文档references/finding-model.md6.6 KB
- 参考文档references/reference-leakage.md5.8 KB
- 参考文档references/remediation.md5.6 KB
- 参考文档references/repo-hygiene.md8.0 KB
- 参考文档references/safety-model.md6.4 KB
- 参考文档references/stack-adapters.md6.1 KB
- 参考文档references/token-forensics.md7.3 KB
- 脚本scripts/baseline.mjs6.5 KB
- 脚本scripts/config.mjs10.3 KB
- 脚本scripts/context-footprint.mjs25.2 KB
- 脚本scripts/detect-stack.mjs11.4 KB
- 脚本scripts/doc-hygiene.mjs18.7 KB
- 脚本scripts/findings.mjs8.5 KB
- 脚本scripts/measure-command.mjs5.9 KB
- 脚本scripts/redact.mjs9.8 KB
- 脚本scripts/reference-leakage.mjs23.6 KB
- 脚本scripts/repo-inventory.mjs23.6 KB
- 脚本scripts/report.mjs5.0 KB
- 脚本scripts/usage-forensics.mjs18.5 KB
- 脚本scripts/validate-installation.mjs8.6 KB
- 脚本tests/analyzers.test.mjs13.7 KB
- 脚本tests/config.test.mjs5.5 KB
- 脚本tests/context-footprint.test.mjs10.2 KB
- 脚本tests/detect-stack.test.mjs4.6 KB
- 脚本tests/findings.test.mjs6.2 KB
- 参考文档tests/fixtures/bare/README.md55 B
- 参考文档tests/fixtures/node-app/.claude/agents/x.md73 B
- 参考文档tests/fixtures/node-app/.claude/commands/c.md55 B
- 参考文档tests/fixtures/node-app/.claude/rules/one.md17 B
- 参考文档tests/fixtures/node-app/.claude/settings.json277 B
- 参考文档tests/fixtures/node-app/CLAUDE.md175 B
- 参考文档tests/fixtures/node-app/package.json326 B
- 参考文档tests/fixtures/node-app/packages/inner/CLAUDE.md104 B
- 脚本tests/fixtures/node-app/packages/inner/index.ts20 B
- 参考文档tests/fixtures/node-app/pnpm-lock.yaml—
- 脚本tests/fixtures/node-app/src/index.ts20 B
- 脚本tests/fixtures/node-app/test/a.test.ts26 B
- 参考文档tests/fixtures/node-app/tsconfig.json42 B
- 参考文档tests/fixtures/with space/package.json65 B
- 脚本tests/plugin-surfaces.test.mjs8.4 KB
- 脚本tests/redact.test.mjs9.0 KB
- 脚本tests/reference-leakage.test.mjs6.7 KB
- 脚本tests/report.test.mjs9.2 KB
- 脚本tests/usage-forensics.test.mjs8.3 KB
03 SKILL.md 正文
repo-cleanup — evidence-driven repo & Claude-setup auditor
Portable: assumes nothing about language, package manager or layout beyond what detect-stack.mjs
reports. Zero dependencies; every script is node >= 22.
You are the interpreter, not the measurer. Scripts produce numbers; you turn numbers into findings with a severity, a confidence and a recommendation. Never assert a number you did not get from a script or a command you ran.
Non-negotiables
- Read-only by default.
audit,plan,verifywrite nothing outside.repo-cleanup/. Never.gitignore, never source, never settings. Checkgit status --porcelainbefore and after, and report that it is unchanged. - Evidence or it is a suspicion.
confidence: confirmedneeds a measurement taken now or a static proof over the full file set. An estimate is never confirmed, and the word estimate appears next to every estimated number. - Lead with what was NOT verified. Before findings, not in a footnote.
- The host repo's rules bind you. Read its
CLAUDE.mdand.claude/rules/**first; treat what they protect as protected. - No secret reaches a report. Everything written passes
redact(). Credential files are detected by name, never opened. - Attribution and themes are the only places a third-party product may be named.
Everywhere else a product name is a leak — see
reference-leakage.md. - One finding per fix. There is no "fix everything" verb; do not improvise one.
Modes
Argument after /repo-cleanup; default audit.
| Mode | Reference to load | Script |
|---|---|---|
context |
context-budget.md |
context-footprint.mjs |
tokens |
token-forensics.md |
usage-forensics.mjs |
docs |
doc-hygiene.md |
doc-hygiene.mjs |
repo |
repo-hygiene.md |
repo-inventory.mjs |
refs |
reference-leakage.md |
reference-leakage.mjs |
audit (default) |
all five | all five |
plan <ID> |
remediation.md |
— |
fix <ID> |
remediation.md + safety-model.md |
detected gate |
verify [<ID>] |
remediation.md |
re-run the relevant analyzer |
stack-adapters.md only when the stack is unsupported or you are adding an adapter.
Workflow
0. Orient — always
node .claude/skills/repo-cleanup/scripts/detect-stack.mjs
Emits stack.json. A repo with no manifest and no git is valid input: degrade, do not fail.
Read the host CLAUDE.md + .claude/rules/**. Load finding-model.md and safety-model.md.
1. Measure
Run the invoked mode's script(s); load only that mode's reference. Scripts print JSON to stdout. Announce anything potentially expensive before running it and bound it with a timeout.
Save each result: writeEvidence(root, name, data) from scripts/report.mjs.
2. Interpret
Turn observations[] into findings via makeFinding() in scripts/findings.mjs — it enforces
the schema and will throw on an empty limitations or an estimate claiming confirmed. That is
the guard working; fix the finding, do not bypass it.
Impact needs volume. Without tokens data, a footprint finding's impact is unquantified and its
confidence is at most medium. Say so rather than inventing a multiplier.
Drop observations that do not support a finding. An observation is not a finding.
3. Report
writeReport({ root, mode, ranAt, stack, findings, summary, notVerified, ran });
Ranking, grouping and section order are deterministic — do not hand-format the report. Record a
baseline with writeBaseline() so verify has something to compare against.
In chat: the top three findings and the single first action. Link .repo-cleanup/report.md; do not
paste it.
4. plan / fix / verify
Follow remediation.md. fix requires one finding id, a clean tree, re-confirmed evidence, no
protected path, the smallest change, and the detected gate green afterwards. Gate red ⇒ stop and
restore. Settings changes route through the bundled update-config skill.
5. Self-audit — every run
If SKILL.md exceeds its 6 KB cap, or a reference has grown detail belonging in a script, raise it
as a DOC- finding against this skill. It is not exempt from its own rules.
Do not rebuild what exists
settings.jsonedits →update-config.- Permission-prompt reduction →
fewer-permission-prompts. - Logic review →
/code-review,/simplify,/security-review. This skill finds dead and duplicated code; it does not review correctness.
Install elsewhere
Copy .claude/skills/repo-cleanup/ and .claude/commands/repo-cleanup.md into the target repo,
then node .claude/skills/repo-cleanup/scripts/validate-installation.mjs. Optional
.repo-cleanup.yml at the repo root (documented subset — see scripts/config.mjs). Never write
into another repository on the user's behalf; hand them the steps.
Tests: node --test ".claude/skills/repo-cleanup/tests/*.test.mjs".
04 同仓库更多 Skills
brand-ui
Build UI with the brand-ui component system (@elabs-ai/components-* packages — ui, data, ai, flow, maps, charts, marketing, editor, viewer, terminal, tokens, icons). Use when working in a project that depends on @elabs-ai/components-ui or any @elabs-ai/components-* package, when adding/composing components, building dashboards, data tables, AI/chat surfaces, React Flow canvases, MapLibre maps, code editors, file/document viewers, app shells, forms, or marketing sections, when theming with the token system, or when the user mentions brand-ui, @brand, light/dark themes, or "our design system". Provides live project context, the real component API, composition patterns, and the rules that keep components token-driven, accessible, and theme-safe.
brand-ui-update-theme
Use when an existing brand-ui theme family should be improved from new material — updated brand guidelines, a new logo, product screenshots, a live site, feedback like "the green is off" or "match their new design system" — e.g. "update the qlik theme with these links", "refresh our theme from the new brand book", "/update-theme". For a brand with no theme yet, use brand-ui-create-theme.
brand-ui-theme
Create or retune a brand-ui theme (token work). Use when adding a new theme, re-branding the system to a customer's palette, adjusting global radius/spacing/surfaces, or fixing token-level contrast across themes. Use when the user says "new theme", "brand it for <customer>", "make corners less rounded", "dark theme", "adjust the tokens", or "our colors". Every change is a token in a theme stylesheet — never a hardcoded value in a component.
brand-ui-start
The front door for building UI with brand-ui — a router/concierge that asks what you want to do and hands you to the right flow. Use when someone is starting out and unsure where to begin ("help me with brand-ui", "where do I start", "I want to build something", "what can brand-ui do", "get me going"), or types /brand-ui-start. Routes to three flows — build a NEW app (brand-ui-new-app), improve/migrate an EXISTING app (brand-ui-migrate), or just help me USE brand-ui in an app that already has it (brand-ui). If the intent is already obvious (the person said "build me a dashboard" or "audit this screen"), skip the question and go straight to that flow.
brand-ui-registry
Curate the brand-ui shadcn-compatible registry (maintainer workflow). Use when deciding whether something belongs as an imported @elabs-ai/components-* primitive vs a copy-own registry block/template, when adding or editing a registry item, or when validating/building the registry for distribution. Use when the user says "add a registry item", "make this a block", "publish to the registry", or "package vs registry". For consuming registry items in an app, use the `brand-ui` skill (npx shadcn add).
brand-ui-new-app
Define-to-build — scaffold a new brand-ui app from a plain-language description (VP-02). Use when the user wants to START an app, page, or demo ("build me a sales dashboard", "I need an admin console for X", "new app", "scaffold a chat assistant", "create a landing page for a pitch") rather than add to an existing one. Runs a staged interview (quick 3-question mode or full 7-stage spec mode), writes an app-spec.md, then scaffolds from the matching template + playbook with every wiring point annotated and a starter CLAUDE.md so later agent sessions stay on-brand. For adding components to an existing app use `brand-ui`; for authoring library components use `brand-ui-component`.