| name | worktree-scaffold |
| description | Parallel feature development automation using git worktrees with project scaffolding. Use when developers ask to checkout features, create feature workspaces, work on multiple features in parallel, set up worktrees, scaffold new features, list active workspaces, clean up feature branches, or manage parallel development workflows. Triggers on phrases like "checkout feature", "create workspace", "parallel features", "list workspaces", "remove workspace", "init worktree config", or any request involving git worktrees with boilerplate generation. Use when this capability is needed. |
| metadata | {"author":"escotilha"} |
Worktree Scaffold
Automate parallel feature development by combining git worktrees with project scaffolding. Create isolated workspaces with pre-generated boilerplate for each feature.
Commands
| Pattern | Action |
|---|
checkout feature {name} | Create single worktree + scaffold |
checkout features {a}, {b}, {c} | Create multiple worktrees + scaffolds |
list workspaces | Show all active worktrees |
remove workspace {name} | Clean up worktree and optionally branch |
init worktree config | Generate .worktree-scaffold.json template |
Workflow
Creating Feature Workspaces
- Validate feature name (alphanumeric + hyphens only)
- Check if branch exists; create from current HEAD if not
- Create worktree at
{worktreeDir}/{branchPrefix}{name} (default: ../feature-{name})
- Run scaffolding based on
.worktree-scaffold.json config
- Report success with workspace path and next steps
git worktree add <path> -b <branch>
git worktree add <path> <branch>
git worktree list
git worktree remove <path>
git worktree prune
Creating a Feature Workspace
if [[ ! "$FEATURE_NAME" =~ ^[a-zA-Z0-9-]+$ ]]; then
echo "Error: Feature name must be alphanumeric with hyphens only"
exit 1
fi
WORKTREE_DIR="${CONFIG_WORKTREE_DIR:-../}"
BRANCH_PREFIX="${CONFIG_BRANCH_PREFIX:-feature/}"
BRANCH_NAME="${BRANCH_PREFIX}${FEATURE_NAME}"
WORKTREE_PATH="${WORKTREE_DIR}${FEATURE_NAME}"
if git show-ref --verify --quiet "refs/heads/${BRANCH_NAME}"; then
git worktree add "$WORKTREE_PATH" "$BRANCH_NAME"
else
git worktree add "$WORKTREE_PATH" -b "$BRANCH_NAME"
fi
cd "$WORKTREE_PATH"
Scaffold Generation
Read .worktree-scaffold.json from project root and generate files:
Variable Substitution:
| Variable | Input Example | Output |
|---|
{name} | user-auth | user-auth |
{Name} | user-auth | UserAuth (PascalCase) |
{NAME} | user-auth | USER_AUTH (SCREAMING_SNAKE) |
{date} | — | 2026-01-13 |
{author} | — | git config user.name |
Listing Workspaces
git worktree list --porcelain | while read -r line; do
done
Removing Workspaces
cd "$WORKTREE_PATH" && git status --porcelain
git worktree remove "$WORKTREE_PATH"
git branch -d "$BRANCH_NAME"
git worktree prune
Configuration
Create .worktree-scaffold.json in project root. Use assets/worktree-scaffold.template.json as a starting point:
{
"worktreeDir": "../",
"branchPrefix": "feature/",
"scaffolds": {
"default": [
{ "path": "src/features/{name}/index.ts", "template": "feature-index" },
{ "path": "src/features/{name}/types.ts", "template": "feature-types" },
{ "path": "src/features/{name}/__tests__/{name}.test.ts", "template": "feature-test" }
],
"component": [
{ "path": "src/components/{Name}/{Name}.tsx", "template":
Config Fields
| Field | Type | Default | Description |
|---|
worktreeDir | string | "../" | Directory for worktrees relative to repo |
branchPrefix | string | "feature/" | Prefix for branch names |
scaffolds | object | {} | Named scaffold sets |
scaffolds.default | array | [] | Default scaffold files |
templates | object | {} | Template content by name |
hooks.postScaffold | string | — | Command to run after scaffolding |
Error Handling
| Error | Cause | Resolution |
|---|
| "Worktree already exists" | Path in use | Use different name or remove existing |
| "Branch already exists" | Branch created elsewhere | Will use existing branch |
| "Cannot remove worktree" | Uncommitted changes | Commit/stash changes or use --force |
| "Not a git repository" | Not in git repo | Initialize git or cd to repo |
Requirements
- Git 2.20+ (worktree improvements)
- Bash 4.0+ or zsh
- jq (JSON processor for config parsing)
- Node.js projects: npm/yarn/pnpm
- Python projects: pip/poetry
Examples
Single feature:
User: checkout feature user-auth
→ Creates ../user-auth with feature/user-auth branch + scaffolding
Multiple features:
User: checkout features payment-flow, email-notifications, dark-mode
→ Creates 3 worktrees in parallel, reports summary
List workspaces:
User: list workspaces
→ Shows table of active worktrees with paths and status
Cleanup:
User: remove workspace user-auth
→ Warns if uncommitted changes, removes worktree, optionally deletes branch
Converted and distributed by TomeVault — claim your Tome and manage your conversions.