git-rollback

A command-driven guide for undoing the latest Git commit. Git is a version-control system that records changes to code.

In plain words
What is it for?
Use it with the explicit rollback command to perform a soft, mixed, or hard rollback. A hard rollback permanently discards the affected changes.
Why use it?
It lets you remove the latest commit while choosing whether to keep the changes staged, unstaged, or discard them.

Skill for Claude CodeCodex

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 skills/flasherses/claude-code-dotfiles/git-rollback
Any agent
npx skills add flasherses/claude-code-dotfiles --skill git-rollback
Clone the repo
git clone --depth 1 https://github.com/flasherses/claude-code-dotfiles

Made for: Claude Code, Codex.

Per session 71 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 930 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.00071 $0.00930
Opus 5 $0.00036 $0.00465
Sonnet 5 $0.00014 $0.00186
Haiku 4.5 $0.00007 $0.00093

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

Security

Grade A, and why

git-rollback 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.

skills/git-rollback/SKILL.md · 99 lines

What it actually says

Git Rollback — 回滚最后一次 Commit

目标

撤销最近一次 git commit,根据模式保留或丢弃变更。不可逆操作,必须由用户显式触发。

前置检查

执行前必须完成以下检查,任一失败则中止:

# 1. 确认在 git 仓库中
git status 2>$null
if ($LASTEXITCODE -ne 0) {
    Write-Host "❌ 不在 git 仓库中"; exit 1
}

# 2. 检查是否有未提交变更(可选保护)
$uncommitted = git status --porcelain
if ($uncommitted) {
    Write-Host "⚠️ 存在未提交的变更:"
    Write-Host $uncommitted
    Write-Host "这些变更不会被回滚影响,但建议先处理"
}

# 3. 显示即将回滚的 commit
Write-Host "`n即将回滚的 commit:"
git log -1 --format="  %h — %s (%an, %ar)"

三种回滚模式

模式 命令 commit 暂存区 工作区
--soft git reset --soft HEAD~1 撤销 ✅ 保留 ✅ 保留
--mixed git reset --mixed HEAD~1 撤销 ❌ 清空 ✅ 保留
--hard git reset --hard HEAD~1 撤销 ❌ 清空 ❌ 丢弃

默认模式: --mixed(最安全) hard 模式: 需要用户二次确认

执行流程

Step 1: 确定模式

  • 如果用户没有指定模式 → 使用 --mixed
  • 如果用户说了 soft / --soft → 使用 --soft
  • 如果用户说了 hard / --hard必须二次确认

Step 2: 二次确认(hard 模式专用)

Write-Host "⚠️ HARD 模式将永久丢弃所有变更!"
Write-Host "最近一次 commit 的内容:"
git show --stat HEAD
$confirm = Read-Host "确认执行 hard reset?(输入 YES 继续)"
if ($confirm -ne "YES") {
    Write-Host "已取消"; exit 0
}

Step 3: 执行

# soft 或 mixed
git reset <mode> HEAD~1

# 然后显示结果
Write-Host "`n回滚后的状态:"
git log -1 --format="  HEAD → %h — %s (%ar)"
git status --short

⚠️ 易错点

  1. 已 push 的 commit — 如果 commit 已经推送到远程,回滚后需要 git push --force 才能同步。这会覆盖远程历史——绝对不要在 main/master 上做,只在个人分支上做。
  2. hard reset 不可恢复 — 一旦执行,变更只能通过 reflog 找回(git reflog + git cherry-pick)。
  3. merge commit 回滚HEAD~1 在 merge commit 上可能行为不符合预期,需要加 -m 1 参数。

回滚后的恢复

如果用户后悔了回滚操作:

git reflog                        # 找到回滚前的 commit hash
git reset --hard <commit-hash>    # 恢复到该 commit
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 · 99 lines · 71 tokens per session scan A b21f1d993e50

Subscribe to this mod's changes

git-rollback is a skill published in the GitHub repository flasherses/claude-code-dotfiles (5 stars, last pushed 22d ago), licensed MIT. It adds 71 tokens to every session and 930 once invoked, about $0.0004 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-31.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens