Slide 8 / 55
Slide 8

Transcript

Claude Code has a headless mode that lets you automate tasks from the command line.

Here are the current command-line patterns:

Run claude by itself for an interactive session.

Run claude followed by a prompt in quotes for a one-off interactive request.

Use claude -p for print mode when you want a non-interactive answer from a script. Combine it with claude -c -p to continue the most recent conversation in print mode.

You can also pipe input: "cat pgexplain.log | claude -p 'What are our slowest queries? Why?'" - this feeds log files or other data directly into Claude for analysis.

For background sessions and monitoring, use claude agents. Headless mode is powerful for automation and batch processing, but keep the command shape explicit so scripts are predictable.