Skip to content

feat(hooks): loop/goal instruction-review hook - #16

Merged
sneg55 merged 4 commits into
mainfrom
sneg55/loop-goal-review-hook
Jul 1, 2026
Merged

sneg55 merged 4 commits into
mainfrom
sneg55/loop-goal-review-hook

Conversation

@sneg55

@sneg55 sneg55 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

What

Adds a new UserPromptSubmit hook, hooks/suggest-loop-improvements.sh. When the user runs /loop or /goal, it injects an instruction so Claude:

  1. Proposes 2-3 improved, drop-in replacements for the command (adding the missing precision — explicit success criteria, a stop condition, bounded scope, a verification step — while preserving the interval and args).
  2. Presents them via the AskUserQuestion tool as an interactive picker: A / B / C plus "Run original unchanged".
  3. Runs only the option the user selects — no copy-paste.
┌─ Improve loop? ─────────────────────────────┐
│ ○ A — Tighter stop condition                │
│ ○ B — Explicit success criteria             │
│ ○ C — Bounded scope + verification          │
│ ○ Run original unchanged                    │
└─────────────────────────────────────────────┘

How

  • The hook does no LLM work and spawns no nested session — it only injects context, so the already-running model generates the variants. Fast (<50ms), needs no API key.
  • UserPromptSubmit has no matcher, so it filters by prompt text (/loop* / /goal*) and is a silent no-op for every other prompt.
  • Non-blocking (exit 0): if the command is already precise, or the session is headless (no interactive prompt), the original runs unchanged.

Wiring

  • hooks/hooks.json — plugin manifest (${CLAUDE_PLUGIN_ROOT}).
  • install.sh — jq-merge into ~/.claude/settings.json (idempotent).
  • hooks/README.md — documented under Available Hooks.

Test

printf '{"prompt":"/loop 5m /foo"}' | ./hooks/suggest-loop-improvements.sh   # injects review block
printf '{"prompt":"hello"}'         | ./hooks/suggest-loop-improvements.sh   # empty, exit 0 (no-op)
jq -e . hooks/hooks.json && bash -n install.sh                                # both valid

Already wired into this machine's global ~/.claude/settings.json for dogfooding.

Notes

  • No version bump included — this repo bumps VERSION + plugin manifests in a dedicated release PR, so I left that for the release step.
  • /goal isn't a command shipped by this repo, but the hook matches its text harmlessly if you have one defined elsewhere.

🤖 Generated with Claude Code

sneg55 and others added 4 commits July 1, 2026 17:09
New UserPromptSubmit hook suggest-loop-improvements.sh. When the user runs
/loop or /goal, it injects an instruction so Claude proposes 2-3 improved,
drop-in replacements for the command and presents them via AskUserQuestion
(A/B/C plus "Run original unchanged") - the user picks one, no copy-paste,
and only the selected command runs.

The hook does no LLM work and spawns no nested session: it only injects
context, so the running model generates the variants. Fast, no API key,
non-blocking (exit 0) - a silent no-op for every other prompt, for already-
precise commands, and in headless sessions.

Wired into hooks.json (plugin) and install.sh (jq-merge), documented in
hooks/README.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The suggest-loop-improvements README claimed the interactive picker works
for both /loop and /goal. It does not: /goal is a client-side local command
whose effect runs at submit time, before Claude's turn, so an advisory
(exit 0) injection cannot intercept it. Document the model-driven vs
client-side distinction so the behavior is not misrepresented.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add suggest-loop-improvements.sh to the hook lists in AGENT.md,
skills/new-project/SKILL.md, and the README wiring summary, and to the
manual settings.json example in TEAM.md. Bump VERSION and both plugin
manifests 0.4.3 -> 0.4.4 for the new hook.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
/goal is a client-side local command whose effect runs at submit time,
before Claude's turn, so an advisory injection can't gate it (as observed
in practice). Drop /goal from the matcher, rename the injected tag to
<loop-review>, and align statusMessages and docs to /loop only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sneg55
sneg55 marked this pull request as ready for review July 1, 2026 21:42
@sneg55
sneg55 merged commit 866593c into main Jul 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant