Skip to content

feat: add crit plan-hook for Claude Code PermissionRequest integration#214

Merged
tomasz-tomczyk merged 2 commits intomainfrom
feat/plan-hook-binary
Mar 28, 2026
Merged

feat: add crit plan-hook for Claude Code PermissionRequest integration#214
tomasz-tomczyk merged 2 commits intomainfrom
feat/plan-hook-binary

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

@tomasz-tomczyk tomasz-tomczyk commented Mar 28, 2026

What changed

Adds a crit plan-hook subcommand designed to be used as a Claude Code PermissionRequest hook for ExitPlanMode. When Claude tries to exit plan mode, the hook intercepts it, opens a crit review session for the plan content, and blocks the exit until the user approves or adds comments.

  • New crit plan-hook subcommand reads the PermissionRequest event JSON from stdin
  • Extracts the plan content from tool_input.plan, saves it via the existing plan versioning system
  • Starts a crit daemon (reusing the crit plan flow) and opens the browser for review
  • Blocks until the user finishes reviewing, then outputs hookSpecificOutput JSON (allow/deny) to stdout
  • All error paths fail-open (allow through) so hook failures never block the agent
  • Updates the Claude Code plugin hooks/hooks.json to use crit plan-hook instead of the previous shell script (plan-review.sh), removing the $CLAUDE_PLUGIN_ROOT path dependency

Why

The previous shell script approach (plan-review.sh) relied on $CLAUDE_PLUGIN_ROOT being set by the plugin system, which was unreliable. Using the binary directly is simpler, has no path dependency, and gets native Go JSON parsing instead of jq.

Testing

# Build
go build -o crit .

# Simulate a hook event
echo '{"tool_input":{"plan":"# My Plan\n\nDo the thing."}}' | ./crit plan-hook

Entering plan mode in Claude Code and exiting should now trigger a crit review session.

@tomasz-tomczyk tomasz-tomczyk merged commit d26e444 into main Mar 28, 2026
2 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the feat/plan-hook-binary branch March 28, 2026 09:39
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