Coding

improve-codebase-architecture

Try it

Surface architectural friction in a codebase and propose **deepening opportunities** — refactors that turn shallow modules into deep ones, informed by the project's `CONTEXT.md` glossary and `docs/adr/` decisions. Walks the codebase with an Explore sub-agent, applies the **deletion test** to suspected pass-through modules, presents a numbered list of candidates with files / problem / solution / benefits, and drops into a grilling loop once the user picks one — naming new concepts into `CONTEXT.md` inline and offering an ADR only when a rejection is load-bearing. Writes no production code. Use this skill whenever the user says "improve architecture", "improve the architecture", "architecture review", "find refactoring opportunities", "find deepening opportunities", "find shallow modules", "make this more testable", "this code is hard to navigate", or invokes `/improve-codebase-architecture` — even if they don't name the skill.

What it does

Surface architectural friction and propose **deepening opportunities** — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability. This skill is _informed_ by the project's domain model: the domain language in gives names to good seams; the ADRs in record dec…

The skill document

Improve Codebase Architecture

Surface architectural friction and propose deepening opportunities — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability. This skill is informed by the project's domain model: the domain language in CONTEXT.md gives names to good seams; the ADRs in docs/adr/ record decisions the skill should not re-litigate.

When to use this skill

Trigger on any of:

  • "improve architecture" / "improve the architecture" / "architecture review"
  • "find refactoring opportunities" / "find deepening opportunities" / "find shallow modules"
  • "make this more testable" / "this code is hard to navigate" / "AI-navigable"
  • /improve-codebase-architecture
  • The user has an area of the codebase they want pressure-tested for refactor opportunities, ideally with the domain already documented (CONTEXT.md) and key decisions captured (docs/adr/), and wants a deliberate architecture-review pass rather than an ad-hoc code review.

Do not auto-trigger for:

  • A request to implement a specific refactor — use task-executor.
  • A bug or regression — use diagnose.
  • A line-by-line review of a specific diff — use code-review.

Glossary

Use these terms exactly in every suggestion. Consistent language is the point — don't drift into "component," "service," "API," or "boundary." Full definitions in LANGUAGE.md.

  • Module — anything with an interface and an implementation (function, class, package, slice).
  • Interface — everything a caller must know to use the module: types, invariants, error modes, ordering, config. Not just the type signature.
  • Implementation — the code inside.
  • Depth — leverage at the interface: a lot of behaviour behind a small interface. Deep = high leverage. Shallow = interface nearly as complex as the implementation.
  • Seam — where an interface lives; a place behaviour can be altered without editing in place. (Use this, not "boundary.")
  • Adapter — a concrete thing satisfying an interface at a seam.
  • Leverage — what callers get from depth.
  • Locality — what maintainers get from depth: change, bugs, knowledge concentrated in one place.

Key principles (see LANGUAGE.md for the full list):

  • Deletion test — imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
  • The interface is the test surface.
  • One adapter = hypothetical seam. Two adapters = real seam.

Process

1. Explore

Read the project's domain glossary (CONTEXT.md) and any ADRs in the area you're touching first.

Then use the Agent tool with subagent_type=Explore to walk the codebase. Don't follow rigid heuristics — explore organically 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: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.

Evidence gates — both must hold before anything becomes a candidate:

  • Friction must be observed, not theoretical. Cite the pain: the awkward call sites (file:line), the shotgun-surgery pattern ("these 4 files change together — check git log --oneline -- "), the test that needs 40 lines of setup to exercise one branch. "This could be cleaner" with no cited pain is not a candidate.
  • Read before ruling. A claim about a module you haven't opened this session is a hypothesis. Before ruling on the deletion test, read the module and at least 2 of its call sites. The operational form of the test: if every caller could call the layer below directly with no loss of clarity, the module fails — it's a pass-through. If deleting it would smear real logic (validation, ordering, error translation) across its callers, it passes.

2. Present candidates

Present a numbered list of deepening opportunities. For each candidate:

  • Files — which files/modules are involved
  • Problem — why the current architecture is causing friction
  • Evidence — the observed friction, cited: the call sites you read (file:line), the co-changing files, the awkward tests. No citation, no candidate.
  • Solution — plain English description of what would change
  • Benefits — explained in terms of locality and leverage, and also in how tests would improve

Zero candidates is a valid outcome. A healthy codebase produces a short or empty list. Report "no deepening opportunities found — here's what I checked" rather than padding the list with theoretical refactors to appear thorough.

Use CONTEXT.md vocabulary for the domain, and LANGUAGE.md vocabulary for the architecture. If CONTEXT.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, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly (e.g. "contradicts ADR-0007 — but worth reopening because…"). Don't list every theoretical refactor an ADR forbids.

Do NOT propose interfaces yet. Ask the user: "Which of these would you like to explore?"

3. Grilling loop

Once the user picks a candidate, drop into a grilling conversation. Walk the design tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.

Side effects happen inline as decisions crystallize:

  • Naming a deepened module after a concept not in CONTEXT.md? Add the term to CONTEXT.md as a pure glossary entry. Create the file lazily if it doesn't exist.
  • Sharpening a fuzzy term during the conversation? Update CONTEXT.md right there. Don't batch.
  • User rejects the candidate with a load-bearing reason? Offer an ADR, framed as: "Want me to record this as an ADR so future architecture reviews don't re-suggest it?" Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones.
  • Want to explore alternative interfaces for the deepened module? See INTERFACE-DESIGN.md.
  • Need to choose how to test across a dependency? See DEEPENING.md for the four dependency categories and the test strategy each demands.

Examples

Example 1: A shallow validator cluster

User: /improve-codebase-architecture — focused on src/orders/validation/

Claude:

  1. Explore. Reads CONTEXT.md (sees Order, OrderLine, Cart) and docs/adr/0004-validation-pipeline.md. Spawns Explore on src/orders/validation/ and finds 11 single-function modules (validateSku.ts, validateQty.ts, …) each called from one place in OrderIntake.
  2. Candidates. Presents one numbered candidate: "Collapse the validate* cluster into a deep OrderIntakeValidator module — current shallow validators have interface nearly as complex as implementation; the real bugs hide in how OrderIntake composes them, where no test exercises the seam." Files / Problem / Evidence (the OrderIntake call site read, plus the two validate* modules opened for the deletion test) / Solution / Benefits. Notes: does not contradict ADR-0004 (which is about when to validate, not how to compose validators).
  3. Grilling. User picks the candidate. Walks the design tree: dependency category (in-process, DEEPENING.md §1), seam placement (one external seam at OrderIntakeValidator, internal validators stay private), test surface (assert at validate(order) → Result, delete the 11 per-function tests). Adds OrderIntakeValidator to CONTEXT.md.

Example 2: A candidate that contradicts an ADR — but worth reopening

User: /improve-codebase-architecture

Claude: Surfaces a candidate to merge WebhookDispatcher and WebhookRetryQueue. Notes "contradicts ADR-0012 — but worth reopening because the original split was justified by sync delivery, and the codebase has since moved to async." User confirms ADR-0012 is stale. Hands off the actual merge to task-executor; updates CONTEXT.md with the unified WebhookDelivery term and notes that ADR-0012 needs a superseding ADR.

Anti-patterns

  • ❌ Proposing a refactor without applying the deletion test — leads to suggestions that just move complexity instead of concentrating it.
  • ❌ Ruling on the deletion test from a module's name or the file listing. Read the module and ≥2 call sites first; until then it's a hypothesis, not a candidate.
  • ❌ Manufacturing candidates from theoretical concerns: ❌ "OrderMapper could be more flexible" (no cited pain) vs. ✅ "OrderMapper's 3 call sites each re-wrap its output (intake.ts:41, sync.ts:88, api.ts:120) — the seam is in the wrong place." The first pads the list; the second names the friction.
  • ❌ Naming things "FooHandler" / "BarService" / "BazManager" when CONTEXT.md already names the concept. Use the domain term.
  • ❌ Introducing a port + adapter for a dependency with only one implementation. One adapter = hypothetical seam.
  • ❌ Re-litigating an ADR without explicit cause. ADRs are decisions the skill should not reopen unless the constraint that drove them is gone.
  • ❌ Proposing interfaces in Step 2. Step 2 is candidates only — interface design happens after the user picks one, and benefits from the parallel sub-agent process in INTERFACE-DESIGN.md.
  • ❌ Letting old shallow-module tests survive alongside new deep-module tests. The interface is the test surface — replace, don't layer (see DEEPENING.md).
  • ✅ Architecture-language vocabulary used consistently, candidates measured by the deletion test, interfaces designed twice, tests at the new seam only.

Notes

  • Composes with task-executor: hand off the chosen candidate (with its decided interface) to task-executor for the implementation. This skill writes no production code.
  • Composes with code-review: use code-review for line-by-line review of a specific diff; this skill is for surfacing architecture-level refactors before any diff exists.
  • Adapted from Matt Pocock's improve-codebase-architecture — same architecture vocabulary, deletion test, deepening process, and parallel interface design. Adapted to compose with the other skills in this library.

Related skills

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván558 installs18 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván855 installs69 stars

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai22 installs8 stars

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Run Git operations — commits, branches, merges, rebases, conflict resolution, and recovery — with safety rules enforced.

by Iván534 installs31 stars

More from dennisrongo

Browse all skills

Write and run E2E tests for React Native / Expo apps using Maestro CLI — the open-source tool that drives the **real native app** on an Android emulator or iOS simulator, not a web build. Covers what browser-based e2e (Playwright, Expect, e2e-verify) cannot reach: native components, biometrics, secure storage, push notifications, platform-specific modules. Write YAML flows, run headed for authoring or headless for CI. Scripts currently automate the Android workflow end-to-end (Java + SDK detection, emulator boot, adb reverse); iOS simulator setup requires Xcode + `xcrun simctl` and is documented but not automated by the setup script. Use this skill whenever the user says "test my react native app", "e2e test the mobile app", "write maestro tests", "test the expo app", "automate emulator testing", or "/maestro-mobile-test" — even if they don't name the skill. Not for web apps (e2e-verify), unit/component tests (write-tests with RNTL + Jest), or API contract tests.

by dennisrongo2 installs

Verify a change end-to-end in a real browser, routed by one question — who needs this check to run again? Ephemeral checks run via Expect (millionco/expect) or browser-use (AI agent driving headless Chromium — references/browser-use.md) when installed, else Claude driving the browser directly; regression-critical flows (auth, money, signup, checkout, deletion) get durable Playwright tests under write-tests discipline. Evidence rule either way — an AI-walked flow yields "no issues found in the paths walked" with observations quoted, never "e2e passes". Safety gate: never production, never real user cookies. Use this skill whenever the user says "verify this in the browser", "test it end to end", "test my web app", "e2e test this", "write playwright tests", "run expect", "run browser-use", "smoke test the UI", or "/e2e-verify" — even if they don't name the skill. Not for native mobile (maestro-mobile-test), unit/integration authoring (write-tests), or debugging a failing e2e test (diagno

by dennisrongo1 installs

Pre-commit SQL code review for uncommitted database changes. Detects antipatterns that cause real production incidents — broken TRY/CATCH error handling, swallowed errors, retry patterns without loops, tables missing PK/indexes, type-mismatch truncation, dynamic-SQL injection, NOLOCK in write paths, UPDATE/DELETE without WHERE, hardcoded env values, cross-DB refs, and more (full catalog in the skill body). Reports BLOCKER/WARN/INFO findings with file:line citations and fixes. Never edits SQL. Use this skill whenever the user says "/sql-review", "review my SQL", "review the SQL diff", "lint the SQL", "check my SQL changes", "SQL pre-commit check", "audit my stored proc", or asks about SQL antipatterns in a diff — even if they don't name the skill. Distinct from code-review (general review) — this carries SQL-specific incident patterns.

by dennisrongo1 installs

Scaffold a new Tauri 2 desktop app (Rust backend + TypeScript/React frontend) using a thin-frontend / rich-Rust-backend architecture with modular commands, trait-based platform abstractions, encrypted secrets at rest, single-instance enforcement, a self-hosted updater, and a cross-platform CI matrix. Three modes: full project scaffold, add a Tauri command slice, add a Rust module slice. Use this skill whenever the user says "create a new Tauri app", "scaffold a Tauri 2 project", "new desktop app with Tauri", "Tauri + React project", "add a Tauri command end-to-end", "add a Rust module to my Tauri app", "my Tauri conventions", or "/tauri-2-app" — even if they don't name the skill. Full good-pattern catalog and pitfall list live in the skill body.

by dennisrongo1 installs

Turn a feature idea, conversation context, or rough notes into researched, detailed, dependency-ordered checkbox tasks appended to the project's roadmap/backlog file — exactly the format goal-runner consumes, so a fresh unattended session can execute them. Grounds every task in the actual codebase before writing it (grep/read or Explore scouts; think-like-fable rigor if installed), puts what + done-when on the checkbox line with verified files, acceptance criteria, and a verification command in plain sub-bullets, and labels assumptions. Appends to the existing ROADMAP.md/BACKLOG.md/TODO.md; when none exists it asks once and defaults to ROADMAP.md. Use this skill whenever the user says "add this to the backlog", "add it to the roadmap", "plan these tasks", "break this down into tasks", "capture this as roadmap tasks", "turn these notes into a task list", or "/backlog-planner" — even if they don't name the skill. Not for executing tasks (goal-runner, task-executor, autopilot) — this writ

by dennisrongo1 installs

Produce a durable onboarding artifact for a codebase — writes ONBOARDING.md covering a "read this first" minimum, system overview, dependency map, startup flow, auth flow, and 5-15 important files, every claim backed by file:line citations; refreshes an existing onboarding doc instead of rewriting it. Use this skill whenever the user says "explain this codebase", "explain the codebase", "onboard me", "give me a tour", "tour this repo", "what does this repo do", "where do I start", "codebase overview", "read this first", "I haven't looked at this in months", or "/codebase-explainer" — even if they don't name the skill.

by dennisrongo1 installs