/mattpocock-skills:improve-codebase-architecturefrom mattpocock-skills
Scan a codebase for places where callers carry too much implementation complexity, present architectural candidates as a visual HTML report, then explore the candidate the user selects.
Ships in mattpocock-skills. 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.
Read when SKILL.md points to them; scripts run unread.
Surface architectural friction and propose changes that place substantial behaviour behind a small interface. Use deep-module principles to evaluate the design; explain the result in direct engineering prose. The aim is testability and AI-navigability.
This command is informed by the project's domain model and built on a shared design vocabulary:
CONTEXT.md gives names to good seams; ADRs in docs/adr/ record decisions this command should not re-litigate.Scope before you scan — YAGNI. Deepening a module pays off by making future changes to it easier, so put extra weight on the parts of the codebase that have recently changed. Decide where to look before you look:
git log --oneline) to find the codebase's hot spots — the files and areas that keep coming up — and let those paths pull your attention first. If the changes are scattered with no clear hot spot, widen the net.Read the project's domain glossary (CONTEXT.md) and any ADRs in the area you're touching first.
Then spawn a sub-agent to walk the codebase. Don't follow rigid heuristics — explore organically and note where you experience friction:
Apply the deletion test to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
Before a finding can become a candidate, prove it. For each possible candidate collect:
Do not turn vocabulary matching into proof. Seeing "Sealer", "manifest", "adapter", or "interface" in code does not by itself prove a bad seam. If the evidence is plausible but incomplete, present it as a Question to validate, not as a Problem.
Write a self-contained HTML file to the OS temp directory so nothing lands in the repo. Resolve the temp dir from $TMPDIR, falling back to /tmp (or %TEMP% on Windows), and write to <tmpdir>/architecture-review-<timestamp>.html so each run gets a fresh file.
Before serving the report, call the Skill tool with "validate-mermaid" and validate the absolute report path with Mermaid 11.16.1. The compatibility command python3 scripts/validate-report.py <absolute-report-path> delegates to that skill's validator when a direct Skill tool call is unavailable. If validate-mermaid is not installed, stop and tell the user instead of skipping validation. Fix every reported diagram and rerun validation until it succeeds. Do not serve a report with unvalidated Mermaid syntax. Pin the report's Mermaid CDN import to the same exact 11.16.1 version; do not use a floating @11 URL.
Make the report reachable from the user's browser. Run python3 scripts/serve-report.py <absolute-report-path> from this skill's directory as a long-running process. The script chooses a free port and prints a tokenized REPORT_URL=http://localhost:<port>/<token>/; give that URL to the user, followed by the absolute file path as a fallback. Keep the server running while the user reviews the report. If the harness cannot run the bundled script, use an equivalent single-file local server that does not expose the rest of the temp directory.
Opening the file directly is optional. Use xdg-open, open, or start only when a desktop session is available, and never treat a successful opener exit code as proof that the user can see the report. Do not finish with only a temp-file path.
The report uses Tailwind via CDN for layout and styling, and Mermaid via CDN for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals — use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a before/after visualisation. Be visual.
Lead each substantial candidate with a concise statement of the proposed change. The reader should know what to add, move, replace, or consolidate before reading the supporting context. If the evidence is incomplete, lead with the concrete question or experiment needed to validate the idea instead of presenting an unearned recommendation.
Each candidate must cover the following material, but it does not need to expose these items as a fixed series of headings. Use sections when they help the reader scan the argument; combine them when a short narrative is clearer.
Strong, Worth exploring, or Speculative) and confidence (High, Medium, or Low).Write for a reader who has not been living in the code:
CompletionFinalizer that owns Evidence Bundle assembly behind Finalize(...)" over "This responsibility should move into exosign."End the report with a Top recommendation section that states the implementation decision, why it should come first, the expected result, and any open decision that must be resolved before coding.
Use CONTEXT.md vocabulary for the domain, and use the /codebase-design vocabulary when it adds architectural precision. If CONTEXT.md defines "Order," talk about "the Order intake module" rather than inventing a generic name. Do not stack glossary terms where plain language communicates the same reasoning more naturally.
ADR conflicts: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly in the card (e.g. a warning callout: "contradicts ADR-0007 — but worth reopening because…"). Don't list every theoretical refactor an ADR forbids.
Intentional interfaces are not automatic problems. Protocol libraries, low-level codecs, migration steps, and provider adapters often intentionally expose ordering or byte-level primitives. If a spec says the caller owns orchestration, the report must either respect that decision or explicitly frame the candidate as "reopen this decision because..." with evidence that the decision is now hurting callers.
See HTML-REPORT.md for the full HTML scaffold, diagram patterns, and styling guidance.
Do not make the interface sketch implementation-ready or settle low-level types prematurely. Make it concrete enough to evaluate ownership, caller experience, migration work, and failure semantics. After the file is written, ask the user: "Which of these would you like to explore?"
Once the user picks a candidate, call the Skill tool with "grilling" to work through the unresolved choices with them: constraints, dependencies, the shape of the proposed module, what it owns, and which tests survive.
Side effects happen inline as decisions crystallize — call the Skill tool with "domain-modeling" to keep the domain model current as you go:
CONTEXT.md? Add the term to CONTEXT.md. Create the file lazily if it doesn't exist.CONTEXT.md right there.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub royalbis/mattpocock-skills --plugin mattpocock-skillsOther plugins' skills for the same job
37 skills in this plugin
/ask-mattAsk which skill or flow fits your situation. A router over the skills in this repo./claude-handoffHand the current conversation off to a fresh background agent that picks up the work immediately./codebase-designShared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.