agentleFS
nfeuernfeuer/project-foundation-kit/.claude/skills/parallel-work/SKILL.md

parallel-work

Skill0 starsChanged 4 months agoMITView on GitHub

Isolate concurrent Claude sessions in git worktrees so multiple agents never cross wires on main — create, work, PR, and auto-clean per-branch worktrees

  • Commits and pushes

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this whenever more than one Claude instance may touch the repo at once, or whenever you start a discrete unit of work that will become …

    line 13
  2. Distinctive:

    Update that file once to propagate the values everywhere.

    line 21
  3. Distinctive:

    If you dispatch a long-running background agent to work in the tree, lock it so the pruner won't reclaim it mid-flight:

    line 45
  4. Distinctive:

    One branch = one worktree = one concern: Don't stack unrelated changes.

    line 78
  5. Distinctive:

    When you finish, report:

    line 89

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Parallel Work — Worktree Isolation for Concurrent Agents

Use this whenever more than one Claude instance may touch the repo at once, or whenever you start a discrete unit of work that will become its own PR. The rule is simple: never edit source files on the trunk_branch. Each stream of work gets its own branch in its own git worktree, so two agents editing at the same time can't corrupt each other's tree or produce a tangled trunk.

Profile-driven. The worktree root and trunk branch come from .claude/kit.yaml (worktree_dir, default: .claude/worktrees; trunk_branch, default: main). Update that file once to propagate the values everywhere.

The require-worktree.sh PreToolUse hook enforces this — it blocks Edit/Write on the trunk_branch in the primary worktree. If you hit that block, you're in the wrong place; follow this skill.

Workflow

1. Start an isolated worktree

Pick a branch name matching the change type (feat/, fix/, docs/, chore/):

# worktree_dir from kit.yaml (default: .claude/worktrees)
repo_root=$(git rev-parse --show-toplevel)
name=<short-kebab-slug>
git worktree add "$repo_root/.claude/worktrees/$name" -b feat/$name

From here on, use absolute paths under that worktree for every edit. Do not cd narration into it and back — always address files as $repo_root/.claude/worktrees/$name/... (substitute worktree_dir from .claude/kit.yaml for .claude/worktrees if your project overrides it).

2. Background agents: lock the worktree

If you dispatch a long-running background agent to work in the tree, lock it so the pruner won't reclaim it mid-flight:

# worktree_dir from kit.yaml (default: .claude/worktrees)
git worktree lock "$repo_root/.claude/worktrees/$name"

Unlock when the agent is done (git worktree unlock <path>).

3. Do the work, then gate it

Make your changes in the worktree. Before opening a PR, run the pre-pr skill inside the worktree — it runs lint, types, and tests so CI doesn't fail on arrival. Do not skip this; a red PR blocks the queue for every other agent.

4. Commit, push, open the PR

# worktree_dir from kit.yaml (default: .claude/worktrees)
git -C "$repo_root/.claude/worktrees/$name" add -A
git -C "$repo_root/.claude/worktrees/$name" commit -m "feat: ..."
git -C "$repo_root/.claude/worktrees/$name" push -u origin feat/$name
gh pr create --head feat/$name --fill

5. Cleanup is automatic

Once the PR merges, the prune-merged-worktrees.sh hook removes the worktree and deletes the local branch — at session start and immediately after any gh pr merge. You don't need to clean up by hand. It refuses to prune a tree that is locked, dirty, recently active, or lacks a merged PR, so it's safe to leave running.

Coordination rules for a fleet of agents

  • One branch = one worktree = one concern. Don't stack unrelated changes.
  • Exempt files can be edited on the trunk_branch (the hook allows them): CLAUDE.md, .claude/settings*, config/*.yaml, .gitignore. A coordinating session may touch these directly; feature work should not.
  • Never force-push another agent's branch and never merge a PR whose CI is red or whose worktree is still locked.
  • If two changes truly must land together, say so in the PR body and merge in dependency order — don't co-edit one branch from two sessions.

Output

When you finish, report:

## Worktree Summary
- Branch: feat/<name>
- Worktree: <worktree_dir>/<name>   (worktree_dir from .claude/kit.yaml)
- Pre-PR gate: PASS / FAIL — <detail>
- PR: #<n> (<url>)
- Cleanup: automatic on merge

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.