Recipes / Dev & code
Claude CodeWorkflowDev & code

Treat the workflow, not the agent, as the product

Replies describe running Claude Code headless with claude -p from scripts and cron, wrapped in a simple state machine: task record, bounded run, artifacts, checks, human approval.

Setup time30 min
CostIncluded in plan
RunsPer automated task
NeedsClaude Code (claude -p), scripts or CI
Last updated2026-10-15
RedditSource

How do you automate your workflow with claude code?

by r/ClaudeCode commenters · not retrieved

✓ Reddit blocks our fetcher (login wall). Thread content confirmed via a search-engine snapshot on 2026-10-15; the username wasn't in that snapshot.

Read the original ↗
Part 1 · What the source did

Replies describe running Claude Code headless with claude -p from scripts and cron, wrapped in a simple state machine: task record, bounded run, artifacts, checks, human approval.

  • One commenter runs several headless instances in tmux and chains tasks with a bash script.
  • Another suggests layering: CLAUDE.md rules, then a few skills, then a typecheck hook.
  • Another lays out a safe automation shape that ends in human approval before merge.

Summary written by Agent Cookbook. See the original for the full context.

Part 2 · Our copy-paste version

Adapted by us from what the source described. Fill in the [BRACKETS].

The prompt

claude -p with this prompt, from a script: Task: [TASK RECORD: repo, path, objective, constraints]. Work only in [PATH]. When done, write handoff.md: files changed, assumptions, tests run, open questions. Do not commit. (The script then runs [CHECKS] outside the agent and only notifies me if they pass.)
🛡
Approval rulePlans and merges are approved by a human; the script never auto-merges.

Set it up

  1. Write a task file per job.
  2. Run claude -p with --allowedTools limited to what the task needs.
  3. Run checks outside the agent.
  4. Review handoff.md and approve the merge.

Common failures

⚠
What usually goes wrong
  • Automating plan approval too early.
  • No artifact means you can't tell the run happened; always write handoff.md.

Variations

  • Same pattern with codex exec.

Related recipes