Use when starting feature work that needs a branch, creating worktrees for isolation, making atomic commits during development, or completing a development branch via merge, PR, preserve, or discard
View on GitHubSelect agents to install to:
npx add-skill https://github.com/lgbarn/shipyard/blob/main/skills/git-workflow/SKILL.md -a claude-code --skill git-workflowInstallation paths:
.claude/skills/git-workflow/<!-- TOKEN BUDGET: 450 lines / ~1350 tokens --> # Git Workflow ## Activation Triggers - Starting feature work that needs branch isolation - Creating, switching, or removing worktrees - Completing a development branch (merge, PR, preserve, discard) - `/shipyard:worktree` command invoked ## Overview Comprehensive git workflow covering the full development lifecycle: branch creation, worktree isolation, atomic commits, and branch completion. **Core principle:** Systematic directory selection + safety verification + structured completion options = reliable development workflow. ## Part 1: Branch and Worktree Setup **Announce at start:** "I'm using the git-workflow skill to set up an isolated workspace." ### Directory Selection Process Follow this priority order: #### 1. Check Existing Directories ```bash # Check in priority order ls -d .worktrees 2>/dev/null # Preferred (hidden) ls -d worktrees 2>/dev/null # Alternative ``` **If found:** Use that directory. If both exist, `.worktrees` wins. #### 2. Check CLAUDE.md ```bash grep -i "worktree.*director" CLAUDE.md 2>/dev/null ``` **If preference specified:** Use it without asking. #### 3. Ask User If no directory exists and no CLAUDE.md preference: ``` No worktree directory found. Where should I create worktrees? 1. .worktrees/ (project-local, hidden) 2. ~/.config/shipyard/worktrees/<project-name>/ (global location) Which would you prefer? ``` ### Safety Verification **For Project-Local Directories (.worktrees or worktrees):** **MUST verify directory is ignored before creating worktree:** ```bash # Check if directory is ignored (respects local, global, and system gitignore) git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null ``` **If NOT ignored:** Fix immediately: 1. Add appropriate line to .gitignore 2. Commit the change 3. Proceed with worktree creation **Why critical:** Prevents accidentally committing worktree contents to repository. **For Global