rebase-commits

将零散的 commits 整合为清晰的逻辑提交,使 Git 历史更易读。 Use when: (1) 用户说 "rebase commits"、"整理提交历史"、"让历史更干净" (2) 用户想将多个相关 commits 合并为逻辑单元 (3) 完成一个功能后需要清理 commit 历史 (4) 提交历史混乱,需要重新组织

Best use case

rebase-commits is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

将零散的 commits 整合为清晰的逻辑提交,使 Git 历史更易读。 Use when: (1) 用户说 "rebase commits"、"整理提交历史"、"让历史更干净" (2) 用户想将多个相关 commits 合并为逻辑单元 (3) 完成一个功能后需要清理 commit 历史 (4) 提交历史混乱,需要重新组织

Teams using rebase-commits should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/rebase-commits/SKILL.md --create-dirs "https://raw.githubusercontent.com/Lionad-Morotar/local-tools/main/local-link/skills/rebase-commits/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/rebase-commits/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How rebase-commits Compares

Feature / Agentrebase-commitsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

将零散的 commits 整合为清晰的逻辑提交,使 Git 历史更易读。 Use when: (1) 用户说 "rebase commits"、"整理提交历史"、"让历史更干净" (2) 用户想将多个相关 commits 合并为逻辑单元 (3) 完成一个功能后需要清理 commit 历史 (4) 提交历史混乱,需要重新组织

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Rebase Commits

将零散的 commits 整合为清晰的逻辑提交。自动识别 commit 分组模式,生成 rebase 脚本,批量修改 commit message。

## Workflow

### Step 1: 分析 Commit 历史

获取需要 rebase 的 commit 范围:

```bash
# 查看 commit 历史
git log --oneline <start-commit>..HEAD

# 统计数量
git rev-list --count <start-commit>..HEAD
```

### Step 2: 识别分组模式

根据 commit message 和文件变更识别分组策略:

| 模式 | 识别特征 | 分组策略 |
|------|----------|----------|
| 功能分组 | 相同功能/模块的变更 | 每个功能合并为 1 个 commit |
| 类型分组 | `docs:`、`feat:`、`fix:`、`chore:` | 按类型和逻辑合并 |
| 目录分组 | 相同目录的文件变更 | 按模块合并 |
| 工作流分组 | `docs(phase-01)`、`feat(plan-01)` | 按阶段/计划合并 |

### Step 3: 生成分组方案

向用户展示建议的分组方案:

```
建议将 N 个 commits 合并为 M 个逻辑提交:

1. init: 项目初始化与基础配置
   - 包含: chore: add config, docs: readme...

2. feat: 实现核心功能 A
   - 包含: feat: add component, fix: bug fix...

3. feat: 实现核心功能 B
   - 包含: feat: add service, test: add tests...

确认此方案?或需要调整?
```

### Step 4: 创建备份分支

在执行 rebase 前创建备份:

```bash
git branch backup/<branch-name>-pre-rebase
```

### Step 5: 执行 Rebase

使用交互式 rebase:

```bash
# 启动交互式 rebase
git rebase -i <base-commit>^

# 在编辑器中调整:
# - pick: 保留 commit
# - squash/s: 合并到前一个 commit
# - fixup/f: 合并并丢弃 message
# - reword/r: 修改 message
```

### Step 6: 优化 Commit Message

确保 message 清晰描述变更:

```
<type>(<scope>): <subject>

<body>
```

### Step 7: 验证结果

```bash
# 查看新的 commit 历史
git log --oneline <base-commit>..HEAD

# 确认文件状态
git status
```

## Commit Message 规范

优化后的 message 应遵循:

```
<type>(<scope>): <subject>

类型说明:
- feat: 新功能实现
- fix: 修复问题
- docs: 文档更新
- chore: 杂项(构建、工具等)
- refactor: 重构(无功能变化)
- test: 测试相关
- style: 代码格式(不影响功能)
```

## 示例

### 转换前(零散 commits)

```
b2799237 docs: add readme
ed56958e fix: typo
2aa4a3e1 feat: add login page
a0fd7b27 feat: add login api
e15b958e fix: login bug
...
```

### 转换后(逻辑 commits)

```
ca1036c7 docs: 添加项目文档
8f336f51 feat: 实现用户登录功能
9632bb66 feat: 实现用户注册功能
```

## 恢复备份

如果 rebase 后需要恢复:

```bash
git reset --hard backup/<branch-name>-pre-rebase
```

## 注意事项

1. **只在本地分支执行** - 已推送的共享分支不要 rebase
2. **先创建备份** - 始终保留恢复选项
3. **确认工作区干净** - rebase 前确保无未提交更改
4. **处理冲突** - 如遇冲突,解决后 `git rebase --continue`

Related Skills

debug-by-commits

7
from Lionad-Morotar/local-tools

通过 Git Commit 二分法调试前端白屏/卡死问题。 当用户报告页面白屏、无响应、卡死,且怀疑是代码问题时使用。 特别适用于: 1. 开发服务器能启动但页面显示白屏 2. 页面无响应或卡死(可能是死循环) 3. 需要快速定位引入问题的具体 commit 4. 需要排除缓存、配置等干扰因素

open-u-dashboard

7
from Lionad-Morotar/local-tools

open understand dashboard for user

sync-template-skill

7
from Lionad-Morotar/local-tools

这是一个技能文件的模板,展示了技能的基本结构和内容组织方式。

talk-humanize

7
from Lionad-Morotar/local-tools

Be direct and informative. No filler, no fluff, but give enough to be useful.

search-web

7
from Lionad-Morotar/local-tools

使用 Evaluator-optimizer 模式进行系统性多轮网络搜索,采用结构化 Ask 流程在搜索前澄清研究目标。基于 YC Office Hours 的提问方法论,确保搜索方向清晰、结果可验证。当用户需要深入调查复杂主题、验证假设或全面收集信息时使用。

save-to-eagle

7
from Lionad-Morotar/local-tools

归档网络内容到 Eagle 素材库。支持:(1) Behance/Pixiv 图片归档,(2) 网页视频录制(页面动画、滚动录制)。使用方式:'归档 [URL]' 归档图片;'录制网页视频 [URL]' 录制页面动画;'滚动录制 [URL]' 自动滚动截图。支持评分如 '归档 [URL], 3/5'。

save-ob-chaos

7
from Lionad-Morotar/local-tools

将对话内容快速存档到 Obsidian Chaos 文件夹。触发词:"存档到 Obsidian"、"保存到 Chaos"、"ob 存档"、"记下这个"、"保存这段内容"、"存到 chaos"。

save-ob-chaos-mermaid

7
from Lionad-Morotar/local-tools

将 Mermaid 图表保存到 Obsidian Chaos 文件夹。触发词:"保存 mermaid 到 chaos"、"mermaid 存档"。

save-ob-chaos-excalidraw

7
from Lionad-Morotar/local-tools

绘制 Excalidraw 图表并存档到 Obsidian Chaos 文件夹。触发词:"画个图存到 Obsidian"、"excalidraw 存档"、"画个流程图保存"、"画图存到 chaos"、"创建图表并存档"、"画架构图到 ob"。

release-project

7
from Lionad-Morotar/local-tools

项目版本发布流程指导,帮助用户完成版本规划、Changelog 管理、版本号升级、Git 标签创建和 npm 首次发布准备。Use when: (1) 用户需要发布新版本 (2) 需要创建版本发布流程 (3) 需要管理版本号和 Changelog (4) 需要自动化版本发布 (5) 需要检查 release 分支同步 (6) 首次 npm 发布准备

recognize-codebase-branch-flow

7
from Lionad-Morotar/local-tools

识别并记忆项目 git 分支模型

read-codebase

7
from Lionad-Morotar/local-tools

阅读棕地项目代码库,智能分析代码结构,递归补充其调用链上所有函数的注释。