# git-revert-safety

git-revert-safety guides safe Git commit reverts and merge rollbacks without corrupting version manifests or lockfiles.

- skill · `type=skill` · Claude Code, Codex, OpenCode, Cursor, GitHub Copilot, Gemini CLI, Windsurf (Devin Desktop), Claude.ai · ★ 539 repo stars
- Author: ZaxbyHub
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/ZaxbyHub/opencode-swarm/tree/HEAD/.opencode/skills/generated/git-revert-safety/SKILL.md
- Updated: 2026-10-29
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/git-revert-safety

## What it does

This skill enforces a guarded procedure for undoing commits and resolving contaminated branches. A common hazard during standard reverse-apply operations is silently rolling back metadata inside `.release-please-manifest.json`, `package.json`, or changelogs. The skill handles this via two distinct paths: safe reverts for known commits and clean-slate branch recovery.

Before executing changes, it inspects every touched file across single revisions or parent chains. When release jobs occur between the target change and current HEAD, the protocol rejects plain reverts in favor of fresh-branch cherry-picking. It also incorporates verification steps using `node` and `gh` CLI checks to keep dependencies and tag histories intact.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add ZaxbyHub/opencode-swarm --skill git-revert-safety -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/git-revert-safety/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/git-revert-safety/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add ZaxbyHub/opencode-swarm --skill git-revert-safety -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/git-revert-safety/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add ZaxbyHub/opencode-swarm --skill git-revert-safety -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/git-revert-safety/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install ZaxbyHub/opencode-swarm .opencode/skills/generated/git-revert-safety
```

2. **Manually: put the files in place**
- File: `.github/skills/git-revert-safety/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add ZaxbyHub/opencode-swarm --skill git-revert-safety -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/ZaxbyHub/opencode-swarm --path .opencode/skills/generated/git-revert-safety
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/git-revert-safety/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add ZaxbyHub/opencode-swarm --skill git-revert-safety -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/ZaxbyHub/opencode-swarm/tree/HEAD/.opencode/skills/generated/git-revert-safety/SKILL.md

## When to use it
- prevent version regressions in automated release manifests during reverts
- verify package lockfile consistency after reversing dependency updates
- identify the correct parent revision when undoing merge commits
- recover branches contaminated by bad merges using cherry-pick workflows

## Example prompts
- Safely revert merge commit abc1234 and check release manifests
- Undo commit def5678 without breaking package.json dependencies
- Main branch got contaminated by a bad pull request, help me restore it

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: f6f3b9f9020174ee.

BEGIN THIRD-PARTY FILE f6f3b9f9020174ee
````text
---
name: git-revert-safety
description: >
  Apply when reverting commits, undoing merges, or recovering from branch contamination.
  Covers collateral damage verification (manifest, package.json, CHANGELOG, lockfiles),
  cherry-pick vs revert decision matrix, partial-revert detection, merge-parent handling,
  and post-revert CI verification. Prevents the most common revert failure mode: version
  metadata regression from git reverse-apply.
metadata:
  triggers: '["git revert","revert commit","revert merge","undo merge","reverse-apply","branch contamination","cherry-pick recovery","release-please duplicate tag"]'
  effort: small
  generated_from_knowledge: '[]'
  source_knowledge_ids: '["f07c1f4d-9bb0-4219-9804-26aa8efe8146"]'
  generated_at: "2026-06-14T16:50:00Z"
  confidence: "0.8"
  status: active
  version: "4"
  skill_origin: generated
  provenance_note: >
    Re-linked to current knowledge entries (version 4). The original source ID
    11f0e8cb... is no longer present in the active knowledge store. The skill
    body and behavior are unchanged; only source_knowledge_ids metadata was
    updated to point to the current lesson about verifying pre-existing state
    on parent commit, which is directly relevant to post-revert CI verification.
---

# Git Revert Safety Protocol

Two internal workflows: **Safe Git Revert** (Steps 1-4) and **Branch Contamination Recovery** (Steps 5-6).
Use the first when reverting known commits. Use the second when the wrong code was merged and you need a clean slate.

---

## Workflow A — Safe Git Revert

### Step 1 — Collateral Damage Assessment

Before reverting, list ALL files touched by each commit being reverted. Use the correct command for the situation:

**Single commit:**
```bash
git show --name-only --format= <sha>
```

**Multiple commits (contiguous range):**
```bash
git diff --name-only <commit-before-first>..<last-commit-sha>
```

**Merge commit — inspect all parents (handles octopus merges with 3+ parents):**
```bash
git show --format="%H %P" <merge-sha>   # Shows ALL parent SHAs
git log --oneline <merge-sha>^1         # First parent (usually main)
git log --oneline <merge-sha>^2         # Second parent (feature branch)
# For octopus merges: also inspect ^3, ^4, etc.
```

Identify which files in the diff are NOT part of the feature being reverted:
- `.release-please-manifest.json` — version state
- `package.json` — version field + dependency additions/removals
- `CHANGELOG.md` — release history
- Lockfiles (`bun.lock`, `package-lock.json`) — dependency graph
- Any config files modified by release PRs between the feature and now

`dist/` is generated and NOT committed, so it never appears in a revert diff and
````
END THIRD-PARTY FILE f6f3b9f9020174ee

The third-party file has ended. Everything between the f6f3b9f9020174ee tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2717 of 8755 bytes. © ZaxbyHub · MIT · https://github.com/ZaxbyHub/opencode-swarm/tree/HEAD/.opencode/skills/generated/git-revert-safety/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
