revert-forge
Skill0 starsChanged 30 days agoApache-2.0View on GitHub
Safe git rollback of a failed or rejected implementation. Stashes uncommitted work, validates refs, blocks shell injection, caps retries at one. Use when asked to revert, roll back, or undo a failed change.
- Deletes or force-pushes
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- archieSkill
- deep-research-firecrawlSkill
- lfmSkill
- redteamSkill
- rust-forgeSkill
- sandbox-forgeSkill
- selinaSkill
- ui-forgeSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 7 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Before performing any reset, checkout, or revert operation:
- Distinctive: line 22
If git stash fails or indicates there is nothing to stash, proceed only after confirming the working tree status.
- Very specific: line 26
Never pass refs through a shell string (sh -c, backticks, eval).
- Distinctive: line 36
Before rollback: if the resolved SHA has an entry from the last 12 hours, refuse and tell the user a rollback of this target was already …
- Distinctive: line 37
After rollback (success or failure): append the entry.
- Distinctive: line 58
Check the attempt log (§3).
- Very specific: line 59
If the tree is dirty: git stash push -u -m "revert-forge auto-stash before rollback".
- Distinctive: line 63
Verify: git status --porcelain is clean and git log --oneline -3 shows the expected state.
- Distinctive: line 71
Default to git revert; git reset --hard or any history-discarding op → confirm with user first.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Revert Forge
Goal
Restore the working directory or git branch safely to a previous clean state when a feature implementation fails, is rejected, or causes severe regressions. Prevent data loss of unrelated uncommitted work and defend against shell injection.
Safety Requirements
1. Mandatory Git Stash (Prevent Data Loss)
Before performing any reset, checkout, or revert operation:
- You MUST save any uncommitted changes in the working directory or staging area.
- Command:
git stash push -u -m "revert-forge auto-stash before rollback" - If
git stashfails or indicates there is nothing to stash, proceed only after confirming the working tree status.
2. Argument Validation & Escaping (CWE-88)
To prevent command or option injection via malformed branch/commit names:
- Never pass refs through a shell string (
sh -c, backticks,eval). Use argv (e.g.Command::new("git").arg("revert").arg(sha)); from a shell tool, single-quote the ref. - Reject any ref that starts with
-or contains whitespace or shell metacharacters (;,&,|,$,`,<,>). - Resolve every target to a commit SHA first and use the SHA from then on:
git rev-parse --verify --end-of-options '<ref>^{commit}'Non-zero exit → stop and report the ref as invalid.
3. Loop Prevention (Attempt Tracking)
Attempts are tracked on disk so the limit survives context compaction and restarts:
- File:
$(git rev-parse --git-dir)/revert-forge-attempts— inside.git, so never committed. - Line format:
<target-sha> <ISO-8601 UTC timestamp>. - Before rollback: if the resolved SHA has an entry from the last 12 hours, refuse and tell the user a rollback of this target was already attempted. Proceed only if the user explicitly overrides in the current turn.
- After rollback (success or failure): append the entry.
Choosing the Rollback Method
| Situation | Method | History |
| Bad commit(s) already pushed or on a shared branch | git revert --no-edit <sha> (range: git revert --no-edit <old>..<new>) | Preserved — default |
| Merge commit | git revert --no-edit -m 1 <merge-sha> | Preserved |
| Unpushed local commits only, user wants them gone | git reset --hard <good-sha> | Discarded — user confirm required |
| Return to another branch | git switch <branch> | Unchanged |
Unpushed check: git branch -r --contains <sha> prints nothing → commit is local only. Even then, prefer git revert unless the user asks to drop history.
Safe Execution Flow
git status --porcelain. Abort if a merge/rebase/cherry-pick is in progress (git rev-parse -q --verify MERGE_HEAD/REBASE_HEAD/CHERRY_PICK_HEAD).- Validate and resolve the target to a SHA (§2).
- Check the attempt log (§3); refuse if a recent attempt exists.
- If the tree is dirty:
git stash push -u -m "revert-forge auto-stash before rollback". Report the stash ref (stash@{0}) to the user. - Pick the method from the table above.
reset --hard→ ask the user and wait for a yes. - Execute. If
git reverthits conflicts:git revert --abort, report the conflicting files, stop. ⊥ auto-resolve. - Append the attempt entry (§3).
- Verify:
git status --porcelainis clean andgit log --oneline -3shows the expected state; run the project's test command if one exists. - Log the reason via
lfm. Remind the user their work is in the stash (git stash popto restore).
Boundaries
- ⊥ reset/checkout/revert before uncommitted work is stashed.
- Default to
git revert;git reset --hardor any history-discarding op → confirm with user first. - ⊥ pass unvalidated ref names to a shell; argv only.
- ≤ 1 rollback attempt per target SHA per 12h, tracked in
.git/revert-forge-attempts. - ∀ revert → log reason via
lfm.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

