Claude Code cheatsheet

Claude Code: Sessions and flags

9 common Claude Code tasks.

Run one prompt and exit

Print mode runs the prompt, prints the answer and exits, which suits scripts.

claude -p "summarize this repository"

Pipe content in

Send a file or command output to Claude as context.

cat error.log | claude -p "explain this error"

Continue the last session

Pick up the most recent conversation in this directory.

claude -c

Resume an earlier session

Choose from earlier sessions, or pass a session ID.

claude --resume

Choose a model

Start with a specific model, by alias or full name.

claude --model sonnet

Start in plan mode

Plan mode lets Claude read and plan without making changes.

claude --permission-mode plan

Give access to another folder

Let Claude work with files outside the current directory.

claude --add-dir ../shared-lib

Get machine-readable output

Return the result as JSON so scripts can parse it.

claude -p "list the TODOs" --output-format json

Add to the system prompt

Add instructions for this run while keeping Claude Code's defaults.

claude --append-system-prompt "Always write tests for new code"

Was this page helpful?