worktree-impl

whywaita's avatarfrom whywaita

Create a git worktree for isolated implementation after planning. Use when starting implementation or when a clean worktree is requested.

⭐0stars🔀0forks📁View on GitHub🕐Updated Jan 10, 2026

When & Why to Use This Skill

The worktree-impl skill automates the creation and management of Git worktrees, allowing developers to implement features or fixes in isolated environments. By streamlining the setup of task-specific directories, it eliminates the need for frequent stashing and reduces context-switching overhead, ensuring a clean and organized version control workflow.

Use Cases

  • Parallel Feature Implementation: Create a dedicated, isolated directory to start a new feature without affecting or stashing current progress in the main working tree.
  • Urgent Bug Fixing: Quickly spin up a clean environment based on the production branch to address critical issues while keeping the development workspace intact.
  • Concurrent Code Comparison: Maintain multiple active branches in separate folders to run tests or compare behaviors across different versions of the codebase simultaneously.
  • Automated Workspace Setup: Use the agent to handle branch naming, fetching, and directory sanitization for a standardized project structure under .worktrees/.
nameworktree-impl
descriptionCreate a git worktree for isolated implementation after planning. Use when starting implementation or when a clean worktree is requested.

Git Worktree Implementation

Workflow

  1. Confirm the current directory is a git repo.
  2. Fetch latest refs: git fetch origin.
  3. List existing worktrees: git worktree list.
  4. Decide branch name.
    • If a name is provided, use it.
    • Otherwise infer naming from git branch -r and propose a name for approval.
  5. Determine base branch:
    • git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'
  6. Create the worktree:
    • git worktree add -b <branch-name> .worktrees/<sanitized-name> origin/<base>
    • <sanitized-name> replaces / with -.
  7. Offer next actions:
    • cd <worktree-path> && codex
    • Continue in current session after cd

Placement rules

  • Place worktrees under <repo>/.worktrees/<branch-name>/.
  • Keep .worktrees/ out of version control (add to .gitignore if needed).