Repository navigation
Claude Code mod: one plan approval when the plugin guard skips the mod's hook (#2007) - #2043
Merged
Merged
Conversation
…d's hook (#2007) On Team/Enterprise accounts Claude Code seats its built-in guard (cc-plugin-sec-default) above the person's plugins and sends classic.PermissionRequest past the mod. The approved second ExitPlanMode then reached the plugin's own PermissionRequest command hook, which opened a second review server, while Claude Code asked in the terminal too. While the approved call is in flight the mod now records the approval in <data dir>/claude-code-mod/<session>/plan-approvals/<tool use id>.json (owner-only folder) and removes it when the call settles. The classic hook takes a fresh record for its session whose plan matches and answers the same allow (approved text, reviewer's mode) without starting a server. Without the guard the mod answers first and nothing else changes.
…from a real folder this user owns (#2007)
azaj01
pushed a commit
to azaj01/plannotator
that referenced
this pull request
Oct 25, 2026
…p#2159) The mod's classic.PermissionRequest hook was registered with no matcher, so under a guard plugin seated above (cc-plugin-sec-default on Team/Enterprise accounts) Claude Code printed "its classic.PermissionRequest hook was skipped" at the first permission prompt of any tool. Register it with the matcher { tool_name: 'ExitPlanMode' }; the plan approval path is unchanged (backnotprop#2043's approval record answers a skip there). Tests: the registration's matcher (bun), and in the engine harness the approved ExitPlanMode prompt answered by the mod with updatedInput.plan and setMode while another tool's prompt goes past it; also updates a stale harness assertion for the Inbox's search action.
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2007
What happened
On Team/Enterprise accounts Claude Code seats its built-in guard
cc-plugin-sec-defaultabove the person's plugins, and the guard sendsclassic.PermissionRequest(andprompt.context) past the mod. The mod'stool.callhook still runs, so the first ExitPlanMode opens the non-blocking review as usual. But the approved second ExitPlanMode is never answered by the mod: the event reaches the plugin's ownPermissionRequestcommand hook (plannotator), which opened a second review server, and Claude Code asked in the terminal as well. The second server was left running.Fix
controller.ts,plan.ts,launch.ts): when an ExitPlanMode call matches the approval and is passed through, the mod also writes{ v: 1, hash, plan, permissionMode?, at }to<data dir>/claude-code-mod/<session>/plan-approvals/<tool use id>.json(folder made owner-only first), and removes it when the call settles. A failed write leaves the call as before.server/mod-plan-approval.ts, wired first in the Claude Code plan path ofindex.ts): for a main-loop ExitPlanModePermissionRequest, it takes a record for thatsession_idwhose hash matches the requested plan (the fix(hook): review Claude's plan file, not its stale inline snapshot #1667 plan-file rule, or the inline plan) and whose own plan text hashes to that hash, at most 10 minutes old, from a realplan-approvalsfolder (lstat, never a symlink) and a file both owned by the hook's user (whereprocess.getuidexists), deletes it (answers once) and prints the same allow the mod gives (updatedInput.plan= approved text,setModeto the reviewer's mode). No server starts.classic.PermissionRequestfirst, the command hook never runs, and the record is just written and removed: nothing visible changes for anyone else.Tests
hooks/mod/controller.test.ts: the record is written for the approved call (owner-only folder, exact contents) and removed on settle; nothing recorded for another plan; a failed write keeps the call passing.server/mod-plan-approval.test.ts: the mod's names, path and SHA-256 equal the CLI's; allow once with approved text and mode; the plan file beats a stale inline plan; other plan / session / subagent / tool / event / stale record are left to the classic review;..session ids; a malformed record beside a good one; a forged record whose plan does not match its hash; a symlinkedplan-approvalsfolder; and the hook as a process: a recorded approval prints the allow and exits with no server, no record still opens the classic review.tests/register.test.ts(engine harness,claude plugin test): the record exists while the approved call runs beneath the mod and is gone after.Not verified
I could not run a Team/Enterprise Claude Code with the guard seated, so the claim that Claude Code honors the command hook's allow (and dismisses its own dialog) in that setup rests on it being the same classic hook output the non-mod flow already uses. A CLI older than this PR ignores the record, so the double approval stays until the binary is updated. The
prompt.contextskip (only the Inbox reminder line) is unchanged.The uid check is not exercised by a test (making a file owned by another user needs root).
Follow-up
uninstall --purgedoes not removeclaude-code-mod/(it is not inPURGE_OWNED_TOP_LEVELinpackages/server/uninstall.ts), so launch folders and these approval records survive a purge. Not changed here.The engine harness has one failure that is also on
main(the Inbox bundled tool list now includessearch); unrelated.