Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Revert Rca Loop

ASecurity

Detect when an AI-authored PR is reverted and trigger a Reflection session for RCA. Monitors revert commits, matches to AI PRs, and initiates analysis. Scheduled to run hourly. Invoke with /revert-rca-loop.

2 stars
0 votes
0 copies
0 views
Added 9/22/2026
developmentgobashsqltestinggitapisecuritydocumentation

Works with

cliapi

Security Analysis

A100/100

Scanned 9/22/2026

Install to Claude Code

$npx -y skills add mattbutlerengineering/mattbutlerengineering --skill revert-rca-loop --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Revert Rca Loop?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Revert Rca Loop
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mattbutlerengineering-revert-rca-loop/badge)](https://www.skillsdirectory.com/skills/mattbutlerengineering-revert-rca-loop)

More formats (shields.io, HTML) on the badges page.

Download with Pro
Files
SKILL.md
---
name: revert-rca-loop
description: "Detect when an AI-authored PR is reverted and trigger a Reflection session for RCA. Monitors revert commits, matches to AI PRs, and initiates analysis. Scheduled to run hourly. Invoke with /revert-rca-loop."
user-invocable: true
---

# Revert RCA Loop

Detects and analyzes reversions of AI-authored PRs to identify patterns and prevent recurrence.

**Goal:** Close the learning loop when the autonomous system makes a mistake: capture the revert, trigger RCA, file follow-up tasks.

## Architecture

```
Periodic Check (hourly)
  → Query GitHub for recent reverts
  → Filter for AI-authored PRs (marked "Generated by @mbe/agent-core")
  → Match revert commit to original PR
  → Check if RCA issue already exists
  → If new revert: Create RCA issue + Trigger Reflection session
  → Track trend (reverts/day, patterns, root causes)
```

## Workflow

### Step 1: Detect Recent Reverts

Query the last 24 hours of commits on main for revert patterns:

```bash
# Find revert commits (last 24h)
git log --oneline --since="24 hours ago" --grep="^Revert" | head -20
```

Parse each revert commit:

- Extract original commit SHA or PR number from message: `Revert "feat: #1234 description"`
- Or: `Revert "title (#1234)"`
- Extract: `1234` (PR number)

For each potential revert:

```bash
# Get the reverted commit details
REVERT_COMMIT=$(git log -1 --format=%H --grep="^Revert" --since="24 hours ago")
ORIGINAL_COMMIT=$(git show $REVERT_COMMIT | grep -oP 'This reverts commit \K[0-9a-f]+' || echo "")

# Try to find the original PR from the commit message
PR_NUM=$(git log -1 --format=%B $REVERT_COMMIT | grep -oP '#\K[0-9]+' | head -1)
```

### Step 2: Verify PR is AI-Authored

For each potential revert:

```bash
# Check if the PR body contains "Generated by @mbe/agent-core"
gh pr view $PR_NUM --json body --jq '.body' | grep -q "Generated by @mbe/agent-core"
if [ $? -eq 0 ]; then
  echo "Revert detected: AI-authored PR #$PR_NUM was reverted"
else
  echo "Revert is not for an AI PR, skipping"
fi
```

### Step 3: Check for Existing RCA Issue

Before creating a new issue, check if an RCA was already filed:

```bash
# Query for RCA issue for this PR
EXISTING=$(gh issue list \
  --search "RCA for #$PR_NUM" \
  --state open \
  --label "revert-rca" \
  --json number \
  --jq ".[0].number")

if [ -n "$EXISTING" ]; then
  echo "RCA issue #$EXISTING already exists, skipping"
  exit 0
fi
```

### Step 4: Create RCA Issue

If no existing RCA issue, create one:

```bash
gh issue create \
  --title "RCA: PR #$PR_NUM was reverted" \
  --label "revert-rca,acmm" \
  --body "## Revert Details

| Field | Value |
|-------|-------|
| Reverted PR | #$PR_NUM |
| Revert Commit | $REVERT_COMMIT |
| Original Author | @mbe/agent-core |
| Reverted At | $(date -u +%Y-%m-%dT%H:%M:%SZ) |

## Original PR Summary

$(gh pr view $PR_NUM --json title,body --jq '"**Title:** \(.title)\n\n**Body:**\n\(.body)"')

## RCA Checklist

- [ ] Review the revert commit and reason
- [ ] Identify root cause category (logic error, incomplete testing, edge case, unsafe pattern)
- [ ] Check if this is a recurring pattern
- [ ] File follow-up task if needed (improve testing, add validation, update templates)
- [ ] Update agent-core or skill documentation if systemic issue

## Root Cause Categories

When analyzing, categorize the root cause:

- **Logic Error** — Agent misunderstood requirements or made an incorrect implementation choice
- **Incomplete Testing** — Test coverage missed an edge case or integration scenario
- **Missing Validation** — Input validation or constraint enforcement was insufficient
- **Unsafe Pattern** — Code violates security or reliability guidelines (SQL injection, race condition, etc.)
- **Environment-Specific** — Issue only manifests in production (timing, state, external service)
- **Transient** — Issue was environmental noise (flaky test, temporary API outage) and revert was unnecessary

---

*Auto-created by revert-rca-loop*"
```

Capture the issue number: `ISSUE_NUM=$(echo $OUTPUT | jq -r '.number')`

### Step 5: Trigger Reflection Session

Create a GitHub issue that will trigger a Reflection session via RemoteTrigger.

The reflection session should:

1. Fetch the RCA issue and revert commit details
2. Analyze the PR changes and the reason for revert
3. Identify the root cause category
4. Document findings in `.claude/reflections/rca-<issue_num>.md`
5. Close the RCA issue as documented

```bash
# Log a trigger event for reflection
mkdir -p .claude/state
echo "{\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"revert_pr\":$PR_NUM,\"rca_issue\":$ISSUE_NUM}" >> .claude/state/revert-rca-triggers.jsonl
```

### Step 6: Track Trends

Append to revert tracking log:

```bash
cat >> .claude/improvement-loop/revert-log.md <<'EOF'
## $(date -u +%Y-%m-%d)

- **PR #$PR_NUM** reverted
  - RCA Issue: #$ISSUE_NUM
  - Timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)
  - Status: RCA pending

EOF
```

### Step 7: Alert if Threshold Exceeded

If reverts/day > 3, create a meta-improvement issue:

```bash
REVERT_COUNT=$(git log --since="7 days ago" --grep="^Revert" --oneline | wc -l)
if [ "$REVERT_COUNT" -gt 3 ]; then
  gh issue create \
    --title "[Meta] Revert rate elevated (${REVERT_COUNT}/day)" \
    --label "meta-improvement,acmm" \
    --body "The 7-day revert rate is ${REVERT_COUNT}/day (threshold: 3). This suggests the autonomous system is unstable. Investigate pattern from revert-rca-loop output and consider:

- Improving test coverage
- Tightening validation rules
- Reducing agent complexity/ambition
- Adding pre-commit gates"
fi
```

## Scheduling

Run hourly to catch reverts quickly:

- **Name:** `mbe-revert-rca-loop`
- **Schedule:** `7 * * * *` (every hour at :07 to avoid conflicts)
- **Prompt:** `/revert-rca-loop`

## Success Criteria

A successful revert-rca-loop run:

1. ✅ Detects all reverts in the last 24h
2. ✅ Correctly identifies AI-authored PRs
3. ✅ Creates RCA issue without duplicates
4. ✅ Logs revert event for trend analysis
5. ✅ Alerts when revert rate exceeds threshold

## Output Files

| File                                      | Purpose                                       |
| ----------------------------------------- | --------------------------------------------- |
| `.claude/state/revert-rca-triggers.jsonl` | Event log (timestamp, reverted PR, RCA issue) |
| `.claude/improvement-loop/revert-log.md`  | Human-readable revert history                 |
| `RCA Issue #N`                            | Investigation and findings                    |
| `.claude/reflections/rca-*.md`            | Detailed RCA analysis and learnings           |

## Integration with Progress Tracker

The revert-rca-loop feeds data into `/progress-tracker`:

- Tracks revert rate (target: < 1/day)
- Identifies recurring root causes
- Triggers escalation if rate climbs
- Suggests process improvements

## Integration with Learning Loop

Findings from RCA issues inform the learning loop:

- Patterns identified in RCA flow back to agent-core improvements
- Test coverage gaps found in RCA become new test requirements
- Systemic issues trigger updates to CLAUDE.md or gotchas.md

## Troubleshooting

| Issue                    | Cause                       | Fix                                             |
| ------------------------ | --------------------------- | ----------------------------------------------- |
| No reverts detected      | No revert commits on main   | Check git log manually                          |
| AI PR not detected       | Body doesn't contain marker | Check PR body format in pr-creator.ts           |
| Duplicate RCA issues     | Check logic failed          | Improve search query to match PR number exactly |
| Reflection not triggered | Event log not created       | Verify `.claude/state/` is writable             |

## Examples

### Example 1: Logic Error in Feature PR

Revert: `Revert "feat: add payment retry logic (#1234)"`

- Root cause: Agent didn't account for webhook race condition
- Fix: Add pessimistic locking to payment service
- Learning: Update PR examples in prompt-builder to show concurrency patterns

### Example 2: Missing Edge Case in Test PR

Revert: `Revert "test: expand coverage for auth flow (#1250)"`

- Root cause: New tests broke on parallel execution
- Fix: Add test isolation/setup/teardown
- Learning: Add vitest concurrency patterns to skill examples

### Example 3: Unsafe SQL Pattern

Revert: `Revert "feat: batch user deletion (#1267)"`

- Root cause: SQL query vulnerable to injection (missing parameterization)
- Fix: Use Prisma parameterized queries
- Learning: Add security review to quality gates

## Next Steps After RCA

Once RCA is complete (issue closed with findings documented):

1. **Follow-up issue** — If systemic: Create task to fix root cause
2. **Skill improvement** — Update relevant skill SKILL.md with pattern
3. **Test addition** — Add regression test to prevent recurrence
4. **Documentation** — Update CLAUDE.md or gotchas.md if pattern is widespread

Attribution

mattbutlerengineeringmattbutlerengineering
View sourceMore from mattbutlerengineering →
SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284722 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2192 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →