undo-work
Skill9 starsChanged 3 months agoMITView on GitHub
Safely discard or revert failed implementation attempts and restore a clean working state.
In this repository56 other files it gives its agents.
- .claude/agents/CLAUDE.mdCLAUDE.md
- .claude/hooks/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- .claude/prompts/CLAUDE.mdCLAUDE.md
- .claude/rules/CLAUDE.mdCLAUDE.md
- .claude/skills/CLAUDE.mdCLAUDE.md
- docs/CLAUDE.mdCLAUDE.md
- vision/CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- scaffold/llms.txtllms.txt
- architecture-checkSkill
- backlog-reviewSkill
- bootstrapSkill
- brainstormSkill
- buildSkill
- claude-sense-checkSkill
- code-qualitySkill
- commitSkill
- continueSkill
- custom-hooksSkill
- dashboardSkill
- debug-sessionSkill
- deploySkill
- discoverSkill
- doctorSkill
- fix-issueSkill
- framework-upgradeSkill
- handoffSkill
- help-meSkill
- ideateSkill
- lanesSkill
- manual-testSkill
- merge-downSkill
- merge-upSkill
- optimizeSkill
- parallel-workSkill
- performance-checkSkill
- phase-reviewSkill
- pr-statusSkill
- quality-checkSkill
- quickstartSkill
- refine-loopSkill
- researchSkill
- retrospectiveSkill
- security-auditSkill
- skill-createSkill
- skill-evalSkill
- sprint-endSkill
- sprint-startSkill
- story-cycleSkill
- testing-cycleSkill
- test-validatorSkill
- UAT-cycleSkill
- uninstallSkill
- weekly-maintenanceSkill
- wrap-upSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 9 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 39
NEVER discard work without explicit user confirmation.
- Distinctive: line 47
Ask the user to confirm one of these rollback levels:
- Distinctive: line 82
If a checkpoint tag exists, prefer it as the rollback target — it was set by story-cycle Phase 3.pre at the exact point before …
- Distinctive: line 84
If no checkpoint tag exists, identify the commit where the story started:
- Distinctive: line 130
NEVER execute destructive git commands without showing the user exactly what will be affected and getting explicit confirmation
- Distinctive: line 131
NEVER force push after a reset — the rollback is local only
- Distinctive: line 132
Always prefer git stash --include-untracked (recoverable) over destructive alternatives.
- Distinctive: line 133
If on main branch, REFUSE to reset — only feature/sprint branches
- Distinctive: line 134
If there are commits that have already been pushed to remote, WARN the user that local reset won't affect the remote
≈ “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
undo-work
Safely undo work when an implementation attempt has gone wrong. Provides structured rollback with safeguards against accidental data loss.
Arguments: $ARGUMENTS
1. Assess Current State
git status
git log --oneline -10
git stash listDetermine the situation:
- Uncommitted changes only → Soft or hard reset options
- One or more commits on feature branch → Revert commits or reset branch
- Mid-story-cycle → Full story rollback
Present findings to the user before proceeding.
2. Confirm Scope with User
<HARD-GATE>
NEVER discard work without explicit user confirmation. Always show exactly what will be lost.
</HARD-GATE>Show the user:
- Files that will be affected (list modified/added/deleted files)
- Commits that will be reverted (if any)
- Whether there's uncommitted work at risk
Ask the user to confirm one of these rollback levels:
| Level | What it does | When to use |
| Soft | Stash uncommitted changes (recoverable via git stash pop) | "Let me save this aside and try a different approach" |
| Hard | Discard all uncommitted changes | "This attempt is wrong, start fresh from last commit" |
| Story | Reset branch to before the story's commits | "The whole story implementation needs to restart" |
3. Execute Rollback
Soft (stash)
git stash push -m "undo-work: <user-provided reason or auto-description>"Report: "Changes stashed. Use git stash pop to recover if needed."
Hard (discard uncommitted)
git diff --stat # Show what will be lost — confirm with user
git stash push --include-untracked -m "undo-work: <user-provided reason>"
git stash drop # Discard the stash (changes intentionally discarded)This captures both tracked changes AND untracked files into a stash, achieving a clean working directory. If the user changes their mind before the drop, git stash pop recovers everything.
Story (reset branch to before story commits)
- Check for story-cycle checkpoint tags first:
git tag -l 'story-checkpoint-*'If a checkpoint tag exists, prefer it as the rollback target — it was set by story-cycle Phase 3.pre at the exact point before implementation began.
- If no checkpoint tag exists, identify the commit where the story started:
git log --oneline main..HEAD- Show the user exactly which commits will be removed (or that a checkpoint tag was found).
- After confirmation:
If checkpoint tag exists:
git stash push --include-untracked -m "undo-work: story rollback backup"
git reset --soft <checkpoint-tag>
git restore .
git tag -d <checkpoint-tag>If no checkpoint tag (fall back to commit-based):
git reset --soft <commit-before-story> # Keep changes staged (safest)<IF>User wants a clean slate (not just unstaged)</IF>
git stash push --include-untracked -m "undo-work: story rollback backup"
git reset --soft <commit-before-story>
git restore .4. Verify Clean State
git status
git log --oneline -5Confirm the working directory is in the expected state.
5. Document (Optional)
<IF>The failed attempt has useful learnings</IF>
Suggest the user note what went wrong in the current session context so the next attempt avoids the same pitfalls. Do NOT auto-create documentation files.
Rules
- NEVER execute destructive git commands without showing the user exactly what will be affected and getting explicit confirmation
- NEVER force push after a reset — the rollback is local only
- Always prefer
git stash --include-untracked(recoverable) over destructive alternatives. Usegit restore .for discarding tracked file changes,git reset --softfor undoing commits while keeping changes staged - If on
mainbranch, REFUSE to reset — only feature/sprint branches - If there are commits that have already been pushed to remote, WARN the user that local reset won't affect the remote
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.

