claude-code - 💡(How to fix) Fix [BUG] /goal stop hook enters infinite loop when goal references unregistered skills

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

  1. 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)

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.

Fix Action

Fix / Workaround

  • Related issue: #58334 (/goal clear not 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

Code Example

/goal Fix bugs #1-#6.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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:

  1. 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)
  2. Respect user confirmation — If the user explicitly confirms the goal is met, the hook should stop firing
  3. Have a max-retry limit — After N consecutive unsatisfied evaluations with no progress, the hook should surface a clear message and stop looping
  4. Allow graceful exit — The agent should be able to call something like /goal clear or /goal done to terminate the loop (related: #58334)

Steps to Reproduce

  1. Set a /goal that includes references to multiple custom/plugin skills:
    /goal Fix bugs #1-#6.
  2. Complete all the substantive work (fix bugs, merge PRs, etc.)
  3. When the agent attempts to finish, the stop hook fires and checks whether /ck:plan, /ck:cook, /ck:team etc. were invoked via the Skill tool
  4. Since these skills aren't registered in the available-skills list, the conditions can never be met
  5. The stop hook fires again after the agent's response, creating an infinite loop
  6. The agent repeatedly explains it cannot invoke those skills, but the hook keeps firing
  7. 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 clear not 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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING