@@ -25,6 +25,50 @@ Before writing any code:
25253 . ** Understand context** - Read relevant existing code
26264 . ** Note constraints** - Testing requirements, style guidelines, dependencies
2727
28+ #### Context Gathering Strategy
29+
30+ ** File priority order** - Read files in this sequence:
31+
32+ | Priority | What to Read | Why |
33+ | ----------| --------------| -----|
34+ | 1st | Files in task's ` **Files:** ` field | Direct targets of the change |
35+ | 2nd | Test files for target functionality | Understand expected behavior and edge cases |
36+ | 3rd | Types/interfaces used by targets | Know the data shapes you're working with |
37+ | 4th | Direct imports of target files | Understand dependencies and patterns |
38+ | 5th | Config files (tsconfig, package.json) | Only if relevant to the task |
39+
40+ ** File budget by task complexity:**
41+
42+ | Task Size | Max Files | Examples |
43+ | -----------| -----------| ----------|
44+ | Small | 3-5 files | Fix a bug, add a field, update a string |
45+ | Medium | 8-10 files | Add a feature, refactor a module |
46+ | Large | 15 files | New subsystem, cross-cutting change |
47+
48+ If you need more context than this, you're likely scope-creeping. Stop and re-evaluate.
49+
50+ ** Discovery commands** to find related code:
51+
52+ ``` bash
53+ # Find files that import the target
54+ grep -r " import.*from.*target" src/
55+
56+ # Find test files
57+ find . -name " *target*test*" -o -name " *target*spec*"
58+
59+ # Find type definitions
60+ grep -r " interface Target\|type Target" src/
61+ ```
62+
63+ ** When to stop exploring and start coding:**
64+
65+ You have enough context when you understand:
66+ 1 . The task goal and acceptance criteria
67+ 2 . Existing patterns in the codebase (naming, structure, error handling)
68+ 3 . Exactly where changes need to be made
69+
70+ Don't read the entire codebase. If you're reading files "just in case," stop and start coding.
71+
2872### Phase 2: Plan
2973
3074Break the task into concrete steps:
0 commit comments