一键导入
validate-git-safety
MANDATORY: Run before git push --force, rebase, or reset to verify safety
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
MANDATORY: Run before git push --force, rebase, or reset to verify safety
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Guide for writing clear, descriptive commit messages
Merge task branch to base branch with linear history (works from task worktree)
MANDATORY: Use instead of `git rebase` - provides automatic backup and conflict recovery
MANDATORY: Use instead of `git rebase -i` for squashing - unified commit messages
Analyze mistakes with conversation length as potential cause (CAT-specific)
Run scheduled retrospective analysis, derive action items, and track effectiveness
| name | validate-git-safety |
| description | MANDATORY: Run before git push --force, rebase, or reset to verify safety |
Purpose: Validate git history-rewriting operations won't affect protected branches or cause unintended data loss.
git filter-branchgit rebase with --all or --branchesv[0-9]+ (e.g., v1, v13, v21)# 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!
# 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>
During CAT task execution, NEVER operate on the main /workspace worktree.
# 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:
# 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 [[ "$(pwd)" == "/workspace" ]]; then
echo "ERROR: Task worktrees exist but operating on main"
ls /workspace/.worktrees/
exit 1
fi
fi
Before any history-rewriting operation:
git branch -agit branch | grep -E "^ v[0-9]+"git branch backup-before-op-$(date +%Y%m%d-%H%M%S)# Before running dangerous command, check:
COMMAND="git filter-branch --tree-filter 'rm secrets.txt' HEAD"
# Check for dangerous flags
if echo "$COMMAND" | grep -qE "(--all|--branches)"; then
echo "BLOCKED: --all/--branches affects protected branches"
echo "Use: git filter-branch <branch-name>"
exit 1
fi
# Check target isn't version branch
TARGET=$(echo "$COMMAND" | grep -oE "v[0-9]+")
if [[ -n "$TARGET" ]]; then
echo "BLOCKED: Cannot modify version branch $TARGET"
exit 1
fi
echo "Command appears safe"
# If version branch history was modified:
# 1. Check reflog for original position
git reflog show v21
# 2. Reset to original commit
git branch -f v21 v21@{1}
# 3. Verify restored
git log v21 -5 --oneline