본문으로 건너뛰기
cccskills
무료GitHub에 공개

git-worktree

Use Git worktrees to isolate parallel coding tasks. Use when setting up a task checkout, working in a shared repo, or managing existing worktrees.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md5.2 KB
  • agents/openai.yaml43 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Git Worktrees for Parallel Agents

In Cloudroom ($ROOM_THREAD_ID is set)

Never run git worktree add yourself. Cloudroom only deletes worktrees it made, so hand-made ones pile up in ~/code forever.

  • New task: start the thread with New worktree instead.

  • Move this thread to its own worktree: fork it into a Cloudroom-managed worktree. Cloudroom makes the branch and deletes the folder once its last thread is archived (after the worktree retention setting, default 30 days).

    room-cli thread fork "$ROOM_THREAD_ID" --new-environment worktree --title "<task>" \
      --prompt "You now run in a new worktree. Copy the gitignored .env files from <primary checkout> into it, then stop and wait for the user."
    

    It branches from main, so uncommitted edits stay behind; commit them first or pass --base-branch <ref>. Then tell the user to continue in the new thread and archive this one. Skip the rest of this skill.

Start here

Detect where you are before editing:

[ "$(git rev-parse --path-format=absolute --git-dir)" = "$(git rev-parse --path-format=absolute --git-common-dir)" ] \
  && echo "primary checkout" || echo "worktree"
  • Primary checkout → create a task-named worktree, complete the setup below, and cd into it before editing.
  • Worktree (including one created by Cursor) → proceed with the task.

Working model

Worktrees have separate working files and branches but share Git history, stashes, config, and refs.

  • One task = one worktree = one agent session. Never share a working directory between agents.
  • Keep the primary checkout on main, only for review, merging, and pushing.
  • Nothing auto-merges. The human reviews each diff before merging or discarding the worktree.
  • Keep task branches local and short-lived. Push only main unless the user explicitly asks to push a task branch.
  • Merge one worktree at a time. If main moved, rebase the task branch before merging.

Creating and removing

git worktree add ../myrepo-task-x          # new worktree + branch "myrepo-task-x"
git worktree add ../fix-y -b fix-y main    # explicit branch off main
git worktree list                          # see all worktrees
git worktree remove ../myrepo-task-x       # delete when merged/abandoned
git worktree prune                         # clean up stale registrations

A branch can be checked out in only one worktree, including main.

In Cursor, use the Agents Window or /worktree <task>. /apply-worktree applies results to the main checkout; /delete-worktree discards them. /best-of-n model1,model2 <task> runs the same task in parallel worktrees, one per model. Cursor auto-deletes older worktrees, so preserve results promptly; pushing task branches still requires explicit approval.

Complete the setup

A fresh worktree contains tracked files only. Bootstrap it before task work:

  1. Env/secret files — copy .env, .env.local, and similar files from the primary checkout. Never symlink them: edits would change the originals.
  2. Dependencies — install locally (npm ci, pnpm install, uv sync, bundle install). Never symlink node_modules from the primary checkout: bundlers such as Next.js/Turbopack reject paths outside the worktree. If it is a symlink, remove it with rm -f node_modules and install normally.
  3. Databases and services — choose shared or per-worktree state. For shared services, pin their identity to avoid duplicate instances and port conflicts. For shared Docker Compose services, pin the project name, for example with a top-level name:; otherwise each worktree's folder name creates a separate project. Copy or re-seed per-worktree state such as SQLite files.
  4. Ports — run dev/test servers and debuggers one at a time, or configure separate ports per worktree.
  5. Generated files and caches — rebuild gitignored output in the worktree (npm run build, codegen).
  6. Git hooks — core.hooksPath and .git/config are shared; verify hook scripts don't assume the primary checkout's path.

Automate setup

In Cursor, .cursor/worktrees.json runs setup on creation ($ROOT_WORKTREE_PATH is the primary checkout):

{
  "setup-worktree": [
    "npm ci",
    "cp $ROOT_WORKTREE_PATH/.env.local .env.local"
  ]
}

Otherwise, put the checklist in scripts/setup-worktree.sh and run it first in each new worktree. Find the primary checkout from a worktree with:

dirname "$(git rev-parse --path-format=absolute --git-common-dir)"

Merge and clean up

# from the primary checkout, after reviewing the worktree's diff:
git merge --no-ff task-branch     # or: git merge --squash task-branch
git worktree remove ../myrepo-task-x
git branch -d task-branch

In Cursor, use /apply-worktree, then review and commit.

  • Delete each worktree as soon as its branch is merged or pushed to main. Nothing else cleans them up.
  • Rebase or restart worktrees that have stalled for days.
  • Commit early and often. Deleting a worktree loses uncommitted work; commits remain in the shared repository.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

4x4

무료

Pull 16 fast decisions out of the user with 4 sets of 4 open questions, then present an implementation plan. Only for risky changes, large product decisions, or large refactors. Run when the user types /4x4. Agents may suggest it in one line but never start it on their own.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

davidondrej/skills4.2천2026년 10월 19일 업데이트

Record concise ADRs that preserve the user's decisions without conversational noise. Use for "adr-verbatim", "new ADR", "document that as an ADR", "record this decision", or supplied ADR wording.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

davidondrej/skills4.2천2026년 10월 19일 업데이트

Keep a Mac awake for a set duration or while a process runs. Use only when the user explicitly invokes /anti-sleep.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

davidondrej/skills4.2천2026년 10월 19일 업데이트

Clarify a feature, change, or refactor through questions, then write a build prompt for another agent. Use for /ask-then-build or requests to ask questions before producing an implementation prompt.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

davidondrej/skills4.2천2026년 10월 19일 업데이트

bb-cli

무료

Use this when controlling bb. The bb CLI inspects and manages threads, environments, projects, machines, providers, skills, plugins, settings, terminals, and other BB services.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

davidondrej/skills4.2천2026년 10월 19일 업데이트

Build, install, and debug bb plugins. Use when the user wants a bb plugin, a sidebar panel, a bb CLI subcommand, an agent tool, a theme, a provider, or to extend bb itself. For running threads and the core bb CLI, use bb-cli instead.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

davidondrej/skills4.2천2026년 10월 19일 업데이트

davidondrej의 스킬 모두 보기

이 스킬의 문제 신고