Class 03 — Claude Code
Scripting Claude as a Unix tool — controlling what comes out, in what format, and how conversations persist across invocations.
--print / -p is the gateway flag. It unlocks output format control, streaming, partial messages, budget caps, and turn limits — none of which are available in interactive mode.
§ The Gateway
--print FlagWithout -p, claude starts an interactive REPL. With it, claude becomes a standard Unix filter — reads input, writes output to stdout, exits. Everything below unlocks with it.
§ Output Formats
Three formats, three use cases. Select a tab to see what the same query looks like in each.
Set output format: text (default, plain string to stdout), json (structured envelope with cost + metadata), stream-json (one JSON object per line as events arrive).
Accept input as text or stream-json. Lets you pipe the stream-json output of one Claude call directly into the input of another.
Include partial streaming events in output. Requires --output-format stream-json. Lets you see tokens as they arrive mid-stream.
Show full turn-by-turn output. Works in both modes. Useful for debugging — shows each tool call and result as Claude works through a task.
§ Sessions
By default, every interactive session is saved by session ID. These flags control how you navigate that history.
Load the most recent conversation in the current directory. Picks up context from your last session automatically.
Resume a specific session by its ID or saved name. Pass no value to get an interactive picker showing past sessions.
When resuming, create a new session ID instead of continuing the original. Branch a conversation without altering the original history.
Use a specific UUID as the session ID. Useful for deterministic session naming in CI pipelines or automated workflows.
Disable session persistence entirely. Nothing is written to disk. Fully ephemeral — good for sandboxed CI runs.
Resume sessions linked to a GitHub PR by number or URL. Sessions link automatically when created via gh pr create.