autospec-worktree-setup
This Agent Skill is generated from autospec.worktree-setup. When the user invokes "$autospec-worktree-setup" or "/autospec.worktree-setup",
load and follow these instructions directly. Treat the text after the skill or
command name as "$ARGUMENTS". Do not route back through "autospec worktree-setup"; this skill
is the prompt for the stage.
Project specs directory: ./specs
User Input
$ARGUMENTS
You MUST consider the user input before proceeding (if not empty).
Outline
You are generating a project-specific setup script that will be run when creating new git worktrees. This script handles copying essential configuration files and running package manager install commands instead of copying large dependency directories.
Follow this execution flow:
Analyze project structure:
Identify package managers by checking for lockfiles:
package-lock.json -> npm
yarn.lock -> yarn
pnpm-lock.yaml -> pnpm
bun.lockb -> bun
go.sum or go.mod -> go
requirements.txt or Pipfile.lock -> pip/pipenv
poetry.lock or pyproject.toml with [tool.poetry] -> poetry
Cargo.lock -> cargo
Gemfile.lock -> bundler
composer.lock -> composer
Identify essential directories/files to copy:
Autospec-related (REQUIRED for autospec workflows):
.autospec/ - Contains constitution, config, memory, and generated scripts. The constitution.yaml is REQUIRED for all workflow stages (specify, plan, tasks, implement).
.agents/skills/ (if exists) - Shared autospec skills for Codex and OpenCode skill-aware sessions.
.claude/skills/ (if exists) - Claude Code project skills. Required if using agent_preset: claude.
opencode.json (if exists) - OpenCode configuration file with permissions and model settings. Located at project root, not inside .opencode/.
IDE/Editor configuration:
.vscode/ (if exists)
.idea/ (if exists)
- Other gitignored config directories needed for development
Identify files/directories to EXCLUDE:
- Dependency directories:
node_modules/, vendor/, __pycache__/, .venv/, venv/, target/, dist/, build/, .bundle/
- Generated files:
*.log, *.tmp, .cache/, coverage/
Handle secrets:
- By default, EXCLUDE these secret patterns:
.env* (.env, .env.local, .env.production, etc.)
credentials.*
secrets.*
*.pem
*.key
*.p12
*token* files
.ssh/
- If
--include-env was specified in the user input, include .env* files but still exclude other secret patterns
Generate the setup script:
Create a POSIX-compatible bash script at .autospec/scripts/setup-worktree.sh with the following structure:
#!/bin/bash
# setup-worktree.sh - Project-specific worktree setup script
# Generated by autospec worktree gen-script
#
# Usage: Called automatically by 'autospec worktree create' or run manually:
# ./setup-worktree.sh <worktree_path>
#
# Environment variables (set by worktree create command):
# WORKTREE_PATH - Path to the new worktree
# WORKTREE_NAME - Name of the worktree
# WORKTREE_BRANCH - Branch checked out in worktree
# SOURCE_REPO - Path to source repository
set -euo pipefail
# Get worktree path from argument or environment
WORKTREE_PATH="${1:-${WORKTREE_PATH:-}}"
SOURCE_REPO="${SOURCE_REPO:-$(git rev-parse --show-toplevel)}"
if [ -z "$WORKTREE_PATH" ]; then
echo "Error: Worktree path required. Usage: $0 <worktree_path>"
exit 1
fi
echo "Setting up worktree at: $WORKTREE_PATH"
echo "Source repository: $SOURCE_REPO"
# Function to copy directory if it exists
copy_if_exists() {
local src="$SOURCE_REPO/$1"
local dst="$WORKTREE_PATH/$1"
if [ -d "$src" ]; then
echo "Copying $1..."
mkdir -p "$(dirname "$dst")"
cp -r "$src" "$dst"
fi
}
# Copy essential configuration directories
# Autospec-related (REQUIRED for autospec workflows)
copy_if_exists ".autospec" # Constitution, config, memory, scripts
copy_if_exists ".agents/skills" # Shared Codex/OpenCode skills
copy_if_exists ".claude/skills" # Claude Code project skills
# Copy OpenCode config file if it exists
if [ -f "$SOURCE_REPO/opencode.json" ]; then
echo "Copying opencode.json..."
cp "$SOURCE_REPO/opencode.json" "$WORKTREE_PATH/opencode.json"
fi
# IDE/Editor configuration (if detected)
# copy_if_exists ".vscode"
# copy_if_exists ".idea"
# Run package manager install commands
cd "$WORKTREE_PATH"
# (Include detected package manager commands)
echo "Worktree setup complete!"
Ensure the script:
- Uses POSIX-compatible bash (no bashisms)
- Is idempotent (safe to run multiple times)
- Handles missing directories gracefully
- Provides clear output about what it's doing
- Exits with appropriate error codes
Create output directory:
- Ensure
.autospec/scripts/ directory exists
- Write the script to
.autospec/scripts/setup-worktree.sh
- Make it executable (the CLI will set permissions)
Report results:
- List directories that will be copied
- List package manager commands that will be run
- Note any secrets that are being excluded
- If
--include-env was used, warn about security implications
Output Location
The generated script MUST be written to: .autospec/scripts/setup-worktree.sh
Important Constraints
- The script must work with the existing
autospec worktree create command
- Secrets are NEVER copied by default - this is a security requirement
- Dependency directories are NEVER copied - install commands are run instead
- The script must be readable and well-commented for user customization
Source: ariel-frischer/autospec — distributed by TomeVault.
1---2name: autospec-worktree-setup3description: Generate project-specific worktree setup script based on project analysis. Use when this capability is needed.4---56# autospec-worktree-setup78This Agent Skill is generated from autospec.worktree-setup. When the user invokes "$autospec-worktree-setup" or "/autospec.worktree-setup",9load and follow these instructions directly. Treat the text after the skill or10command name as "$ARGUMENTS". Do not route back through "autospec worktree-setup"; this skill11is the prompt for the stage.1213Project specs directory: ./specs1415## User Input1617```text18$ARGUMENTS19```2021You **MUST** consider the user input before proceeding (if not empty).2223## Outline2425You are generating a project-specific setup script that will be run when creating new git worktrees. This script handles copying essential configuration files and running package manager install commands instead of copying large dependency directories.2627Follow this execution flow:28291. **Analyze project structure**:30 - Identify package managers by checking for lockfiles:31 - `package-lock.json` -> npm32 - `yarn.lock` -> yarn33 - `pnpm-lock.yaml` -> pnpm34 - `bun.lockb` -> bun35 - `go.sum` or `go.mod` -> go36 - `requirements.txt` or `Pipfile.lock` -> pip/pipenv37 - `poetry.lock` or `pyproject.toml` with `[tool.poetry]` -> poetry38 - `Cargo.lock` -> cargo39 - `Gemfile.lock` -> bundler40 - `composer.lock` -> composer41 - Identify essential directories/files to copy:4243 **Autospec-related (REQUIRED for autospec workflows):**44 - `.autospec/` - Contains constitution, config, memory, and generated scripts. The `constitution.yaml` is REQUIRED for all workflow stages (specify, plan, tasks, implement).45 - `.agents/skills/` (if exists) - Shared autospec skills for Codex and OpenCode skill-aware sessions.46 - `.claude/skills/` (if exists) - Claude Code project skills. Required if using `agent_preset: claude`.47 - `opencode.json` (if exists) - OpenCode configuration file with permissions and model settings. Located at project root, not inside `.opencode/`.4849 **IDE/Editor configuration:**50 - `.vscode/` (if exists)51 - `.idea/` (if exists)52 - Other gitignored config directories needed for development53 - Identify files/directories to EXCLUDE:54 - Dependency directories: `node_modules/`, `vendor/`, `__pycache__/`, `.venv/`, `venv/`, `target/`, `dist/`, `build/`, `.bundle/`55 - Generated files: `*.log`, `*.tmp`, `.cache/`, `coverage/`56572. **Handle secrets**:58 - By default, EXCLUDE these secret patterns:59 - `.env*` (`.env`, `.env.local`, `.env.production`, etc.)60 - `credentials.*`61 - `secrets.*`62 - `*.pem`63 - `*.key`64 - `*.p12`65 - `*token*` files66 - `.ssh/`67 - If `--include-env` was specified in the user input, include `.env*` files but still exclude other secret patterns68693. **Generate the setup script**:7071 Create a POSIX-compatible bash script at `.autospec/scripts/setup-worktree.sh` with the following structure:7273 ```bash74 #!/bin/bash75 # setup-worktree.sh - Project-specific worktree setup script76 # Generated by autospec worktree gen-script77 #78 # Usage: Called automatically by 'autospec worktree create' or run manually:79 # ./setup-worktree.sh <worktree_path>80 #81 # Environment variables (set by worktree create command):82 # WORKTREE_PATH - Path to the new worktree83 # WORKTREE_NAME - Name of the worktree84 # WORKTREE_BRANCH - Branch checked out in worktree85 # SOURCE_REPO - Path to source repository8687 set -euo pipefail8889 # Get worktree path from argument or environment90 WORKTREE_PATH="${1:-${WORKTREE_PATH:-}}"91 SOURCE_REPO="${SOURCE_REPO:-$(git rev-parse --show-toplevel)}"9293 if [ -z "$WORKTREE_PATH" ]; then94 echo "Error: Worktree path required. Usage: $0 <worktree_path>"95 exit 196 fi9798 echo "Setting up worktree at: $WORKTREE_PATH"99 echo "Source repository: $SOURCE_REPO"100101 # Function to copy directory if it exists102 copy_if_exists() {103 local src="$SOURCE_REPO/$1"104 local dst="$WORKTREE_PATH/$1"105 if [ -d "$src" ]; then106 echo "Copying $1..."107 mkdir -p "$(dirname "$dst")"108 cp -r "$src" "$dst"109 fi110 }111112 # Copy essential configuration directories113 # Autospec-related (REQUIRED for autospec workflows)114 copy_if_exists ".autospec" # Constitution, config, memory, scripts115 copy_if_exists ".agents/skills" # Shared Codex/OpenCode skills116 copy_if_exists ".claude/skills" # Claude Code project skills117118 # Copy OpenCode config file if it exists119 if [ -f "$SOURCE_REPO/opencode.json" ]; then120 echo "Copying opencode.json..."121 cp "$SOURCE_REPO/opencode.json" "$WORKTREE_PATH/opencode.json"122 fi123124 # IDE/Editor configuration (if detected)125 # copy_if_exists ".vscode"126 # copy_if_exists ".idea"127128 # Run package manager install commands129 cd "$WORKTREE_PATH"130 # (Include detected package manager commands)131132 echo "Worktree setup complete!"133 ```1341354. **Ensure the script**:136 - Uses POSIX-compatible bash (no bashisms)137 - Is idempotent (safe to run multiple times)138 - Handles missing directories gracefully139 - Provides clear output about what it's doing140 - Exits with appropriate error codes1411425. **Create output directory**:143 - Ensure `.autospec/scripts/` directory exists144 - Write the script to `.autospec/scripts/setup-worktree.sh`145 - Make it executable (the CLI will set permissions)1461476. **Report results**:148 - List directories that will be copied149 - List package manager commands that will be run150 - Note any secrets that are being excluded151 - If `--include-env` was used, warn about security implications152153## Output Location154155The generated script MUST be written to: `.autospec/scripts/setup-worktree.sh`156157## Important Constraints158159- The script must work with the existing `autospec worktree create` command160- Secrets are NEVER copied by default - this is a security requirement161- Dependency directories are NEVER copied - install commands are run instead162- The script must be readable and well-commented for user customization163164---165> Source: [ariel-frischer/autospec](https://github.com/ariel-frischer/autospec) — distributed by [TomeVault](https://tomevault.io).166<!-- tomevault:4.0:skill_md:2026-06-27 -->