# Claude Code Run Modes

> 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:** [Claude Code Basics](https://learn.benibix.com/learn/ai-claude-code)  
**Time:** 11 min

**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

## 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.

![A claude -p command with a prompt goes in. Claude works with tools but no chat, prints the answer to the screen or a pipe, and the program ends. A note says to set the allowed tools before you run it.](https://learn.benibix.com/diagrams/cc-non-interactive-mode.svg)

### 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.

**Words in this lesson:** [Non-Interactive Mode](https://learn.benibix.com/term/ai/non-interactive-mode), [Bare Mode](https://learn.benibix.com/term/ai/bare-mode), [Background Session](https://learn.benibix.com/term/ai/background-session), [Cloud Session](https://learn.benibix.com/term/ai/cloud-session), [Remote Control](https://learn.benibix.com/term/ai/remote-control), [Worktree Isolation](https://learn.benibix.com/term/ai/worktree-isolation)

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

**Answer:** Remote Control. Remote Control keeps the session on your own machine, and you drive it from the web or the phone app. A cloud session runs on a server from a fresh copy.

---

Source: https://learn.benibix.com/learn/ai-claude-code/claude-code-run-modes
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
