Skip to content

Commit c72ac71

Browse files
committed
FEAT: Add Improve Codebase Architecture Skill
Add the improve-codebase-architecture skill with reference docs and update skills-lock.json to include it. This skill helps identify and propose architectural improvements for better testability and module depth.
1 parent 6dc6857 commit c72ac71

3 files changed

Lines changed: 159 additions & 0 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Reference
2+
3+
## Dependency Categories
4+
5+
When assessing a candidate for deepening, classify its dependencies:
6+
7+
### 1. In-process
8+
9+
Pure computation, in-memory state, no I/O. Always deepenable — just merge the modules and test directly.
10+
11+
### 2. Local-substitutable
12+
13+
Dependencies that have local test stand-ins (e.g., PGLite for Postgres, in-memory filesystem). Deepenable if the test substitute exists. The deepened module is tested with the local stand-in running in the test suite.
14+
15+
### 3. Remote but owned (Ports & Adapters)
16+
17+
Your own services across a network boundary (microservices, internal APIs). Define a port (interface) at the module boundary. The deep module owns the logic; the transport is injected. Tests use an in-memory adapter. Production uses the real HTTP/gRPC/queue adapter.
18+
19+
Recommendation shape: "Define a shared interface (port), implement an HTTP adapter for production and an in-memory adapter for testing, so the logic can be tested as one deep module even though it's deployed across a network boundary."
20+
21+
### 4. True external (Mock)
22+
23+
Third-party services (Stripe, Twilio, etc.) you don't control. Mock at the boundary. The deepened module takes the external dependency as an injected port, and tests provide a mock implementation.
24+
25+
## Testing Strategy
26+
27+
The core principle: **replace, don't layer.**
28+
29+
- Old unit tests on shallow modules are waste once boundary tests exist — delete them
30+
- Write new tests at the deepened module's interface boundary
31+
- Tests assert on observable outcomes through the public interface, not internal state
32+
- Tests should survive internal refactors — they describe behavior, not implementation
33+
34+
## Issue Template
35+
36+
<issue-template>
37+
38+
## Problem
39+
40+
Describe the architectural friction:
41+
42+
- Which modules are shallow and tightly coupled
43+
- What integration risk exists in the seams between them
44+
- Why this makes the codebase harder to navigate and maintain
45+
46+
## Proposed Interface
47+
48+
The chosen interface design:
49+
50+
- Interface signature (types, methods, params)
51+
- Usage example showing how callers use it
52+
- What complexity it hides internally
53+
54+
## Dependency Strategy
55+
56+
Which category applies and how dependencies are handled:
57+
58+
- **In-process**: merged directly
59+
- **Local-substitutable**: tested with [specific stand-in]
60+
- **Ports & adapters**: port definition, production adapter, test adapter
61+
- **Mock**: mock boundary for external services
62+
63+
## Testing Strategy
64+
65+
- **New boundary tests to write**: describe the behaviors to verify at the interface
66+
- **Old tests to delete**: list the shallow module tests that become redundant
67+
- **Test environment needs**: any local stand-ins or adapters required
68+
69+
## Implementation Recommendations
70+
71+
Durable architectural guidance that is NOT coupled to current file paths:
72+
73+
- What the module should own (responsibilities)
74+
- What it should hide (implementation details)
75+
- What it should expose (the interface contract)
76+
- How callers should migrate to the new interface
77+
78+
</issue-template>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
name: improve-codebase-architecture
3+
description: Explore a codebase to find opportunities for architectural improvement, focusing on making the codebase more testable by deepening shallow modules. Use when user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more AI-navigable.
4+
---
5+
6+
# Improve Codebase Architecture
7+
8+
Explore a codebase like an AI would, surface architectural friction, discover opportunities for improving testability, and propose module-deepening refactors as GitHub issue RFCs.
9+
10+
A **deep module** (John Ousterhout, "A Philosophy of Software Design") has a small interface hiding a large implementation. Deep modules are more testable, more AI-navigable, and let you test at the boundary instead of inside.
11+
12+
## Process
13+
14+
### 1. Explore the codebase
15+
16+
Use the Agent tool with subagent_type=Explore to navigate the codebase naturally. Do NOT follow rigid heuristics — explore organically and note where you experience friction:
17+
18+
- Where does understanding one concept require bouncing between many small files?
19+
- Where are modules so shallow that the interface is nearly as complex as the implementation?
20+
- Where have pure functions been extracted just for testability, but the real bugs hide in how they're called?
21+
- Where do tightly-coupled modules create integration risk in the seams between them?
22+
- Which parts of the codebase are untested, or hard to test?
23+
24+
The friction you encounter IS the signal.
25+
26+
### 2. Present candidates
27+
28+
Present a numbered list of deepening opportunities. For each candidate, show:
29+
30+
- **Cluster**: Which modules/concepts are involved
31+
- **Why they're coupled**: Shared types, call patterns, co-ownership of a concept
32+
- **Dependency category**: See [REFERENCE.md](REFERENCE.md) for the four categories
33+
- **Test impact**: What existing tests would be replaced by boundary tests
34+
35+
Do NOT propose interfaces yet. Ask the user: "Which of these would you like to explore?"
36+
37+
### 3. User picks a candidate
38+
39+
### 4. Frame the problem space
40+
41+
Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
42+
43+
- The constraints any new interface would need to satisfy
44+
- The dependencies it would need to rely on
45+
- A rough illustrative code sketch to make the constraints concrete — this is not a proposal, just a way to ground the constraints
46+
47+
Show this to the user, then immediately proceed to Step 5. The user reads and thinks about the problem while the sub-agents work in parallel.
48+
49+
### 5. Design multiple interfaces
50+
51+
Spawn 3+ sub-agents in parallel using the Agent tool. Each must produce a **radically different** interface for the deepened module.
52+
53+
Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category, what's being hidden). This brief is independent of the user-facing explanation in Step 4. Give each agent a different design constraint:
54+
55+
- Agent 1: "Minimize the interface — aim for 1-3 entry points max"
56+
- Agent 2: "Maximize flexibility — support many use cases and extension"
57+
- Agent 3: "Optimize for the most common caller — make the default case trivial"
58+
- Agent 4 (if applicable): "Design around the ports & adapters pattern for cross-boundary dependencies"
59+
60+
Each sub-agent outputs:
61+
62+
1. Interface signature (types, methods, params)
63+
2. Usage example showing how callers use it
64+
3. What complexity it hides internally
65+
4. Dependency strategy (how deps are handled — see [REFERENCE.md](REFERENCE.md))
66+
5. Trade-offs
67+
68+
Present designs sequentially, then compare them in prose.
69+
70+
After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated — the user wants a strong read, not just a menu.
71+
72+
### 6. User picks an interface (or accepts recommendation)
73+
74+
### 7. Create GitHub issue
75+
76+
Create a refactor RFC as a GitHub issue using `gh issue create`. Use the template in [REFERENCE.md](REFERENCE.md). Do NOT ask the user to review before creating — just create it and share the URL.

‎skills-lock.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
"sourceType": "github",
77
"computedHash": "cbe644b0c6760ae2a1eaafa39133920d889331327065d92a131675a665273e56"
88
},
9+
"improve-codebase-architecture": {
10+
"source": "mattpocock/skills",
11+
"sourceType": "github",
12+
"computedHash": "76d07c4c0bebc162cc76ca7494bfe7a90e279f35832f7ce6dfc4ce16518fd560"
13+
},
914
"skill-creator": {
1015
"source": "anthropics/skills",
1116
"sourceType": "github",

0 commit comments

Comments
 (0)