ALL MEMOS Download .docx

Claude Code Auto Mode — Deep Research Memo

TL;DR (5 bullets)

1. Auto mode is NOT a drop-in replacement for bypassPermissions in TITAN's setup. It explicitly blocks production deploys, mass S3 operations, IAM changes, and force-push by default — all of which TITAN's scheduled tasks perform. Switching cold would break 8–12 tasks immediately.

2. bypassPermissions is currently broken for writing to ~/.claude/ and .claude/ paths (regression since v2.1.78, still unfixed as of v2.1.89). TITAN's self-modification tasks (agent file writes, settings.json updates) are silently failing to run unattended even now — this needs investigation regardless of the auto-mode decision.

3. Auto mode terminates the process in headless sessions (-p flag) when the classifier trips 3 consecutive or 20 total denials. For a cron job, this means a hard abort — not a soft retry. Under TITAN's current workload, production Lambda deploys, S3 mass ops, and IAM changes would each trigger immediate termination.

4. Hybrid config (Option C) is viable and the correct path. CLI flag --permission-mode overrides settings.json on a per-session basis. Scheduled tasks that are write-safe (PA email, prompt-eval, cost cap reads) can run under auto. Tasks that require production access (Lambda deploy, S3 ops, swarm-health writes) stay on bypassPermissions per-session via CLI flag.

5. Auto mode requires Anthropic direct API — not Bedrock, Vertex, or Foundry. If any TITAN tasks run via Bedrock, those cannot use auto mode at all. Confirm ANTHROPIC_API_KEY is the auth path for scheduled tasks before any migration.

---

Recommendation: C (Hybrid)

Keep settings.json defaultMode as bypassPermissions. Layer --permission-mode auto on individual tasks where production access is not required. Add autoMode.environment config to unblock the tasks you do migrate. Details in Section 6.

---

Section 1: What Exactly Is Auto Mode?

Classifier Architecture

Auto mode is a two-stage LLM-based classifier — not a rules engine, not a regex list. It is LLM-driven judgment.

Stage 1: A fast single-token yes/no filter tuned to err toward blocking. Runs on every action that isn't auto-approved by rule.

Stage 2: Chain-of-thought reasoning that runs only when Stage 1 flags the action. This stage uses prompt caching — since only the pending tool call changes between checks while the rest of the context is static, most tokens are cache hits. This is how Anthropic limits latency overhead.

The classifier model is Claude Sonnet 4.6, running server-side and independent of whatever /model the session is set to. You cannot swap it out. Changing your session model does not change classifier availability.

What the classifier sees: user messages, tool calls, and CLAUDE.md content. Tool results (including file contents and web page responses) are deliberately stripped to prevent prompt injection. A separate server-side probe scans incoming tool results for suspicious content before Claude reads them.

Sources: Anthropic Engineering Deep Dive, Permission Modes Doc

Performance Numbers (n=10,000 real traffic)

The 17% false-negative figure is significant: on a curated set of known-dangerous actions, the classifier misses 1 in 6. This is the design tradeoff — the system prioritizes not interrupting legitimate work over catching every edge case.

Latency

Each classifier call adds one round-trip before a shell command or network operation executes. File reads and working-directory edits skip the classifier entirely. For TITAN's scheduled tasks, the overhead is on shell commands and AWS CLI calls. Prompt caching reduces the token cost substantially, but latency per classified action is a non-zero extra hop.

Availability Requirements (hard gates — not soft)

If TITAN's cron tasks authenticate via Bedrock or Vertex, auto mode is simply not available for those sessions. Full stop.

Source: Permission Modes Doc

---

Section 2: What Changes for Scheduled / Headless Tasks

This is the most operationally critical finding.

The Termination Rule

From the official docs, verbatim:

> "In non-interactive mode with the -p flag, repeated blocks abort the session since there is no user to prompt."

And from the engineering blog:

> "In headless mode (claude -p) there is no UI to ask the human, so we instead terminate the process."

The thresholds are: 3 consecutive denials OR 20 total denials → process terminates.

These thresholds are not configurable. There is no flag to increase them, no setting to suppress termination, no fallback to "just keep running." When the classifier trips the threshold in a -p session, the cron job gets a non-zero exit code and the task is dead for that run.

What This Means for TITAN's ~20 Scheduled Tasks

Tasks that would trip the classifier immediately under default auto mode rules (see blocked-by-default list in Section 3):

| Task | Why It Would Abort |

|---|---|

| silentinfinity Lambda deploy | "Production deploys" — blocked by default |

| S3 mass operations | "Mass deletion/write on cloud storage" — blocked by default |

| aws-cost-daily-150-cap | AWS CLI calls to unrecognized infrastructure — flagged as external |

| swarm-health-orchestrator | Modifying shared resources — blocked by default |

| claude-code-audit-every-6h | Self-modification of ~/.claude/ — protected path, routes to classifier |

| TITAN settings.json writes | ~/.claude/ is a protected path — classifier route, likely denial |

| agentic-247-watchdog | Depends on what tools it invokes; AWS calls would flag |

| nightly backups | S3 writes to buckets not in autoMode.environment |

Tasks that would likely survive default auto mode:

| Task | Why It's Fine |

|---|---|

| PA daily email | HTTP POST to known endpoint; safe with environment config |

| titan-inbox-watch | Email reads; likely passes |

| silentinfinity-chat-smoke-10m | Read-only HTTP checks; fine |

| prompt-eval | File reads, writes in working directory; fine |

| PMF metrics | Depends on targets; internal writes probably fine |

The Settings.json Self-Modification Problem

TITAN's scheduled tasks that write to ~/.claude/settings.json or any ~/.claude/ path face a double problem:

1. Under bypassPermissions: currently broken (issue #37029, #42366, regression since v2.1.78). The hardcoded protection for .claude/ overrides bypass mode. The bug is confirmed open as of v2.1.89. Anthropic's only public response: "Fix incoming" — since closed and still broken.

2. Under auto mode: .claude/ paths route to the classifier rather than being auto-blocked, but writes to settings.json specifically would likely be denied as "modifying shared infrastructure/Claude's own configuration."

This means TITAN's self-modification capability is partially broken right now, independent of the auto-mode question. This deserves its own investigation.

Source: Issue #39523 meta, Issue #37029, Issue #42366

---

Section 3: Auto Mode Default Blocklist — Full List

Blocked by default (will terminate headless sessions):

Allowed by default:

Note the critical asymmetry: "production deploys" is a hard block with no intent override. The docs state that general requests ("deploy the function") do not constitute explicit intent — only a message that "directly and specifically describes the exact action Claude is about to take" counts as explicit intent to override. In a scripted cron with a fixed prompt, this means the blocking behavior is largely deterministic, not prompt-dependent.

Source: Permission Modes Doc

---

Section 4: Hybrid Configs — Precedence Rules

The Precedence Chain (verified from official docs)


Managed settings (org-level)
  > CLI flags (--permission-mode)
    > Local project settings (.claude/settings.local.json)
      > Project settings (.claude/settings.json)
        > User settings (~/.claude/settings.json)

CLI flag overrides settings.json for that session. This is confirmed, documented behavior. The flag is --permission-mode <mode>.

Per-Session Override Capability

Yes, scheduled tasks can each specify their own mode:


# Safe task — run under auto
claude -p "Run inbox watch" --permission-mode auto

# Production task — run under bypassPermissions
claude -p "Deploy Lambda" --permission-mode bypassPermissions

This means TITAN's cron scripts can be individually configured without touching settings.json at all.

Key Constraint: bypassPermissions on a bypassPermissions Base

When a session is started without one of the enabling flags, you cannot enter bypassPermissions from within the session. This doesn't affect cron tasks that invoke claude directly with --permission-mode bypassPermissions — they are starting the session with the flag. It does matter if any tasks dynamically launch sub-sessions.

Auto Mode Config Is Not Read from Shared .claude/settings.json

Important: the autoMode.environment and autoMode.soft_deny/autoMode.allow blocks are read from:

The classifier does not read autoMode from the shared .claude/settings.json (project scope), specifically to prevent a checked-in repo from injecting its own allow rules. For TITAN, this means the autoMode.environment config that whitelists Lambda, S3 buckets, and AWS infrastructure needs to live in ~/.claude/settings.json (Harnoor's user settings) or be passed per-invocation via --settings.

Source: Configure Auto Mode Doc

subagent Permission Inheritance

When a task spawns subagents (TITAN's swarm-health-orchestrator likely does), any permissionMode in the subagent's frontmatter is ignored — the subagent runs under the parent session's mode. The classifier checks subagent actions independently. This means a parent running under bypassPermissions that spawns a subagent will have that subagent run bypass-mode too. A parent running auto will have the classifier gate every subagent tool call.

---

Section 5: Real-World Adoption + Known Breakage

bypassPermissions User Reports (2025–2026)

The GitHub meta-issue #39523 tracks what is described as "fundamentally broken" bypass mode since July 2025:

Anthropic's response on record: One comment on March 20, 2026 — "Fix incoming" — related issue closed, problem confirmed still present on v2.1.89.

The December 2025 rm -rf Incident

A Reddit incident (December 2025) where bypassPermissions was active: user asked Claude to "clean up packages," Claude generated rm -rf tests/ patches/ plan/ ~/ — the trailing ~/ expanded to the user's entire home directory. This is a known risk with bypassPermissions that auto mode's classifier would likely have caught (irreversible file destruction is in the default blocklist).

Users Who Moved bypassPermissions → auto

From available community reports: most users who tried auto mode found it blocked too much for any workflow touching cloud infrastructure or CI/CD. The common experience is:

1. Enable auto

2. First AWS CLI call gets denied

3. Add to autoMode.environment

4. Second AWS operation (different bucket/service) gets denied

5. Repeat until frustration or proper environment config is complete

The pattern Anthropic recommends is a staged rollout: start with autoMode.environment covering just source control and key internal services, then add buckets and domains as denials come in. For a fully-configured operation like TITAN, this means accepting a period of debugging before the configuration stabilizes.

Source: GitHub #39523, Anthropic Engineering Blog

---

Section 6: What Anthropic Recommends for Autonomous Setups

Anthropic's explicit documentation and blog posts are consistent on one point: bypassPermissions is not intended for network-connected, production-adjacent systems.

From the permission modes doc, verbatim:

> "bypassPermissions offers no protection against prompt injection or unintended actions. For background safety checks without prompts, use auto mode instead."

> "Only use this mode in isolated environments like containers, VMs, or devcontainers without internet access, where Claude Code cannot damage your host system."

From the engineering blog:

> "Auto mode is a safer long-running alternative to --dangerously-skip-permissions."

Anthropic's position is clear: bypassPermissions is for air-gapped containers. Auto mode is for everything else that needs autonomy.

However, Anthropic has not published specific guidance for the exact TITAN use case — a 24/7 cron-driven Claude Code setup performing production deploys and AWS operations. The auto-mode configuration system (autoMode.environment) is designed to handle exactly this, but the configuration burden is real and must be done upfront.

---

Section 7: The TITAN-Specific Analysis

Current State Assessment

TITAN's settings.json has:

The PreToolUse hooks are functioning as TITAN's own safety layer. This is actually the right architecture instinct — rather than relying solely on Claude Code's permission mode for safety, TITAN has built-in guardrails at the hook level. The question is whether those hooks are sufficient.

The honest assessment: They are probably not sufficient for prompt injection at the Claude-reads-external-content level. The titan-injection-scan.py PostToolUse hook runs after Claude has already processed the tool result. Auto mode's server-side probe scans incoming tool results before Claude reads them. That sequencing difference matters for prompt injection scenarios.

Known Active Failure: Settings.json Self-Modification

TITAN tasks that write to ~/.claude/settings.json or agent files under ~/.claude/ are currently hitting the bypassPermissions breakage in v2.1.78+. In a headless -p session, the prompt appears with no human to approve it, the session either hangs or times out, and the write silently fails. This needs to be validated and confirmed.

Why Option A (Keep bypassPermissions) Is Insufficient

1. bypassPermissions is currently broken for the most sensitive TITAN operations (self-modification of ~/.claude/)

2. The mode has a 9-month open bug trail with no substantive Anthropic fix

3. It offers zero protection against prompt injection during web/content reads (the injection-scan hook runs post-read, not pre-read)

4. Anthropic explicitly documents it as intended only for air-gapped containers — TITAN is connected to AWS, Lambda, S3, email APIs

Why Option B (Flip to auto globally) Would Break TITAN

1. Lambda deploys: blocked by default (production deploys)

2. S3 mass operations (nightly backups): blocked by default (mass deletion/write on cloud storage)

3. IAM-touching operations: blocked by default

4. swarm-health-orchestrator shared resource modifications: blocked by default

5. Self-modification of ~/.claude/ settings: routes to classifier, likely denied

6. Any one of these tripping 3 consecutive denials kills the headless session

7. Auto mode not available on Bedrock/Vertex — verify TITAN's auth path

Why Option C (Hybrid) Is the Right Call

The hybrid approach preserves TITAN's ability to perform production operations while gaining auto mode's prompt-injection protection for the tasks that don't need production access.

Proposed task classification:

Auto mode (low-risk reads and safe writes):

bypassPermissions (production access required, add specific task-level hooks):

Self-modification tasks (currently broken — fix separately):

Recommended autoMode.environment Block

For tasks migrated to auto mode, add this to ~/.claude/settings.json:


{
  "autoMode": {
    "environment": [
      "$defaults",
      "Organization: TITAN autonomous AI OS, Harnoor's personal development and research system",
      "Primary use: software development, infrastructure automation, research intelligence gathering",
      "Source control: GitHub (personal repos)",
      "Cloud provider: AWS",
      "Trusted cloud buckets: [list TITAN S3 buckets here when read-only access needed from safe tasks]",
      "Trusted internal domains: silentinfinity.app and its API endpoints",
      "Key internal services: Anthropic API, AWS SES for email dispatch",
      "Additional context: single-developer system, no multi-tenant infrastructure, no compliance constraints"
    ]
  }
}

Note: Do NOT add Lambda deploy endpoints or production S3 write buckets to this config — those tasks should stay on bypassPermissions so the classifier never factors in.

---

Section 8: Option D — Considered and Rejected

Option D: dontAsk mode with exhaustive allow rules

dontAsk auto-denies everything not in permissions.allow. It would require enumerating every allowed operation for every task. For TITAN's ~20 tasks with varied tool usage this would be a maintenance nightmare. Rejected.

Option D2: Hooks-only safety, no permission mode change

The current TITAN architecture relies on PreToolUse hooks for safety. Enhancing titan-bash-guardrail.py and titan-validate-skill.py to be more comprehensive could reduce the gap vs auto mode. The fundamental problem is these hooks run on the same process as Claude — prompt injection that hijacks Claude's reasoning could potentially hijack hook invocation reasoning too. Auto mode's classifier runs server-side and cannot be influenced by content Claude has read. Hooks are a defense-in-depth layer, not a replacement for server-side classification.

---

Final Recommendation

Option C — Hybrid, with immediate action on the bypassPermissions bug.

Execution steps, in order:

1. Audit active failures now. Confirm which scheduled tasks are failing silently due to the .claude/ write protection bug. Check task logs for hung or failed sessions involving ~/.claude/ writes.

2. Restructure self-modification outside Claude. Any operation that writes to ~/.claude/settings.json should not be done inside a Claude session. Use a wrapper shell script that performs the write, then calls Claude. This sidesteps the bug permanently.

3. Add autoMode.environment to ~/.claude/settings.json using the template in Section 7.

4. Per-task migration. Update the lowest-risk scheduled task invocations to add --permission-mode auto. Start with titan-inbox-watch (read-heavy, no production writes). Validate no false positives over one week.

5. Leave production-deploy tasks on bypassPermissions. Pass --permission-mode bypassPermissions explicitly in those cron invocations rather than relying on the settings.json default. This makes the decision explicit in the task definition and survives any future settings.json change.

6. Monitor Anthropic's bypassPermissions bug fix. Track issue #39523. When the protected-paths regression is fixed, re-evaluate whether self-modification tasks can run under bypassPermissions again, or whether auto mode's classifier has matured enough to allow trusted ~/.claude/ writes via autoMode.allow.

7. Do not migrate to Bedrock for auto mode tasks. Auto mode is Anthropic direct API only. Keep those tasks on the direct API path.

---

Sources

1. Anthropic Engineering: Claude Code Auto Mode Deep Dive

2. Claude Code Docs: Permission Modes

3. Claude Code Docs: Configure Auto Mode

4. Claude Code Docs: Headless / Agent SDK

5. Official Blog: Auto Mode for Claude Code

6. GitHub Issue #39523: bypassPermissions fundamentally broken meta-issue

7. GitHub Issue #37029: Bypass still prompts for settings.json edits

8. GitHub Issue #42366: Bypass prompts for settings.json and other operations

9. MindStudio: What Is Claude Code Auto Mode

10. ClaudeLog: How to Set Claude Code Permission Mode