[BUG] /goal stop hook enters infinite loop when goal references unregistered skills
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When /goal is set with instructions that reference specific slash commands/skills (e.g., /ck:plan, /ck:cook, /ck:team, etc.), the stop hook evaluates whether those tools were invoked during the session. If the referenced skills are not registered in the current session's available-skills list (e.g., they come from a plugin or custom skill that isn't loaded), the stop hook can never be satisfied — it fires repeatedly in an infinite loop after every agent response.
The loop continues until:
- The context window is exhausted (token waste)
- The user manually presses Ctrl+C
Each iteration of the stop hook consumes tokens evaluating the same unsatisfiable conditions, and the agent cannot break out of the loop programmatically. Even after the user confirms the work is complete ("All PRs merged"), the hook keeps firing.
What Should Happen?
The /goal stop hook should:
- Detect unregistered skills — If the goal references slash commands that aren't in the session's available-skills list, the hook should skip those conditions (or warn once and mark them as N/A)
- Respect user confirmation — If the user explicitly confirms the goal is met, the hook should stop firing
- Have a max-retry limit — After N consecutive unsatisfied evaluations with no progress, the hook should surface a clear message and stop looping
- Allow graceful exit — The agent should be able to call something like
/goal clearor/goal doneto terminate the loop (related: #58334)
Steps to Reproduce
- Set a
/goalthat includes references to multiple custom/plugin skills:
````
/goal Fix bugs #1-#6.
- Complete all the substantive work (fix bugs, merge PRs, etc.)
- When the agent attempts to finish, the stop hook fires and checks whether
/ck:plan,/ck:cook,/ck:teametc. were invoked via the Skill tool - Since these skills aren't registered in the available-skills list, the conditions can never be met
- The stop hook fires again after the agent's response, creating an infinite loop
- The agent repeatedly explains it cannot invoke those skills, but the hook keeps firing
- Loop continues until context exhaustion or manual Ctrl+C
Error Messages/Logs
No error — the hook silently re-evaluates and re-injects its "conditions not met" feedback after every response. The agent sees repeated system-reminder messages listing the unsatisfied skill invocations.
Claude Model
Opus 4.6
Is this a regression?
Not sure — /goal is a relatively new feature
Last Working Version
_No response_
Claude Code Version
2.1.139
Platform
Anthropic API (Claude Max)
Operating System
macOS (Darwin 25.3.0)
Terminal/Shell
zsh
Additional Information
- Related issue: #58334 (
/goal clearnot working) - The infinite loop wastes significant tokens — in my case, ~30+ loop iterations before I could Ctrl+C
- The agent correctly identifies the problem and asks the user to Ctrl+C, but the hook overrides this and forces another evaluation cycle
- Workaround: Press Ctrl+C manually when you see the loop starting
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗