Automated summary
Manages Git worktrees for a monorepo: create, list, and cleanup with automatic dependency installation and GitHub issue validation.
Strengths
- Automates worktree creation from GitHub issues with issue state validation
- Automatically installs dependencies with pnpm after creation
- Provides a formatted table of active worktrees with ahead/behind status
- Cleans up worktrees whose branches have been merged into main
Limitations
- Specific to the USOPC monorepo directory structure
- Requires the GitHub CLI (`gh`) to be installed and configured
- Does not handle merge conflicts during cleanup
Use this skill to quickly create an isolated work environment for a GitHub issue, or to clean up stale worktrees after merging.
Do not use it if you are working outside the USOPC monorepo or if you prefer to manage worktrees manually with Git.
Security analysis
SafeThe skill only executes standard git worktree operations, pnpm install, and gh issue view, all applied locally within the repository. There is no command to fetch or execute external scripts, delete files outside controlled worktree paths, or exfiltrate data. The allowed tools are restricted to safe, legitimate development commands.
No concerns found
How this analysis is madeExamples
/worktree create 42/worktree list/worktree cleanupname: worktree description: Smart worktree management — create, list, and clean up git worktrees with automatic gotcha handling (pnpm install, hook script copy, issue validation). argument-hint: <create|list|cleanup> [issue-number] disable-model-invocation: true allowed-tools: Bash(git *), Bash(cd *), Bash(pnpm *), Bash(gh issue view *), Bash(gh repo view *), Bash(ls *), Glob, Read
Smart Worktree Management
You are managing git worktrees for the USOPC Athlete Support Agent monorepo. The argument is: $ARGUMENTS.
Parse the argument to determine the subcommand:
create <issue-number>— Create a new worktree for an issuelist— List active worktrees with statuscleanup— Remove worktrees whose branches have been merged
If no subcommand is provided or the argument is empty, print the usage:
Usage: /worktree <command> [args]
create <issue-number> — Create worktree for a GitHub issue
list — List active worktrees with branch status
cleanup — Remove merged worktrees and prune refs
Subcommand: create <issue-number>
Step 1: Validate the issue exists
Run gh issue view <issue-number> --json number,title,state to confirm the issue exists and is open. If the issue doesn't exist or is closed, warn the user and stop.
Step 2: Determine paths
- Get the main repo root:
git rev-parse --show-toplevel(if in a worktree, usegit worktree listto find the main repo) - Worktree path:
../usopc-issue-<number>relative to the main repo (i.e., a sibling directory) - Derive a short branch name from the issue title:
feat/<kebab-case-summary>(max 50 chars, lowercase, hyphens only)
Step 3: Fetch latest main
Run git fetch origin main to ensure we branch from the latest main.
Step 4: Create the worktree
git worktree add <worktree-path> -b <branch-name> origin/main
If the worktree path already exists, warn and stop.
Step 5: Install dependencies
cd <worktree-path> && pnpm install
Step 6: Print summary
Worktree created:
Path: <worktree-path>
Branch: <branch-name>
Issue: #<number> — <title>
Dependencies installed.
Navigate with: cd <worktree-path>
Subcommand: list
Step 1: List worktrees
Run git worktree list and parse the output.
Step 2: For each worktree (excluding bare/main)
- Show the path, branch name
- Run
git -C <path> log --oneline -1for latest commit - Run
git -C <path> rev-list --left-right --count origin/main...<branch>for ahead/behind status
Step 3: Print formatted table
Active worktrees:
../usopc-issue-42 feat/add-auth +3 / -0 (latest: abc1234 Add auth middleware)
../usopc-issue-55 fix/query-perf +1 / -2 (latest: def5678 Fix slow query)
Subcommand: cleanup
Step 1: List worktrees
Run git worktree list and identify non-main worktrees.
Step 2: Check each branch
For each worktree branch, check if it has been merged into origin/main:
git branch --merged origin/main | grep <branch-name>
Step 3: Remove merged worktrees
For each merged worktree, remove it:
git worktree remove <path>
Print which worktrees were removed.
Step 4: Prune and clean up
git worktree prune
git fetch --prune origin
Step 5: Print summary
Cleaned up:
Removed: ../usopc-issue-42 (feat/add-auth — merged)
Removed: ../usopc-issue-55 (fix/query-perf — merged)
Pruned stale worktree references.
If no worktrees were eligible for cleanup, say so.
Important notes
- Always use absolute paths when running git commands to avoid confusion between worktree and main repo.
- The main repo root can be found via
git worktree list— it's the first entry (the one without[branch]or with[main]). scripts/update-hours.mjsandscripts/stamp-readme-hours.mjsare tracked in git, so they'll be available in worktrees automatically — no copying needed.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/smart-git-worktree-management-mm5t8bfy/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/smart-git-worktree-management-mm5t8bfy' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/smart-git-worktree-management-mm5t8bfy/download' --output '.skill-downloads/smart-git-worktree-management-mm5t8bfy/SKILL.md.part' && mv '.skill-downloads/smart-git-worktree-management-mm5t8bfy/SKILL.md.part' '.skill-downloads/smart-git-worktree-management-mm5t8bfy/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Tools declared by the author (check availability in your agent): Bash(git *), Bash(cd *), Bash(pnpm *), Bash(gh issue view *), Bash(gh repo view *), Bash(ls *), Glob, Read
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/smart-git-worktree-management-mm5t8bfy/SKILL.md' && test -s '.skill-downloads/smart-git-worktree-management-mm5t8bfy/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/worktree' && cp -R '.skill-downloads/smart-git-worktree-management-mm5t8bfy' '.claude/skills/worktree'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/smart-git-worktree-management-mm5t8bfy'openskills read 'smart-git-worktree-management-mm5t8bfy'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/smart-git-worktree-management-mm5t8bfy/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.