diff --git a/.claude/templates/coding_prompt.template.md b/.claude/templates/coding_prompt.template.md index 823d2972..83646e08 100644 --- a/.claude/templates/coding_prompt.template.md +++ b/.claude/templates/coding_prompt.template.md @@ -101,6 +101,33 @@ Get the next feature to implement: Use the feature_get_next tool ``` +**IMPORTANT - PROJECT COMPLETION:** If `feature_get_next` returns: +```json +{"error": "All features are passing! No more work to do."} +``` + +This means **the project is complete!** Take these final steps: + +1. **Write final summary** to `claude-progress.txt`: + - Note that all features are implemented + - List any remaining recommendations + - Include final completion statistics + +2. **Perform one final verification** (optional): + - Test 2-3 core features to ensure app is stable + - Check for console errors + - Verify app is production-ready + +3. **Commit final state**: + ```bash + git add -A + git commit -m "chore: All features complete - project production-ready" + ``` + +4. **End session gracefully** - Do NOT continue with more regression tests. The agent loop will automatically stop when it detects completion. + +--- + Once you've retrieved the feature, **immediately mark it as in-progress**: ``` diff --git a/agent.py b/agent.py index 50edc46d..cadcf7b7 100644 --- a/agent.py +++ b/agent.py @@ -23,7 +23,7 @@ sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace") from client import create_client -from progress import has_features, print_progress_summary, print_session_header +from progress import has_features, is_project_complete, print_progress_summary, print_session_header from prompts import ( copy_spec_to_project, get_coding_prompt, @@ -198,6 +198,16 @@ async def run_autonomous_agent( # Handle status if status == "continue": + # Check if project is complete (all features passing) + if is_project_complete(project_dir): + print("\n" + "=" * 70) + print(" ALL FEATURES COMPLETE!") + print("=" * 70) + print("\nAll features have been implemented and verified.") + print("Project is production-ready!") + print("\nThe agent will now stop to avoid unnecessary token usage.") + break # Exit the loop - project is complete + delay_seconds = AUTO_CONTINUE_DELAY_SECONDS target_time_str = None diff --git a/progress.py b/progress.py index dfb700b4..654ef843 100644 --- a/progress.py +++ b/progress.py @@ -89,6 +89,25 @@ def count_passing_tests(project_dir: Path) -> tuple[int, int, int]: return 0, 0, 0 +def is_project_complete(project_dir: Path) -> bool: + """ + Check if all features are passing (project is complete). + + Args: + project_dir: Directory containing the project + + Returns: + True if all features are passing, False otherwise + """ + passing, in_progress, total = count_passing_tests(project_dir) + + # Project is complete if: + # 1. There are features (total > 0) + # 2. All features are passing (passing == total) + # 3. No features are in progress + return total > 0 and passing == total and in_progress == 0 + + def get_all_passing_features(project_dir: Path) -> list[dict]: """ Get all passing features for webhook notifications.