// 84 tips tagged "bash"
When you're building automation around Claude Code, pass --output-format json to get machine-readable output instead of plain text — every message, tool call, and result comes back as structured JSON that your scripts can parse, filter, and act on programmatically.
The -p (print) flag runs Claude Code as a one-shot command — ask a question, get an answer, and return to your shell. Perfect for quick lookups, scripting, piping output, and integrating Claude into shell workflows without starting a full interactive session.
String together multiple claude -p calls with && to build automated multi-step workflows — lint the code, then run the tests, then generate a changelog, then create the PR — each step running only if the previous one succeeds.
Describe the command-line tool you need — what flags it takes, what it does, what it outputs — and Claude builds the whole thing: argument parsing, help text, validation, error handling, and the core logic, ready to use or distribute to your team.
Tell Claude about a manual task you do repeatedly — deploying, backing up a database, cleaning up old files, syncing environments — and it writes a shell script that automates the whole workflow, with proper error handling, logging, and safety checks built in.
Prefix any shell command with ! in a Claude Code session to run it directly — the output appears in the conversation, giving Claude immediate context without you switching to another terminal or asking Claude to run it for you.
Add --output-format json to get Claude Code's response as structured JSON instead of plain text — perfect for shell scripts, CI pipelines, and automation workflows that need to parse, filter, or chain Claude's output programmatically.
Pipe any file, log, diff, or command output straight into Claude Code using standard Unix pipes — Claude reads the piped content as context alongside your prompt, no copy-pasting needed.
Tell Claude to read your project's tools and create a Makefile with discoverable targets for every common workflow — setup, dev, test, lint, build, deploy, and database tasks — giving your team one consistent interface regardless of the underlying toolchain.
Instead of Googling shell syntax, describe what you want — "find all files modified this week over 1MB" — and Claude writes the command, tests it on your system, explains what each flag does, and iterates until it works.
Describe your schedule in plain English — "every weekday at 9am" or "first Monday of each month at midnight" — and Claude writes the cron expression, explains each field, and lists the next few fire times so you can verify it before deploying.
A PostToolUse hook fires after every tool execution — use it to write an audit log of every command Claude runs, every file it edits, and every search it performs, giving your team full visibility into what happened during a session.