git-rollback

git-rollback is a skill for Claude Code from flasherses/claude-code-dotfiles. It costs 71 tokens per session (930 once invoked), scanned A, original, MIT.

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 Code

Written for Claude Code: disable-model-invocation in frontmatter.

Part of the claude-code-dotfiles plugin — 3 skills, 4 commands, 5 agents, 1 plugin shipped together

Good fit Use it with the explicit rollback command to perform a soft, mixed, or hard rollback. A hard rollback permanently discards the affected changes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/flasherses/claude-code-dotfiles/git-rollback
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.

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.

Or install claude-code-dotfiles, the plugin that ships this one along with the rest of its 3 skills, 4 commands, 5 agents, 1 plugin.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for git-rollback

README.md
[![agentmods](https://agentmods.dev/badge/skills/flasherses/claude-code-dotfiles/git-rollback/github.svg)](https://agentmods.dev/skills/flasherses/claude-code-dotfiles/git-rollback)
Your own site
<a href="https://agentmods.dev/skills/flasherses/claude-code-dotfiles/git-rollback"><img src="https://agentmods.dev/badge/skills/flasherses/claude-code-dotfiles/git-rollback/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for git-rollback

Your own site · 80×15
<a href="https://agentmods.dev/skills/flasherses/claude-code-dotfiles/git-rollback"><img src="https://agentmods.dev/badge/skills/flasherses/claude-code-dotfiles/git-rollback.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00071 $0.00930
Opus 5.5 $0.00028 $0.00372
Sonnet 5.5 $0.00014 $0.00186
Haiku 4.5 $0.00007 $0.00093

Measured 2mo ago against content hash b21f1d993e50, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 2mo 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. 2mo 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 (6 stars, last pushed 3mo ago), licensed MIT. It adds 71 tokens to every session and 930 once invoked, about $0.0003 per session on Opus 5.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

git-rollback compared with skills from other repositories

git-rollback next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
git-rollbackflasherses/claude-code-dotfilesSkill63mo agoMITA71Claude Code
create-prprisma/ormSkill48ktodayApache-2.0A48Claude Code, Codex
git-commitThinkInAIXYZ/deepchatSkill6.4ktodayApache-2.0A15Claude Code, Codex
repo-syncdavidondrej/skillsSkill4.3ktodayMITA25Claude Code, Codex
engineer-bot-opsmakecindy/cindySkill9.7ktodayApache-2.0A57Claude Code, Codex
mcore-split-prNVIDIA/skillsSkill3.9ktodayApache-2.0A25Claude Code
contributingHugoRCD/evlogSkill1.9k4d agoMITA68Claude Code, Codex