skills/improve-codebase-architecture/SKILL.md
Analyze codebases for architectural friction and propose module-deepening refactors as testability improvements. Use when the codebase feels hard to change, tests are brittle, or modules seem shallow. Applies John Ousterhout's deep module principle — small interfaces hiding large implementations for better testability and AI navigability.
npx skillsauth add Thomashighbaugh/opencode improve-codebase-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Surface architectural friction and propose deepening opportunities — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
Use the explore agent to walk the codebase organically. Note where you experience friction:
Apply the deletion test: would deleting this module concentrate complexity, or just move it?
For each candidate found, present a card-like section with markdown tables:
## Candidate: [module name]
### Files
| File | Role |
|------|------|
| src/x.ts | [description] |
| src/y.ts | [description] |
### Problem
[Why the current architecture is causing friction]
### Solution
[Plain English description of what would change]
### Benefits
| Dimension | Improvement |
|-----------|-------------|
| Locality | [how locality improves] |
| Leverage | [how leverage improves] |
| Testability | [how tests improve] |
### Recommendation Strength: [Strong | Worth exploring | Speculative]
If the candidate contradicts an existing ADR, note it clearly:
> ⚠️ Contradicts ADR-0007 — but worth reopening because [reason]
End with a Top Recommendation section stating which candidate to tackle first and why.
Once the user picks a candidate, run the grilling skill (/ideation grill) to walk the design tree — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
Side effects as decisions crystallize:
Use these terms consistently in every suggestion:
| Term | Definition | |------|-----------| | Module | A unit of code with an interface and implementation | | Interface | The public surface — functions, types, exports | | Depth | Ratio of implementation complexity to interface complexity | | Seam | A place where you can change behavior without changing the module | | Adapter | A module that translates one interface to another | | Leverage | How much behavior you get per line of interface code | | Locality | How much of a change stays within one module |
tools
Create valid, type-safe TypeScript tools for OpenCode — generates correct boilerplate, typed interfaces, and handler stubs. Use when building new tools for global config or per-project .opencode/tools/.
testing
Explore multiple solution branches in parallel, evaluate each, and recommend the best path. Use when the user explicitly invokes /ideation tree-of-thoughts or asks for "tree of thought" / "branching exploration".
testing
Run multiple independent reasoning passes and find consensus. Use when the decision is critically important, the stakes are high, or the user explicitly requests "run it multiple times" / "check consistency" / "self-consistency".
testing
Optimization by PROmpting — generate candidate prompt variations, test each against a benchmark, and report the best performer. Use when the user invokes /ideation opro or asks for "prompt optimization" / "OPRO".