Skip to content

feat: support Claude Code 'auto' permission mode#879

Merged
tiann merged 1 commit into
mainfrom
feat/claude-auto-mode
Jun 11, 2026
Merged

feat: support Claude Code 'auto' permission mode#879
tiann merged 1 commit into
mainfrom
feat/claude-auto-mode

Conversation

@tiann

@tiann tiann commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Closes #858

What

Adds Claude Code's auto mode (--permission-mode auto) as a first-class HAPI permission mode for claude-flavored sessions. Auto mode runs without routine permission prompts while a classifier blocks anything irreversible, destructive, or aimed outside the environment — a safer alternative to Yolo (bypassPermissions).

How

auto differs from acceptEdits/bypassPermissions in one important way: those are emulated by HAPI inside its canCallTool handler, while auto (like plan) is enforced inside Claude itself by the classifier. That drives the two non-mechanical changes:

  • shared/src/modes.ts — add auto to CLAUDE_PERMISSION_MODES and PERMISSION_MODES (label Auto, tone warning). CLI flag parsing, hub validation, runner spawn args, and the web mode dropdown all derive from these lists, so they pick it up automatically.
  • cli/src/claude/runClaude.ts — the message-queue batch hash previously only tracked isPlan. It now treats auto the same way, so switching to/from auto mid-session starts a new Claude process with the matching --permission-mode flag (otherwise the switch would silently not take effect until the next respawn).
  • cli/src/claude/utils/permissionHandler.ts — allow auto as a plan-exit target mode, matching Claude Code's own "Approve and start in auto mode" plan-approval option.
  • web/src/api/client.ts — extend the approvePermission mode union.

Permission escalations in auto mode (classifier blocks, explicit ask rules) still arrive through the existing --permission-prompt-tool stdiocanCallTool path and surface in the web UI as normal — no local auto-approval is added for auto, since Claude's classifier is the decision-maker.

Notes

  • Requires Claude Code ≥ 2.1.83 and an auto-mode-eligible account; on older binaries claude rejects the flag at spawn and the error surfaces in the session, same as any unsupported flag.
  • auto stays claude-only: codex/gemini/cursor/kimi/opencode keep their own mode lists and validation rejects it for them (covered by the new shared test).
  • dontAsk mode is intentionally out of scope.

Testing

  • bun typecheck — clean (cli/web/hub)
  • bun run test — cli, hub, web, shared all pass (one pre-existing apiMachine.test.ts failure on macOS, reproduces on clean main, unrelated)
  • New test: shared/src/modes.test.ts (auto is claude-only + label/tone)

Add 'auto' as a first-class HAPI permission mode for claude-flavored sessions,
enforced by Claude's classifier rather than emulated in canCallTool. Includes
mode configuration, CLI respawn on auto transitions, plan-exit targeting, API
extensions, and documentation updates.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying hapi with  Cloudflare Pages  Cloudflare Pages

Latest commit: b64905b
Status: ✅  Deploy successful!
Preview URL: https://b2f4dfd4.hapi-bqd.pages.dev
Branch Preview URL: https://feat-claude-auto-mode.hapi-bqd.pages.dev

View logs

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • No high-confidence findings on the added/modified lines.

Summary
Review mode: initial
No correctness, security, regression, data-loss, performance, or maintainability issues found in the reviewed diff. Residual risk: I did not execute the suite; the most relevant remaining gap is no direct test for the Claude plan-exit fake restart targeting auto.

Testing

  • Not run (automation review only)

HAPI Bot

@tiann tiann merged commit 93d0041 into main Jun 11, 2026
4 checks passed
@tiann tiann deleted the feat/claude-auto-mode branch June 11, 2026 03:43
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.

Support 'Auto Mode' in claude code

1 participant