From 95a141f79104a350f09ce0fc1ba5dac015e3be16 Mon Sep 17 00:00:00 2001 From: Clawd Date: Sat, 28 Feb 2026 07:53:12 -0800 Subject: Fix: system prompt passing and strengthen phase enforcement - Fix systemPrompt option (was incorrectly using extraArgs) - Rewrite research phase prompt: - Emphasize writing to research.md as PRIMARY output - Explicitly forbid asking about phase transitions - Add document format template - Clarify that chat is for questions only - Rewrite plan phase prompt: - Same emphasis on plan.md as primary output - Include code snippet format examples - Forbid implementation attempts - Change research/plan permissionMode to acceptEdits (was 'plan') - 'plan' mode may have been blocking file writes --- src/main/claude/phases.ts | 148 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 104 insertions(+), 44 deletions(-) (limited to 'src/main/claude/phases.ts') diff --git a/src/main/claude/phases.ts b/src/main/claude/phases.ts index d503f3a..2ea1ea8 100644 --- a/src/main/claude/phases.ts +++ b/src/main/claude/phases.ts @@ -12,53 +12,107 @@ export interface PhaseConfig { export const phaseConfigs: Record = { research: { - permissionMode: "plan", + permissionMode: "acceptEdits", tools: ["Read", "Glob", "Grep", "Bash", "Write"], initialMessage: "What areas of the codebase should I research? What are you trying to build?", - systemPrompt: `You are in RESEARCH mode. + systemPrompt: `You are in RESEARCH mode. Your ONLY job is to understand the codebase. -Your job is to deeply understand the codebase before any changes are made. +CRITICAL RULES: +1. You MUST write ALL findings to .claude-flow/research.md — this is your PRIMARY output +2. DO NOT just respond in chat. The document viewer shows research.md, so write there. +3. DO NOT suggest moving to planning or implementation +4. DO NOT ask "are you ready to implement?" or similar +5. DO NOT modify any source code files +6. The user controls phase transitions via UI buttons — never prompt them about it -When the user tells you what to research: -1. Read files thoroughly — understand all intricacies -2. Write your findings to .claude-flow/research.md -3. Format it as clear, readable markdown +WORKFLOW: +1. Ask what to research (if unclear) +2. Read files thoroughly using Read, Glob, Grep +3. Write structured findings to .claude-flow/research.md +4. Keep updating research.md as you learn more -Rules: -- DO NOT make any code changes -- DO NOT modify any files except .claude-flow/research.md -- Be thorough — surface-level reading is not acceptable +FORMAT for research.md: +\`\`\`markdown +# Research Findings -When the user clicks "Review", read .claude-flow/research.md for their annotations and update accordingly. -When the user clicks "Submit", they're ready to move to planning.`, - }, +## Overview +[High-level summary of what you found] - plan: { - permissionMode: "plan", - tools: ["Read", "Glob", "Grep", "Write"], - initialMessage: - "I'll create a detailed implementation plan based on my research. Give me a moment...", - systemPrompt: `You are in PLANNING mode. +## Architecture +[Key components, patterns, structure] -Based on the research in .claude-flow/research.md, write a detailed implementation plan. +## Relevant Files +[List of important files with descriptions] -Write the plan to .claude-flow/plan.md with: -- Detailed explanation of the approach -- Specific code snippets showing proposed changes -- File paths that will be modified -- Trade-offs and considerations -- A granular TODO list with checkboxes +## Key Insights +[Important discoveries, patterns, potential issues] -Rules: -- DO NOT implement anything -- DO NOT modify any source files -- Only write to .claude-flow/plan.md +## Questions/Unknowns +[Things that need clarification] +\`\`\` -The plan should be detailed enough that implementation becomes mechanical. +When the user adds annotations (// REVIEW:, // NOTE:, TODO:) to research.md and clicks Review, address each annotation and update the document. -When the user clicks "Review", read .claude-flow/plan.md for their annotations and update accordingly. -When the user clicks "Submit", begin implementation.`, +Remember: Your output goes in research.md, not chat. Chat is for clarifying questions only.`, + }, + + plan: { + permissionMode: "acceptEdits", + tools: ["Read", "Glob", "Grep", "Write"], + initialMessage: + "I'll create a detailed implementation plan based on my research. Writing to plan.md...", + systemPrompt: `You are in PLANNING mode. Your ONLY job is to create an implementation plan. + +CRITICAL RULES: +1. You MUST write the plan to .claude-flow/plan.md — this is your PRIMARY output +2. DO NOT just respond in chat. The document viewer shows plan.md, so write there. +3. DO NOT implement anything — no code changes to source files +4. DO NOT ask "should I start implementing?" or similar +5. The user controls phase transitions via UI buttons — never prompt them about it +6. Base your plan on .claude-flow/research.md + +WORKFLOW: +1. Read .claude-flow/research.md to understand the codebase +2. Write a detailed plan to .claude-flow/plan.md +3. Include specific code snippets showing proposed changes +4. Make the plan detailed enough that implementation is mechanical + +FORMAT for plan.md: +\`\`\`markdown +# Implementation Plan + +## Goal +[What we're building/changing] + +## Approach +[High-level strategy] + +## Changes + +### 1. [First change] +**File:** path/to/file.ts +**What:** [Description] +**Code:** +\\\`\\\`\\\`typescript +// Proposed code +\\\`\\\`\\\` + +### 2. [Second change] +... + +## TODO +- [ ] Task 1 +- [ ] Task 2 +- [ ] Task 3 + +## Risks/Considerations +[Potential issues, edge cases] +\`\`\` + +When the user adds annotations to plan.md and clicks Review, address each annotation and update the document. + +Remember: Your output goes in plan.md, not chat. Chat is for clarifying questions only.`, }, implement: { @@ -66,16 +120,22 @@ When the user clicks "Submit", begin implementation.`, tools: ["Read", "Write", "Edit", "Bash", "Glob", "Grep"], initialMessage: "Starting implementation. I'll follow the plan exactly and mark tasks complete as I go.", - systemPrompt: `You are in IMPLEMENTATION mode. The plan has been approved. - -Read .claude-flow/plan.md and execute it: -- Follow the plan exactly -- Mark tasks complete (- [x]) as you finish them -- Run typecheck/lint continuously if available -- Do not add unnecessary comments -- Do not stop until all tasks are complete - -If you encounter issues not covered by the plan, stop and ask.`, + systemPrompt: `You are in IMPLEMENTATION mode. Execute the approved plan. + +CRITICAL RULES: +1. Read .claude-flow/plan.md and follow it exactly +2. Mark tasks complete in plan.md as you finish them: - [ ] → - [x] +3. DO NOT deviate from the plan without asking +4. Run tests/typecheck if available +5. Stop and ask if you encounter issues not covered by the plan + +WORKFLOW: +1. Read .claude-flow/plan.md +2. Execute each task in order +3. Update plan.md to mark tasks complete +4. Continue until all tasks are done + +If something in the plan is unclear or problematic, ask before proceeding.`, }, }; -- cgit v1.2.3