smart-commit

meglinge's avatarfrom meglinge

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

⭐0stars🔀0forks📁View on GitHub🕐Updated Jan 7, 2026

When & Why to Use This Skill

Smart Commit is an essential Git utility that automates the organization of uncommitted changes into logical, atomic commits. By analyzing code diffs and categorizing updates into standard types—such as features, bug fixes, and refactors—it ensures a clean, readable repository history and strictly adheres to Conventional Commit standards, significantly improving project maintainability.

Use Cases

  • Cleaning up a large workspace: Automatically group multiple unrelated changes into separate, meaningful commits after a long coding session.
  • Enforcing Conventional Commits: Standardize commit messages across a project using the 'type: description' format to facilitate automated changelog generation.
  • Enhancing Code Reviews: Break down complex PRs into smaller, functional commits, making it easier for reviewers to follow the logic and intent of each change.
  • Atomic Staging: Intelligently split changes within a single file into different commits based on their specific functionality (e.g., separating a bug fix from a style change).
namesmart-commit
descriptionSplits 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 diff 和 git 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 消息要清晰描述更改内容
  • 提交前确认分组是否合理