Install
openclaw skills install @dennisrongo/improve-codebase-architectureSurface 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.
openclaw skills install @dennisrongo/improve-codebase-architectureSurface 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.
Trigger on any of:
/improve-codebase-architectureCONTEXT.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:
task-executor.diagnose.code-review.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.
Key principles (see LANGUAGE.md for the full list):
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:
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:
file:line), the shotgun-surgery pattern ("these 4 files change together — check git log --oneline -- <dir>"), the test that needs 40 lines of setup to exercise one branch. "This could be cleaner" with no cited pain is not a candidate.Present a numbered list of deepening opportunities. For each candidate:
file:line), the co-changing files, the awkward tests. No citation, no candidate.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?"
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:
CONTEXT.md? Add the term to CONTEXT.md as a pure glossary entry. Create the file lazily if it doesn't exist.CONTEXT.md right there. Don't batch.User: /improve-codebase-architecture — focused on src/orders/validation/
Claude:
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.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).OrderIntakeValidator, internal validators stay private), test surface (assert at validate(order) → Result<Order, ValidationError[]>, delete the 11 per-function tests). Adds OrderIntakeValidator to CONTEXT.md.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.
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.CONTEXT.md already names the concept. Use the domain term.task-executor: hand off the chosen candidate (with its decided interface) to task-executor for the implementation. This skill writes no production code.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.improve-codebase-architecture — same architecture vocabulary, deletion test, deepening process, and parallel interface design. Adapted to compose with the other skills in this library.