autospec-worktree-setup
Skill150 starsChanged 2 months agoMITView on GitHub
Generate project-specific worktree setup script based on project analysis.
- Reads credentials
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- autospec-analyzeSkill
- autospec-checklistSkill
- autospec-clarifySkill
- autospec-constitutionSkill
- autospec-implementSkill
- autospec-planSkill
- autospec-specifySkill
- autospec-tasksSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 27
Follow this execution flow:
- Very specific: line 67
If --include-env was specified in the user input, include .env* files but still exclude other secret patterns
- Very specific: line 71
Create a POSIX-compatible bash script at .autospec/scripts/setup-worktree.sh with the following structure:
- Very specific: line 143
Ensure .autospec/scripts/ directory exists
- Very specific: line 144
Write the script to .autospec/scripts/setup-worktree.sh
- Very specific: line 151
If --include-env was used, warn about security implications
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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
$ARGUMENTSYou 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-> npmyarn.lock-> yarnpnpm-lock.yaml-> pnpmbun.lockb-> bungo.sumorgo.mod-> gorequirements.txtorPipfile.lock-> pip/pipenvpoetry.lockorpyproject.tomlwith[tool.poetry]-> poetryCargo.lock-> cargoGemfile.lock-> bundlercomposer.lock-> composer
Identify essential directories/files to copy:
Autospec-related (REQUIRED for autospec workflows):
.autospec/- Contains constitution, config, memory, and generated scripts. Theconstitution.yamlis 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 usingagent_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/
- Dependency directories:
- Identify package managers by checking for lockfiles:
- 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-envwas specified in the user input, include.env*files but still exclude other secret patterns
- By default, EXCLUDE these secret patterns:
Generate the setup script:
Create a POSIX-compatible bash script at
.autospec/scripts/setup-worktree.shwith 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)
- Ensure
- 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-envwas 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 createcommand - 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
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

