Skip to content
BENIBIX Learn

Claude Code Run Modes

Level 5 · Growing past one chat

How to run Claude Code with no chat in a script or in the background. How to run it in the cloud, from your phone, or in its own copy.

Course contentsLesson 16 of 16

After this lesson you can

  • Run one prompt with -p in a script
  • Say what bare mode leaves out
  • Choose a cloud session, Remote Control or a worktree for a job

11 mincovers 6 glossary entries

Worth reading first: Claude Code Subagents

How to run Claude Code without a chat

Non-interactive mode runs Claude Code on one prompt and then exits. You start it with -p, short for --print. The answer goes to the screen or into another program, as plain text, JSON or a stream of JSON lines. A run with -p starts in Manual mode, so it denies anything that needs a yes unless a rule allows it.

Bare mode, the --bare flag, starts with none of your extras. It skips hooks, skills, plugins, MCP servers, auto memory and CLAUDE.md. Nothing from the machine is loaded, so a run gives the same result on every computer. It needs an API key, since it does not read your plan sign-in. The docs say it will become the default for -p.

A background session is a full Claude Code chat with no terminal attached. You can close the terminal and the work goes on. Run claude agents to see them all, which ones are working, which need you and which are done. You can attach to one, reply, and leave again.

A cloud session runs on Anthropic's servers, not on your computer. So it keeps going with your laptop shut. You start one on the web or with claude --cloud. It starts from a fresh copy of your repo, so it cannot see files that live only on your machine.

Remote Control is the other way round. The session keeps running on your own computer, with your files and tools. You drive it from the web or the Claude phone app. Use it to answer a question or say yes to a step while you are away from your desk.

Worktree isolation gives each session its own copy of the project, on a new branch. You start it with --worktree and a name, and the copy goes in a folder inside .claude. Two sessions in two worktrees can edit at once and never clash. A helper agent can work in its own copy the same way.

bash
claude -p "list the TODOs in src/" --output-format json
claude --bare -p "run the linter and sum up the errors" --allowedTools "Bash(npm run lint)"
claude --worktree feature-auth
One answer as JSON for a script. One clean run that loads nothing from the machine. One session in its own copy.
With -p, a prompt goes in, an answer comes out, and Claude Code exits.

Worked example

Lucy runs two fixes at once

Lucy has a bug to fix and a page to build on the same day. She opens 2 terminals and starts claude --worktree fix-login in one and claude --worktree new-page in the other.

Each session edits its own copy on its own branch. By lunch both are done, and she merges them one at a time.

The words for this lesson6

Check yourself

You want to answer Claude from your phone while it keeps working on your own computer's files. Which do you use?

Finished this lesson?

Marking it complete also marks its 6 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.