Skip to content

Mode-aware Claude Code gate: skip diff + review when in auto-accept mode #79

@Cannon07

Description

@Cannon07

Summary

Make the Claude Code integration permission-mode aware: when Claude Code is in auto-accept mode (permission_mode = acceptEdits or bypassPermissions), skip both the diff preview and the review gate, since there is no real accept/reject moment to line the preview up with.

Follow-up to #74.

Background

Claude Code's PreToolUse hook payload includes a permission_mode field (values: default, plan, acceptEdits, auto, dontAsk, bypassPermissions). The plugin already receives this — the claudecode normaliser (lua/code-preview/pre_tool/normalisers.lua) is essentially identity, so raw.permission_mode is available in pre_tool.handle().

Today, diff.defer_claude_permissions = true only suppresses the forced permissionDecision: "ask" JSON (lua/code-preview/pre_tool/emitters.lua). It does not stop the diff from opening — diff.show_diff() is an unconditional side effect in present_single_file() (lua/code-preview/pre_tool/init.lua). It's also global, not mode-aware.

Proposal

  • Read permission_mode from the Claude Code hook payload and thread it through normalise()handle().
  • When the mode is auto-accept (acceptEdits / bypassPermissions), skip both:
    1. the diff side effect (show_diff), and
    2. the permission emit (already effectively a no-op in those modes, but make intent explicit).
  • Gate the behaviour behind an opt-in config flag (e.g. diff.skip_in_auto_accept) so existing behaviour is preserved by default. Final flag name TBD.
  • Claude Code only — other backends own their own gate (per ADR-0002).

Open questions

  • Flag name + default (skip_in_auto_accept? default off?).
  • Which modes count as "auto-accept" — just acceptEdits/bypassPermissions, or also auto/dontAsk?
  • Should the changes registry / neo-tree decoration still update when the diff is skipped, or stay fully silent?
  • Worth an ADR, given it interacts with the ADR-0002 force-gate decision.

Acceptance

  • With the flag enabled and Claude Code in auto-accept mode, no diff opens and no gate prompt fires.
  • With the flag disabled (default), behaviour is unchanged.
  • Normal (default) mode is unaffected regardless of the flag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions