Agent Skills: Smart Commit

Splits uncommitted changes into multiple logical commits by functionality. Use when asked to organize commits, split changes, or create atomic commits.

UncategorizedID: meglinge/megskills/smart-commit

Install this agent skill to your local

pnpm dlx add-skill https://github.com/meglinge/megskills/tree/HEAD/skills/smart-commit

Skill Files

Browse the full folder contents for smart-commit.

Download Skill

Loading file tree…

skills/smart-commit/SKILL.md

Skill Metadata

Name
smart-commit
Description
Splits uncommitted changes into multiple logical commits by functionality. Use when asked to organize commits, split changes, or create atomic commits.

Smart Commit

将未提交的更改按功能/逻辑分成多个独立的 commit。

工作流程

  1. 分析更改

    • 运行 git status 查看所有未提交的文件
    • 运行 git diffgit diff --cached 查看具体更改内容
  2. 分类更改

    • 阅读每个文件的更改内容
    • 按功能/逻辑将更改分组:
      • 新功能
      • Bug 修复
      • 重构
      • 文档更新
      • 配置变更
      • 测试相关
      • 样式/格式化
  3. 逐组提交

    • 对每组相关更改:
      git add <相关文件...>
      git commit -m "<type>: <简洁描述>"
      
    • 如果单个文件包含多个功能的更改,使用 git add -p 分块暂存

Commit 消息格式

使用 Conventional Commits 格式:

  • feat: 添加用户登录功能
  • fix: 修复分页计算错误
  • refactor: 重构数据库连接逻辑
  • docs: 更新 API 文档
  • test: 添加用户模块单元测试
  • chore: 更新依赖版本
  • style: 格式化代码

注意事项

  • 每个 commit 应该是独立的、可编译的
  • 相关的更改放在同一个 commit
  • 不相关的更改分开提交
  • commit 消息要清晰描述更改内容
  • 提交前确认分组是否合理