Skip to content

Claude Code automation means letting Claude Code work with no human at the prompt: /goal, claude -p in scripts and CI, hooks, background sessions, dynamic workflows, cloud routines and the Claude Agent SDK. Each unattended run is only as safe as its permissions, and only as trustworthy as the machine check that decides whether its output merges.

This hub helps developers and tech leads pick a surface for each job Claude Code could finish alone, from a 200-file migration to a nightly dependency report, and check the result without reading every diff.

Which Claude Code surface should run your job?

Section titled “Which Claude Code surface should run your job?”

Choose by trigger and location: a job needing your local database runs on your machine; one that runs while your laptop sleeps goes to CI or a routine.

Your jobSurfaceTriggerRead
Keep working until a check passes/goal with a verifiable conditionYou, onceGoal workflows
A script or CI step your code checksclaude -p --output-format jsonScript or cronScripting Claude Code
A rule that must hold on every tool callHooks in .claude/settings.jsonLifecycle eventHooks
A team procedure anyone can runA skill, optionally in a plugin/name or Claude’s choiceCustom commands and skills
A scoped specialistA subagent in .claude/agents/DelegationCustom subagents
Several local tasks at onceclaude --bg, watched in claude agentsYouAgent view
Dozens to hundreds of agentsA dynamic workflow, or /effort ultracodeYou, or Claude’s planDynamic workflows
Runs while your machine is offA routine (/schedule, research preview)Clock, HTTP call or GitHub eventRoutines
Pull request review and fixesanthropics/claude-code-action@v1Workflow eventGitHub Actions
Your own program drives the agent loopThe Claude Agent SDKYour codeAgent SDK
Steer a session from your phoneRemote Control and channelsYou, or an eventChannels and Remote Control
Effort, MCP servers, worktreesSession configurationSetupAdvanced techniques

For the other tools, see the Codex and Cursor automation hubs and background and cloud agents compared.

In what order should you automate Claude Code?

Section titled “In what order should you automate Claude Code?”

Each step reuses what the previous one proved.

  1. Run the task interactively until it succeeds twice, and note the command that proves it, such as npm test: that is your gate or /goal condition.

  2. Run it headless with the narrowest permissions, a spending cap and JSON output. claude -p starts in Manual permission mode (auto mode on third-party providers or with telemetry off, from v2.1.285), and dontAsk denies every tool call that would prompt (reads in the working directories and read-only commands still run), so you list the commands the job needs:

    Terminal window
    claude -p "Triage the failing tests in ci.log. Do not edit test files." \
    --permission-mode dontAsk \
    --allowedTools "Read" "Grep" "Glob" "Bash(npm test *)" \
    --output-format json --max-budget-usd 2.00 > triage.json
    jq -e '.subtype == "success" and .is_error == false
    and ((.permission_denials // []) | length == 0)' triage.json
  3. Add a hook for every rule that must always hold, such as blocking writes to migrations/. Hooks hold even when the model ignores instructions.

  4. Parallelise once one run is reliable: start each task with claude --bg --worktree <name>, one checkout per session.

  5. Schedule it or move it to CI: a routine for cloud runs, claude-code-action for pull request events.

  6. Reach for the Agent SDK last, when claude -p can no longer express the flow; driving agents from code compares the three vendors’ SDKs.

How do you verify unattended Claude Code output without reading every line?

Section titled “How do you verify unattended Claude Code output without reading every line?”

Trust gates, not summaries:

  • A result your script checks. The wrapper fails unless subtype, is_error and permission_denials show a clean run. A /goal “met” verdict is a model’s judgement, not proof.
  • Independent checks. CI reruns tests, type check and lint on the pushed branch; the agent cannot mark its own work green.
  • A second reviewer. /code-review, or claude ultrareview from the shell (review automation).
  • An audit trail. Archive the JSON output with the run.

A human signs off at the merge on that evidence bundle; evidence, not diffs explains the reviewer’s new job.

What breaks when Claude Code runs unattended?

Section titled “What breaks when Claude Code runs unattended?”
SymptomCauseRecovery
A headless run stops earlydontAsk denied a needed toolRead .permission_denials; add one narrow --allowedTools rule
/schedule returns “Unknown command”ANTHROPIC_API_KEY overrides the claude.ai login routines needUnset the key, or use claude.ai/code/routines
A goal reports “met” but CI is redThe evaluator judged the conversationName a command and exit code in the condition; let CI decide
Spend keeps climbingNo cap on a headless runPass --max-budget-usd (-p only); see cost control
A teammate’s run behaves differentlyThey are on a different version or channel (stable is v2.1.287 and latest v2.1.296 on 2026-10-12; v2.1.283 is used here)Compare claude --version; pin one channel
A PR-triggered job leaks a secretThe contributor’s hooks or MCP servers ran with the job’s secretsRun with --bare --setting-sources "" --strict-mcp-config; check out the contributor’s commit into a separate directory the agent only reads, with trusted scripts from the default branch; see agent identity and secrets

Where to go next with Claude Code automation

Section titled “Where to go next with Claude Code automation”