Reset (internal)
Internal executor for the public @gh-reset boundary.
Responsibility
- Stay on current branch.
- Never stash in this skill.
- Reset/clean only after explicit confirmation.
- Do not merge/push from this skill.
- Own all runnable terminal commands for reset flow.
Core flow
- Validate repository and resolve branch.
- Fetch remotes and resolve target reference.
- Inspect impact (dirty state, ahead commits, clean dry-run).
- If any impact exists, require explicit proceed confirmation.
- Confirm hard reset and execute.
- Confirm clean and execute.
- Optionally run non-git cleanup (each with separate confirmation).
- Verify terminal state and report.
Command runbook
1) Validate location and branch
git rev-parse --is-inside-work-tree
BRANCH=$(git branch --show-current)
- If detached HEAD (
$BRANCHempty), stop and ask user to check out a branch.
2) Fetch and resolve target
git fetch --all --prune
Resolve TARGET in this order:
origin/mainexists -> useorigin/main- else
origin/$BRANCHexists -> useorigin/$BRANCH - else tracking ref exists -> use
@{u} - else stop and ask user for explicit target ref
Suggested checks:
git show-ref --verify --quiet refs/remotes/origin/main
git show-ref --verify --quiet "refs/remotes/origin/$BRANCH"
git rev-parse --abbrev-ref "@{u}"
3) Inspect impact before destruction
Dirty check:
git status --short
Ahead-of-main check (when origin/main exists):
git rev-list --count origin/main..HEAD
Clean dry-run preview:
git clean -fdxn
4) Mandatory proceed prompt on non-empty impact
If any of the following is non-empty/non-zero:
- dirty tracked/untracked state,
- ahead commits vs
origin/main, - files listed by clean dry-run,
then explicitly prompt whether to proceed before destructive execution.
If user does not explicitly confirm, stop.
5) Confirm and execute hard reset
Require explicit confirmation, then run:
git reset --hard "$TARGET"
6) Confirm and execute clean
Require explicit confirmation of clean mode, then run one:
git clean -fdx
or
git clean -fd
7) Optional non-git cleanup (separate confirmations)
Each optional command requires its own explicit confirmation. Examples:
docker builder prune -fdocker system prune(strong confirmation)podman builder prunepodman system prunenpm cache clean --force
8) Final verification
git branch --show-current
git status --short
git log -1 --oneline
Report: current branch, target used, whether ahead commits were dropped, and clean status.
Notes
- Keep this skill independent from
@gh-main. - No browser/script-specific cleanup steps are part of this skill.