.codex/skills/rollback/SKILL.md
Safely rollback changes with USER section preservation
npx skillsauth add harshanandak/forge .codex/skills/rollbackInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Comprehensive rollback system with multiple methods and automatic USER content preservation.
This command provides safe rollback operations with comprehensive validation and USER section preservation.
bunx forge rollback
Interactive menu with 6 options:
1. Working Directory Check
2. Input Validation
/^[0-9a-f]{4,40}$/i or be 'HEAD';, |, &, $, `, (, ), <, >, \n, \r)3. USER Section Preservation
.claude/commands/custom/4. Dry Run Mode
5. Non-Destructive
git revert (creates new commit)git reset --hard (destructive)What Gets Preserved:
<!-- USER:START -->
Your custom content here
<!-- USER:END -->
<!-- USER:START:custom-name -->
Named USER section
<!-- USER:END:custom-name -->
Process:
.claude/commands/custom/Result: Your customizations survive rollback operations.
Use when: Quick undo of most recent change
How it works:
git revert HEAD --no-edit
Example:
bunx forge rollback
# Select: 1. Rollback last commit
✓ Working directory is clean
✓ Extracting USER sections...
✓ Executing: git revert HEAD --no-edit
✓ Restoring USER sections...
✓ Amended commit to preserve USER content
Rollback complete!
Commit: a1b2c3d "Revert: add authentication feature"
Files affected: 5
Use when: Need to revert a commit from earlier in history
How it works:
git revert <commit-hash> --no-edit
Example:
bunx forge rollback
# Select: 2. Rollback specific commit
# Enter: a1b2c3d
✓ Validating commit hash...
✓ Working directory is clean
✓ Extracting USER sections...
✓ Executing: git revert a1b2c3d --no-edit
✓ Restoring USER sections...
✓ Amended commit to preserve USER content
Rollback complete!
Commit: x9y8z7w "Revert: a1b2c3d"
Files affected: 8
Input validation:
Use when: Need to revert an entire merged pull request
How it works:
git revert -m 1 <merge-commit-hash> --no-edit
Example:
bunx forge rollback
# Select: 3. Rollback merged PR
# Enter: def456 (merge commit hash)
✓ Validating commit hash...
✓ Working directory is clean
✓ Extracting USER sections...
✓ Executing: git revert -m 1 def456 --no-edit
✓ Restoring USER sections...
✓ Amended commit to preserve USER content
✓ Beads integration: Issue #123 marked as 'reverted'
Rollback complete!
Commit: m1n2o3p "Revert: Merge pull request #123"
Files affected: 15
Beads issue: #123 status → reverted
Beads Integration:
#123)bd update <id> --status reverted --comment "PR reverted"Use when: Only certain files need to be restored
How it works:
git checkout HEAD~1 -- <file1> <file2> ...
git commit -m "Rollback: <files>"
Example:
bunx forge rollback
# Select: 4. Rollback specific files
# Enter: AGENTS.md,CLAUDE.md
✓ Validating file paths...
✓ Working directory is clean
✓ Extracting USER sections...
✓ Executing: git checkout HEAD~1 -- AGENTS.md CLAUDE.md
✓ Committing changes...
✓ Restoring USER sections...
✓ Amended commit to preserve USER content
Rollback complete!
Commit: q4r5s6t "Rollback: AGENTS.md, CLAUDE.md"
Files affected: 2
Path validation:
../../../etc/passwd)path.resolve() + startsWith() checkUse when: Need to revert a range of commits
How it works:
git revert <start-commit>..<end-commit> --no-edit
Example:
bunx forge rollback
# Select: 5. Rollback entire branch
# Enter: abc123..def456
✓ Validating commit range...
✓ Working directory is clean
✓ Extracting USER sections...
✓ Executing: git revert abc123..def456 --no-edit
✓ Restoring USER sections...
✓ Amended commit to preserve USER content
Rollback complete!
Commits reverted: 7
Files affected: 24
Range validation:
start..end.. separatorUse when: Want to see what would change without executing
How it works:
Example:
bunx forge rollback
# Select: 6. Preview rollback (dry run)
# Enter method: partial
# Enter target: AGENTS.md,package.json
✓ Validating inputs...
✓ DRY RUN MODE - No changes will be made
Preview of rollback:
Method: partial
Target: AGENTS.md, package.json
Files that would be affected:
- AGENTS.md
- package.json
USER sections that would be preserved:
- AGENTS.md: 2 sections
Custom commands that would be preserved:
- .claude/commands/custom/my-workflow.md
No changes made (dry run).
During Development (/dev):
After Shipping (/ship):
After Merging (/premerge + user merge):
Recovery Scenarios:
# Standard workflow
/status → /plan → /dev → /validate → /ship → /review → /premerge → /verify
# Recovery workflow
/dev → (issues discovered) → bunx forge rollback → /dev (retry)
/ship → (CI fails) → bunx forge rollback → /dev (fix) → /ship
/verify → (production issues) → bunx forge rollback → /plan (redesign)
# 1. Development phase - implement feature
/dev
# ... implementation ...
git commit -m "feat: add payment integration"
# 2. Check phase - tests fail
/validate
# ERROR: Security vulnerability in payment handling
# 3. Rollback the implementation
bunx forge rollback
# Select: 1. Rollback last commit
# 4. Plan with security in mind
/plan payment-integration
# 5. Implement correctly
/dev
# ... proper implementation with security ...
# 6. Verify and ship
/validate → /ship
If Beads is installed (bun install -g @beads/bd), rollback automatically updates issue tracking.
When rolling back a merged PR:
#123, fixes #456, etc.)bd update <id> --status reverted --comment "PR reverted by rollback"
If automatic detection doesn't work:
# After rollback
bd update 123 --status reverted --comment "Rolled back due to production issues"
Cause: Uncommitted changes in working directory
Solution:
# Option 1: Commit changes
git add .
git commit -m "wip: current work"
# Option 2: Stash changes
git stash
# Then retry rollback
bunx forge rollback
Cause: Commit hash doesn't match required pattern
Valid formats:
HEAD (special keyword)a1b2c3d (4-40 character hex string)abc123def456 (longer hash)Invalid formats:
abc;rm -rf / (contains shell metacharacter)12 (too short, < 4 chars)not-a-hash (not hexadecimal)Solution:
# Get valid commit hash
git log --oneline
# Copy full or abbreviated hash (4+ chars)
Cause: File path resolves to outside project root
Examples:
../../../etc/passwd (path traversal)/absolute/path/outside/projectSolution:
# Use relative paths within project
bunx forge rollback
# Select: 4. Rollback specific files
# Enter: src/auth.js,docs/API.md (relative paths)
Cause: File path contains shell metacharacters
Rejected characters: ;, |, &, $, `, (, ), <, >, \n, \r
Solution:
# Remove special characters from filename
mv "file;name.js" "filename.js"
# Or escape properly (not recommended)
Cause: Branch range doesn't include .. separator
Valid formats:
abc123..def456a1b2c3d..x9y8z7wInvalid formats:
abc123-def456 (wrong separator)abc123 (no range)Solution:
# Use correct format
bunx forge rollback
# Select: 5. Rollback entire branch
# Enter: <start-commit>..<end-commit>
Cause: Revert conflicts with subsequent changes
Solution:
# 1. Rollback creates conflict markers
git status
# On branch: main
# Unmerged paths:
# both modified: src/auth.js
# 2. Resolve conflicts manually
# Edit src/auth.js, remove markers
# 3. Complete the revert
git add src/auth.js
git revert --continue
# 4. USER sections restored automatically
Cause: Markers missing or malformed
Check markers:
grep -n "USER:START" AGENTS.md
grep -n "USER:END" AGENTS.md
Valid markers:
<!-- USER:START -->
Content
<!-- USER:END -->
<!-- USER:START:name -->
Named section
<!-- USER:END:name -->
Invalid markers:
<!-- USER START --> (missing colon)
<!-- USER:START (missing closing -->)
<!-- USER:END --> (no matching START)
Solution:
# Fix markers before rollback
# Ensure all USER:START have matching USER:END
All inputs are validated before use in git commands:
Commit hashes:
if (target !== 'HEAD' && !/^[0-9a-f]{4,40}$/i.test(target)) {
return { valid: false, error: 'Invalid commit hash format' };
}
File paths:
const resolved = path.resolve(projectRoot, file);
if (!resolved.startsWith(projectRoot)) {
return { valid: false, error: 'Path outside project' };
}
Shell metacharacters:
if (/[;|&$`()<>\r\n]/.test(file)) {
return { valid: false, error: 'Invalid characters in path' };
}
Uses:
git revert (creates new commit, preserves history)git checkout HEAD~1 -- <files> (restores specific files)Never uses:
git reset --hard (destroys commits)git push --force (overwrites remote)git clean -f (deletes untracked files)Always preserved:
.claude/commands/custom/Never lost:
# 1. Always commit work before rollback
git add .
git commit -m "wip: current state"
# 2. Use dry run to preview
bunx forge rollback
# Select: 6. Preview rollback (dry run)
# 3. Execute rollback
bunx forge rollback
# Select appropriate method
# 4. Verify USER sections preserved
grep -A5 "USER:START" AGENTS.md
# 5. Push if needed (after verification)
git push
# Scenario: Just committed but realized approach is wrong
git log --oneline
# abc123d (HEAD) feat: add caching layer
# def456e fix: validation bug
bunx forge rollback
# 1. Rollback last commit
# Output:
# ✓ Working directory is clean
# ✓ Extracting USER sections...
# ✓ Executing: git revert HEAD --no-edit
# ✓ Restoring USER sections...
# ✓ Rollback complete!
git log --oneline
# xyz789f (HEAD) Revert: feat: add caching layer
# abc123d feat: add caching layer
# def456e fix: validation bug
# Scenario: PR #123 caused production issues
git log --oneline
# merge789 (HEAD) Merge pull request #123
# feat456a feat: add real-time updates
# bugfix123 fix: websocket connection
bunx forge rollback
# 3. Rollback merged PR
# Enter: merge789
# Output:
# ✓ Validating commit hash...
# ✓ Working directory is clean
# ✓ Extracting USER sections...
# ✓ Executing: git revert -m 1 merge789 --no-edit
# ✓ Restoring USER sections...
# ✓ Beads: Issue #123 → status: reverted
# ✓ Rollback complete!
bd show 123
# ID: 123
# Title: Add real-time updates
# Status: reverted
# Comments:
# - PR reverted by rollback
# Scenario: Accidentally updated wrong files in last commit
git show HEAD --name-only
# commit abc123
# feat: update documentation
# AGENTS.md (should not have changed)
# docs/API.md
# README.md
bunx forge rollback
# 4. Rollback specific files
# Enter: AGENTS.md
# Output:
# ✓ Validating file paths...
# ✓ Working directory is clean
# ✓ Extracting USER sections...
# ✓ Executing: git checkout HEAD~1 -- AGENTS.md
# ✓ Committing changes...
# ✓ Restoring USER sections...
# ✓ Rollback complete!
# Files affected: 1
git status
# On branch: main
# nothing to commit, working tree clean
# (AGENTS.md restored to previous version)
# Scenario: Want to see what rollback would do
bunx forge rollback
# 6. Preview rollback (dry run)
# Method: commit
# Target: HEAD
# Output:
# ✓ Validating inputs...
# ✓ DRY RUN MODE - No changes will be made
#
# Preview of rollback:
# Method: commit
# Target: HEAD
#
# Files that would be affected:
# - src/auth/middleware.js
# - src/auth/validators.js
# - tests/auth.test.js
#
# USER sections that would be preserved:
# - AGENTS.md: 2 sections
# - CLAUDE.md: 1 section
#
# Custom commands that would be preserved:
# - .claude/commands/custom/deploy.md
#
# No changes made (dry run).
# Decision: Proceed with rollback
bunx forge rollback
# 1. Rollback last commit
development
Pull issues, metrics, quality gates, and analysis data from SonarCloud. ALWAYS use this skill when the user mentions SonarCloud, asks about code quality metrics, wants to check PR quality gates, or needs to review security vulnerabilities and technical debt from static analysis. Also trigger during /review workflow when SonarCloud issues need addressing. Trigger on phrases like "SonarCloud", "quality gate", "code quality metrics", "technical debt", "coverage report", "static analysis issues", "security vulnerabilities from scan".
tools
Produces comprehensive research reports that go far beyond what built-in web search can achieve. Sends research tasks to Parallel AI's pro/ultra processors which spend 3-25 minutes autonomously crawling, reading, and synthesizing dozens of sources — returning structured reports with citations. Built-in WebSearch can only run a few queries; this skill runs an entire research pipeline externally. No binary install — requires PARALLEL_API_KEY in .env.local. ALWAYS use this skill instead of doing multiple WebSearch calls when the user needs a comprehensive report, market analysis, competitive landscape, industry deep-dive, strategic recommendations, or multi-source synthesis. This is the RIGHT tool for any research task that would require more than 3-4 web searches to answer properly. Also trigger during /plan Phase 2 research and /research workflows.
testing
Test content
testing
Test content