improve-codebase-architecture
Survey an existing codebase for architectural friction and turn it into a short, ranked list of deepening candidates (shallow modules, pass-through layers, scattered knowledge, leaked ordering or error rules, code that is hard to test through its interface), then work through the one the user picks. Read-only until the user chooses.
- Use it when
- The user asks to "improve the architecture", "find refactoring opportunities", "make this codebase easier to test or navigate", "where is this too tangled", or when the same scattered code keeps being changed. Not for designing a new module from scratch (see codebase-design), reviewing a diff, or carrying out the refactor itself.
- What kind it is
- A written method: it lays out how the work is done and what to check along the way.
- Size
- 1,136 words. The whole text loads when the skill fires; only the 104-word description is always loaded.
- Starts with
- Ask for the job it describes.
How it is organised
What’s inside
The skill’s top-level sections, in order. The bar is each section’s share of the 1,136 words, so you can see where the weight sits before reading.
- 1Terms used in every suggestion162 words
- 21. Scope before you scan95 words
- 32. Explore182 words
- 43. Present candidates251 words
- 54. Work through the chosen candidate213 words
- 6Common mistakes125 words
The skill itself
Read it before you install it
improve-codebase-architecture/SKILL.md · 1,136 wordsDownloadSkill on GitHub ↗---
name: improve-codebase-architecture
description: Survey an existing codebase for architectural friction and turn it into a short, ranked list of deepening candidates (shallow modules, pass-through layers, scattered knowledge, leaked ordering or error rules, code that is hard to test through its interface), then work through the one the user picks. Read-only until the user chooses. Use when the user asks to "improve the architecture", "find refactoring opportunities", "make this codebase easier to test or navigate", "where is this too tangled", or when the same scattered code keeps being changed. Not for designing a new module from scratch (see codebase-design), reviewing a diff, or carrying out the refactor itself.
license: MIT
---
# Improve codebase architecture
Find where the current structure causes friction and propose **deepening opportunities**: refactors that turn shallow modules into deep ones, so the code is easier to test and easier for a person or an agent to navigate.
This is an investigation. It reads the code and the history and reports. It does not edit, move or delete anything, and it ends with a chosen and designed candidate, not a finished refactor. Implementing is a separate request.
## Terms used in every suggestion
Use these precisely; do not drift into "component", "service", "API" or "boundary".
- **Module**: anything with an interface and an implementation, at any scale.
- **Interface**: everything a caller must know, including ordering, errors, configuration and performance, not just the signature.
- **Depth**: behaviour exercised per unit of interface learned. **Shallow** means the interface is nearly as complex as the implementation.
- **Seam**: a place where behaviour can change without editing that place; where an interface lives.
- **Adapter**: a concrete thing satisfying an interface at a seam.
- **Leverage**: what callers gain from depth. **Locality**: change, bugs and knowledge concentrated in one place.
For the project's own domain concepts, use the project's words. If it has a glossary, read it before you look, so your names for modules match its language and give good seams their names. Read any decision records (ADRs) in the area too; they hold decisions you should not re-litigate lightly. If neither exists, carry on without remark.
## 1. Scope before you scan
Deepening a module pays off when future changes to it get easier, so weight recently changed code. Decide where to look before you look:
- If the user named a direction (a module, a subsystem, a pain point), take it and skip the rest of this step.
- Otherwise read the commit history (a read-only listing such as the one-line log) back a good stretch, and find the hot spots: files and areas that keep coming up. Let those pull your attention first. If changes are scattered with no clear hot spot, widen the net.
## 2. Explore
If you can delegate, a read-only worker can walk the codebase; otherwise do it yourself. Do not follow a rigid checklist. Explore, and note where *you* feel friction:
- Where does understanding one concept mean bouncing between many small modules?
- Where are modules shallow?
- Where were pure functions extracted only for testability while the real bugs hide in how they are called (no locality)?
- Where do tightly coupled modules leak across their seams, or the same ordering, error or policy rules get repeated by every caller?
- What is untested, or hard to test through its current interface?
Apply the **deletion test** to anything you suspect is shallow: would deleting it concentrate complexity, or only move it? "Concentrates" is the signal you want. Before recommending a new seam, classify what the cluster depends on (in-process, locally substitutable, remote but owned, or truly external). A seam is real only if something varies across it.
Separate **observed cost** (a thing that actually slows changes or hides bugs, with evidence) from **speculative opportunity** (it merely looks improvable). Report both, but label them.
## 3. Present candidates
Default to a compact Markdown list in the reply. Rank candidates; each one gets:
- **Files and modules** involved, with the evidence (specific files, change history, tests that are hard to write).
- **Problem**: why the current structure causes friction.
- **Direction**: what would change, in plain language. Do not commit to a final interface yet.
- **Benefits**: in terms of leverage, locality, and how the tests would improve.
- **Cost and risk**: migration effort, compatibility, what might break.
- **Strength**: `Strong`, `Worth exploring` or `Speculative`.
- **Sketch**: a small before and after of the relationships, in text, when it clarifies.
Include "leave it as it is" as a real option for any candidate where the friction is mild. An investigation may conclude that no refactor is justified; say so rather than manufacturing work.
If a candidate contradicts an existing ADR, mention it only when the friction is real enough to justify reopening it, and mark it plainly ("contradicts ADR-0007, but worth reopening because..."). Do not list every refactor an ADR happens to forbid.
End with one **top recommendation** and why you would tackle it first. Then ask: "Which of these would you like to explore?" Do not propose interfaces before the user picks.
A visual report is optional. If the user wants one, write a self-contained page outside the repository, in the system temporary directory, so nothing lands in the project, and give the user its absolute path. Do not start a server or open a browser unless they ask.
## 4. Work through the chosen candidate
Once the user picks, settle it by conversation:
- Ask **one question at a time**, with your recommended answer, and wait for the reply before the next. Look up facts yourself in the code. The decisions belong to the user.
- Cover the constraints, the dependencies and their category, the shape of the deepened module, what sits behind the seam, and which existing tests survive and which are replaced.
- If alternative interfaces are still on the table, design at least two radically different ones and compare them on depth, locality and seam placement before recommending one.
- Keep the domain language current as decisions form. If you name the deepened module after a concept missing from the glossary, propose the entry. If the user sharpens a fuzzy term, record it. Say what you changed.
- If the user **rejects** a candidate for a load-bearing reason that a future reviewer would need in order to avoid suggesting it again, offer to record it as an ADR: "Want me to record this so future architecture reviews don't re-suggest it?" Skip ephemeral reasons ("not worth it right now") and self-evident ones. Write the ADR only if they agree.
Finish with the chosen candidate, the decisions made, and the open questions. Do not start the refactor.
## Common mistakes
| Mistake | Instead |
|---|---|
| Scanning everything for anything improvable | Start from the user's pain point or from where change is landing |
| Treating every thin wrapper as shallow | Run the deletion test first |
| Proposing a seam with only one implementation and no real variation | Show what varies, or do not add it |
| Listing every refactor an ADR forbids | Surface a conflict only when the friction justifies reopening it |
| Proposing interfaces before the user chooses | Present candidates, then ask |
| Turning the investigation into edits | Report, get a choice, design, and stop |
| Presenting guesses as findings | Label speculative candidates and give evidence for the rest |
The second audit
What we found in the sources
It is a distinct job from codebase-design: surveying an existing codebase for friction and producing ranked candidates, rather than designing one module. It follows mattpocock/skills' process (scope first, explore for friction, deletion test, candidates with a strength label, then a decision conversation) and makes it read-only, host-neutral and self-contained. Every source below was read at the commit the auditor recorded. Nothing was taken from a source without a permissive license.
What each source contributed
- mattpocock/skills ↗ · Primary basis · MIT
Scoping the scan to where change is landing, using commit history to find hot spots when the user named no direction; reading the glossary and ADRs first; the friction questions; the deletion test; the candidate fields (files, problem, solution, benefits, strength of Strong, Worth exploring or Speculative); a top recommendation; surfacing an ADR conflict only when the friction justifies reopening it; not proposing interfaces before the user picks; and the follow-up loop that keeps the glossary current and offers an ADR when a candidate is rejected for a load-bearing reason.
- xu91102/claude-everything-Workflow ↗ · Added ideas · MIT
Framing the work as explicitly read-only; keeping speculative candidates apart from evidence-backed friction; classifying dependency types before recommending a seam; extra friction signs (repeated caller policy, pass-through layers, leaked ordering and error rules); a compact Markdown report by default; never opening a browser silently; and 'do not turn an architecture audit into an unapproved refactor'.
- mascah/skills ↗ · Added ideas · MIT
Start from the user's pain point or evidence of repeated change; include keeping the current design as a candidate; an investigation may conclude that no refactor is justified; a request to review does not authorize implementation.
- rengwu/wayfinder-maps ↗ · Added ideas · MIT
Host-neutral wording for the exploring worker (use one if the environment supports it, otherwise explore directly), 'if neither a glossary nor ADRs exist, proceed silently', and writing the one-question-at-a-time interview with a recommended answer into the skill instead of calling another skill.
What changed
- The description names the job, lists the phrases a person would type (improve the architecture, find refactoring opportunities, where is this too tangled) and has a not-for clause. The upstream description is 'Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick', and the upstream frontmatter sets disable-model-invocation, so it never triggers on its own.
- Made the investigation read-only and the stopping point explicit: it ends with a chosen, designed candidate and does not refactor.
- The report is a compact Markdown list by default. The upstream mandates a Tailwind-and-Mermaid HTML page loaded from CDNs, written to the temp folder and opened with xdg-open, open or start without asking. Now a visual page is optional, written outside the repository, with the absolute path given, and no browser or server is started unless the user asks.
- Replaced the calls to /codebase-design, /grilling and /domain-modeling with a short terms reminder and the interview rules written in place, so the skill stands alone. The HTML-REPORT.md companion is gone.
- Added 'leave it as it is' as a possible candidate and an explicit label for observed cost versus speculation.
- Subagent use is optional rather than required.
Problems found in the sources
- mattpocock/skills: Calls three other skills by name (/codebase-design, /grilling, /domain-modeling) and links to HTML-REPORT.md, which is not in the bundle. Sets disable-model-invocation, so it never self-triggers. Tells the agent to write an HTML page that loads Tailwind and Mermaid from CDNs and to open it with an OS command, with no consent step; that is one host's convention and fetches third-party scripts when the page opens. Asks the agent to 'spawn a sub-agent', which not every host has. It says 'Do NOT propose interfaces yet' while each candidate card requires a solution description and a before/after diagram of the deepening; whether that tension is intended is unclear. The scope-first step was added upstream on 2026-07-13 (commit title seen in GitHub history).
- xu91102/claude-everything-Workflow: Read-only and consent-aware, but refers to skills/codebase-design, skills/visual-companion, skills/grilling, skills/domain-modeling and a central router, plus skills/codebase-design/references/design-it-twice.md; none are in the bundle.
- mascah/skills: Evidence-first and the most cautious about authorizing change. Refers to references/discipline.md and a shaping helper (declared optional); neither is in the bundle.
- rengwu/wayfinder-maps: Lives under skills/.optional/. The scope-first YAGNI paragraph is absent, which the upstream added on 2026-07-13, a day after this repository was created; so the file is either an older copy or the paragraph was removed on purpose (unclear). It still links to HTML-REPORT.md, not in the bundle.
- CapitalCantrip/quality-gates: Same text as the pinned mattpocock file with GLOSSARY.md, dashes reworded, and 'Call the Skill tool with ...' wording, which is one host's tool name.
- marinvch/Cortex: The mattpocock text with [[codebase-design]] wiki links, a references/codebase-design.md path, a capability frontmatter field and a closing section that sends users to /cortex-install. That section also says a weaker setup 'returns generic advice' without giving a basis.
What was dropped
- The HTML report scaffold, the Tailwind and Mermaid CDN instructions, the shell commands for opening a file on each OS, and the badge and before/after card styling.
- Cortex's wiki links, /cortex-install and the 'When the floor is not met' section.
- xu91102's central-router, visual-companion and spec references.
- mascah's optional shaping helper and references/discipline.md.
Read but not used (15)
- the-inconvenience-store/skills: skills/improve-codebase-architecture/SKILL.md has the same SHA-256 as the pinned mattpocock file: a byte-identical copy.
- CapitalCantrip/quality-gates: .claude/skills/improve-codebase-architecture/SKILL.md is the pinned mattpocock text with GLOSSARY.md, reworded dashes and 'Call the Skill tool with' wording (verified by diff). Nothing taken beyond what the mattpocock file already gave.
- marinvch/Cortex: skills/improve-codebase-architecture/SKILL.md is the mattpocock text with wiki links and an added closing section (see findings). Nothing taken beyond what the mattpocock file already gave.
- RollRollRoll/agent-toolkit: skills/development/improve-codebase-architecture/SKILL.md is a Chinese translation of the mattpocock text, checked section by section; its wording tells the agent to call the Skill tool by name, and it points to references/html-report.md, not in the bundle.
- mattpocock/skills: skills/engineering/codebase-design/SKILL.md: the pinned codebase-design file; a different job (module design). Used in the codebase-design skill.
- rengwu/wayfinder-maps: skills/.optional/codebase-design/SKILL.md: a pseudocode variant of codebase-design; a different job (module design). Used in the codebase-design skill.
- helderberto/agent-skills: skills/codebase-design/SKILL.md: a condensed codebase-design; a different job (module design). Read there; not used.
- xu91102/claude-everything-Workflow: skills/codebase-design/SKILL.md: a condensed codebase-design; a different job (module design). Used in the codebase-design skill.
- panda850819/pandastack: skills/engineering/codebase-design/SKILL.md: a condensed codebase-design; a different job (module design). Read there; not used.
- MokeyBytes/capstan: skills/codebase-design/SKILL.md: a near copy of codebase-design; a different job (module design). Read there; not used.
- CapitalCantrip/quality-gates: .claude/skills/codebase-design/SKILL.md: a near copy of codebase-design; a different job (module design). Read there; not used.
- the-inconvenience-store/skills: skills/codebase-design/SKILL.md: a byte-identical copy of codebase-design; a different job (module design). Read there; not used.
- mascah/skills: skills/codebase-design/SKILL.md: a short codebase-design; a different job (module design). Used in the codebase-design skill.
- dougborg/harness-kit: claude-skills/codebase-design/SKILL.md: a rewritten codebase-design; a different job (module design). Used in the codebase-design skill.
- RollRollRoll/agent-toolkit: skills/development/codebase-design/SKILL.md: a Chinese translation of codebase-design; a different job (module design). Read there; not used.
Same text, wherever you work
Use it where you work
Copy the folder into your skills directory, then ask for the job or type its start command.
- Download
SKILL.mdwith the button above, and put it in a folder namedimprove-codebase-architecture. - Zip the folder.
- In Claude, open Settings → Skills and upload the zip.
SKILL.md is plain Markdown. Copy the text and paste it as the system prompt or the first message. It will not trigger by itself there; you start it.