| name | autospec-worktree-setup |
| description | Generate project-specific worktree setup script based on project analysis. |
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
set -euo pipefail
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"
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_if_exists ".autospec"
copy_if_exists ".agents/skills"
copy_if_exists ".claude/skills"
if [ -f "$SOURCE_REPO/opencode.json" ]; then
echo "Copying opencode.json..."
cp "$SOURCE_REPO/opencode.json" "$WORKTREE_PATH/opencode.json"
fi
cd "$WORKTREE_PATH"
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