adopt
Bootstrap an existing repo for ForgeDock — triage open issues, apply labels, suggest a starter milestone, and identify first…
Create a revert PR to roll back a shipped feature or fix that caused a production incident
> /plugin marketplace add RapierCraftStudios/ForgeDock > /plugin install forgedock@forgedock
How it fires
How this command gets triggered: by you, by Claude, or both.
/rollbackContext preview
What this command does when you run it.
Create a revert PR to roll back a shipped feature or fix that caused a production incident
description: Create a revert PR to roll back a shipped feature or fix that caused a production incident argument-hint: "[PR number to revert, or \"last\" for most recent deploy]" install: extras
<!-- SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios --> <!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
> **Skill names**: `{FORGE_SKILL_PREFIX}` is `forgedock:` (plugin install) or empty (`install.sh`), resolved once per run by `commands/work-on.md` § Skill Name Resolution. If the skill is not found under either name, STOP and report "skill not found" — never run the phase inline.
**Input**: $ARGUMENTS
**Config variables used by this command** (set in `forge.yaml`):
You are the pipeline's emergency rollback system. When a shipped feature or fix causes production issues, this command creates a revert PR and fast-tracks it through the pipeline.
**Agent model policy**: `model: "{DEFAULT_MODEL}"` — resolved from forge.yaml `agents.default_model`, else "sonnet" (standard tier). Fallback: `model: "opus"` if rate-limited. User can override with `--model <name>`. Feature gate: pass `effort` in Task/Skill spawns only on Claude Code >= 2.1.154.
**NEVER use plan mode (EnterPlanMode)** — it breaks execution context.
---
| Input | Action | |-------|--------| | PR number (e.g., `142`) | Revert that specific PR | | `last` or empty | Revert the most recent merge to `main` | | Issue number with `#` (e.g., `#55`) | Find the PR that closed this issue, revert it |
# If PR number given directly
gh pr view {PR_NUMBER} --json number,title,mergeCommit,headRefName,baseRefName,body,mergedAt
# If "last" — find most recent merge to main
gh pr list --state merged --base main --limit 1 --json number,title,mergeCommit,mergedAt
# If issue number — find the PR that closed it
gh pr list --state merged --search "Closes #{ISSUE}" --limit 1 --json number,title,mergeCommitBefore reverting, check:
1. **Was the PR actually merged to main?** If it's only on staging, revert from staging instead. 2. **Are there dependent PRs merged after this one?** If later PRs build on this code, a simple revert may break them.
# Check what changed in the PR
gh pr diff {PR_NUMBER} --name-only
# Check if any later PRs touched the same files
MERGE_DATE=$(gh pr view {PR_NUMBER} --json mergedAt --jq '.mergedAt')
gh pr list --state merged --base main --json number,title,mergedAt,files \
--jq ".[] | select(.mergedAt > \"$MERGE_DATE\") | {number, title}"If dependent PRs exist, warn the user:
⚠️ PRs merged AFTER #{PR_NUMBER} that touch the same files:
- #{LATER_PR} — {title}
A simple revert may break these. Options:
1. Revert all dependent PRs together (risky)
2. Create a targeted fix instead of a full revert
3. Proceed with revert anyway (you'll need to fix conflicts)
Which approach? (Reply or press enter for option 1)---
cd {REPO_PATH}
git fetch origin main
git worktree add ../revert-pr-{PR_NUMBER} -b revert/pr-{PR_NUMBER} origin/main
cd ../revert-pr-{PR_NUMBER}# Get the merge commit SHA
MERGE_SHA=$(gh pr view {PR_NUMBER} --json mergeCommit --jq '.mergeCommit.oid')
# Revert the merge commit (use -m 1 for merge commits to select the mainline parent)
git revert -m 1 $MERGE_SHA --no-editIf the revert has conflicts:
# Show conflicts git diff --name-only --diff-filter=U # Report to user echo "Revert has conflicts in these files:" git diff --name-only --diff-filter=U echo "" echo "This usually means later changes depend on the reverted PR." echo "Manual resolution needed — opening conflicted files for review."
If conflicts cannot be auto-resolved, report to user and STOP.
Read `forge.yaml → verification.commands` for project-specific tool commands:
# Python compile check (always runs — no config needed)
for f in {reverted_python_files}; do
python3 -m py_compile "$f" 2>&1
done
# Python format check (config-driven)
PYTHON_FORMAT=$(yq '.verification.commands.python.format // ""' forge.yaml 2>/dev/null || echo '')
if [ -n "$PYTHON_FORMAT" ]; then
eval "$PYTHON_FORMAT" 2>&1 | head -20
else
echo "SKIPPED — python.format not configured in verification.commands"
fi
# TypeScript typecheck (config-driven)
TS_TYPECHECK=$(yq '.verification.commands.typescript.typecheck // ""' forge.yaml 2>/dev/null || echo '')
if [ -n "$TS_TYPECHECK" ]; then
eval "$TS_TYPECHECK" 2>&1 | head -20
else
echo "SKIPPED — typescript.typecheck not configured in verification.commands"
fi---
git push origin revert/pr-{PR_NUMBER}
gh pr create --base main --title "Revert: #{PR_NUMBER} — {original_title}" --body "$(cat <<'PR_EOF'
## Revert
Reverts #{PR_NUMBER} ({original_title}).
**Reason**: {user-provided reason or "Production incident — rollback requested"}
**Original PR**: #{PR_NUMBER}
**Merge commit**: {MERGE_SHA}
## What This Reverts
{List of files changed, from the original PR}
## Verification
- [ ] Revert compiles cleanly
- [ ] No dependent PRs broken
- [ ] Production incident should resolve after deploy
PR_EOF
)"**If this is a P0 incident** (user said "urgent", "P0", "production down", or similar):
gh pr merge {REVERT_PR} --mergeForgeDock — autonomous AI dev pipeline for Claude Code. GitHub as agent memory: issue in, PR out.
Bootstrap an existing repo for ForgeDock — triage open issues, apply labels, suggest a starter milestone, and identify first…
Pull production analytics from GSC, Bing Webmaster, Clarity, Umami, Cloudflare, Stripe, and GA4 — generate insights and create…
Audit agent outputs from an orchestration run — timeline analysis, stall detection, active vs idle time breakdown
Trace a production issue or pipeline failure end-to-end through GitHub artifacts, then file a detailed improvement issue to the…
Autonomous deploy loop — runs until zero open issues remain. Detects pipeline state and resumes from any position. Fully…
Guided idea-to-backlog setup for a brand-new project — interview, defaults, doubts, spike doc, validated orchestrate-ready backlog