git-worktree
Use this skill whenever a task involves running parallel work on a git repository without conflicts — e.g. "fix this bug while I keep working on my feature", "run Claude on two branches at once", "work on this task in isolation", "create a throwaway branch for this experiment", or anything where two agents or sessions might edit the same files. Also trigger when the user asks to use worktrees directly, or when an agent needs its own isolated checkout so it can work without disturbing the main branch. Even if the user just says "do this in parallel" or "don't mess up my current work", consider worktrees.
What this skill does
# Git Worktree Skill Git worktrees let you check out multiple branches of the same repository into separate directories simultaneously. Each directory is a fully independent working tree — its own HEAD, index, and files — but all share the same `.git` history and objects, so they stay lightweight. Use this skill to give each agent or parallel task its own isolated workspace. --- ## When to reach for worktrees - Two or more agents might edit the same files simultaneously - A task should not disturb the current branch's working state - You need a throwaway sandbox that can be discarded cleanly if things go wrong - The user asks to work on multiple features or fixes in parallel - You want to run tests on one branch while editing another --- ## Core commands ### Create a worktree ```bash # New branch from current HEAD git worktree add ../my-task -b my-task-branch # From a specific commit or existing branch git worktree add ../hotfix -b hotfix origin/main # Detached HEAD (no branch) git worktree add --detach ../scratch HEAD # Empty worktree on an unborn branch (blank slate) git worktree add --orphan ../experiment -b experiment ``` The new directory is ready to use immediately. `cd` into it and work normally. ### List all worktrees ```bash git worktree list # /path/to/main abc1234 [main] # /path/to/my-task def5678 [my-task-branch] ``` ### Remove a worktree when done ```bash # Clean remove (fails if the worktree has uncommitted changes) git worktree remove ../my-task # Force remove (discard dirty worktree) git worktree remove --force ../my-task # If you deleted the directory manually, clean up the metadata git worktree prune ``` ### Move a worktree ```bash git worktree move ../my-task ../new-location ``` ### Lock / unlock (for portable drives or network shares) ```bash git worktree lock ../my-task --reason "on external drive" git worktree unlock ../my-task ``` ### Repair after a manual move ```bash # Run inside the moved worktree git worktree repair # Or from main, pointing at each moved worktree git worktree repair ../new-location-1 ../new-location-2 ``` --- ## Recommended layout for agents Place worktrees as siblings of the main repo directory so paths stay predictable and `.gitignore` patterns do not need updating: ``` projects/ my-app/ ← main repo (agents work here by default) my-app-task-a/ ← worktree for task A my-app-task-b/ ← worktree for task B ``` Create them from the main repo root: ```bash git worktree add ../my-app-task-a -b task-a git worktree add ../my-app-task-b -b task-b ``` --- ## Agent workflow 1. **Create** a worktree on a fresh branch before starting work. 2. **Work** entirely inside that directory — treat it like a normal repo. 3. **Commit** as usual; history is shared with the main repo. 4. **Verify** the result (tests, review, etc.). 5. **Merge or PR** the branch back via standard git workflow. 6. **Remove** the worktree once done. ```bash # Step 1 — set up git worktree add ../my-app-fix-login -b fix-login # Step 2 — work cd ../my-app-fix-login # ... make changes ... # Step 3 — commit git add -A && git commit -m "fix: resolve login redirect loop" # Step 4 — back in main repo, merge cd ../my-app git merge fix-login # Step 5 — clean up git worktree remove ../my-app-fix-login git branch -d fix-login ``` --- ## Safety rules - **One branch per worktree.** Git prevents the same branch from being checked out in two worktrees at once. Use separate branch names for each worktree. - **Do not share an index.** Never point two worktrees at the same directory. - **Avoid submodules in moved worktrees.** `git worktree move` cannot move a worktree that contains submodules; handle those manually. - **Discard freely.** If a worktree session goes wrong, `git worktree remove --force` discards it entirely with no impact on other branches. - **Prune stale metadata.** After manually deleting a worktree directory, run `git worktree prune` in the main repo to remove orphaned administrative files. --- ## Troubleshooting | Symptom | Fix | |---|---| | `fatal: '<branch>' is already checked out` | Use a different branch name, or check `git worktree list` | | Worktree directory deleted but `git worktree list` still shows it | Run `git worktree prune` | | Moved worktree can no longer find the repo | Run `git worktree repair` inside the moved directory | | Locked worktree blocks removal | `git worktree unlock <path>` then remove | | Changes in worktree not visible in main | Changes are per-worktree until committed and merged |
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.