Agent skill
worktree-setup
Create an isolated git worktree with a feature branch for PACT workflows. Use when: starting a new feature, beginning orchestrate or comPACT, creating sub-scope isolation for ATOMIZE, or manually isolating work. Triggers on: worktree setup, feature isolation, parallel workflow, new worktree.
Install this agent skill to your Project
npx add-skill https://github.com/Synaptic-Labs-AI/PACT-Plugin/tree/main/pact-plugin/skills/worktree-setup
SKILL.md
Worktree Setup
Create an isolated git worktree with a feature branch for PACT workflows. This provides filesystem isolation so multiple features or sub-scopes can run in parallel without interference.
When to Use
- Starting a new feature workflow (
/PACT:orchestrate,/PACT:comPACT) - ATOMIZE phase creating sub-scope isolation
- Manually isolating work for a feature branch
Process
Follow these steps in order. Stop and report any errors to the user.
Step 1: Check for Existing Worktree
Before creating anything, check if a worktree already exists for this branch.
git worktree list
- If a worktree for the target branch already exists, reuse it. Report: "Reusing existing worktree at {path}" and skip to Step 4.
- If the worktree appears in the list but is marked prunable, run
git worktree prunefirst and proceed to create a new one.
- If the worktree appears in the list but is marked prunable, run
- If the branch exists but has no worktree, ask the user: "Branch
{branch}already exists. Check out existing branch, or create a new branch name?"
Step 2: Ensure .worktrees/ Directory
All worktrees live in .worktrees/ relative to the repo root.
# Get main repo root (from a worktree, returns absolute path; from main repo, returns relative .git — the cd && pwd wrapper normalizes both to absolute)
MAIN_GIT_DIR=$(git rev-parse --git-common-dir)
REPO_ROOT=$(cd "$(dirname "$MAIN_GIT_DIR")" && pwd)
# Create directory and ensure gitignored
mkdir -p "$REPO_ROOT/.worktrees"
grep -q '\.worktrees' "$REPO_ROOT/.gitignore" 2>/dev/null || echo '.worktrees/' >> "$REPO_ROOT/.gitignore"
Step 3: Create the Worktree
git worktree add "$REPO_ROOT/.worktrees/{branch}" -b {branch}
Where {branch} is the feature branch name (e.g., feature-auth or feature-auth--backend for sub-scopes).
If creation fails:
- Branch already exists: Ask user whether to check out the existing branch (
git worktree add "$REPO_ROOT/.worktrees/{branch}" {branch}without-b) - Disk/permissions error: Surface git's error message and offer fallback to working in the main repo directory
Step 4: Report
Output the result:
Worktree ready at {REPO_ROOT}/.worktrees/{branch}
Branch: {branch}
Return the worktree path so it can be passed to subsequent phases and agents.
Edge Cases
| Case | Handling |
|---|---|
| Already in a worktree for this feature | Detect via git worktree list, reuse existing |
| Worktree directory exists but is stale | Run git worktree prune first, then retry |
| Branch name already exists | Ask user: check out existing or create new name |
| Creation fails (disk/permissions) | Surface error, offer fallback to main repo |
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
n8n-code-javascript
Write JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using $input/$json/$node syntax, making HTTP requests with $helpers, working with dates using DateTime, troubleshooting Code node errors, or choosing between Code node modes.
n8n-node-configuration
Operation-aware node configuration guidance. Use when configuring nodes, understanding property dependencies, determining required fields, choosing between get_node detail levels, or learning common configuration patterns by node type.
pact-coding-standards
Clean code principles, error handling patterns, and coding standards for PACT Code phase. Use when: implementing features, refactoring code, reviewing code quality, establishing coding conventions, or handling errors and exceptions. Triggers on: code quality, clean code, refactoring, error handling, logging patterns, naming conventions, code review, code phase.
pact-handoff-harvest
HANDOFF discovery, review, save, and cleanup workflow for the PACT secretary. Use when: processing agent HANDOFFs after workflow phases, running session consolidation, or recovering orphaned breadcrumbs from prior sessions. Triggers: harvest HANDOFFs, process HANDOFFs, incremental, consolidation, breadcrumb recovery.
n8n-code-python
Write Python code in n8n Code nodes. Use when writing Python in n8n, using _input/_json/_node syntax, working with standard library, or need to understand Python limitations in n8n Code nodes.
n8n-workflow-patterns
Proven workflow architectural patterns from real n8n workflows. Use when building new workflows, designing workflow structure, choosing workflow patterns, planning workflow architecture, or asking about webhook processing, HTTP API integration, database operations, AI agent workflows, or scheduled tasks.
Didn't find tool you were looking for?