Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计通过

rewrite-commit-history重写提交历史记录

Agent Skill

rewrite-commit-history 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

318

周安装

13

GitHub Stars

14

下载量

103
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:rewrite-commit-history(重写提交历史记录)
来源仓库:https://github.com/ravnhq/ai-toolkit
仓库路径:skills/rewrite-commit-history
安装命令:
npx skills add https://github.com/ravnhq/ai-toolkit --skill rewrite-commit-history
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/ravnhq/ai-toolkit --skill rewrite-commit-history

简介

用于查找、检索和筛选相关信息。rewrite-commit-history 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

  • 适合根据关键词、任务场景或来源线索快速定位候选结果。
  • 可结合来源仓库、安装命令和原始 README 继续核验具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网或文件读写。
  • 注意避免执行未知命令或访问敏感资源。

SKILL.md

Rewrite Commit History

Rewrite a feature branch's messy commit history into clean, conventional commits that tell a progressive, linear story — safe to read, review, and bisect.

Workflow

Step 1 — Guard

Abort if the working tree is dirty. A clean rewrite requires a clean state.

git status --porcelain

If output is non-empty: stop. Tell the user to stash or commit pending changes first.

Then detect the parent branch. The entire rewrite depends on using the correct base — a wrong base means wrong diffs and wrong commits.

git log --oneline --decorate --graph --all | head -20

Check if the branch has commits relative to main:

git log --oneline main..HEAD 2>/dev/null | wc -l

If the count is 0 or the command fails, the branch was likely forked from something other than main. Ask the user to confirm the target branch before proceeding. Do not assume main.

Common alternatives: master, develop, staging, origin/main.

Once confirmed, set the base branch for all subsequent steps:

BASE=<confirmed-branch>  # e.g. BASE=main or BASE=develop

Step 2 — Backup

Create a timestamped backup branch at the current HEAD before touching anything.

BRANCH=$(git rev-parse --abbrev-ref HEAD)
EPOCH=$(date +%s)
git branch backup/${BRANCH}-${EPOCH}

Confirm backup was created. This is the restore point if anything goes wrong.

Step 3 — Analyze

Read the full diff and log between the base branch and HEAD.

git log --oneline ${BASE}..HEAD
git diff --stat ${BASE}...HEAD

For large branches (many files), start with --stat to see the scope before reading the full diff. Then read individual files as needed to understand the changes in depth.

git diff ${BASE}...HEAD

Identify the logical units of work. Look for:

  • Feature additions (new files, new functions)
  • Bug fixes (targeted changes to existing code)
  • Refactors (structural changes with no behavioral difference)
  • Config/tooling changes
  • Tests added or updated
  • Docs updated

Group related changes together. A good commit is one logical unit, not one file.

Step 4 — Plan

Present the proposed commit sequence to the user. Each entry must include:

  • The conventional commit message (type + scope + subject)
  • A brief summary of which files/changes are included

Order commits so each builds on the previous — the branch should compile and make sense at every point.

Example plan format:

1. feat(auth): add JWT token generation
   Files: src/auth/token.ts, src/auth/types.ts

2. feat(auth): add login endpoint with token issuance
   Files: src/routes/auth.ts, src/routes/auth.test.ts

3. chore: update env example with JWT secret
   Files: .env.example

Before confirming, verify every file that appears in git diff --stat ${BASE}...HEAD is assigned to at least one commit in the plan. Unassigned files will cause the tree parity check to fail in Step 6.

Step 5 — Confirm

Wait for user approval before executing. Accept:

  • Approval as-is
  • Edits to commit messages
  • Reordering of commits
  • Splitting one commit into two
  • Merging two commits into one

Do not proceed until the user confirms the plan.

Step 6 — Execute

Soft-reset to the merge base, then create each commit one at a time with selective staging.

git reset --soft $(git merge-base ${BASE} HEAD)

For each planned commit:

git add <specific files for this commit>
git commit -m "<conventional commit message>"

Use selective git add — never git add -A for a batch. Each commit must contain only its planned files.

After all commits, verify tree parity against the backup:

BRANCH=$(git rev-parse --abbrev-ref HEAD)
# Find the backup branch (most recent for this branch).
# sort works correctly here because the epoch timestamp is always 10 digits (valid until 2286).
BACKUP=$(git branch --list "backup/${BRANCH}-*" | sort | tail -1 | tr -d ' ')
git diff HEAD ${BACKUP}

If diff is non-empty: something was lost or corrupted. Restore immediately:

git reset --hard ${BACKUP}

Report the failure and stop.

Step 7 — Verify

Confirm success:

  • git log --oneline ${BASE}..HEAD shows the new clean history
  • git diff HEAD ${BACKUP} is empty (tree parity confirmed)
  • Report the backup branch name so the user can delete it when satisfied

Conventional Commit Types

TypeUse for
featNew feature or capability
fixBug fix
refactorCode change with no behavior change
testAdding or updating tests
docsDocumentation only
choreBuild, tooling, config, deps
perfPerformance improvement
ciCI/CD changes
styleFormatting, whitespace (no logic change)
revertReverts a previous commit

Format: type(scope): subject — subject is imperative, lowercase, no period.

Breaking changes: Append ! after type/scope, e.g. feat(api)!: rename endpoint.

Base Branch Override

Default base is main. Override with BASE=<branch> before running, or ask the user if uncertain.

Common alternatives: master, develop, staging, origin/main.

Examples

Positive Trigger

User: "Can you clean up my commits before I open this PR? It's a bunch of WIP saves."

Expected behavior: Use this skill. Start with Step 1 (guard check), then proceed through all steps.

Positive Trigger

User: "Rewrite my commit history into conventional commits."

Expected behavior: Use this skill. Follow the full 7-step workflow.

Non-Trigger

User: "Write a commit message for my current changes."

Expected behavior: Do not use this skill. Write a single commit message directly.

Non-Trigger

User: "Squash my last 3 commits into one."

Expected behavior: Do not use this skill. Use git reset --soft HEAD~3 directly and commit.

Troubleshooting

Working Tree Is Not Clean

  • Error: git status --porcelain returns output before the rewrite starts.
  • Cause: Unstaged or staged changes exist in the working directory.
  • Solution: Ask the user to stash (git stash) or commit pending changes, then retry.

Merge Base Cannot Be Found

  • Error: git merge-base ${BASE} HEAD fails or returns unexpected output.
  • Cause: The base branch name is wrong, or the branch has no common ancestor with the specified base.
  • Solution: Ask the user to confirm the base branch. Try git log --oneline to see branch history.

Tree Parity Check Fails After Rewrite

  • Error: git diff HEAD ${BACKUP} is non-empty after all commits are created.
  • Cause: One or more files were missed during selective staging, or a file was double-staged.
  • Solution: Immediately restore with git reset --hard ${BACKUP}. Report which files diverged. Re-plan and retry.

Backup Branch Not Found During Verify

  • Error: git branch --list "backup/${BRANCH}-*" returns empty.
  • Cause: Branch was deleted or the shell variable substitution failed.
  • Solution: Run git branch --list "backup/*" to locate any backup branches. Do not proceed with verification until the backup is confirmed.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.2%
按下载量换算38

Claude

29.38%
按下载量换算30

Cursor

17.49%
按下载量换算18

Gemini CLI

8.88%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills