When running in --auto or headless mode, the discuss step could loop indefinitely — each pass reads its own CONTEXT.md, finds "gaps" in referenced types/interfaces, creates new decisions to fill them, and repeats. Observed: 34 passes, 167 decisions, 7 hours, zero code written. Fixes: - Add max_discuss_passes config (default: 3) to WorkflowConfig - Add single-pass guard instruction to SDK self-discuss prompt - Add pass cap documentation to CLI discuss-phase workflow - Add pass guard step to SDK headless discuss-phase prompt - Add stall detection note to autonomous workflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4.4 KiB
4.4 KiB
Extract implementation decisions that downstream agents need. Analyze the phase to identify gray areas and capture decisions that guide research and planning.
Headless SDK variant — in autonomous mode, AI self-discusses by analyzing available context and making decisions based on project artifacts and codebase patterns.
<downstream_awareness> CONTEXT.md feeds into:
-
Researcher — Reads CONTEXT.md to know WHAT to research
- Locked decisions guide research focus
- Discretion areas get options explored
-
Planner — Reads CONTEXT.md to know WHAT decisions are locked
- Locked decisions become non-negotiable plan constraints
- Discretion areas allow planner flexibility </downstream_awareness>
<scope_guardrail> The phase boundary comes from the roadmap and is FIXED. Discussion clarifies HOW to implement what's scoped, never WHETHER to add new capabilities.
When analysis suggests scope creep: note it in "Deferred Ideas" section, do not act on it. </scope_guardrail>
Load phase context from injected context files. Extract: phase directory, phase number, phase name, has_research, has_context, has_plans.If phase not found: report error via event stream.
If CONTEXT.md already exists: load it and use as-is (in headless mode, existing context is not re-discussed). If no CONTEXT.md: proceed to analysis. Read project-level and prior phase context: - PROJECT.md — vision, principles, non-negotiables - REQUIREMENTS.md — acceptance criteria, constraints - STATE.md — current progress, decisions - Prior CONTEXT.md files — locked preferences from earlier phases Analyze the phase to identify gray areas:- Domain boundary — What capability is this phase delivering?
- Check prior decisions — What's already decided from earlier phases?
- Gray areas by category — For each relevant category, identify 1-2 specific ambiguities
- Auto-resolve each gray area — Make decisions based on:
- Codebase patterns (existing conventions)
- Prior phase decisions (consistency)
- Requirements (constraints)
- Best practices (industry standard)
- Log each decision with rationale
Self-referential gap-finding creates an infinite loop where:
- Pass N creates decisions referencing types/interfaces
- Pass N+1 "discovers" those references as "gaps"
- Pass N+1 creates new decisions that reference more types
- Repeat forever
Write your decisions once, comprehensively, then stop.
Create CONTEXT.md capturing decisions made:# Phase [X]: [Name] - Context
**Gathered:** [date]
**Status:** Ready for planning
**Source:** AI self-discuss (headless mode)
## Phase Boundary
[Clear statement of what this phase delivers]
## Implementation Decisions
### [Category]
- **D-01:** [Decision] — Rationale: [why]
### AI Discretion
[Areas where AI had flexibility and chose approach]
## Existing Code Insights
### Reusable Assets
- [Component/hook/utility]: [How it could be used]
### Established Patterns
- [Pattern]: [How it constrains/enables this phase]
## Specific Ideas
[Any particular approaches derived from codebase analysis]
## Deferred Ideas
[Ideas that came up but belong in other phases]
<success_criteria>
- Phase validated against roadmap
- Prior context loaded and honored
- Gray areas identified and resolved autonomously
- CONTEXT.md captures actual decisions with rationale
- Scope maintained (no creep into deferred ideas) </success_criteria>