/grey-matter:improve-codebase-architecturefrom grey-matter
Scan a codebase for deepening opportunities, classify each by regime, present them as a full-bodied visual HTML report, then grill through whichever one you pick.
Ships in grey-matter. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Surface architectural friction and propose improvements: in the service regime, refactors that turn shallow modules into deep ones; in the frame-loop regime, the opposite, structure that restores data-oriented locality. The aim is testability, performance where it matters, and AI-navigability.
This command is informed by the project's domain model and built on a shared design vocabulary:
GLOSSARY.md gives names to good seams; ADRs in docs/adr/ record decisions this command should not re-litigate. Read both before scanning so you don't re-propose something an ADR already rejected.codebase-design draws a hard line and so must this scan. The deep-module lens is wrong for a game's hot frame loop, and applying it there recommends de-optimising the most performance-sensitive code in the repo.
Classify each hotspot's regime before judging it. A finding in the wrong regime is not a weak finding, it's a wrong one.
The word "locality" is overloaded and the regimes disagree on it. In the service regime it means comprehension locality (related code/decisions in one place, Ousterhout's sense). In the frame-loop regime it means cache/memory locality (data laid out for sequential access). Say which one you mean; never let a service-regime "improve locality" finding fire against a frame loop that already has good cache locality.
Scope before you scan: YAGNI. Deepening (or de-encapsulating) a module pays off by making future changes cheaper, so weight the parts of the codebase that actually keep changing. Decide where to look before you look:
git log --oneline) to find the hot spots, the files and areas that keep coming up, and let those pull your attention first. If changes are scattered with no clear hot spot, widen the net.This hotspot gate is load-bearing: a refactor to code that rarely changes has no payoff. Keep it a gate, not a suggestion.
Read GLOSSARY.md and any ADRs in the area first. Then spawn a sub-agent to walk the codebase. Don't follow rigid heuristics; explore organically and note where you experience friction, and record which regime each hotspot is in. Service-regime questions:
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. (In the frame-loop regime the deletion test inverts: inlining a system's loop can improve the design. Don't run the service-regime deletion test against frame-loop code.)
This review is a full-bodied, visual, communicative deliverable: it exists to convey architectural ideas to the user with before/after diagrams, so HTML is the right format (see docs/agents/report-format.md). Write a self-contained HTML file. A durable review goes in a committed docs/ path; a throwaway per-run report goes in .scratch/. Open it for the user (xdg-open/open/start) and tell them the absolute path.
The report uses Tailwind for layout and Mermaid for graph-shaped diagrams, mixed with hand-built CSS/SVG for editorial visuals (mass diagrams, cross-sections, collapse animations). Degrade gracefully: if these load from a CDN and the network is absent, the content stays readable and the diagram source stays visible, never a blank page. Be visual: each candidate gets a before/after visualisation.
Optionally also drop a light markdown summary alongside it (.scratch/architecture-review-<timestamp>.md): one terse line per candidate (id, regime, files, badge) as a quick skim and as a handle the grill can re-read. This is a sibling skimmable doc, not the source the HTML is generated from, the HTML is the deliverable in its own right.
For each candidate card:
Strong, Worth exploring, or Speculative, as a badge. Blast radius counts against strength: a Strong badge is harder to earn on a large, wide-reaching refactor than on a localised one, bias toward the smallest seam that captures the gain. A Speculative candidate must still pass the deletion test (or the frame-loop equivalent); don't use the tier as a hedge to pad the report.End the report with a Top recommendation section: which candidate you'd tackle first and why.
Use GLOSSARY.md vocabulary for the domain and the codebase-design vocabulary for the architecture. If GLOSSARY.md defines "Order," talk about "the Order intake module," not "the FooBarHandler" and not "the Order service."
ADR conflicts: if a candidate contradicts an existing ADR, surface it only when the friction is real enough to warrant revisiting the ADR, and mark it clearly (an amber callout: "contradicts ADR-0007, but worth reopening because…"). Don't list every theoretical refactor an ADR forbids.
See HTML-REPORT.md for the HTML scaffold, diagram patterns, and styling.
Do NOT propose interfaces yet. After the files are 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 walk the decision tree with them: constraints, dependencies, the shape of the change, what sits behind the seam (service) or how the data is laid out (frame-loop), what tests survive. The grill can challenge the before/after diagram, not just the recommendation, if the diagram doesn't match the real structure, fix it.
Side effects happen inline as decisions crystallise; call the Skill tool with "domain-modeling" (or "game-modeling" for a game system) to keep the domain model current:
GLOSSARY.md? Add the term to GLOSSARY.md. Create the file lazily if it doesn't exist.GLOSSARY.md right there.docs/agents/tkt-conventions.md) with the candidate's problem/solution and the deletion-test result as context, rather than sliding straight into implementation, this skill plans, a separate flow implements.When competing choices need empirical evidence, see spike-options: use it when the choice is hard to reverse, cheap to spike, and reasoning alone cannot settle it.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub smileynet/grey-matter --plugin grey-matter50 skills in this plugin
/adopt-projectAdopt a brownfield repo into grey-matter: characterize its as-is model, subsume existing agent config, seed a triaged board, and wire plumbing./changelogMaintain CHANGELOG.md in Keep a Changelog format with user-facing entries. Use when recording what changed for a release, updating the Unreleased section, or asked to write/update the changelog./cheat-sheetList every skill in this set by category with a one-line description. Use when the user wants a quick reference card of available skills, asks "what skills are there", or "list all commands"./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./code-reviewReview a commit range, staged changes, or working tree on two axes (Standards + Spec) in parallel sub-agents and file findings as tickets. Use to review a branch, PR, WIP changes, or "review since X"./compassFind which skill or flow fits your situation. A router over the skills in this repo. Use when you (or the agent) are unsure which skill to reach for, want to see how the skills fit together, or ask "what should I use for X".