Claude Code runs in two very different ways from the command line. Knowing which one you want saves you time and makes automation possible.
Interactive mode
Run claude on its own to start an interactive session. Claude stays open, reads your prompts, and keeps context between turns. You can mention files with @path, run shell commands with !, and cycle permission modes with Shift+Tab. This is the mode you want for real work: exploring a codebase, iterating on a change, and reviewing results as you go.
You can also pass a first prompt directly and still stay interactive:
claude
claude "explain the auth flow in this repo"
Headless mode
Add -p and Claude runs once, prints the answer, and exits. Nothing stays open. This is the mode for scripts, one-off questions, and anything you want to feed into another program.
claude -p "list the exported functions in lib/auth.js"
Because it prints and exits, -p composes well with the rest of your shell. You can redirect its output to a file, pass it through a pipe, or run it inside a larger script without a human sitting there.
Which one to pick
Use plain claude when you are the one steering and want a back-and-forth. Use claude -p when you want a single result with no session to manage, especially in automation. The rest of this series builds on -p, since it is the door to piping, output formats, and running Claude Code in CI.
Comments
Be the first to comment.