worktree-setup-hook
Post-checkout git hook for automatic worktree setup. Use when: (1) Setting up automatic configuration for new git worktrees, (2) Creating post-checkout hooks that detect new worktrees and run setup tasks, (3) Configuring worktrees to automatically copy env files and install dependencies
Best use case
worktree-setup-hook is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Post-checkout git hook for automatic worktree setup. Use when: (1) Setting up automatic configuration for new git worktrees, (2) Creating post-checkout hooks that detect new worktrees and run setup tasks, (3) Configuring worktrees to automatically copy env files and install dependencies
Teams using worktree-setup-hook should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/worktree-setup-hook/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How worktree-setup-hook Compares
| Feature / Agent | worktree-setup-hook | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Post-checkout git hook for automatic worktree setup. Use when: (1) Setting up automatic configuration for new git worktrees, (2) Creating post-checkout hooks that detect new worktrees and run setup tasks, (3) Configuring worktrees to automatically copy env files and install dependencies
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Worktree Setup Hook Provides a post-checkout git hook template that automatically configures new git worktrees by detecting new worktree creation and running setup tasks. ## Overview The hook detects when a new worktree is created (not a regular checkout) and automatically: - Copies environment files (.env, .env.local, etc.) - Detects the project's package manager and installs dependencies - Runs setup scripts if available ## Quick Start Install the hook template: ```bash cp .cursor/skills/worktree-setup-hook/assets/hook-templates/post-checkout .git/hooks/post-checkout chmod +x .git/hooks/post-checkout ``` The hook will automatically run after `git worktree add` completes. ## How It Works ### Worktree Detection The hook detects new worktrees by checking if the previous HEAD is the null-ref (`0000000000000000000000000000000000000000`). This is how git indicates a new worktree creation. ### Setup Tasks 1. **Environment Files**: Copies `.env.example` to `.env`, `.env.local.example` to `.env.local`, or copies env files from the main worktree 2. **Package Manager Detection**: Automatically detects and installs dependencies: - `package.json` → npm or yarn - `requirements.txt` → pip - `Cargo.toml` → cargo - `go.mod` → go - `Gemfile` → bundle 3. **Setup Scripts**: Runs `setup.sh` or `scripts/setup.sh` if present and executable ## Installation See [setup-guide.md](references/setup-guide.md) for detailed installation instructions, including: - Step-by-step installation - Handling existing hooks - Backup procedures - Troubleshooting ## Customization The hook is a standard POSIX shell script. Edit `.git/hooks/post-checkout` to add custom setup steps or modify behavior. ## Resources - **Hook Template**: `assets/hook-templates/post-checkout` - The main hook script - **Setup Guide**: `references/setup-guide.md` - Detailed installation and configuration instructions
Related Skills
coderabbit-cli
Use CodeRabbit CLI to perform automated code review and iterative improvement in an AI agent workflow. Use when: (1) After generating non-trivial code (new features, refactors, algorithms), (2) Improving code quality, maintainability, or readability before submission, (3) Validating code changes against best practices, (4) Exploring unfamiliar languages, patterns, or domains, or (5) Creating a self-reviewing coding loop. Requires CodeRabbit CLI installed and authenticated. Not for trivial changes (typos, formatting-only) or rapid prototyping without quality constraints.
ai-rules-cli
Use ai-rules CLI to manage and synchronize AI coding rules across multiple AI assistants (Cursor, Claude Code, GitHub Copilot, Opencode, etc.). Use when: (1) Setting up ai-rules in a new project, (2) Updating AI coding guidelines and best practices, (3) Generating platform-specific rule files from source, (4) Checking if generated files are in sync with source files, (5) Managing multi-agent rule consistency, or (6) Adding new rules or modifying existing ones. Requires ai-rules CLI installed. The ai-rules/ directory serves as the single source of truth for all AI coding guidelines.
skill-creator
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
GitHub CLI Operations
Use GitHub CLI (gh) to interact with GitHub repositories, pull requests, issues, and workflows. Use when: (1) Reading PR details, diffs, or metadata, (2) Listing or filtering PRs and issues, (3) Creating PR comments or linking to issues, (4) Checking CI status or mergeability, (5) Extracting issue references from PR descriptions, or (6) Any GitHub repository operation via command line. Requires GitHub CLI installed and authenticated.
git-workspace
Work with git worktrees and workspaces for concurrent development. Use when: (1) Creating new workspaces with \`git worktree add\`, (2) Listing existing worktrees with \`git worktree list\`, (3) Removing worktrees with \`git worktree remove\`, (4) Pruning stale worktree metadata with \`git worktree prune\`, (5) Managing multiple checked-out branches simultaneously, (6) Migrating uncommitted work between workspaces, or (7) Any git workspace/worktree operation. Requires Git 2.5+ for worktree support.
create-slash-command
Create new slash commands for DevAgent workflows. Use when you need to create a new command file in .agents/commands/ and symlink it to .cursor/commands/ for Cursor IDE integration. This skill handles the complete command creation workflow including file generation, symlink creation, and structure validation.
git-hooks-automation
Master Git hooks setup with Husky, lint-staged, pre-commit framework, and commitlint. Automate code quality gates, formatting, linting, and commit message enforcement before code reaches CI.
expo-tailwind-setup
Set up Tailwind CSS v4 in Expo with react-native-css and NativeWind v5 for universal styling
environment-setup-guide
Guide developers through setting up development environments with proper tools, dependencies, and configurations
devcontainer-setup
Creates devcontainers with Claude Code, language-specific tooling (Python/Node/Rust/Go), and persistent volumes. Use when adding devcontainer support to a project, setting up isolated development environments, or configuring sandboxed Claude Code workspaces.
conductor-setup
Configure a Rails project to work with Conductor (parallel coding agents)
worktree-manager
Create, manage, and cleanup git worktrees with Claude Code agents across all projects. USE THIS SKILL when user says "create worktree", "spin up worktrees", "new worktree for X", "worktree status", "cleanup worktrees", "sync worktrees", or wants parallel development branches. Also use when creating PRs from a worktree branch (to update registry with PR number). Handles worktree creation, dependency installation, validation, agent launching in Ghostty, and global registry management.