Skip to content
This repository was archived by the owner on Apr 11, 2026. It is now read-only.

Commit 99a0ca8

Browse files
z23ccclaude
andcommitted
feat(worker+plan): add Phase 1.5 Investigation and investigation targets template
Add Phase 1.5 to worker.md between Re-anchor and TDD/Implement phases. Worker reads Required investigation target files before coding, greps for similar functionality, then proceeds. Skips gracefully when no targets. Update plan skill task spec template with ## Investigation targets section (Required/Optional structure). Add good/bad examples to examples.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0bf4ae4 commit 99a0ca8

3 files changed

Lines changed: 87 additions & 0 deletions

File tree

agents/worker.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,40 @@ git diff --stat HEAD 2>/dev/null || true
219219
Save `GIT_BASELINE_REV` — you'll use it in Phase 5 to generate workspace change evidence.
220220
<!-- /section:core -->
221221

222+
<!-- section:core -->
223+
## Phase 1.5: Pre-implementation Investigation
224+
225+
**If the task spec contains `## Investigation targets` with content, execute this phase. Otherwise skip to Phase 2a/2.**
226+
227+
1. **Read every Required file** listed before writing any code. Note:
228+
- Patterns to follow (function signatures, naming conventions, structure)
229+
- Constraints discovered (validation rules, type contracts, env requirements)
230+
- Anything surprising that might affect your approach
231+
232+
2. **Similar functionality search** — before writing new code:
233+
```bash
234+
# Search for functions/modules that do similar things
235+
# Use terms from the task description + acceptance criteria
236+
grep -r "<key domain term>" --include="*.rs" --include="*.ts" --include="*.py" -l src/
237+
```
238+
If similar functionality exists, pick one:
239+
- **Reuse**: Use the existing code directly
240+
- **Extend**: Modify existing code to support the new case
241+
- **New**: Create new code (justify why existing isn't suitable)
242+
243+
Report what you found:
244+
```
245+
Investigation results:
246+
- Found: `existingHelper()` in src/utils.ts:23 — reusing
247+
- Found: `src/routes/api.ts:45` — following this pattern
248+
- No existing implementation found — creating new
249+
```
250+
251+
3. Read **Optional** files as needed based on Step 1 findings.
252+
253+
4. Continue to Phase 2a/2 only after investigation is complete.
254+
<!-- /section:core -->
255+
222256
<!-- section:tdd -->
223257
## Phase 2a: TDD Red-Green (if TDD_MODE=true)
224258

skills/flow-code-plan/examples.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,43 @@ flowchart LR
332332

333333
---
334334

335+
## Good vs Bad: Investigation Targets
336+
337+
### ✅ GOOD: Specific paths with purpose
338+
339+
```markdown
340+
## Investigation targets
341+
**Required** (read before coding):
342+
- `flowctl/crates/flowctl-cli/src/commands/task/mod.rs:170-177` — existing task spec template to extend
343+
- `flowctl/crates/flowctl-cli/src/commands/task/query.rs:15-82``--desc`/`--accept` pattern to follow
344+
345+
**Optional** (reference as needed):
346+
- `flowctl/crates/flowctl-core/src/types.rs:305-325` — phase registry structure
347+
```
348+
349+
**Why it works**: Exact paths with line ranges. Clear Required vs Optional. Brief purpose descriptions. Worker reads these before coding, grounding implementation in real patterns.
350+
351+
### ❌ BAD: Vague or overloaded targets
352+
353+
```markdown
354+
## Investigation targets
355+
- `src/` — look at the source code
356+
- `tests/` — check the tests
357+
- `lib/utils.ts` — might be useful
358+
- `src/auth/oauth.ts`
359+
- `src/auth/session.ts`
360+
- `src/auth/middleware.ts`
361+
- `src/auth/types.ts`
362+
- `src/auth/index.ts`
363+
- `src/auth/helpers.ts`
364+
- `src/auth/validators.ts`
365+
- `src/auth/errors.ts`
366+
```
367+
368+
**Why it's bad**: No Required/Optional labels. Vague descriptions ("might be useful"). Directory-level paths waste context. Too many targets (11) — worker reads everything and remembers nothing. Max 5-7 targets per task.
369+
370+
---
371+
335372
## Summary
336373

337374
| Include in specs | Don't include |
@@ -342,3 +379,4 @@ flowchart LR
342379
| Recent/surprising APIs | Obvious patterns |
343380
| Non-obvious gotchas | Every function body |
344381
| Acceptance criteria | Redundant details |
382+
| Investigation targets (Required/Optional) | Vague directory paths |

skills/flow-code-plan/steps.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,14 @@ Default to standard unless complexity demands more or less.
282282
- Follow pattern at `src/example.ts:42`
283283
- Reuse `existingHelper()` from `lib/utils.ts`
284284
285+
## Investigation targets
286+
**Required** (read before coding):
287+
- `src/auth/oauth.ts` — existing OAuth flow to extend
288+
- `src/middleware/session.ts:23-45` — session validation pattern
289+
290+
**Optional** (reference as needed):
291+
- `src/auth/*.test.ts` — existing test patterns
292+
285293
## Key context
286294
[Only for recent API changes, surprising patterns, or non-obvious gotchas]
287295
[If stack config exists, include relevant framework conventions here]
@@ -291,6 +299,13 @@ Default to standard unless complexity demands more or less.
291299
- [ ] Criterion 2
292300
```
293301
302+
**Investigation targets rules:**
303+
- Max 5-7 targets per task — enough to ground the worker, not so many it wastes context
304+
- Use exact file paths with optional line ranges (e.g., `src/auth.ts:23-45`)
305+
- **Required** = must read before implementing. **Optional** = helpful reference
306+
- Auto-populated from repo-scout/context-scout findings in Step 1 research
307+
- If no relevant files found by scouts, leave the section empty (worker skips Phase 1.5)
308+
294309
**Layer field**: If stack config is set, tag each task with its primary layer. This helps the worker select the right guard commands (e.g., `pytest` for backend, `pnpm test` for frontend). Full-stack tasks run all guards.
295310
296311
7. Add task dependencies (if not already set via `--deps`):

0 commit comments

Comments
 (0)