Comprehensive rollback system with multiple methods and automatic USER content preservation.
Rollback
This skill provides safe rollback operations with comprehensive validation and USER section preservation.
Usage
bunx forge rollback
Interactive menu with 6 options:
- Rollback last commit - Quick undo of most recent change
- Rollback specific commit - Target any commit by hash
- Rollback merged PR - Revert an entire PR merge
- Rollback specific files - Restore only certain files
- Rollback entire branch - Revert multiple commits
- Preview rollback - Dry run mode (shows changes without executing)
How It Works
Safety Features
1. Working Directory Check
- Requires clean working directory (no uncommitted changes)
- Prevents accidental data loss
- Prompts to commit or stash changes first
2. Input Validation
- Commit hashes: Must match
/^[0-9a-f]{4,40}$/i or be 'HEAD'
- File paths: Validated to be within project (prevents path traversal)
- Methods: Whitelisted to 'commit', 'pr', 'partial', 'branch'
- Shell metacharacters: Rejected (
;, |, &, $, `, (, ), <, >, \n, \r)
3. USER Section Preservation
- Automatically extracts USER sections before rollback
- Restores USER sections after rollback
- Preserves custom commands in
.claude/commands/custom/
- Amends rollback commit to include restored content
4. Dry Run Mode
- Preview affected files without executing
- Shows what would change
- No git operations performed
5. Non-Destructive
- Uses
git revert (creates new commit)
- Never uses
git reset --hard (destructive)
- Preserves full git history
- Can be undone with another rollback
USER Section Preservation
What Gets Preserved:
<!-- USER:START -->
Your custom content here
<!-- USER:END -->
<!-- USER:START:custom-name -->
Named USER section
<!-- USER:END:custom-name -->
Process:
- Extract all USER sections from AGENTS.md, CLAUDE.md, etc.
- Backup custom commands from
.claude/commands/custom/
- Execute rollback operation
- Restore USER sections to current file content
- Restore custom command files
- Amend rollback commit to include restored content
Result: Your customizations survive rollback operations.
Rollback methods
Six methods, selected interactively. Full step-by-step walkthroughs (commands,
prompts, expected output) are in references/methods.md —
read it when running a specific rollback.
- Rollback last commit — undo the most recent commit.
- Rollback specific commit — revert one commit by hash.
- Rollback merged PR — revert a merge commit.
- Rollback specific files — restore named files from the previous commit.
- Rollback entire branch — reset a range.
- Preview (dry run) — show what a rollback would do, change nothing.
Integration, issue status & troubleshooting
When to reach for rollback, how it fits the workflow, how revert state is recorded,
and error recovery are in
references/workflow-integration.md.
1---2name: rollback3description: Safely undo committed or shipped changes with non-destructive git revert or restore. Use only when the user explicitly asks to roll back, revert, undo, back out, or restore; never reset hard, force-push, or substitute for PR review, monitoring, or issue status work.4---56Comprehensive rollback system with multiple methods and automatic USER content preservation.78# Rollback910This skill provides safe rollback operations with comprehensive validation and USER section preservation.1112## Usage1314```bash15bunx forge rollback16```1718Interactive menu with 6 options:191. **Rollback last commit** - Quick undo of most recent change202. **Rollback specific commit** - Target any commit by hash213. **Rollback merged PR** - Revert an entire PR merge224. **Rollback specific files** - Restore only certain files235. **Rollback entire branch** - Revert multiple commits246. **Preview rollback** - Dry run mode (shows changes without executing)2526## How It Works2728### Safety Features2930**1. Working Directory Check**31- Requires clean working directory (no uncommitted changes)32- Prevents accidental data loss33- Prompts to commit or stash changes first3435**2. Input Validation**36- Commit hashes: Must match `/^[0-9a-f]{4,40}$/i` or be 'HEAD'37- File paths: Validated to be within project (prevents path traversal)38- Methods: Whitelisted to 'commit', 'pr', 'partial', 'branch'39- Shell metacharacters: Rejected (`;`, `|`, `&`, `$`, `` ` ``, `(`, `)`, `<`, `>`, `\n`, `\r`)4041**3. USER Section Preservation**42- Automatically extracts USER sections before rollback43- Restores USER sections after rollback44- Preserves custom commands in `.claude/commands/custom/`45- Amends rollback commit to include restored content4647**4. Dry Run Mode**48- Preview affected files without executing49- Shows what would change50- No git operations performed5152**5. Non-Destructive**53- Uses `git revert` (creates new commit)54- Never uses `git reset --hard` (destructive)55- Preserves full git history56- Can be undone with another rollback5758### USER Section Preservation5960**What Gets Preserved**:61```markdown62<!-- USER:START -->63Your custom content here64<!-- USER:END -->6566<!-- USER:START:custom-name -->67Named USER section68<!-- USER:END:custom-name -->69```7071**Process**:721. Extract all USER sections from AGENTS.md, CLAUDE.md, etc.732. Backup custom commands from `.claude/commands/custom/`743. Execute rollback operation754. Restore USER sections to current file content765. Restore custom command files776. Amend rollback commit to include restored content7879**Result**: Your customizations survive rollback operations.8081## Rollback methods8283Six methods, selected interactively. Full step-by-step walkthroughs (commands,84prompts, expected output) are in [references/methods.md](references/methods.md) —85read it when running a specific rollback.86871. **Rollback last commit** — undo the most recent commit.882. **Rollback specific commit** — revert one commit by hash.893. **Rollback merged PR** — revert a merge commit.904. **Rollback specific files** — restore named files from the previous commit.915. **Rollback entire branch** — reset a range.926. **Preview (dry run)** — show what a rollback would do, change nothing.9394## Integration, issue status & troubleshooting9596When to reach for rollback, how it fits the workflow, how revert state is recorded,97and error recovery are in98[references/workflow-integration.md](references/workflow-integration.md).