Validate git operations won't affect protected branches or cause data loss
View on GitHubSelect agents to install to:
npx add-skill https://github.com/cowwoc/claude-code-cat/blob/main/plugin/skills/validate-git-safety/SKILL.md -a claude-code --skill validate-git-safetyInstallation paths:
.claude/skills/validate-git-safety/# Validate Git Safety Skill **Purpose**: Validate git history-rewriting operations won't affect protected branches or cause unintended data loss. ## When to Use - Before `git filter-branch` - Before `git rebase` with `--all` or `--branches` - Before any history-rewriting operation - Before deleting branches ## Protected Branch Patterns ### Version Branches (NEVER modify) - Pattern: `v[0-9]+` (e.g., v1, v13, v21) - Protection: NEVER delete, rewrite history, or force push ### Main/Master (careful modifications only) - Only fast-forward merges - No history rewriting ### Task Branches - Treat as immutable after completion ## Dangerous Commands ```bash # NEVER use --all with history rewriting git filter-branch --all git rebase --all # NEVER force push without explicit request git push --force git push -f # NEVER delete version branches git branch -D v21 # NEVER rebase shared branches git checkout main git rebase feature # Rewrites main! ``` ## Safe Alternatives ```bash # Target specific branch (not --all) git filter-branch main # Rebase feature onto main (not main onto feature) git checkout feature git rebase main # Use --force-with-lease instead of --force git push --force-with-lease # Move version branch pointer forward (not rewrite) git branch -f v21 <new-commit> ``` ## Worktree Verification (M101) **During CAT task execution, NEVER operate on the main `/workspace` worktree.** ```bash # Before ANY git operation in a CAT task, verify location: CURRENT_DIR=$(pwd) if [[ "$CURRENT_DIR" == "/workspace" ]] && [[ -d "/workspace/.worktrees" ]]; then echo "BLOCKED: Currently in main worktree while task worktrees exist" echo "Expected: /workspace/.worktrees/<task-name>" echo "Current: $CURRENT_DIR" exit 1 fi ``` **Check for active task worktrees:** ```bash # If any worktrees exist, you should be in one of them (not main) if ls -d /workspace/.worktrees/*/ 2>/dev/null | head -1 | grep -q .; then # Worktrees exist - verify we're in one if [[ "$(p