agentleFS
p10ns11yp10ns11y/skills/git-worktrees/SKILL.md

git-worktrees

Skill2 starsChanged 40 days agoMITView on GitHub

Effective git worktree workflows for agents and humans: branches vs worktrees, safe commit-then-merge integration (never cp into main checkout), conflict handling, when to use or skip worktrees, macOS concurrency, and disk hygiene for global ~/.grok/worktrees/ clones. Use when creating worktrees, integrating agent task branches, or cleaning up after large orchestration runs.

24 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use obsidian-bases, verification-before-completion and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • wangzhuofengSkill

    obsidian-bases

    Create and edit Obsidian Bases (.base files) with views, filters, formulas, and summaries. Use when working with .base files, creating database-like views of notes, or when the user mentions Bases, table views, card views, filters, or formulas in Obsidian.

    Also in 3 projects that use this

  • OpenAISkill

    verification-before-completion

    Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always

    Also in 4 projects that use this

  • SentrySkill

    security-review

    Finds exploitable application security vulnerabilities in code changes. Use for Warden security scans, appsec review, OWASP-style checks, authentication or authorization bugs, injection, XSS, SSRF, path traversal, secrets, unsafe crypto, webhook verification, open redirects, or sensitive data exposure.

    Also in 4 projects that use this

  • OpenAISkill

    systematic-debugging

    Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

    Also in 4 projects that use this

  • CloudflareSkill

    receiving-code-review

    Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation

    Also in 3 projects that use this

  • CloudflareSkill

    security-audit

    Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.

    Also in 3 projects that use this

  • +3 more from openai

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 24 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If linear history without merge commits: still commit in each WT, then cherry-pick.

    line 75

“Common” is measured: kept by at least 6 in 10 of the 24 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

git-worktrees

Load rule: Formal SoT. Disk/Grok CLI detail → references/disk-hygiene.md only if needed.
CLT: ../rules/clt-dual-load.mdc — one agent per worktree enables safe fan-out (asymmetric parallel); never merge via cp.

// Signature
branch  ≔ *what* (line of commits)
worktree ≔ *where* (extra checkout on same .git)

// Axioms
A1  Integrate = commit in WT → merge/cherry-pick on integration  — never cp/rsync
A2  One agent ⇔ one worktree directory
A3  Remove WT only after merge + verify (or explicit abandon)
A4  Concurrent add on macOS: stagger (sleep ~1s) to avoid index SIGBUS
A5  Two layers: repo-local .worktrees/  vs  global ~/.grok/worktrees/ full clones
A6  After large plans: hygiene mandatory (see disk-hygiene)

Pair: concurrent-cli-agents · agent-orchestrator · split-to-prs.


Use / skip

Use whenPrefer instead when
≥2 tasks same repo concurrentsingle task → one checkout
long feature + main for hotfixesunrelated repos → separate clones
side-by-side run/comparenever touch disk → cloud sandbox
agent isolationsame few files always → serialize (WT ≠ less conflict)
disk tight + heavy node_modules → serialize or /tmp clones

This library convention: .worktrees/<tool>-<slug> · branch agent/<tool>/<slug> · create via concurrent-cli-agents script when present.


Safe integration

1. Agent only inside its WT path
2. Validate in that WT
3. git commit on agent/<tool>/<slug>
4. Orch on primary: integration branch checked out
5. Merge one branch at a time → resolve on primary → re-validate
6. Remove WT after success
# merge agent branch onto current (primary)
<path>/git-worktrees/scripts/agent-worktree-merge.sh --branch agent/cursor/<slug>

Merge order: docs/low-churn first, then code.

Why never cp

RiskFailure
last writer winssilent drop of other task
stale copyhalf-finished files
lost workuncommitted + force-remove
no auditno per-task commits/PRs

If linear history without merge commits: still commit in each WT, then cherry-pick.


Coordinator checklist

[ ] create WT+branch per task (stagger on macOS)
[ ] disjoint files in prompts
[ ] agent commits before "done"
[ ] git worktree list ↔ branch
[ ] merge one-by-one on primary
[ ] conflicts only on primary
[ ] validate integration
[ ] remove WT; optional branch -d
[ ] large plans → disk hygiene

Scripts

ScriptPurpose
concurrent-cli-agents agent-worktree-create.shnew WT + branch
scripts/agent-worktree-list.shlist
scripts/agent-worktree-merge.shmerge one agent branch
scripts/agent-worktree-remove.shremove after merge
scripts/agent-worktree-clean.shGrok global cleanup + branch preserve

Conflicts

Primary checkout only · fix · git add · merge --continue · re-validate.
Heavy conflict → abort, rebase smaller task onto merged result.


Anti-patterns

¬Do
cp/rsync integratemerge/cherry-pick
commit integration while agents still edit same filesserialize or disjoint
worktree remove --force pre-mergemerge first
two agents one WT dirone WT each
WT without commitsbranch+commit
delete agent/* before on targetmerge first
leave ~/.grok/worktrees/ orphansgc / clean.sh

Stack/handoff naming: see agent-orchestrator + gt-flow; artificial final branch names.

Done when: agent commits on their branch; integration via merge; hygiene run after multi-WT plans.

Disk/Grok CLI: references/disk-hygiene.md.

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.