ctx-cc 3.4.0 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/ctx.md +33 -622
- package/commands/map-codebase.md +55 -156
- package/package.json +3 -2
- package/references/ui-brand.md +256 -0
- package/src/install.js +8 -0
- package/workflows/ctx-router.md +324 -0
- package/workflows/map-codebase.md +329 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
<purpose>
|
|
2
|
+
Smart router for CTX - understands natural language, detects intent, and routes to the right workflow.
|
|
3
|
+
|
|
4
|
+
Users don't need to memorize commands. They describe what they want, CTX routes automatically.
|
|
5
|
+
</purpose>
|
|
6
|
+
|
|
7
|
+
<ui_reference>
|
|
8
|
+
@~/.claude/ctx/references/ui-brand.md
|
|
9
|
+
</ui_reference>
|
|
10
|
+
|
|
11
|
+
<intent_detection>
|
|
12
|
+
Parse the user's message to detect intent. Check patterns in order:
|
|
13
|
+
|
|
14
|
+
| Pattern | Intent | Action |
|
|
15
|
+
|---------|--------|--------|
|
|
16
|
+
| "build", "create", "make", "start new", "I want to..." + "app/project/feature" | new-project | Route to init flow |
|
|
17
|
+
| "fix", "bug", "broken", "not working", "error", "crash", "fails" | debug | Route to debug flow |
|
|
18
|
+
| "test", "QA", "check", "accessible", "works?", "validate" | qa | Route to QA flow |
|
|
19
|
+
| "study", "analyze", "understand", "learn", "explore", "what is this", "deeply study" | analyze | Route to map-codebase flow |
|
|
20
|
+
| "improve", "optimize", "better", "enhance", "upgrade", "refactor" | improve | Analyze + suggest improvements |
|
|
21
|
+
| "review", "audit", "security", "ready", "before deploy" | review | Verify flow |
|
|
22
|
+
| "deploy", "ship", "publish", "release", "push", "launch" | ship | Ship flow |
|
|
23
|
+
| "status", "progress", "where", "what's next", "current" | status | Status report |
|
|
24
|
+
| "help", "how", "what can", "commands", "guide" | help | Show help |
|
|
25
|
+
| "continue", "next", "go", "do it" | continue | Read STATE.md and continue |
|
|
26
|
+
|
|
27
|
+
Store detected intent for routing.
|
|
28
|
+
</intent_detection>
|
|
29
|
+
|
|
30
|
+
<process>
|
|
31
|
+
|
|
32
|
+
<step name="verify_ctx_structure" priority="first">
|
|
33
|
+
**MANDATORY FIRST STEP - Execute before anything else:**
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
test -d .ctx && echo "exists" || echo "missing"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Store result:
|
|
40
|
+
- If "exists": CTX is initialized, load state
|
|
41
|
+
- If "missing": CTX not initialized, may need setup
|
|
42
|
+
</step>
|
|
43
|
+
|
|
44
|
+
<step name="detect_intent">
|
|
45
|
+
Parse user message and detect intent using patterns above.
|
|
46
|
+
|
|
47
|
+
Output detected intent for routing decision.
|
|
48
|
+
</step>
|
|
49
|
+
|
|
50
|
+
<step name="route_no_ctx">
|
|
51
|
+
**If NO .ctx/ folder (new user):**
|
|
52
|
+
|
|
53
|
+
Route by detected intent:
|
|
54
|
+
|
|
55
|
+
### Intent: new-project
|
|
56
|
+
|
|
57
|
+
Output:
|
|
58
|
+
```
|
|
59
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
60
|
+
CTX ► WELCOME
|
|
61
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
62
|
+
|
|
63
|
+
I understood: "{{user_request}}"
|
|
64
|
+
|
|
65
|
+
You want to build something new. Let's set it up!
|
|
66
|
+
|
|
67
|
+
───────────────────────────────────────────────────────
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Execute /ctx:init inline (don't tell user to run it separately).
|
|
71
|
+
|
|
72
|
+
### Intent: analyze (study/explore)
|
|
73
|
+
|
|
74
|
+
Output:
|
|
75
|
+
```
|
|
76
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
77
|
+
CTX ► ANALYZING CODEBASE
|
|
78
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
79
|
+
|
|
80
|
+
I understood: "{{user_request}}"
|
|
81
|
+
|
|
82
|
+
Let me analyze this codebase with 4 specialized mappers.
|
|
83
|
+
|
|
84
|
+
───────────────────────────────────────────────────────
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Step 1: Create structure**
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
mkdir -p .ctx/codebase
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Step 2: Show spawning indicator**
|
|
94
|
+
|
|
95
|
+
Output:
|
|
96
|
+
```
|
|
97
|
+
◆ Spawning 4 mappers in parallel...
|
|
98
|
+
→ ctx-tech-mapper
|
|
99
|
+
→ ctx-arch-mapper
|
|
100
|
+
→ ctx-quality-mapper
|
|
101
|
+
→ ctx-concerns-mapper
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Step 3: Spawn 4 mapper agents in parallel**
|
|
105
|
+
|
|
106
|
+
Read model profile (default to "balanced"):
|
|
107
|
+
```bash
|
|
108
|
+
MODEL_PROFILE="haiku"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Spawn all 4 agents with a SINGLE message containing multiple Task calls:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
Task(prompt="Analyze this codebase for technology stack. Write comprehensive analysis to: .ctx/codebase/TECH.md. Include languages, frameworks, dependencies, versions, build tools. Return confirmation with line count when complete.", subagent_type="ctx-tech-mapper", model="haiku", run_in_background=true, description="Map tech stack")
|
|
115
|
+
|
|
116
|
+
Task(prompt="Analyze this codebase architecture. Write comprehensive analysis to: .ctx/codebase/ARCH.md. Include architectural pattern, layer structure, module boundaries, entry points, data flow. Return confirmation with line count when complete.", subagent_type="ctx-arch-mapper", model="haiku", run_in_background=true, description="Map architecture")
|
|
117
|
+
|
|
118
|
+
Task(prompt="Analyze this codebase for quality patterns. Write comprehensive analysis to: .ctx/codebase/QUALITY.md. Include test coverage, linting, type safety, documentation, code smells. Return confirmation with line count when complete.", subagent_type="ctx-quality-mapper", model="haiku", run_in_background=true, description="Map quality")
|
|
119
|
+
|
|
120
|
+
Task(prompt="Analyze this codebase for concerns and risks. Write comprehensive analysis to: .ctx/codebase/CONCERNS.md. Include security issues, technical debt, performance problems, operational risks. Return confirmation with line count when complete.", subagent_type="ctx-concerns-mapper", model="haiku", run_in_background=true, description="Map concerns")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Step 4: Wait for completion and show progress**
|
|
124
|
+
|
|
125
|
+
Use TaskOutput to wait for each agent. As each completes, output:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
✓ ctx-tech-mapper complete: TECH.md ({{N}} lines)
|
|
129
|
+
✓ ctx-arch-mapper complete: ARCH.md ({{N}} lines)
|
|
130
|
+
✓ ctx-quality-mapper complete: QUALITY.md ({{N}} lines)
|
|
131
|
+
✓ ctx-concerns-mapper complete: CONCERNS.md ({{N}} lines)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Step 5: Verify output**
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
ls -la .ctx/codebase/
|
|
138
|
+
wc -l .ctx/codebase/*.md
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Step 6: Create summary**
|
|
142
|
+
|
|
143
|
+
Read all 4 documents:
|
|
144
|
+
```bash
|
|
145
|
+
cat .ctx/codebase/TECH.md
|
|
146
|
+
cat .ctx/codebase/ARCH.md
|
|
147
|
+
cat .ctx/codebase/QUALITY.md
|
|
148
|
+
cat .ctx/codebase/CONCERNS.md
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Write `.ctx/codebase/SUMMARY.md` with key findings from each document.
|
|
152
|
+
|
|
153
|
+
**Step 7: Show completion banner**
|
|
154
|
+
|
|
155
|
+
Output:
|
|
156
|
+
```
|
|
157
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
158
|
+
CTX ► MAPPING COMPLETE ✓
|
|
159
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
160
|
+
|
|
161
|
+
┌─────────────────────────────────────────────────────┐
|
|
162
|
+
│ CODEBASE SUMMARY │
|
|
163
|
+
├─────────────────────────────────────────────────────┤
|
|
164
|
+
│ Tech: {{primary_language}}, {{framework}} │
|
|
165
|
+
│ Architecture: {{pattern}} │
|
|
166
|
+
│ Quality: {{coverage}}% coverage, {{warnings}} │
|
|
167
|
+
│ Concerns: {{concern_count}} identified │
|
|
168
|
+
└─────────────────────────────────────────────────────┘
|
|
169
|
+
|
|
170
|
+
Files created:
|
|
171
|
+
.ctx/codebase/TECH.md
|
|
172
|
+
.ctx/codebase/ARCH.md
|
|
173
|
+
.ctx/codebase/QUALITY.md
|
|
174
|
+
.ctx/codebase/CONCERNS.md
|
|
175
|
+
.ctx/codebase/SUMMARY.md
|
|
176
|
+
|
|
177
|
+
───────────────────────────────────────────────────────
|
|
178
|
+
|
|
179
|
+
## ▶ Next Up
|
|
180
|
+
|
|
181
|
+
**Initialize project** — set up CTX workflow with this context
|
|
182
|
+
|
|
183
|
+
`/ctx:init`
|
|
184
|
+
|
|
185
|
+
<sub>`/clear` first → fresh context window</sub>
|
|
186
|
+
|
|
187
|
+
───────────────────────────────────────────────────────
|
|
188
|
+
|
|
189
|
+
**Also available:**
|
|
190
|
+
- `cat .ctx/codebase/SUMMARY.md` — view full summary
|
|
191
|
+
- `/ctx:map-codebase --refresh` — re-analyze codebase
|
|
192
|
+
|
|
193
|
+
───────────────────────────────────────────────────────
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Intent: debug
|
|
197
|
+
|
|
198
|
+
Output:
|
|
199
|
+
```
|
|
200
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
201
|
+
CTX ► DEBUG MODE
|
|
202
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
203
|
+
|
|
204
|
+
I understood: "{{problem_description}}"
|
|
205
|
+
|
|
206
|
+
Let me analyze the codebase first, then investigate.
|
|
207
|
+
|
|
208
|
+
───────────────────────────────────────────────────────
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
First map codebase (same as analyze), then spawn debugger agent.
|
|
212
|
+
|
|
213
|
+
### Intent: help or unknown
|
|
214
|
+
|
|
215
|
+
Output:
|
|
216
|
+
```
|
|
217
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
218
|
+
CTX ► WELCOME
|
|
219
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
220
|
+
|
|
221
|
+
What would you like to do?
|
|
222
|
+
|
|
223
|
+
┌─────────────────────────────────────────────────────┐
|
|
224
|
+
│ AVAILABLE ACTIONS │
|
|
225
|
+
├─────────────────────────────────────────────────────┤
|
|
226
|
+
│ "Build something new" → Set up your project │
|
|
227
|
+
│ "Fix a bug" → Debug the issue │
|
|
228
|
+
│ "Study the codebase" → Analyze everything │
|
|
229
|
+
│ "Test the app" → Run full QA │
|
|
230
|
+
└─────────────────────────────────────────────────────┘
|
|
231
|
+
|
|
232
|
+
Just describe what you want in natural language!
|
|
233
|
+
|
|
234
|
+
───────────────────────────────────────────────────────
|
|
235
|
+
```
|
|
236
|
+
</step>
|
|
237
|
+
|
|
238
|
+
<step name="route_with_ctx">
|
|
239
|
+
**If .ctx/ folder EXISTS:**
|
|
240
|
+
|
|
241
|
+
### Load state first
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
cat .ctx/STATE.md
|
|
245
|
+
cat .ctx/config.json 2>/dev/null || echo "{}"
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Extract:
|
|
249
|
+
- `status`: Current workflow status
|
|
250
|
+
- `currentPhase`: Active phase
|
|
251
|
+
- `profile`: Model profile (quality/balanced/budget)
|
|
252
|
+
|
|
253
|
+
### Route by Intent + State
|
|
254
|
+
|
|
255
|
+
| Intent | Action |
|
|
256
|
+
|--------|--------|
|
|
257
|
+
| new-project | Warn project exists, offer to add phase |
|
|
258
|
+
| analyze | Run map-codebase (refresh) |
|
|
259
|
+
| debug | Spawn debugger with context |
|
|
260
|
+
| qa | Spawn QA agent |
|
|
261
|
+
| status | Show status from STATE.md |
|
|
262
|
+
| continue | Resume from STATE.md status |
|
|
263
|
+
|
|
264
|
+
### Status Report Format
|
|
265
|
+
|
|
266
|
+
Output:
|
|
267
|
+
```
|
|
268
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
269
|
+
CTX ► STATUS
|
|
270
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
271
|
+
|
|
272
|
+
Project: {{name}}
|
|
273
|
+
Status: {{status}}
|
|
274
|
+
Profile: {{profile}}
|
|
275
|
+
|
|
276
|
+
Progress: ████████░░ {{percent}}%
|
|
277
|
+
|
|
278
|
+
| Phase | Status | Tasks |
|
|
279
|
+
|-------|--------|----------|
|
|
280
|
+
| 1 | ✓ | 5/5 |
|
|
281
|
+
| 2 | ◆ | 2/4 |
|
|
282
|
+
| 3 | ○ | 0/3 |
|
|
283
|
+
|
|
284
|
+
Current: {{current_phase}}
|
|
285
|
+
|
|
286
|
+
───────────────────────────────────────────────────────
|
|
287
|
+
|
|
288
|
+
## ▶ Next Up
|
|
289
|
+
|
|
290
|
+
**{{next_action}}**
|
|
291
|
+
|
|
292
|
+
`/ctx` or describe what you want to do
|
|
293
|
+
|
|
294
|
+
───────────────────────────────────────────────────────
|
|
295
|
+
```
|
|
296
|
+
</step>
|
|
297
|
+
|
|
298
|
+
</process>
|
|
299
|
+
|
|
300
|
+
<research_integration>
|
|
301
|
+
**When to use ArguSeek:**
|
|
302
|
+
|
|
303
|
+
For debug, improve, and review intents, research BEFORE spawning agents:
|
|
304
|
+
|
|
305
|
+
```
|
|
306
|
+
mcp__arguseek__research_iteratively({
|
|
307
|
+
query: "{{tech_stack}} {{problem_or_goal}} best practices solutions 2025"
|
|
308
|
+
})
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Include research findings in agent prompts.
|
|
312
|
+
</research_integration>
|
|
313
|
+
|
|
314
|
+
<success_criteria>
|
|
315
|
+
- [ ] .ctx structure checked first
|
|
316
|
+
- [ ] Intent detected from user message
|
|
317
|
+
- [ ] Correct flow routed
|
|
318
|
+
- [ ] UI patterns used consistently (banners, boxes, progress)
|
|
319
|
+
- [ ] ArguSeek called for research-worthy intents
|
|
320
|
+
- [ ] Task() agents spawned with full context
|
|
321
|
+
- [ ] STATE.md created/updated
|
|
322
|
+
- [ ] Clear "Next Up" shown with command
|
|
323
|
+
- [ ] User knows to run /ctx to continue
|
|
324
|
+
</success_criteria>
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
<purpose>
|
|
2
|
+
Orchestrate parallel codebase mapper agents to analyze codebase and produce structured documents in .ctx/codebase/
|
|
3
|
+
|
|
4
|
+
Each agent has fresh context, explores a specific focus area, and **writes documents directly**. The orchestrator only receives confirmation + line counts, then writes a summary.
|
|
5
|
+
|
|
6
|
+
Output: .ctx/codebase/ folder with 4 structured documents about the codebase state.
|
|
7
|
+
</purpose>
|
|
8
|
+
|
|
9
|
+
<philosophy>
|
|
10
|
+
**Why dedicated mapper agents:**
|
|
11
|
+
- Fresh context per domain (no token contamination)
|
|
12
|
+
- Agents write documents directly (no context transfer back to orchestrator)
|
|
13
|
+
- Orchestrator only summarizes what was created (minimal context usage)
|
|
14
|
+
- Faster execution (agents run simultaneously)
|
|
15
|
+
|
|
16
|
+
**Document quality over length:**
|
|
17
|
+
Include enough detail to be useful as reference. Prioritize practical examples (especially code patterns) over arbitrary brevity.
|
|
18
|
+
|
|
19
|
+
**Always include file paths:**
|
|
20
|
+
Documents are reference material for Claude when planning/executing. Always include actual file paths formatted with backticks: `src/services/user.ts`.
|
|
21
|
+
</philosophy>
|
|
22
|
+
|
|
23
|
+
<process>
|
|
24
|
+
|
|
25
|
+
<step name="resolve_model_profile" priority="first">
|
|
26
|
+
Read model profile for agent spawning:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
MODEL_PROFILE=$(cat .ctx/config.json 2>/dev/null | grep -o '"profile"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Default to "balanced" if not set.
|
|
33
|
+
|
|
34
|
+
**Model lookup table:**
|
|
35
|
+
|
|
36
|
+
| Agent | quality | balanced | budget |
|
|
37
|
+
|-------|---------|----------|--------|
|
|
38
|
+
| ctx-*-mapper | sonnet | haiku | haiku |
|
|
39
|
+
|
|
40
|
+
Store resolved model for use in Task calls below.
|
|
41
|
+
</step>
|
|
42
|
+
|
|
43
|
+
<step name="check_existing">
|
|
44
|
+
Check if .ctx/codebase/ already exists:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
ls -la .ctx/codebase/ 2>/dev/null
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**If exists:**
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
.ctx/codebase/ already exists with these documents:
|
|
54
|
+
[List files found]
|
|
55
|
+
|
|
56
|
+
What's next?
|
|
57
|
+
1. Refresh - Delete existing and remap codebase
|
|
58
|
+
2. Skip - Use existing codebase map as-is
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Wait for user response.
|
|
62
|
+
|
|
63
|
+
If "Refresh": Delete .ctx/codebase/, continue to create_structure
|
|
64
|
+
If "Skip": Exit workflow
|
|
65
|
+
|
|
66
|
+
**If doesn't exist:**
|
|
67
|
+
Continue to create_structure.
|
|
68
|
+
</step>
|
|
69
|
+
|
|
70
|
+
<step name="create_structure">
|
|
71
|
+
Create .ctx/codebase/ directory:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
mkdir -p .ctx/codebase
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Expected output files:**
|
|
78
|
+
- TECH.md (from ctx-tech-mapper)
|
|
79
|
+
- ARCH.md (from ctx-arch-mapper)
|
|
80
|
+
- QUALITY.md (from ctx-quality-mapper)
|
|
81
|
+
- CONCERNS.md (from ctx-concerns-mapper)
|
|
82
|
+
|
|
83
|
+
Continue to spawn_agents.
|
|
84
|
+
</step>
|
|
85
|
+
|
|
86
|
+
<step name="spawn_agents">
|
|
87
|
+
Spawn 4 parallel ctx-*-mapper agents.
|
|
88
|
+
|
|
89
|
+
Use Task tool with the appropriate `subagent_type`, `model="{mapper_model}"`, and `run_in_background=true` for parallel execution.
|
|
90
|
+
|
|
91
|
+
**CRITICAL:** Use the dedicated mapper agents. The mapper agent writes documents directly.
|
|
92
|
+
|
|
93
|
+
**Agent 1: Tech Focus**
|
|
94
|
+
|
|
95
|
+
Task tool parameters:
|
|
96
|
+
```
|
|
97
|
+
subagent_type: "ctx-tech-mapper"
|
|
98
|
+
model: "{mapper_model}"
|
|
99
|
+
run_in_background: true
|
|
100
|
+
description: "Map codebase tech stack"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Prompt:
|
|
104
|
+
```
|
|
105
|
+
Analyze this codebase for technology stack.
|
|
106
|
+
|
|
107
|
+
Write comprehensive analysis to: .ctx/codebase/TECH.md
|
|
108
|
+
|
|
109
|
+
Include:
|
|
110
|
+
- Languages and their proportions
|
|
111
|
+
- Frameworks and libraries
|
|
112
|
+
- Dependencies and versions
|
|
113
|
+
- Build tools and scripts
|
|
114
|
+
- Runtime requirements
|
|
115
|
+
|
|
116
|
+
Return confirmation with line count when complete.
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Agent 2: Architecture Focus**
|
|
120
|
+
|
|
121
|
+
Task tool parameters:
|
|
122
|
+
```
|
|
123
|
+
subagent_type: "ctx-arch-mapper"
|
|
124
|
+
model: "{mapper_model}"
|
|
125
|
+
run_in_background: true
|
|
126
|
+
description: "Map codebase architecture"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Prompt:
|
|
130
|
+
```
|
|
131
|
+
Analyze this codebase architecture.
|
|
132
|
+
|
|
133
|
+
Write comprehensive analysis to: .ctx/codebase/ARCH.md
|
|
134
|
+
|
|
135
|
+
Include:
|
|
136
|
+
- Architectural pattern (MVC, hexagonal, etc.)
|
|
137
|
+
- Layer structure
|
|
138
|
+
- Module boundaries
|
|
139
|
+
- Entry points
|
|
140
|
+
- Data flow patterns
|
|
141
|
+
|
|
142
|
+
Return confirmation with line count when complete.
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Agent 3: Quality Focus**
|
|
146
|
+
|
|
147
|
+
Task tool parameters:
|
|
148
|
+
```
|
|
149
|
+
subagent_type: "ctx-quality-mapper"
|
|
150
|
+
model: "{mapper_model}"
|
|
151
|
+
run_in_background: true
|
|
152
|
+
description: "Map codebase quality"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Prompt:
|
|
156
|
+
```
|
|
157
|
+
Analyze this codebase for quality patterns.
|
|
158
|
+
|
|
159
|
+
Write comprehensive analysis to: .ctx/codebase/QUALITY.md
|
|
160
|
+
|
|
161
|
+
Include:
|
|
162
|
+
- Test coverage and patterns
|
|
163
|
+
- Linting and formatting status
|
|
164
|
+
- Type safety
|
|
165
|
+
- Documentation coverage
|
|
166
|
+
- Code smells
|
|
167
|
+
|
|
168
|
+
Return confirmation with line count when complete.
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Agent 4: Concerns Focus**
|
|
172
|
+
|
|
173
|
+
Task tool parameters:
|
|
174
|
+
```
|
|
175
|
+
subagent_type: "ctx-concerns-mapper"
|
|
176
|
+
model: "{mapper_model}"
|
|
177
|
+
run_in_background: true
|
|
178
|
+
description: "Map codebase concerns"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Prompt:
|
|
182
|
+
```
|
|
183
|
+
Analyze this codebase for concerns and risks.
|
|
184
|
+
|
|
185
|
+
Write comprehensive analysis to: .ctx/codebase/CONCERNS.md
|
|
186
|
+
|
|
187
|
+
Include:
|
|
188
|
+
- Security vulnerabilities
|
|
189
|
+
- Technical debt
|
|
190
|
+
- Performance issues
|
|
191
|
+
- Operational risks
|
|
192
|
+
- Compliance gaps
|
|
193
|
+
|
|
194
|
+
Return confirmation with line count when complete.
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Continue to collect_confirmations.
|
|
198
|
+
</step>
|
|
199
|
+
|
|
200
|
+
<step name="collect_confirmations">
|
|
201
|
+
Wait for all 4 agents to complete using TaskOutput.
|
|
202
|
+
|
|
203
|
+
Read each agent's output to collect confirmations.
|
|
204
|
+
|
|
205
|
+
**Expected confirmation format from each agent:**
|
|
206
|
+
```
|
|
207
|
+
## Mapping Complete
|
|
208
|
+
|
|
209
|
+
**Focus:** {focus}
|
|
210
|
+
**Document written:**
|
|
211
|
+
- `.ctx/codebase/{DOC}.md` ({N} lines)
|
|
212
|
+
|
|
213
|
+
Ready for orchestrator summary.
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**What you receive:** Just file paths and line counts. NOT document contents.
|
|
217
|
+
|
|
218
|
+
If any agent failed, note the failure and continue with successful documents.
|
|
219
|
+
|
|
220
|
+
Continue to verify_output.
|
|
221
|
+
</step>
|
|
222
|
+
|
|
223
|
+
<step name="verify_output">
|
|
224
|
+
Verify all documents created successfully:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
ls -la .ctx/codebase/
|
|
228
|
+
wc -l .ctx/codebase/*.md
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Verification checklist:**
|
|
232
|
+
- All 4 documents exist
|
|
233
|
+
- No empty documents (each should have >20 lines)
|
|
234
|
+
|
|
235
|
+
If any documents missing or empty, note which agents may have failed.
|
|
236
|
+
|
|
237
|
+
Continue to create_summary.
|
|
238
|
+
</step>
|
|
239
|
+
|
|
240
|
+
<step name="create_summary">
|
|
241
|
+
Create SUMMARY.md by reading and synthesizing the 4 documents:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Read each document for synthesis
|
|
245
|
+
cat .ctx/codebase/TECH.md
|
|
246
|
+
cat .ctx/codebase/ARCH.md
|
|
247
|
+
cat .ctx/codebase/QUALITY.md
|
|
248
|
+
cat .ctx/codebase/CONCERNS.md
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Write `.ctx/codebase/SUMMARY.md`:
|
|
252
|
+
|
|
253
|
+
```markdown
|
|
254
|
+
# Codebase Summary
|
|
255
|
+
|
|
256
|
+
## Tech Stack
|
|
257
|
+
{Key findings from TECH.md}
|
|
258
|
+
|
|
259
|
+
## Architecture
|
|
260
|
+
{Key findings from ARCH.md}
|
|
261
|
+
|
|
262
|
+
## Quality
|
|
263
|
+
{Key findings from QUALITY.md}
|
|
264
|
+
|
|
265
|
+
## Concerns
|
|
266
|
+
{Top 3-5 concerns from CONCERNS.md}
|
|
267
|
+
|
|
268
|
+
## Recommendations
|
|
269
|
+
1. {Most important action}
|
|
270
|
+
2. {Second priority}
|
|
271
|
+
3. {Third priority}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Continue to offer_next.
|
|
275
|
+
</step>
|
|
276
|
+
|
|
277
|
+
<step name="offer_next">
|
|
278
|
+
Present completion summary and next steps.
|
|
279
|
+
|
|
280
|
+
**Get line counts:**
|
|
281
|
+
```bash
|
|
282
|
+
wc -l .ctx/codebase/*.md
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Output format:**
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
Codebase mapping complete.
|
|
289
|
+
|
|
290
|
+
Created .ctx/codebase/:
|
|
291
|
+
- TECH.md ([N] lines) - Technologies and dependencies
|
|
292
|
+
- ARCH.md ([N] lines) - System design and patterns
|
|
293
|
+
- QUALITY.md ([N] lines) - Code quality assessment
|
|
294
|
+
- CONCERNS.md ([N] lines) - Technical debt and issues
|
|
295
|
+
- SUMMARY.md ([N] lines) - Executive summary
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Next Up
|
|
301
|
+
|
|
302
|
+
**Initialize project** - use codebase context for planning
|
|
303
|
+
|
|
304
|
+
/ctx:init
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
**Also available:**
|
|
309
|
+
- Re-run mapping: /ctx:map-codebase --refresh
|
|
310
|
+
- Review specific file: cat .ctx/codebase/TECH.md
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
End workflow.
|
|
316
|
+
</step>
|
|
317
|
+
|
|
318
|
+
</process>
|
|
319
|
+
|
|
320
|
+
<success_criteria>
|
|
321
|
+
- .ctx/codebase/ directory created
|
|
322
|
+
- 4 parallel mapper agents spawned with run_in_background=true
|
|
323
|
+
- Agents write documents directly (orchestrator doesn't receive document contents)
|
|
324
|
+
- Use TaskOutput to wait for agent completion
|
|
325
|
+
- All 4 codebase documents exist
|
|
326
|
+
- SUMMARY.md created with synthesis
|
|
327
|
+
- Clear completion summary with line counts
|
|
328
|
+
- User offered clear next steps
|
|
329
|
+
</success_criteria>
|