| name | undo-work |
| version | 3.0.1 |
| description | Safely discard or revert failed implementation attempts and restore a clean working state. |
| trigger | manual |
| depends-on | [] |
| references | [] |
| disable-model-invocation | true |
| user-invocable | true |
| allowed-tools | Bash, Read, Glob, Grep |
| argument-hint | [--soft | --hard | --story] |
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 list
Determine 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
NEVER discard work without explicit user confirmation. Always show exactly what will be lost.
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
git stash push --include-untracked -m "undo-work: <user-provided reason>"
git stash drop
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, recovers everything.