agentleFS
pr-purgatorypr-purgatory/Skills/revert-forge/SKILL.md

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

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
  1. Distinctive:

    Before performing any reset, checkout, or revert operation:

    line 19
  2. Distinctive:

    If git stash fails or indicates there is nothing to stash, proceed only after confirming the working tree status.

    line 22
  3. Very specific:

    Never pass refs through a shell string (sh -c, backticks, eval).

    line 26
  4. Distinctive:

    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 …

    line 36
  5. Distinctive:

    After rollback (success or failure): append the entry.

    line 37
  6. Distinctive:

    Check the attempt log (§3).

    line 58
  7. Very specific:

    If the tree is dirty: git stash push -u -m "revert-forge auto-stash before rollback".

    line 59
  8. Distinctive:

    Verify: git status --porcelain is clean and git log --oneline -3 shows the expected state.

    line 63
  9. Distinctive:

    Default to git revert; git reset --hard or any history-discarding op → confirm with user first.

    line 71

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 stash fails 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

SituationMethodHistory
Bad commit(s) already pushed or on a shared branchgit revert --no-edit <sha> (range: git revert --no-edit <old>..<new>)Preserved — default
Merge commitgit revert --no-edit -m 1 <merge-sha>Preserved
Unpushed local commits only, user wants them gonegit reset --hard <good-sha>Discarded — user confirm required
Return to another branchgit 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

  1. 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).
  2. Validate and resolve the target to a SHA (§2).
  3. Check the attempt log (§3); refuse if a recent attempt exists.
  4. 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.
  5. Pick the method from the table above. reset --hard → ask the user and wait for a yes.
  6. Execute. If git revert hits conflicts: git revert --abort, report the conflicting files, stop. ⊥ auto-resolve.
  7. Append the attempt entry (§3).
  8. Verify: git status --porcelain is clean and git log --oneline -3 shows the expected state; run the project's test command if one exists.
  9. Log the reason via lfm. Remind the user their work is in the stash (git stash pop to restore).

Boundaries

  • ⊥ reset/checkout/revert before uncommitted work is stashed.
  • Default to git revert; git reset --hard or 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.