agentleFS
TashanGKDTashanGKD/cc_plugins/.claude/skills/squash/SKILL.md

squash

Skill4 starsChanged 10 months agoMITView on GitHub

Commit 历史整理与合并。将 TDD 循环产生的多个细碎 commit 合并为有意义的功能 commit,包含安全检查、交互式 rebase 指导。用户提到 squash、整理 commit 时使用。

  • Deletes or force-pushes
  • Commits and pushes

3 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions3 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 3

    1. aymericbeaumet/dotfiles★ 22same name
    2. Pradnyeshp/Claude-Skills★ 2same name
    3. TrimVis/skills★ 2same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository7 other files it gives its agents.

The file

Files
SKILL.md

Commit 历史整理

TDD 产生的小 commit 应该在功能完成后整理

将 TDD 循环产生的多个细碎 commit 合并为有意义的功能 commit。


快捷命令

/squash              # 交互式引导(自动安全检查)
/squash feature       # 合并单个功能的所有 commit
/squash abort         # 中止 rebase

⚠️ 安全警告:Squash 仅适用于本地未推送的 commit。


1. 安全检查

快速检查

检查命令安全危险
保护分支git branch --show-currentfeature/*main/master
未推送git log @{u}..有输出无输出

Golden Rule:只整理本地未推送的 commit。


2. 交互式 Rebase

2.1 合并最近 N 个 commit

# 查看最近 commit
git log --oneline -10

# 合并最近 6 个 commit
git rebase -i HEAD~6

2.2 Rebase 命令

命令说明
pick保留此 commit
squash合并到前一个 commit
fixup合并到前一个,丢弃 message
drop删除此 commit

2.3 合并示例

Before:

pick abc1234 test: 添加订单测试
pick def5678 feat: 实现订单功能
pick ghi9012 refactor: 提取验证函数

After:

pick abc1234 test: 添加订单测试
fixup def5678 feat: 实现订单功能
fixup ghi9012 refactor: 提取验证函数

3. 快速合并

# 方式 A:软重置后重新提交
git reset --soft HEAD~4
git commit -m "feat: 实现完整功能"

# 方式 B:自动 fixup
GIT_SEQUENCE_EDITOR="sed -i '2,$s/^pick/fixup/'" git rebase -i HEAD~4

4. 推送重写的历史

git push --force-with-lease origin feature-branch
命令说明
--force-with-lease推荐:如果远程有新提交则失败
--force / -f强制覆盖,可能丢失他人提交

5. 故障恢复

# 放弃 rebase
git rebase --abort

# 恢复到 rebase 前的状态
git reflog
git reset --hard HEAD@{N}

6. 清理空间

# 快速清理(推荐)
git gc --prune=now

# 激进清理(.git 过大时)
git gc --aggressive --prune=now

小 commit 开发 → 整理后推送 → 干净的历史

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.