undo-commit

A command that reverses the latest local Git commit while keeping its changes staged for editing or recommitting. Git is the version-control system used to track code changes.

In plain words
What is it for?
Use it to reopen the last local, non-merge commit for changes; it does not undo the initial commit or a commit already published to a tracked remote.
Why use it?
It lets you undo a recent commit without discarding the work, while refusing cases where rewriting history could be unsafe.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/damusix/atomic-claude/undo-commit
Clone the repo
git clone --depth 1 https://github.com/damusix/atomic-claude
Per session 31 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 708 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.00708
Opus 5 $0.00015 $0.00354
Sonnet 5 $0.00006 $0.00142
Haiku 4.5 $0.00003 $0.00071

Measured 2d ago against content hash 1fc57693e90c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

undo-commit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

context/commands/undo-commit.md · 131 lines

How it starts

The opening of the file, as written. The whole thing — 131 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Reverses one commit without losing the work. Equivalent to git reset --soft HEAD~1 with safety guards.

Pre-flight

git rev-parse --is-inside-work-tree

If not in a git repo, stop:

not a git repo. /undo-commit requires a git repository.

Verify HEAD has a parent (can't undo the initial commit):

git rev-parse HEAD^ 2>/dev/null

If this fails: refused: HEAD is the initial commit. nothing to undo.

Verify HEAD is not a merge commit (undoing a merge is destructive in a non-obvious way — bounce to the user):

git rev-list --parents -n 1 HEAD | awk '{print NF-1}'

If output >= 2: refused: HEAD is a merge commit. use git reset --hard ORIG_HEAD manually if you understand the consequences.

Verify HEAD is not already on the remote (cannot soft-undo a published commit without rewriting public history):

git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null

If a tracking branch exists, check whether HEAD is reachable from upstream:

git merge-base --is-ancestor HEAD @{u}

If exit 0 (HEAD already on remote): refused: HEAD is already pushed to <upstream>. /undo-commit only undoes local commits. use git revert <sha> for a published commit.

Confirm

Show what's about to be undone:

git log -n 1 --format='  %h %s%n  %an, %ar%n%n  Files:%n' HEAD
git diff --stat HEAD^..HEAD

Ask via AskUserQuestion:

Undo this commit? Changes will be moved back to the staging area.
- Yes, undo
- No, keep it

On No: print kept. and stop. No action.

Action

On Yes:

git reset --soft HEAD~1

Report

Print:

undone. HEAD now at <new-sha-short>.
prior commit's changes are staged. inspect with: git status, git diff --cached
to re-commit: /commit
to discard: git restore --staged <paths> then git restore <paths>

Rules

  • --soft only. Never --mixed, never --hard. The user's work stays in the index where it's visible and recoverable.
  • Refuse on initial commit, merge commit, or pushed HEAD. These cases need human judgment.
  • One commit per invocation. To undo multiple, run again — the per-invocation confirm forces deliberate steps.
  • Print every git command before running it.
  • Do not stage, do not commit, do not push. After git reset --soft, control returns to the user.
  • This is the only command that mutates history. Treat it as destructive (axiom 3) — never act without the per-item Yes.

Read the full file on GitHub · 131 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 131 lines · 31 tokens per session scan A 1fc57693e90c

Subscribe to this mod's changes

undo-commit is a command published in the GitHub repository damusix/atomic-claude (83 stars, last pushed 8d ago), licensed MIT. It adds 31 tokens to every session and 708 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.