Feature-marker create-worktree
Create and bootstrap a git worktree for isolated development work.
install
source · Clone the upstream repo
git clone https://github.com/Viniciuscarvalho/Feature-marker
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/Viniciuscarvalho/Feature-marker "$T" && mkdir -p ~/.claude/skills && cp -r "$T/feature-marker-dist/feature-marker/resources/spec-workflow/skills/create-worktree" ~/.claude/skills/viniciuscarvalho-feature-marker-create-worktree && rm -rf "$T"
manifest:
feature-marker-dist/feature-marker/resources/spec-workflow/skills/create-worktree/SKILL.mdsource content
Create Worktree
Creates and bootstraps a git worktree for isolated development work.
Arguments
(required): Name for the worktree directory and branchname
: Path to a spec file to copy into the worktree's specs directory--spec=<path>
: Base branch to create worktree from (default: current branch or configured default)--base=<branch>
: Skip the onBootstrap hook--no-bootstrap
Configuration
Check for
.claude/spec-workflow/config.yaml:
paths: worktrees: "./worktrees" # Where worktrees are created specs: "./specs" # Where specs live (for copying) worktree: branchNaming: "{name}" # Branch naming pattern defaultBase: null # Default base branch (null = current) onBootstrap: null # Hook script to run after creation
Branch Naming
The
branchNaming pattern supports these tokens:
- The worktree name{name}
- Current date (YYYY-MM-DD){date}
Examples:
→"{name}"my-feature
→"feature/{name}"feature/my-feature
→"{date}-{name}"2024-01-15-my-feature
Bootstrap Hook
If
worktree.onBootstrap is configured, it runs after worktree creation with these environment variables:
| Variable | Description |
|---|---|
| Absolute path to the new worktree |
| Name of the worktree |
| Path to spec file (if --spec was provided) |
| Branch the worktree was created from |
Example hook script:
#!/bin/bash cd "$WORKTREE_PATH" npm install # ... any other setup
Steps
-
Check if worktree exists
- Check if a worktree with the given name already exists at the configured path
- If it does, respond with "Worktree already exists at [path]" and exit
- If it does not exist, proceed
-
Determine paths and branch name
- Worktree path:
(default:{config.paths.worktrees}/{name}
)./worktrees/{name} - Branch name: Apply
pattern (default:branchNaming
){name} - Base branch:
argument, or--base
, or current branchworktree.defaultBase
- Worktree path:
-
Create the worktree
git worktree add -b [branch-name] [worktree-path] [base-branch] -
Notify the user
Worktree created at [path] on branch [branch-name]. -
Handle spec file (if --spec provided)
- Copy the spec file to the worktree's specs directory
- Update spec frontmatter with worktree and branch info
-
Run bootstrap hook (unless --no-bootstrap)
- If
is configured, run it with environment variablesworktree.onBootstrap - If not configured, skip this step
- Report success or failure
- If
-
Final confirmation
Worktree ready at [path]. To work in this worktree: - Open a new terminal in [path] - Or use: cd [path]
Example Usage
# Basic worktree creation /create-worktree feature-login # Create worktree with a spec file /create-worktree user-notifications --spec=specs/2024-01-15-notifications-spec.md # Create worktree from a different base branch /create-worktree hotfix-auth --base=release/v2.0 # Create worktree without running bootstrap /create-worktree quick-fix --no-bootstrap
Notes
- Worktrees are typically gitignored (add
toworktrees/
).gitignore - Each worktree has its own working directory but shares git history
- Worktrees allow parallel work on different features without stashing
- Use
(if available) to remove stale worktrees/worktree-cleanup