All articles

Useful CLI Flags You Might Have Missed

Across this series we have met the main command-line flags one at a time. Here they are together, as a quick reference for the ones that quietly earn their keep.

Session and mode flags

  • -p "prompt" runs headless: print the answer and exit. The door to scripting.
  • -c continues the latest session in the project.
  • -r <id> "prompt" resumes a specific session by ID.
  • --permission-mode <default|acceptEdits|plan|bypassPermissions> sets how much Claude asks before acting.

Scope and model flags

  • --add-dir <path> gives Claude access to folders outside the current project.
  • --model chooses the model for the run.
claude --model sonnet --add-dir ../shared-lib

Output and prompt flags

  • --output-format <text|json|stream-json> controls how results print: readable text, structured JSON, or a stream of events.
  • --append-system-prompt "..." adds standing instructions on top of the defaults.
git diff | claude -p "write a commit message" --output-format json

The one to handle with care

  • --dangerously-skip-permissions removes prompts entirely. The name is the warning; keep it to throwaway sandboxes.

Putting it together

The real power comes from combining them. Pipe data in, run headless, ask for JSON, and set a standing rule, all in one line. Once these become muscle memory, Claude Code stops being just an interactive chat and becomes a tool you can wire into everything from a one-liner to a full CI pipeline.

Comments

Be the first to comment.