Unverified 提交 20938765 authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

Add stop hook to prevent early stopping with incomplete tasks (#2325)

## Summary - Add a Stop hook that checks for incomplete tasks before allowing Claude to stop - The hook blocks stopping if any tasks are in pending or in_progress status - Includes comprehensive tests for the hook behavior ## Test plan - Run the test suite: python3 .claude/hooks/tests/test_stop_hook.py - Verify all tests pass (no tasks allows stop, completed tasks allow stop, pending/in_progress tasks block stop) #skip-bugbot Generated with Claude Code <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a Stop hook to prevent early stopping when work isn’t done. Uses a stricter, prompt-based check of the conversation context with a default bias to continue. - **New Features** - Stop hook returns {"ok": true} to allow stop or {"ok": false, "reason": "..."} to continue. - Evaluates task completion, unresolved errors, follow-ups, and work quality. - Biases to continue unless everything is truly complete; registered under Stop in .claude/settings.json with a 30s timeout. <sup>Written for commit 059862cf76e0df9dd9149df2c8acd840c06dbc15. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by: 's avatarClaude Opus 4.5 <noreply@anthropic.com>
上级 01acdbf2
...@@ -147,6 +147,17 @@ ...@@ -147,6 +147,17 @@
} }
] ]
} }
],
"Stop": [
{
"hooks": [
{
"type": "prompt",
"prompt": "You are evaluating whether Claude should stop working. Your default bias should be to CONTINUE WORKING (ok: false). Only allow stopping when absolutely certain all work is complete.\n\nContext: $ARGUMENTS\n\nAnalyze the conversation and determine:\n\n1. TASK COMPLETION CHECK\n - Has EVERY task the user requested been fully completed?\n - Not just acknowledged, but actually done with verifiable output?\n - Are there any implied subtasks that haven't been addressed?\n\n2. ERROR CHECK\n - Did any errors occur that weren't resolved?\n - Are there failed operations that need retry?\n - Did Claude say it would do something but didn't actually do it?\n\n3. FOLLOW-UP CHECK\n - Is there obvious next-step work that should be done?\n - Did the user's request imply multiple steps where only some were completed?\n - Would a thorough assistant do more here?\n\n4. QUALITY CHECK\n - Was the work done to completion, not just partially?\n - Are there placeholders, TODOs, or incomplete sections?\n - Did Claude stop prematurely mid-task?\n\nDECISION RULES:\n- If ANY task is incomplete → continue (ok: false)\n- If ANY error is unresolved → continue (ok: false)\n- If there's reasonable follow-up work → continue (ok: false)\n- If Claude said \"I'll do X\" but didn't → continue (ok: false)\n- If work quality is partial/rushed → continue (ok: false)\n- ONLY return ok: true if ALL tasks are genuinely, fully complete AND no errors exist AND no reasonable follow-up remains\n\nRespond with JSON:\n- {\"ok\": false, \"reason\": \"specific explanation of what still needs to be done\"} — DEFAULT, use this unless everything is truly complete\n- {\"ok\": true} — ONLY when absolutely certain all work is finished and nothing remains",
"timeout": 30
}
]
}
] ]
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论