Chain Multiple Claude Code Commands with && for Multi-Step Automated Workflows
A single claude -p call does one thing well. Chain them together and you get an automated pipeline where each step builds on the last.
claude -p "fix all linting errors" && \
claude -p "run the tests and fix any failures" && \
claude -p "write a commit message and commit the changes"
Each command runs only if the previous one succeeds — if linting fails to fix cleanly, the tests don't run. If tests still fail, no commit happens. It's a safety chain.
Build multi-step workflows for common tasks:
# Full feature pipeline
claude -p "create the migration and model for a tags system" && \
claude -p "add the controller and routes following the users pattern" && \
claude -p "write tests for the new endpoints" && \
claude -p "run the tests and fix any failures"
# Release preparation
claude -p "run the full test suite and fix failures" && \
claude -p "update the version number to 2.4.0" && \
claude -p "generate a changelog since the last tag" && \
claude -p "commit everything with a release message"
# Code cleanup
claude -p "fix all linting errors" && \
claude -p "remove unused imports across the project" && \
claude -p "run tests to make sure nothing broke" && \
claude -p "commit with message 'chore: code cleanup'"
Combine with other flags for more control:
# Use different models for different steps
claude --model haiku -p "find all deprecated function calls" && \
claude --model opus -p "replace them with the modern equivalents" && \
claude --model haiku -p "run tests to verify"
# Add JSON output for the final step
claude -p "fix the bug in the auth module" && \
claude -p "run tests" && \
claude -p "summarize what changed" --output-format json
Save your most-used chains as shell aliases or scripts:
# In your .zshrc or .bashrc
alias claude-release='claude -p "run tests" && claude -p "generate changelog" && claude -p "bump version and commit"'
One command is a task. A chain of commands is a workflow — && turns Claude Code into a pipeline that does the whole job.
via Claude Code
Log in to leave a comment.
When typing feels slow — describing a complex bug, explaining architecture, or thinking through a problem out loud — press Option+V to switch to voice input. Speak naturally and Claude Code transcribes your words into a prompt, so you can describe what you need at the speed of thought.
When Claude is heading down the wrong path — editing the wrong file, writing code you don't want, or giving a long explanation you don't need — press Escape to stop it immediately. You keep everything it did up to that point and can redirect with a new prompt.
Closed a session and realized you weren't done? Pass --continue (or -c) when launching Claude Code to pick up exactly where you left off — same context, same files, same conversation history — without re-explaining what you were working on.