create-claude-context 1.0.0 → 1.2.1
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/LICENSE +21 -21
- package/README.md +169 -146
- package/bin/create-claude-context.js +75 -61
- package/lib/ai-orchestrator.js +423 -0
- package/lib/call-tracer.js +444 -0
- package/lib/detector.js +456 -373
- package/lib/environment-detector.js +239 -0
- package/lib/index.js +271 -170
- package/lib/installer.js +371 -362
- package/lib/placeholder.js +269 -208
- package/lib/prompts.js +287 -287
- package/lib/spinner.js +60 -60
- package/lib/static-analyzer.js +729 -0
- package/lib/template-populator.js +835 -0
- package/lib/validate.js +147 -147
- package/package.json +59 -59
- package/templates/CLAUDE.md.template +235 -235
- package/templates/base/README.md +257 -257
- package/templates/base/RPI_WORKFLOW_PLAN.md +320 -320
- package/templates/base/agents/api-developer.md +76 -76
- package/templates/base/agents/context-engineer.md +525 -525
- package/templates/base/agents/core-architect.md +76 -76
- package/templates/base/agents/database-ops.md +76 -76
- package/templates/base/agents/deployment-ops.md +76 -76
- package/templates/base/agents/integration-hub.md +76 -76
- package/templates/base/analytics/README.md +114 -114
- package/templates/base/automation/config.json +58 -0
- package/templates/base/automation/generators/code-mapper.js +308 -0
- package/templates/base/automation/generators/index-builder.js +321 -0
- package/templates/base/automation/hooks/post-commit.sh +83 -0
- package/templates/base/automation/hooks/pre-commit.sh +103 -0
- package/templates/base/ci-templates/README.md +108 -108
- package/templates/base/ci-templates/github-actions/context-check.yml +144 -144
- package/templates/base/ci-templates/github-actions/validate-docs.yml +105 -105
- package/templates/base/commands/analytics.md +238 -238
- package/templates/base/commands/auto-sync.md +172 -0
- package/templates/base/commands/collab.md +194 -194
- package/templates/base/commands/help.md +450 -450
- package/templates/base/commands/rpi-implement.md +115 -115
- package/templates/base/commands/rpi-plan.md +93 -93
- package/templates/base/commands/rpi-research.md +88 -88
- package/templates/base/commands/session-resume.md +144 -0
- package/templates/base/commands/session-save.md +112 -0
- package/templates/base/commands/validate-all.md +77 -77
- package/templates/base/commands/verify-docs-current.md +86 -86
- package/templates/base/config/base.json +57 -57
- package/templates/base/config/environments/development.json +13 -13
- package/templates/base/config/environments/production.json +17 -17
- package/templates/base/config/environments/staging.json +13 -13
- package/templates/base/config/local.json.example +21 -21
- package/templates/base/context/.meta/generated-at.json +18 -0
- package/templates/base/context/ARCHITECTURE_SNAPSHOT.md +156 -156
- package/templates/base/context/CODE_TO_WORKFLOW_MAP.md +94 -94
- package/templates/base/context/FILE_OWNERSHIP.md +57 -0
- package/templates/base/context/INTEGRATION_POINTS.md +92 -0
- package/templates/base/context/KNOWN_GOTCHAS.md +195 -195
- package/templates/base/context/TESTING_MAP.md +95 -0
- package/templates/base/context/WORKFLOW_INDEX.md +129 -129
- package/templates/base/context/workflows/WORKFLOW_TEMPLATE.md +294 -294
- package/templates/base/indexes/agents/CAPABILITY_MATRIX.md +255 -255
- package/templates/base/indexes/agents/CATEGORY_INDEX.md +44 -44
- package/templates/base/indexes/code/CATEGORY_INDEX.md +38 -38
- package/templates/base/indexes/routing/CATEGORY_INDEX.md +39 -39
- package/templates/base/indexes/search/CATEGORY_INDEX.md +39 -39
- package/templates/base/indexes/workflows/CATEGORY_INDEX.md +38 -38
- package/templates/base/knowledge/README.md +98 -98
- package/templates/base/knowledge/sessions/README.md +88 -88
- package/templates/base/knowledge/sessions/TEMPLATE.md +150 -150
- package/templates/base/knowledge/shared/decisions/0001-adopt-context-engineering.md +144 -144
- package/templates/base/knowledge/shared/decisions/README.md +49 -49
- package/templates/base/knowledge/shared/decisions/TEMPLATE.md +123 -123
- package/templates/base/knowledge/shared/patterns/README.md +62 -62
- package/templates/base/knowledge/shared/patterns/TEMPLATE.md +120 -120
- package/templates/base/plans/PLAN_TEMPLATE.md +250 -250
- package/templates/base/research/RESEARCH_TEMPLATE.md +153 -153
- package/templates/base/schemas/agent.schema.json +141 -141
- package/templates/base/schemas/anchors.schema.json +54 -0
- package/templates/base/schemas/automation.schema.json +93 -0
- package/templates/base/schemas/command.schema.json +134 -134
- package/templates/base/schemas/hashes.schema.json +40 -0
- package/templates/base/schemas/manifest.schema.json +117 -117
- package/templates/base/schemas/plan.schema.json +136 -136
- package/templates/base/schemas/research.schema.json +115 -115
- package/templates/base/schemas/roles.schema.json +34 -0
- package/templates/base/schemas/session.schema.json +77 -0
- package/templates/base/schemas/settings.schema.json +244 -244
- package/templates/base/schemas/staleness.schema.json +53 -0
- package/templates/base/schemas/team-config.schema.json +42 -0
- package/templates/base/schemas/workflow.schema.json +126 -126
- package/templates/base/session/checkpoints/.gitkeep +2 -0
- package/templates/base/session/current/state.json +20 -0
- package/templates/base/session/history/.gitkeep +2 -0
- package/templates/base/settings.json +3 -57
- package/templates/base/standards/COMPATIBILITY.md +219 -219
- package/templates/base/standards/EXTENSION_GUIDELINES.md +280 -280
- package/templates/base/standards/QUALITY_CHECKLIST.md +211 -211
- package/templates/base/standards/README.md +66 -66
- package/templates/base/sync/anchors.json +6 -0
- package/templates/base/sync/hashes.json +6 -0
- package/templates/base/sync/staleness.json +10 -0
- package/templates/base/team/README.md +168 -168
- package/templates/base/team/config.json +79 -79
- package/templates/base/team/roles.json +145 -145
- package/templates/base/tools/bin/claude-context.js +151 -151
- package/templates/base/tools/lib/anchor-resolver.js +276 -0
- package/templates/base/tools/lib/config-loader.js +363 -363
- package/templates/base/tools/lib/detector.js +350 -350
- package/templates/base/tools/lib/diagnose.js +206 -206
- package/templates/base/tools/lib/drift-detector.js +373 -0
- package/templates/base/tools/lib/errors.js +199 -199
- package/templates/base/tools/lib/index.js +36 -24
- package/templates/base/tools/lib/init.js +192 -192
- package/templates/base/tools/lib/logger.js +230 -230
- package/templates/base/tools/lib/placeholder.js +201 -201
- package/templates/base/tools/lib/session-manager.js +354 -0
- package/templates/base/tools/lib/validate.js +521 -521
- package/templates/base/tools/package.json +49 -49
|
@@ -1,320 +1,320 @@
|
|
|
1
|
-
# RPI (Research, Plan, Implement) Workflow
|
|
2
|
-
|
|
3
|
-
**Created:** {{DATE}}
|
|
4
|
-
**Platform:** Claude Code
|
|
5
|
-
**Context Budget:** 200k tokens max, target <40%
|
|
6
|
-
**Output Budget:** 30k tokens max per response
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## Executive Summary
|
|
11
|
-
|
|
12
|
-
The RPI workflow prevents the "slop" and "dumb zone" problems in AI-assisted development. By separating research, planning, and implementation into distinct phases, we achieve:
|
|
13
|
-
|
|
14
|
-
- **90% fewer cascading errors**
|
|
15
|
-
- **3× faster feature implementation**
|
|
16
|
-
- **5× faster issue resolution**
|
|
17
|
-
- **Self-documenting changes**
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Phase 1: RESEARCH
|
|
22
|
-
|
|
23
|
-
### Purpose
|
|
24
|
-
Understand the system, locate relevant components, prevent context pollution
|
|
25
|
-
|
|
26
|
-
### Artifacts
|
|
27
|
-
- Research document in `.claude/research/active/[feature]_research.md`
|
|
28
|
-
- 150-word summary for parent context
|
|
29
|
-
|
|
30
|
-
### Process
|
|
31
|
-
1. Load WORKFLOW_INDEX.md first (saves 100k+ tokens)
|
|
32
|
-
2. Use parallel Explore agents (3 simultaneous)
|
|
33
|
-
3. Trace call chains with line numbers
|
|
34
|
-
4. Map dependencies (internal + external)
|
|
35
|
-
5. Identify test coverage gaps
|
|
36
|
-
6. Document open questions
|
|
37
|
-
|
|
38
|
-
### Context Budget
|
|
39
|
-
- Starting: Up to 50k tokens for exploration
|
|
40
|
-
- Ending: 20k tokens (research doc only)
|
|
41
|
-
- Compaction: After each phase
|
|
42
|
-
|
|
43
|
-
### Exit Criteria
|
|
44
|
-
- [ ] Research document created
|
|
45
|
-
- [ ] 3-20 relevant files identified
|
|
46
|
-
- [ ] Call chains traced with line numbers
|
|
47
|
-
- [ ] Dependencies mapped
|
|
48
|
-
- [ ] 150-word summary generated
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Phase 2: PLAN
|
|
53
|
-
|
|
54
|
-
### Purpose
|
|
55
|
-
Design implementation with file:line precision, get human alignment
|
|
56
|
-
|
|
57
|
-
### Artifacts
|
|
58
|
-
- Plan document in `.claude/plans/active/[feature]_plan.md`
|
|
59
|
-
- Step-by-step implementation roadmap
|
|
60
|
-
|
|
61
|
-
### Process
|
|
62
|
-
1. Load research document
|
|
63
|
-
2. Reference workflow gotchas
|
|
64
|
-
3. Create modification list with exact line numbers
|
|
65
|
-
4. Plan testing strategy
|
|
66
|
-
5. Estimate context budget per step
|
|
67
|
-
6. Define rollback plan
|
|
68
|
-
|
|
69
|
-
### Context Budget
|
|
70
|
-
- Research doc: 20k tokens
|
|
71
|
-
- Plan creation: 15k tokens
|
|
72
|
-
- Total: 35k tokens (17.5%)
|
|
73
|
-
|
|
74
|
-
### Exit Criteria
|
|
75
|
-
- [ ] Plan document created with file:line references
|
|
76
|
-
- [ ] All modifications listed with risk level
|
|
77
|
-
- [ ] Test strategy defined
|
|
78
|
-
- [ ] Rollback plan documented
|
|
79
|
-
- [ ] Human review completed
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## Phase 3: IMPLEMENT
|
|
84
|
-
|
|
85
|
-
### Purpose
|
|
86
|
-
Execute atomically with continuous testing
|
|
87
|
-
|
|
88
|
-
### Golden Rule
|
|
89
|
-
```
|
|
90
|
-
ONE CHANGE → ONE TEST → ONE COMMIT
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Process
|
|
94
|
-
1. Load plan and affected workflow sections
|
|
95
|
-
2. Make single, atomic change
|
|
96
|
-
3. Run affected tests immediately
|
|
97
|
-
4. Commit if tests pass
|
|
98
|
-
5. Update documentation
|
|
99
|
-
6. Repeat until plan complete
|
|
100
|
-
|
|
101
|
-
### Context Budget
|
|
102
|
-
- Plan: 15k tokens
|
|
103
|
-
- Active code: 30k tokens
|
|
104
|
-
- Test results: 15k tokens
|
|
105
|
-
- Total: 60k tokens (30%)
|
|
106
|
-
|
|
107
|
-
### Context Reset (Every 3 Steps)
|
|
108
|
-
1. Update progress checklist
|
|
109
|
-
2. Re-read plan document
|
|
110
|
-
3. Verify scope alignment
|
|
111
|
-
4. Compact if >35% utilization
|
|
112
|
-
|
|
113
|
-
### Exit Criteria
|
|
114
|
-
- [ ] All plan steps completed
|
|
115
|
-
- [ ] All tests passing
|
|
116
|
-
- [ ] Documentation updated
|
|
117
|
-
- [ ] Changes committed
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
|
-
## Template Files
|
|
122
|
-
|
|
123
|
-
### RESEARCH_TEMPLATE.md
|
|
124
|
-
|
|
125
|
-
```markdown
|
|
126
|
-
# Research: [Feature/Bug Name]
|
|
127
|
-
|
|
128
|
-
**Date:** YYYY-MM-DD
|
|
129
|
-
**Researcher:** Claude Code
|
|
130
|
-
**Status:** IN_PROGRESS | COMPLETE | BLOCKED
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## Objective
|
|
135
|
-
[Clear statement of what we're trying to understand]
|
|
136
|
-
|
|
137
|
-
---
|
|
138
|
-
|
|
139
|
-
## Relevant Files Explored
|
|
140
|
-
|
|
141
|
-
| File | Lines | Key Findings |
|
|
142
|
-
|------|-------|--------------|
|
|
143
|
-
| `path/to/file.py` | 100-200 | Entry point for [feature] |
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## Code Flow Analysis
|
|
148
|
-
|
|
149
|
-
[Entry Point] → [Function A] → [Function B] → [Exit Point]
|
|
150
|
-
|
|
151
|
-
```
|
|
152
|
-
entry_function() [file.py:100]
|
|
153
|
-
├─ helper_a() [file.py:150]
|
|
154
|
-
│ └─ utility() [utils.py:50]
|
|
155
|
-
└─ helper_b() [file.py:200]
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## Dependencies Identified
|
|
161
|
-
|
|
162
|
-
**External:**
|
|
163
|
-
- API Name (purpose)
|
|
164
|
-
|
|
165
|
-
**Internal:**
|
|
166
|
-
- service_file.py (purpose)
|
|
167
|
-
|
|
168
|
-
---
|
|
169
|
-
|
|
170
|
-
## Test Files & Coverage
|
|
171
|
-
|
|
172
|
-
**Existing:**
|
|
173
|
-
- tests/test_feature.py - Covers main flow
|
|
174
|
-
|
|
175
|
-
**Gaps:**
|
|
176
|
-
- ❌ No test for error scenario
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
## Open Questions
|
|
181
|
-
|
|
182
|
-
- [ ] Question 1
|
|
183
|
-
- [ ] Question 2
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## Summary (for Plan Phase, 150 words max)
|
|
188
|
-
|
|
189
|
-
[Concise summary for parent context]
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
### PLAN_TEMPLATE.md
|
|
195
|
-
|
|
196
|
-
```markdown
|
|
197
|
-
# Implementation Plan: [Feature/Fix Name]
|
|
198
|
-
|
|
199
|
-
**Date:** YYYY-MM-DD
|
|
200
|
-
**Based on:** research/active/[feature]_research.md
|
|
201
|
-
**Status:** DRAFT | APPROVED | IMPLEMENTING | COMPLETE
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## Research Summary
|
|
206
|
-
[From Phase 1 - max 200 words]
|
|
207
|
-
|
|
208
|
-
---
|
|
209
|
-
|
|
210
|
-
## Scope Definition
|
|
211
|
-
|
|
212
|
-
**In Scope:**
|
|
213
|
-
- [Explicit list]
|
|
214
|
-
|
|
215
|
-
**Out of Scope:**
|
|
216
|
-
- [What we're NOT touching]
|
|
217
|
-
|
|
218
|
-
---
|
|
219
|
-
|
|
220
|
-
## Files to Modify
|
|
221
|
-
|
|
222
|
-
| File | Lines | Change | Risk |
|
|
223
|
-
|------|-------|--------|------|
|
|
224
|
-
| `path/file.py` | 100-150 | Add parameter | LOW |
|
|
225
|
-
|
|
226
|
-
---
|
|
227
|
-
|
|
228
|
-
## Step-by-Step Implementation
|
|
229
|
-
|
|
230
|
-
### Step 1: [Action Name]
|
|
231
|
-
|
|
232
|
-
**File:** `path/to/file.py`
|
|
233
|
-
**Lines:** 100-120
|
|
234
|
-
|
|
235
|
-
**Current:**
|
|
236
|
-
```python
|
|
237
|
-
def existing_function():
|
|
238
|
-
pass
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
**Proposed:**
|
|
242
|
-
```python
|
|
243
|
-
def existing_function(new_param: str = "default"):
|
|
244
|
-
pass
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
**Test:** `pytest tests/test_file.py -k test_name`
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
### Step 2: [Action Name]
|
|
252
|
-
...
|
|
253
|
-
|
|
254
|
-
---
|
|
255
|
-
|
|
256
|
-
## Verification Checklist
|
|
257
|
-
|
|
258
|
-
- [ ] Syntax check passes
|
|
259
|
-
- [ ] Unit tests pass
|
|
260
|
-
- [ ] Integration tests pass
|
|
261
|
-
- [ ] E2E test passes
|
|
262
|
-
|
|
263
|
-
---
|
|
264
|
-
|
|
265
|
-
## Rollback Plan
|
|
266
|
-
|
|
267
|
-
- Revert: `git revert HEAD`
|
|
268
|
-
- Safe commit: `[hash]`
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
## Documentation Updates Required
|
|
273
|
-
|
|
274
|
-
- [ ] Workflow file: [name]
|
|
275
|
-
- [ ] Agent file: [name]
|
|
276
|
-
- [ ] CLAUDE.md section: [name]
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
---
|
|
280
|
-
|
|
281
|
-
## Error Recovery Protocol
|
|
282
|
-
|
|
283
|
-
| Error Type | Response |
|
|
284
|
-
|------------|----------|
|
|
285
|
-
| Syntax Error | STOP. Fix immediately in same session. |
|
|
286
|
-
| Import Error | Check file paths, verify imports. |
|
|
287
|
-
| Runtime Error | Create research subtask before fixing. |
|
|
288
|
-
| Test Failure | Do NOT add more code. Investigate first. |
|
|
289
|
-
| 3+ Failures | STOP. Compact context. Start new session. |
|
|
290
|
-
|
|
291
|
-
---
|
|
292
|
-
|
|
293
|
-
## Context Management
|
|
294
|
-
|
|
295
|
-
### Compaction Triggers
|
|
296
|
-
- After 5+ file reads without tool use
|
|
297
|
-
- Error loop (3+ failed attempts)
|
|
298
|
-
- Session > 1 hour
|
|
299
|
-
- Context > 35% utilization
|
|
300
|
-
|
|
301
|
-
### Compaction Actions
|
|
302
|
-
1. Save progress to SESSION_HANDOFF.md
|
|
303
|
-
2. Archive tool results
|
|
304
|
-
3. Keep only essential context
|
|
305
|
-
4. Continue or start fresh session
|
|
306
|
-
|
|
307
|
-
---
|
|
308
|
-
|
|
309
|
-
## Key Principles
|
|
310
|
-
|
|
311
|
-
1. **<40% Context Rule:** Performance degrades beyond 40% context utilization
|
|
312
|
-
2. **Sub-Agents:** Use parallel Explore agents for context isolation
|
|
313
|
-
3. **On-Demand Loading:** Load information as needed, not upfront
|
|
314
|
-
4. **Mental Alignment:** Plans align human and AI understanding
|
|
315
|
-
5. **Atomic Changes:** Small, testable, reversible modifications
|
|
316
|
-
|
|
317
|
-
---
|
|
318
|
-
|
|
319
|
-
**Version:** 1.1
|
|
320
|
-
**Status:** TEMPLATE
|
|
1
|
+
# RPI (Research, Plan, Implement) Workflow
|
|
2
|
+
|
|
3
|
+
**Created:** {{DATE}}
|
|
4
|
+
**Platform:** Claude Code
|
|
5
|
+
**Context Budget:** 200k tokens max, target <40%
|
|
6
|
+
**Output Budget:** 30k tokens max per response
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Executive Summary
|
|
11
|
+
|
|
12
|
+
The RPI workflow prevents the "slop" and "dumb zone" problems in AI-assisted development. By separating research, planning, and implementation into distinct phases, we achieve:
|
|
13
|
+
|
|
14
|
+
- **90% fewer cascading errors**
|
|
15
|
+
- **3× faster feature implementation**
|
|
16
|
+
- **5× faster issue resolution**
|
|
17
|
+
- **Self-documenting changes**
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Phase 1: RESEARCH
|
|
22
|
+
|
|
23
|
+
### Purpose
|
|
24
|
+
Understand the system, locate relevant components, prevent context pollution
|
|
25
|
+
|
|
26
|
+
### Artifacts
|
|
27
|
+
- Research document in `.claude/research/active/[feature]_research.md`
|
|
28
|
+
- 150-word summary for parent context
|
|
29
|
+
|
|
30
|
+
### Process
|
|
31
|
+
1. Load WORKFLOW_INDEX.md first (saves 100k+ tokens)
|
|
32
|
+
2. Use parallel Explore agents (3 simultaneous)
|
|
33
|
+
3. Trace call chains with line numbers
|
|
34
|
+
4. Map dependencies (internal + external)
|
|
35
|
+
5. Identify test coverage gaps
|
|
36
|
+
6. Document open questions
|
|
37
|
+
|
|
38
|
+
### Context Budget
|
|
39
|
+
- Starting: Up to 50k tokens for exploration
|
|
40
|
+
- Ending: 20k tokens (research doc only)
|
|
41
|
+
- Compaction: After each phase
|
|
42
|
+
|
|
43
|
+
### Exit Criteria
|
|
44
|
+
- [ ] Research document created
|
|
45
|
+
- [ ] 3-20 relevant files identified
|
|
46
|
+
- [ ] Call chains traced with line numbers
|
|
47
|
+
- [ ] Dependencies mapped
|
|
48
|
+
- [ ] 150-word summary generated
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Phase 2: PLAN
|
|
53
|
+
|
|
54
|
+
### Purpose
|
|
55
|
+
Design implementation with file:line precision, get human alignment
|
|
56
|
+
|
|
57
|
+
### Artifacts
|
|
58
|
+
- Plan document in `.claude/plans/active/[feature]_plan.md`
|
|
59
|
+
- Step-by-step implementation roadmap
|
|
60
|
+
|
|
61
|
+
### Process
|
|
62
|
+
1. Load research document
|
|
63
|
+
2. Reference workflow gotchas
|
|
64
|
+
3. Create modification list with exact line numbers
|
|
65
|
+
4. Plan testing strategy
|
|
66
|
+
5. Estimate context budget per step
|
|
67
|
+
6. Define rollback plan
|
|
68
|
+
|
|
69
|
+
### Context Budget
|
|
70
|
+
- Research doc: 20k tokens
|
|
71
|
+
- Plan creation: 15k tokens
|
|
72
|
+
- Total: 35k tokens (17.5%)
|
|
73
|
+
|
|
74
|
+
### Exit Criteria
|
|
75
|
+
- [ ] Plan document created with file:line references
|
|
76
|
+
- [ ] All modifications listed with risk level
|
|
77
|
+
- [ ] Test strategy defined
|
|
78
|
+
- [ ] Rollback plan documented
|
|
79
|
+
- [ ] Human review completed
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Phase 3: IMPLEMENT
|
|
84
|
+
|
|
85
|
+
### Purpose
|
|
86
|
+
Execute atomically with continuous testing
|
|
87
|
+
|
|
88
|
+
### Golden Rule
|
|
89
|
+
```
|
|
90
|
+
ONE CHANGE → ONE TEST → ONE COMMIT
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Process
|
|
94
|
+
1. Load plan and affected workflow sections
|
|
95
|
+
2. Make single, atomic change
|
|
96
|
+
3. Run affected tests immediately
|
|
97
|
+
4. Commit if tests pass
|
|
98
|
+
5. Update documentation
|
|
99
|
+
6. Repeat until plan complete
|
|
100
|
+
|
|
101
|
+
### Context Budget
|
|
102
|
+
- Plan: 15k tokens
|
|
103
|
+
- Active code: 30k tokens
|
|
104
|
+
- Test results: 15k tokens
|
|
105
|
+
- Total: 60k tokens (30%)
|
|
106
|
+
|
|
107
|
+
### Context Reset (Every 3 Steps)
|
|
108
|
+
1. Update progress checklist
|
|
109
|
+
2. Re-read plan document
|
|
110
|
+
3. Verify scope alignment
|
|
111
|
+
4. Compact if >35% utilization
|
|
112
|
+
|
|
113
|
+
### Exit Criteria
|
|
114
|
+
- [ ] All plan steps completed
|
|
115
|
+
- [ ] All tests passing
|
|
116
|
+
- [ ] Documentation updated
|
|
117
|
+
- [ ] Changes committed
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Template Files
|
|
122
|
+
|
|
123
|
+
### RESEARCH_TEMPLATE.md
|
|
124
|
+
|
|
125
|
+
```markdown
|
|
126
|
+
# Research: [Feature/Bug Name]
|
|
127
|
+
|
|
128
|
+
**Date:** YYYY-MM-DD
|
|
129
|
+
**Researcher:** Claude Code
|
|
130
|
+
**Status:** IN_PROGRESS | COMPLETE | BLOCKED
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Objective
|
|
135
|
+
[Clear statement of what we're trying to understand]
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Relevant Files Explored
|
|
140
|
+
|
|
141
|
+
| File | Lines | Key Findings |
|
|
142
|
+
|------|-------|--------------|
|
|
143
|
+
| `path/to/file.py` | 100-200 | Entry point for [feature] |
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Code Flow Analysis
|
|
148
|
+
|
|
149
|
+
[Entry Point] → [Function A] → [Function B] → [Exit Point]
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
entry_function() [file.py:100]
|
|
153
|
+
├─ helper_a() [file.py:150]
|
|
154
|
+
│ └─ utility() [utils.py:50]
|
|
155
|
+
└─ helper_b() [file.py:200]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Dependencies Identified
|
|
161
|
+
|
|
162
|
+
**External:**
|
|
163
|
+
- API Name (purpose)
|
|
164
|
+
|
|
165
|
+
**Internal:**
|
|
166
|
+
- service_file.py (purpose)
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Test Files & Coverage
|
|
171
|
+
|
|
172
|
+
**Existing:**
|
|
173
|
+
- tests/test_feature.py - Covers main flow
|
|
174
|
+
|
|
175
|
+
**Gaps:**
|
|
176
|
+
- ❌ No test for error scenario
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Open Questions
|
|
181
|
+
|
|
182
|
+
- [ ] Question 1
|
|
183
|
+
- [ ] Question 2
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Summary (for Plan Phase, 150 words max)
|
|
188
|
+
|
|
189
|
+
[Concise summary for parent context]
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
### PLAN_TEMPLATE.md
|
|
195
|
+
|
|
196
|
+
```markdown
|
|
197
|
+
# Implementation Plan: [Feature/Fix Name]
|
|
198
|
+
|
|
199
|
+
**Date:** YYYY-MM-DD
|
|
200
|
+
**Based on:** research/active/[feature]_research.md
|
|
201
|
+
**Status:** DRAFT | APPROVED | IMPLEMENTING | COMPLETE
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Research Summary
|
|
206
|
+
[From Phase 1 - max 200 words]
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Scope Definition
|
|
211
|
+
|
|
212
|
+
**In Scope:**
|
|
213
|
+
- [Explicit list]
|
|
214
|
+
|
|
215
|
+
**Out of Scope:**
|
|
216
|
+
- [What we're NOT touching]
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Files to Modify
|
|
221
|
+
|
|
222
|
+
| File | Lines | Change | Risk |
|
|
223
|
+
|------|-------|--------|------|
|
|
224
|
+
| `path/file.py` | 100-150 | Add parameter | LOW |
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Step-by-Step Implementation
|
|
229
|
+
|
|
230
|
+
### Step 1: [Action Name]
|
|
231
|
+
|
|
232
|
+
**File:** `path/to/file.py`
|
|
233
|
+
**Lines:** 100-120
|
|
234
|
+
|
|
235
|
+
**Current:**
|
|
236
|
+
```python
|
|
237
|
+
def existing_function():
|
|
238
|
+
pass
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Proposed:**
|
|
242
|
+
```python
|
|
243
|
+
def existing_function(new_param: str = "default"):
|
|
244
|
+
pass
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Test:** `pytest tests/test_file.py -k test_name`
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
### Step 2: [Action Name]
|
|
252
|
+
...
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Verification Checklist
|
|
257
|
+
|
|
258
|
+
- [ ] Syntax check passes
|
|
259
|
+
- [ ] Unit tests pass
|
|
260
|
+
- [ ] Integration tests pass
|
|
261
|
+
- [ ] E2E test passes
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Rollback Plan
|
|
266
|
+
|
|
267
|
+
- Revert: `git revert HEAD`
|
|
268
|
+
- Safe commit: `[hash]`
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Documentation Updates Required
|
|
273
|
+
|
|
274
|
+
- [ ] Workflow file: [name]
|
|
275
|
+
- [ ] Agent file: [name]
|
|
276
|
+
- [ ] CLAUDE.md section: [name]
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Error Recovery Protocol
|
|
282
|
+
|
|
283
|
+
| Error Type | Response |
|
|
284
|
+
|------------|----------|
|
|
285
|
+
| Syntax Error | STOP. Fix immediately in same session. |
|
|
286
|
+
| Import Error | Check file paths, verify imports. |
|
|
287
|
+
| Runtime Error | Create research subtask before fixing. |
|
|
288
|
+
| Test Failure | Do NOT add more code. Investigate first. |
|
|
289
|
+
| 3+ Failures | STOP. Compact context. Start new session. |
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Context Management
|
|
294
|
+
|
|
295
|
+
### Compaction Triggers
|
|
296
|
+
- After 5+ file reads without tool use
|
|
297
|
+
- Error loop (3+ failed attempts)
|
|
298
|
+
- Session > 1 hour
|
|
299
|
+
- Context > 35% utilization
|
|
300
|
+
|
|
301
|
+
### Compaction Actions
|
|
302
|
+
1. Save progress to SESSION_HANDOFF.md
|
|
303
|
+
2. Archive tool results
|
|
304
|
+
3. Keep only essential context
|
|
305
|
+
4. Continue or start fresh session
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Key Principles
|
|
310
|
+
|
|
311
|
+
1. **<40% Context Rule:** Performance degrades beyond 40% context utilization
|
|
312
|
+
2. **Sub-Agents:** Use parallel Explore agents for context isolation
|
|
313
|
+
3. **On-Demand Loading:** Load information as needed, not upfront
|
|
314
|
+
4. **Mental Alignment:** Plans align human and AI understanding
|
|
315
|
+
5. **Atomic Changes:** Small, testable, reversible modifications
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
**Version:** 1.1
|
|
320
|
+
**Status:** TEMPLATE
|