Skip to content

devlog/agent-loops/vs-code-claude-code-without-file-collisions-21.md

VS Code + Claude Code, Without File Collisions

Give VS Code and Claude Code separate worktrees

I like keeping VS Code open while Claude Code handles a bounded task. What I do not like is accepting an editor buffer that silently overwrites an agent’s changes. Separate terminals do not prevent that: if both tools point at the same checkout, they share the same files.

Git worktrees solve the filesystem problem. Each worktree gets its own directory and checked-out branch while sharing the repository’s history. You keep editing; Claude keeps working; Git becomes the integration point.

1. Prepare your repository and Claude Code

These commands assume Bash or Zsh, Git, Node.js with npm, and VS Code’s command-line launcher. Start inside your repository. Install Claude Code if needed:

npm install -g @anthropic-ai/claude-code — git status --short

If that prints changes, commit the intended files or stash them before continuing. Do not bury unrelated work in an automatic checkpoint commit. For this walkthrough, start clean and choose branch names that do not already exist.

git switch -c dev/editor-lane — git worktree add -b feature/claude-lane ../fluxo-claude

git worktree list — code .

Your original directory is now the editor lane. The sibling directory named fluxo-claude is the agent lane. Worktrees isolate tracked files, not external resources: database instances, listening ports, and shared caches may still need separate configuration.

2. Point the agent terminal at Fluxo

Open another terminal in the original repository, then move it into the agent worktree: — ROOT=$(git rev-parse --show-toplevel)

cd "$ROOT/../fluxo-claude" — Configure this terminal rather than writing credentials into repository files. The following uses an interactive prompt so your key does not become a literal command in shell history:

read -r -s -p 'Fluxo API key: ' FLUXO_API_KEY; printf '\n'

export ANTHROPIC_AUTH_TOKEN="$FLUXO_API_KEY"

export ANTHROPIC_BASE_URL="https://api.fluxorelay.com" — unset ANTHROPIC_API_KEY — claude — This assumes Fluxo’s Claude Code routing is enabled for your key; follow its current setup instructions if your account requires additional configuration. Existing Claude Code authentication settings can also affect which credentials are used.

Fluxo gives this setup one key and one base URL for Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok and more. Claude Sonnet 5.5 and GPT-6.1 Sol are two concrete model choices, although each client needs the exact model identifier exposed by the relay. The same service works with Claude Code, Codex, Gemini CLI, and any OpenAI SDK.

If you want to follow along through the relay, you can create a Fluxo account.

3. Assign Claude a bounded file task

For a reproducible first run, use documentation rather than a risky refactor. Paste this into Claude Code:

Create docs/relay-workflow.md describing how this repository can use separate Git worktrees for editor and agent work. Inspect existing documentation conventions first. Change only that file, do not commit, and summarize your changes when finished.

Meanwhile, use VS Code in the original checkout to create docs/editor-notes.md with your own workflow notes. Save it before committing. Different directories prevent accidental overwrites; explicit task boundaries prevent unnecessary integration conflicts.

Do not open the agent worktree in your existing editor window and start editing its files. That would reintroduce the shared-file problem.

4. Review and merge the agent branch

After Claude finishes, exit its session. In the agent terminal, inspect everything it changed, including untracked files:

git status --short — git diff — cat docs/relay-workflow.md — git add docs/relay-workflow.md

git diff --cached — git commit -m "Document parallel worktree workflow"

In the original terminal, commit your saved editor file and merge the agent branch:

git add docs/editor-notes.md — git commit -m "Add editor workflow notes"

git merge --no-ff feature/claude-lane — For code changes, run the repository’s actual tests after merging. Separate worktrees prevent simultaneous writes, not logically incompatible changes.

5. Remove the finished agent worktree

From the original checkout, after confirming the merge: — git worktree remove ../fluxo-claude

git branch -d feature/claude-lane — Fluxo bills per real token, including cache reads and writes, with no monthly fee. Users also earn a referral share when people they invite pay. Neither changes the core habit: isolate the files, review the diff, and integrate deliberately.

Next in the buffer

Sign up in a minute and get credit to try every model mentioned here. Sign up →