improve-codebase
Skill9 starsChanged 4 months agoMITView on GitHub
Use when designing or reviewing a module's interface, deciding where a seam goes, finding shallow modules or deepening opportunities, running an architecture review, making code more testable or AI-navigable, or extracting code repeated across three or more projects into a shared library, skill, template, or config. Also supplies the deep-module vocabulary (module, interface, depth, seam, adapter, leverage, locality) when another skill or review needs it.
6 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- jmusick/skillstheir own version, first seen Nov 8, 2026
- chrisleekr/skillstheir own version, first seen Nov 6, 2026
- fabiandistler/agentstheir own version, first seen Nov 1, 2026
- fboulnois/skillstheir own version, first seen Oct 15, 2026
- BuilderIO/builder-agent-skillstheir own version, first seen May 26, 2026
- kimgoetzke/coding-agent-configsedited, first seen Apr 30, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- kimgoetzke/coding-agent-configs★ 226% same
Wrote their own version · 5
- BuilderIO/builder-agent-skills★ 16same name
- fabiandistler/agents★ 2same name
- chrisleekr/skills★ 1same name
- fboulnois/skills★ 1same name
- jmusick/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agentic-scaffoldingSkill
- annas-archive-ebooksSkill
- ansi-artSkill
- clarifySkill
- conjecture-cascadeSkill
- crystallizeSkill
- dianalokadaSkill
- duris-game-knowledgeSkill
- duris-group-combatSkill
- ebook-extractorSkill
- failure-modesSkill
- gpt-pro-loopSkill
- graph-researcherSkill
- jevSkill
- julian-writingSkill
- kalshi-prediction-marketSkill
- lemmaSkill
- medium-paywall-bypassSkill
- ml-learning-methodsSkill
- name-reviewSkill
- no-process-pornSkill
- pm-deep-analysisSkill
- pm-market-analysisSkill
- pm-research-methodologiesSkill
- pm-situation-framingSkill
- prediction-drillSkill
- probe-driven-designSkill
- refine-testsSkill
- remove-ai-sinsSkill
- show-usageSkill
- writing-claude-skillsSkill
- x-undocumented-apiSkill
The file
We split this skill into the rules it gives an agent
9 rules. 0 are common, 9 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Use these terms exactly — don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
- Distinctive: line 58
Read the domain glossary and any recorded decisions in the area first.
- Distinctive: line 83
Use the domain glossary for the domain and this glossary for the architecture: if the domain defines "Order," say "the Order intake module" …
- Distinctive: line 85
If a candidate contradicts a recorded decision, surface it only when the friction is real enough to reopen the decision, and mark it in the …
- Distinctive: line 89
Do NOT propose interfaces yet.
- Distinctive: line 95
Keep the domain language current as decisions crystallize:
- Distinctive: line 98
Sharpening a fuzzy term?: Update the glossary right there.
- Distinctive: line 104
If you solved it twice, you'll solve it again.
- Distinctive: line 109
Parameterize: only the variance you observed.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Improve Codebase
Design deep modules: a lot of behaviour behind a small interface, placed at a clean seam, testable through that interface. The aim is leverage for callers, locality for maintainers, and testability for everyone.
Pick the work:
- Review — find deepening opportunities in one codebase. The default for
/improve-codebase. - Extract — turn code repeated across 3+ projects into one reusable artifact.
- Vocabulary — a design discussion or another skill needs the terms. Use the glossary and principles, then stop.
Glossary
Use these terms exactly — don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
- Module — anything with an interface and an implementation; scale-agnostic (function, class, package, tier-spanning slice). Avoid: unit, component, service.
- Interface — everything a caller must know to use the module correctly: type signature, invariants, ordering constraints, error modes, required config, performance characteristics. Avoid: API, signature (type-level surface only).
- Implementation — what's inside the module.
- Depth — leverage at the interface: behaviour a caller or test can exercise per unit of interface learned. Deep = lots behind little; shallow = interface nearly as complex as the implementation.
- Seam (Feathers) — a place where you can alter behaviour without editing in that place; where a module's interface lives. Seam placement is its own design decision. Avoid: boundary (collides with DDD's bounded context).
- Adapter — a concrete thing satisfying an interface at a seam. Role, not substance: a Postgres repo is a small adapter with a large implementation; an in-memory fake is the reverse.
- Leverage — what callers get from depth: one implementation pays back across N call sites and M tests.
- Locality — what maintainers get from depth: change, bugs, knowledge, and verification concentrate in one place. Fix once, fixed everywhere.
Principles
- Shrink the interface. Fewer methods, simpler parameters, more complexity hidden inside.
- Depth is a property of the interface, not the implementation. A deep module can be internally composed of small, swappable parts — they just aren't part of the interface. Internal seams (private, used by the module's own tests) can coexist with the external seam.
- The deletion test. Imagine deleting the module. Complexity vanishes → it was a pass-through. Complexity reappears across N callers → it was earning its keep.
- The interface is the test surface. Callers and tests cross the same seam. Wanting to test past the interface means the module is probably the wrong shape.
- One adapter means a hypothetical seam. Two adapters means a real one. Don't introduce a seam unless something actually varies across it.
- Design for testability. Accept dependencies, don't create them —
processOrder(order, paymentGateway), notnew StripeGateway()inside. Return results, don't produce side effects —calculateDiscount(cart): Discount, not mutate-and-return-void.
Rejected framings: depth as implementation-lines ÷ interface-lines (rewards padding); "interface" as the interface keyword or public methods (too narrow); "boundary" (overloaded — say seam or interface).
Name domain concepts in the project's domain language: the glossary its AGENTS.md points to, else CONTEXT.md. Decisions the project has recorded (architecture docs, ADRs) are not re-litigated.
Review
1. Explore
Read the domain glossary and any recorded decisions in the area first. Then walk the codebase yourself — no subagents unless the user asks — and note where you experience friction:
- Where does understanding one concept require bouncing between many small modules?
- Where are modules shallow — interface nearly as complex as the implementation?
- Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no locality)?
- Where do tightly-coupled modules leak across their seams?
- Which parts of the codebase are untested, or hard to test through their current interface?
Apply the deletion test to anything you suspect is shallow. A "yes, complexity concentrates" is the signal you want.
2. Present candidates as an HTML report
Publish the report the way the workspace's instructions say to share HTML (for example an html-home root such as ~/.agent/diagrams). With no such rule, write $TMPDIR/architecture-review-<timestamp>.html and open it.
The report uses Tailwind via CDN for layout and Mermaid via CDN where a graph, flow, or sequence communicates the structure; hand-built divs and SVG carry the more editorial visuals (mass diagrams, cross-sections, collapses). Each candidate is a card with:
- Files — which files/modules are involved
- Problem — why the current architecture is causing friction
- Solution — plain English description of what would change
- Benefits — in terms of locality and leverage, and how tests would improve
- Before / After diagram — side-by-side, illustrating the shallowness and the deepening
- Recommendation strength —
Strong,Worth exploring, orSpeculative, as a badge
End with a Top recommendation: which candidate to tackle first and why.
Use the domain glossary for the domain and this glossary for the architecture: if the domain defines "Order," say "the Order intake module" — not "the FooBarHandler," and not "the Order service."
If a candidate contradicts a recorded decision, surface it only when the friction is real enough to reopen the decision, and mark it in the card: "contradicts ADR-0007 — but worth reopening because…".
See HTML-REPORT.md for the scaffold, diagram patterns, and style.
Do NOT propose interfaces yet. After the report is up, ask: "Which of these would you like to explore?"
3. Grill the chosen candidate
Interview the user one question at a time down each branch of the design tree — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive. Resolve dependencies between decisions one by one, give your recommended answer with each question, and explore the codebase instead of asking when the code can answer.
Keep the domain language current as decisions crystallize:
- Naming a deepened module after a concept not in the domain glossary? Add the term.
- Sharpening a fuzzy term? Update the glossary right there.
- User rejects the candidate with a load-bearing reason? Offer to record it where the project keeps decisions: "Want me to record this so future reviews don't re-suggest it?" Skip ephemeral reasons ("not worth it right now") and self-evident ones.
- Want alternative interfaces? Sketch three radically different ones — minimal (1–3 entry points), flexible, and common-caller-first — compare them on depth, locality, and seam placement, and recommend one.
Extract
If you solved it twice, you'll solve it again. Extract once — copy-paste spreads bugs.
- Collect 3+ instances from different projects. Two is too early to abstract.
- Align them side by side. Mark what is common and what varies.
- Abstract the invariant core into a deep module: the smallest interface that serves every instance.
- Parameterize only the variance you observed. Defaults cover the common case; leave an escape hatch for edge cases.
- Package it in the format the signal calls for (table below).
- Apply back to every source project and verify each one through its end-to-end checks or manual harness.
Find instances:
- Intent:
colgrep "<what the code does>" <repo-a> <repo-b> - Exact signature:
rg -l "<signature>" <projects-dir>/*/src - Shared imports:
rg --no-filename "^import .* from" <projects-dir>/*/src | sort | uniq -c | sort -rn | head -20 - Past agent sessions that solved it:
cass search "<technique>" --robot --limit 30, or--aggregate workspaceto see which projects did
| Signal | Package as | Done when |
| Same function or type copy-pasted | Library | Interface is small and stable; README shows minimal use |
Same CLI flags (--json, --verbose) | Shared CLI module | Every source CLI uses it |
| Same "run X, then Y, then Z" workflow | Skill | Description names the triggers; examples come from real runs |
| Same project layout | Template | Variables documented; defaults build out of the box |
| Same lint, format, or CI config | Shared config | Composable; override path documented |
Align like this:
PROJECT A PROJECT B PROJECT C
─────────────────────────────────────────────────────────────────────
fn retry<T>( fn with_retry<T>( fn retry_call<T>(
f: impl Fn() -> T, op: impl Fn() -> T, func: impl Fn() -> T,
max: usize, attempts: u32, max_attempts: usize,
delay: Duration wait: Duration backoff: Duration
) -> Result<T, Error> ) -> Result<T, E> ) -> Result<T, Error>
─────────────────────────────────────────────────────────────────────
COMMON: retry logic with max attempts and delay
VARIES: naming, integer types, error typesDone when every source project uses the artifact and passes its checks, the artifact is smaller than the average instance it replaced, and why the pattern exists is written next to it. Report:
## Extracted Pattern: <name>
Sources: <repo/path:line>, <repo/path:line>, <repo/path:line>
Invariant core: <what never changes>
Variance: <what differs> → <how it is parameterized>
Packaged as: <library | skill | template | config> at <path>
Applied back: <repo> ✓, <repo> ✓, <repo> ✓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.

