To run multiple Claude Code sessions safely, give each one its own git worktree (claude --worktree name creates one under .claude/worktrees), so their edits never collide. Name each session with claude -n or /rename, run them in separate terminal tabs, tmux panes or as background sessions in claude agents, and use notifications or a status view to see which one is waiting for you.
You can run as many Claude Code sessions as you like at the same time: each claude process is independent. The real problems are elsewhere. Two agents editing the same checkout overwrite each other, several sessions burn through your plan faster, and with five tabs open it becomes hard to see which one is quietly waiting for your answer.
This guide covers the setup that avoids those problems: worktrees for isolation, naming, where to run the sessions, how to avoid conflicts, and how to keep track of the ones that need you. It applies to Codex sessions too, since the isolation happens at the git level.
Can you run multiple Claude Code sessions at once?
Yes. Claude Code sessions are separate processes, each with its own context, so you can start one per terminal tab. The official docs recommend isolating them in separate git worktrees when they work on the same repository, so one session can build a feature while another fixes a bug without the edits colliding.
There are three common setups:
| Setup | Good for | Watch out for |
|---|---|---|
| Terminal tabs or windows | Two or three sessions you check often | Easy to miss a tab that is waiting |
| tmux panes | Many sessions on one screen, remote machines | Notifications need extra tmux config |
Background sessions (claude agents) | Many sessions you check occasionally | Claude Code only, not Codex |
Whichever you choose, the rules below about worktrees and naming apply.
How do git worktrees keep parallel sessions apart?
A git worktree is a separate working directory with its own files and branch, sharing the same repository history. In Claude Code, the --worktree flag (or -w) creates one and starts the session inside it:
claude --worktree feature-authBy default the worktree lands in .claude/worktrees/feature-auth/ at the repository root, on a new branch named worktree-feature-auth. Run the same command with another name in a second terminal to start a second isolated session. If you leave out the name, Claude generates one.
Set-up tips from the official worktrees page:
- Add
.claude/worktrees/to your.gitignoreso worktree contents do not show up as untracked files. - A worktree is a fresh checkout, so install dependencies in it, or ask Claude to.
- To copy gitignored files such as
.envinto every new worktree, list them in a.worktreeincludefile at the project root (same syntax as.gitignore). - New worktrees branch from the default branch on the remote. Set
worktree.baseRefto"head"in settings to branch from your current work instead.
When you exit a session, Claude Code checks the worktree. A clean, unnamed one is removed with its branch. If there are changes or commits, it asks whether to keep or remove it. Gitignored files do not count as changes, so copy out anything you need before you exit.
You can also manage worktrees yourself, which is the way to go for Codex or any other agent:
git worktree add ../myapp-feature-a -b feature-a
cd ../myapp-feature-a
claudeList them with git worktree list and remove one with git worktree remove ../myapp-feature-a.
How should I name parallel sessions?
Name every session after its task. The Claude Code docs say naming matters most when you work on several tasks in parallel, because names make sessions findable and resumable:
claude -n auth-refactorInside a session, /rename auth-refactor does the same and shows the name on the prompt bar. Later, claude --resume auth-refactor or /resume auth-refactor brings it back. In the /resume picker, Ctrl+W widens the list to all worktrees of the repository.
Combine the worktree name, the branch and the session name (feature-auth, worktree-feature-auth, feature-auth) and you will always know which tab does what. Name the terminal tabs the same way.
How do I avoid conflicts between sessions?
Most conflicts come from shared state, not from the agents themselves. A checklist:
- One worktree per session on the same repository. Never point two agents at the same checkout.
- Do not resume one session in two terminals. The docs warn that both write to the same transcript and messages can go missing. Use
--fork-sessionto get a separate copy. - Split work by area. Give sessions tasks that touch different files, then merge branches the usual way.
- Watch ports and services. Two dev servers on the same port, or two test runs against one local database, will clash even in separate worktrees.
- Know what is shared. Worktrees of one repository share the
.gitdirectory and project plugins. A "Yes, and don't ask again" approval in one worktree is saved to the main checkout's.claude/settings.local.jsonand applies to all of them. - Mind your usage. Every session draws from the same plan, so four sessions spend it four times faster. See Claude Code usage limits.
Should I use terminal tabs, tmux or background sessions?
Terminal tabs are the simplest. Some terminals implement a status protocol that shows whether each Claude Code session is working, waiting on you or done, which helps when you run several at once. Check your terminal's documentation to see if it supports it.
tmux gives you many panes on one screen and survives disconnects. Add set -g allow-passthrough on and set -g focus-events on to ~/.tmux.conf so Claude Code's desktop notifications reach the outer terminal.
Background sessions are built into Claude Code. claude --bg "fix the flaky login test" starts a session without a terminal, /background (or /bg) moves the current one to the background, and claude agents opens agent view, a list of every background session with its state: working, needs input, idle, completed or failed. claude attach <name> opens one in the current terminal. Background sessions move into their own worktree under .claude/worktrees/ before editing, so isolation is handled for you.
Codex sessions run in their own terminal tabs and are not part of claude agents, which is one reason mixed setups get hard to follow.
How do I know which session is waiting for me?
This is where parallel work breaks down: an agent blocked on a permission prompt does nothing until you notice. The options, from simplest to most complete:
- Notification hooks. A
Notificationhook with thepermission_promptmatcher fires when a prompt has waited about six seconds, and aStophook fires when Claude finishes a reply. The hook input includescwd, so your notification can name the project. Setup is in Claude Code notifications on Mac. - Agent view. With
claude agentsopen, Claude Code notifies you when a background session starts needing input, finishes or fails, and the tab title shows a count such as "2 awaiting input". - Fewer prompts. Allow the safe, repetitive commands with rules so fewer sessions stop at all. See how to allow commands in Claude Code.
Keeping track from the menu bar
Allowbar, a Mac menu bar app for Claude Code and Codex, is built for this setup. It lists every Claude Code and Codex session with its state (working, waiting for you, done), with the ones waiting on you at the top, and clicking a session opens its terminal tab.
When any session asks for permission, a Dynamic Island style panel slides down with the project, the tool and the exact command, and you answer with Allow, Block, or Terminal without hunting for the tab. A done notification tells you when a task finishes, and an activity log keeps, per task, the commands run, the files edited and the permissions you answered, stored on your Mac. Allowbar never approves anything on its own, works only on macOS 14 or later, and supports Claude Code and Codex. For a broader setup, see the Mac setup for coding agents.
Allowbar is in private beta. Join the waitlist; the launch price is $9.99 instead of $29.90.
Sources:
- Run parallel sessions with worktrees (Claude Code docs)
- Manage sessions (Claude Code docs)
- Agent view and background sessions (Claude Code docs)
- Configure your terminal for Claude Code
- git worktree documentation
Frequently asked questions
How many Claude Code sessions can I run at once?
Claude Code does not document a fixed cap on local sessions. The practical limits are your plan's usage, your machine's resources and your attention, since each session draws from the same five-hour and weekly limits.
Do I need git worktrees to run sessions in parallel?
Only if the sessions work in the same repository. Sessions in different projects can share nothing and need no isolation. In the same repository, worktrees stop the agents from overwriting each other's edits.
Where does claude --worktree create the worktree?
Under .claude/worktrees/<name>/ at the repository root, on a new branch named worktree-<name>. Add .claude/worktrees/ to .gitignore.
Can Claude Code and Codex work on the same repository at once?
Yes, if each works in its own worktree. Create one with git worktree add for the Codex session and use claude --worktree for the Claude Code one, then merge their branches as usual.
How do I get back to a named session later?
Run claude --resume <name> from the repository, or /resume <name> inside a session. If the name matches several sessions, Claude Code opens the picker with the name as a search.