Claude Code workflow automation: from one prompt to a pipeline
How to automate repeated work with Claude Code, rung by rung: CLAUDE.md, skills, hooks, headless scripts, CI, and multi-step workflows that stop where a person has to decide.
Some work is the same chain every time. Read the issue, write a plan, implement it, run the tests, review the diff, write the changelog line. Or: draft three landing page concepts, let me pick one, build it, let me check it, deploy it. Done in one long conversation, it works, but you have to come back at the right moment, say the same things again, and remember which step you were on.
Automating it with Claude Code isn't one feature. It's a ladder, and each rung adds a bit of structure. Most people stop one rung too low or climb one rung too high.
#What can you automate in Claude Code?
From the lightest to the heaviest:
| Rung | What it automates | Where it lives |
|---|---|---|
CLAUDE.md | Rules every session follows | The project's root |
| Skills and commands | One repeatable task, started by name or picked by Claude | .claude/skills/, .claude/commands/ |
| Hooks | Steps that must run every time, around tools | .claude/settings.json |
| Subagents | Side work in its own context | .claude/agents/ |
| Headless mode | One task from a script, cron or CI | claude -p |
| GitHub Actions | A task on a pull request or an issue | anthropics/claude-code-action |
| Multi-step workflows | A chain of tasks, with points where you decide | A script, or a workflow runner |
The rule for picking: use the lowest rung that removes the repetition. A rule you keep typing belongs in CLAUDE.md. A task you keep describing belongs in a skill. Only a chain of tasks with handoffs needs a workflow.
#When is a skill enough?
When the repeated thing is one task with a known shape: "write the changelog entry", "review this diff against our checklist", "add an endpoint the way we do it". A skill is a SKILL.md file with instructions, and optionally scripts and examples next to it. You start it with /changelog, or Claude loads it when your request matches its description.
A skill also beats a long prompt you paste each time because it can carry its own context. The line starting with !` runs a shell command before Claude reads the skill, so the current diff or the last release tag is already there. The details are in Claude Code skills and slash commands.
Skills stay inside one conversation, though. If step 2 should start fresh, with only what step 1 produced, a skill won't do it.
#When do you need a hook?
When something must happen every time, not when Claude remembers. Formatting a file after each edit, refusing rm -rf outside the project, running the linter before Claude says it's done. Instructions are followed most of the time; a hook is followed all the time, because it's code that runs on an event (PostToolUse, PreToolUse, Stop…) rather than a request to the model.
Hooks are the guardrails of automation. When nobody watches the run, they're what keeps "most of the time" from becoming the one time it mattered. See Claude Code hooks.
#How do you chain steps in a script?
With headless mode. claude -p "…" runs one task without the interface and exits, so a shell script can call it several times in a row:
#!/bin/sh
set -e
claude -p "Read issue.md. Write plan.md: the files to change and the tests to add." \
--allowedTools "Read,Write"
claude -p "Implement plan.md. Run the tests until they pass." \
--allowedTools "Read,Edit,Write,Bash(npm test *)"
claude -p "Compare the diff with plan.md. Write review.md: what is missing or risky." \
--allowedTools "Read,Bash(git diff *)"
Three things make this work:
- Each call starts with a clean context. Step 3 doesn't inherit step 2's 80,000 tokens of trial and error, only what step 2 left on disk.
- Files are the handoff.
plan.mdandreview.mdcarry what one step knows to the next. Write notes, not only results: the next step needs the reasoning too. - Permissions are decided up front. Nobody is there to approve, so each call lists the tools it may use.
--output-format jsongives you the session id and a cost estimate if you want to log them.
The same calls run in cron or in CI. On GitHub, anthropics/claude-code-action runs Claude Code on a pull request or an issue when someone mentions @claude, with the pull request itself as the review point. Headless mode covers the flags.
#Where does a person fit in an automated workflow?
This is where scripts get awkward. Most real chains have a point where someone has to look: pick one of three concepts, approve a plan before it touches forty files, check a render before it ships. A script has no good place to stop. You can split it in two and run the second half by hand, or let it open a pull request and treat the review as the stop. Both work. Neither shows you the three concepts side by side and sends the one you picked to the next step.
What a workflow with people in it needs:
- Review steps. The run stops, shows what the previous steps produced (pictures, a plan, a diff), and waits.
- Actions on a review. Approve, pick one candidate, or send it back with a comment.
- Loops with a limit. "Send back to the build step" is a loop. Cap it at three or four, or a bad brief burns your usage limit overnight.
- Notifications. A run waiting for you should tell you, on your phone if you're away.
- State that survives. A run waiting since yesterday shouldn't die because the laptop restarted.
#What makes a Claude Code workflow reliable?
The same habits, whatever runs it:
- One step, one job. "Research and implement and test" in one prompt is three steps pretending to be one. Split them, and a failure tells you where.
- Say what each step must leave. "Write
plan.md" can be checked. "Make a plan" can't. A step that ends without its file has failed, even if its last message sounds happy. - Commands for what must not vary. Deploying, installing, uploading: a shell line, not a prompt. A model doesn't need to decide how to run
npm run deploy. - Run independent steps in parallel. Three concepts from three sessions at once take the time of one. Keep steps that share a desktop app or a dev server in sequence.
- Keep project knowledge in a skill. If every step needs "how we name components", put it in a skill the steps use. It then serves your interactive sessions too.
- Know what a run costs. Add up the tokens of every step and every retry. The tenth run of a workflow is when an expensive step shows up.
#Which approach should you pick?
| Situation | Reach for |
|---|---|
| You keep typing the same rule | CLAUDE.md |
| You keep describing the same task | A skill |
| Something must happen after every edit | A hook |
| A task should run at 8 a.m. or on every push | Headless mode in cron or CI |
| A chain of tasks, no one needs to look | A shell script calling claude -p |
| A chain of tasks, with points where you decide | A workflow with review steps |
#In Relais
Relais runs workflows written as a YAML file in your project's .relais/workflows/. The file says the form that starts a run, its steps and where you decide:
name: Landing page
inputs:
brief: longtext
steps:
concepts:
prompt: Three concepts for "{{inputs.brief}}", one folder each, with a screenshot.
outputs: { shots: "*/shot.png" }
choose:
panels:
- { type: gallery, items: "{{steps.concepts.outputs.shots}}" }
actions: [pick, comment, stop]
on:
comment: { goto: concepts, max: 3 }
build:
prompt: Build the concept in {{steps.choose.picked.dir}}.
deploy:
run: npm run deploy
Steps are Claude sessions (up to 8 at once with parallel), shell commands, forms, and reviews where you approve, pick or send the run back with a comment; needs and when decide the order and what to skip. Each agent step gets a clean session with its own model, effort and permissions, and the outputs it must leave. Reviews show galleries with a crisp zoom, Markdown, checklists, the files a step changed and command logs. A run that waits for you turns orange in the sidebar and notifies you; its page adds up what every step cost at API prices. To write one, click Create a workflow, say what it should run, and Claude writes the file with you and checks it. More on the workflows page and all features.