Skip to content

Commit 819734e

Browse files
committed
docs(agents): add context gathering strategy to builder
Signed-off-by: leocavalcante <leo@cavalcante.dev>
1 parent 620d984 commit 819734e

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

agents/opencoder-builder.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,50 @@ Before writing any code:
2525
3. **Understand context** - Read relevant existing code
2626
4. **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

3074
Break the task into concrete steps:

0 commit comments

Comments
 (0)