Claude Code, OpenCode and a human in one repository

Contents
What goes wrong in one shared checkout
The model: one writer per checkout
A worktree and a branch per agent
Starting each tool in its worktree
What a new worktree does not have
Review and merge
Files with one writer
Who commits, who pushes
Pull requests on a local server
If you must share one checkout
Checklist

In the aredel repository a person, Claude Code and OpenCode work on the same code, often on the same day. This page is about how they share the repository: who writes where, who commits and who merges. How each tool is configured is covered in Building AI agents: OpenCode and Claude Code in one repo.

What goes wrong in one shared checkout

A checkout has one working tree and one index, the staging area. When two agents and a person write into the same checkout, each sees the half-finished work of the others. In aredel this happened within two days:

None of these is a bug in a tool. They follow from several writers sharing one working tree and one index.

The model: one writer per checkout

A worktree and a branch per agent

A worktree is a second working directory of the same repository, with its own index and its own branch; objects and history are shared, so it costs little disk. From the main checkout, create one per agent, next to it:

git worktree add ../site-claude -b claude/str-move

git worktree add ../site-opencode -b opencode/logs

git worktree list

…/site def75f4 [main] …/site-claude b3ca3b8 [claude/str-move] …/site-opencode 9594175 [opencode/logs]

The output above is from a test on a throwaway repository named site, 2026-10-23, after each agent had made one commit in its own worktree. The main checkout stayed clean: no file of either agent appeared in it, and each commit landed on its own branch.

Starting each tool in its worktree

Each tool works in the directory it starts in, so start it inside the agent's worktree. Claude Code can also create the worktree itself: claude --worktree name, short -w, starts the session in a new worktree on its own branch, and the same command with another name in a second terminal starts a second isolated session. The repository needs at least one commit; see Claude Code worktrees:

cd ../site-claude && claude

claude --worktree str-move

OpenCode 2.1.3 has no worktree flag on the command line, but it takes the directory to start in as an argument:

opencode ../site-opencode

Inside one session the tools can isolate further: a Claude Code subagent with isolation: worktree runs in a temporary worktree of its own, see Claude Code subagents, and OpenCode 2.x can create worktrees for parallel features, see OpenCode.

What a new worktree does not have

A worktree contains the tracked files and nothing else. Everything git ignores stays in the main checkout:

Review and merge

The person reviews each branch against main with three dots, which shows only what the branch added, then merges it with a merge commit so the branch stays visible in history:

git diff --stat main...claude/str-move

str.md | 1 + 1 file changed, 1 insertion(+)

git merge --no-ff claude/str-move

git merge --no-ff opencode/logs

git log --oneline --graph

* 3127cda Merges opencode/logs |\ | * 9594175 Moves the logs * | 47b1b7d Merges claude/str-move |\ \ | |/ |/| | * b3ca3b8 Moves the str section |/ * def75f4 Initial commit

When a branch is merged, remove its worktree and the branch:

git worktree remove ../site-claude

git branch -d claude/str-move

Files with one writer

Some files are rebuilt from the whole tree: in aredel the sitemap and the feed. Two branches that both rebuild them always conflict, and a rebuild on a branch misses pages from the other branches. Rebuild them once, on main, after merging; an agent that adds a page only notes that the sitemap needs regenerating. The same goes for any file a hook writes for everyone.

Who commits, who pushes

In aredel an agent never commits without asking, and the deny rules of both tools forbid git push for every agent, see Deny rules for OpenCode and Claude Code. With worktrees that rule stays simple: an agent may commit on its own branch when the person agrees; the person merges into main and is the only one who pushes, to GitHub or to a local server. The rule held even for a throwaway server on 127.0.0.1: in the Forgejo test the push was refused for Claude Code and run by the person.

Pull requests on a local server

Reviewing with git diff works, but a web page with the diff, comments and a merge button is easier when several branches wait at once. A GitHub-like server can run on the same machine in a container; with it the flow becomes: the person pushes an agent branch, opens a pull request, reviews and merges it, then pushes main to GitHub. A tested setup with Forgejo, and the alternatives, are in A local GitHub in a container.

If you must share one checkout

Checklist

Official sources:

Article author: Arthur Isaev

Related articles
Building AI agents: OpenCode and Claude Code in one repo
Claude Code, OpenCode and a human in one repository
A local GitHub in a container: Forgejo
Deny rules for OpenCode and Claude Code
Claude Code subagents
OpenCode agents: four complete examples
Agent setup audit: the aredel case

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: