agentleFS
CarpeWuCarpeWu/claude-git-skills/skills/git-commit/SKILL.md

git-commit

Skill0 starsChanged 10 months agoMITView on GitHub

Generates commit messages by analyzing git diffs and learning project commit style. Use when committing code changes, when the user asks for help writing commit messages, or mentions git commit.

  • Reads credentials

174 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use github-pr-create, git-issue and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • mjun0812Skill

    github-pr-create

    Pull Requestを作成するSkill。現在のbranchからpull requestを作成する。言語指定可能。 ユーザーが「PR作って」「pull request作成して」のように依頼したら使うこと。

    Also in 3 projects that use this

  • klauswgSkill

    git-issue

    Prepare, review, create, or update evidence-based GitHub issues for the current repository with duplicate detection, repository-native templates, valid labels, and post-publication verification. Use when the user asks to draft, file, submit, publish, edit, or refine a GitHub issue, bug report, feature request, performance issue, or technical proposal. Always require the user to review and explicitly approve the exact final issue before any GitHub write.

    Also in 3 projects that use this

  • gologo13Skill

    git-push

    Push current branch to origin and sync with remote updates; keywords: git, rebase. Use only on explicit request; before execution, review diffs and list impact scope.

    Also in 6 projects that use this

  • GoogleSkill

    github-pr-review

    Review a GitHub pull request and leave inline comments in a natural human reviewing voice, indistinguishable from comments typed by hand on the GitHub web UI. Deliberately bounded to defects a reader can settle by looking at the anchored line, rather than a deep audit, so every comment is cheap for the author to check. Scales to 2-20 comments by PR size, parallelises analysis across sub-agents, drafts for approval, then posts individually with human pacing. Use when the user says "review this PR", "review PR 123", pastes a github.com/.../pull/N link, or asks for comments on a pull request. Don't use for reviewing local uncommitted changes or a diff against a branch (use the `review` skill for that).

    Also in 4 projects that use this

  • GitHubSkill

    multi-stage-dockerfile

    Create optimized multi-stage Dockerfiles for any language or framework

    Also in 3 projects that use this

  • Microsoft AzureSkill

    test-discipline

    Update tests when changing APIs — no exceptions

    Also in 3 projects that use this

The file

Files
SKILL.md

Git Commit

智能 Git 提交 - 学习项目风格,生成规范 commit message

Context

  • 当前分支: !git branch --show-current
  • Git 状态: !git status --short
  • 暂存变更统计: !git diff --cached --stat
  • 暂存变更详情: !git diff --cached
  • 提交历史样本: !git log --format="%s" -15

Workflow

执行以下 3 个步骤,不要跳过任何步骤。

Step 1: 前置检查与分析

1.1 前置检查

首先检查以下条件,如不满足则立即停止并提示用户:

检查项失败时的处理
暂存区为空停止并提示:暂存区为空,请先使用 git add 添加文件
在 main/master 分支警告:⚠️ 当前在保护分支,建议创建新分支后再提交
检测到敏感文件警告并列出文件,建议排除

敏感文件模式(检测暂存区):

.env, .env.*, *.env
*credential*, *secret*, *token*, *password*
*.pem, *.key, *.p12, *.pfx
id_rsa, id_dsa, id_ecdsa

1.2 学习项目提交风格

分析 Context 中的「提交历史样本」,识别以下模式:

语言判断:

  • 统计 15 条历史 commit 中的中文/英文比例
  • 中文字符占比 > 50% → 使用中文
  • 否则 → 使用英文

格式判断:

模式识别特征示例
Conventional + Scope匹配 类型(范围): feat(api): xxx
Conventional 无 Scope匹配 类型: feat: xxx
方括号前缀匹配 [类型] [feat] xxx
无前缀无固定前缀Add user login

Scope 提取:从历史中提取常用 scope 列表,如:api, ui, core, auth, docs

1.3 分析暂存变更

根据 git diff --cached 判断变更类型:

变更类型识别信号
feat新增文件、新函数/类/组件、新 API 端点
fix修复条件判断、异常处理、边界情况
refactor重命名、提取函数、移动代码(功能不变)
docs.md 文件、注释、README
testtest_.py、.spec.ts、*.test.js
chorepackage.json、配置文件、CI/CD
style纯格式化、空格、缩进

Scope 推断(根据文件路径):

  • src/api/* → api
  • src/ui/* → ui
  • src/core/* → core
  • 跨多模块 → 不加 scope

Step 2: 生成预览

根据 Step 1 的分析结果,生成 commit message 并展示预览。

输出格式:

╭─────────────────────────────────────────────────────╮
│  📋 Git 提交预览                                    │
╰─────────────────────────────────────────────────────╯

🎨 检测到的项目风格:
   语言: [中文/英文]
   格式: [feat(scope): / feat: / 无前缀]
   常用 Scope: [api, ui, core, ...]

📝 生成的提交信息:
╭─────────────────────────────────────────────────────╮
│ <type>(<scope>): <subject>                          │
╰─────────────────────────────────────────────────────╯

📁 将提交的文件:
   • file1.py  (+xx, -xx)
   • file2.py  (+xx, -xx)
   [共 N 个文件, +XX 行, -XX 行]

⚠️ 注意事项:
   [如有敏感文件警告或其他提示,在此显示]

─────────────────────────────────────────────────────
请选择操作:
  • 输入 "ok" 或 "确认" → 执行提交
  • 输入修改意见 → 重新生成
  • 输入 "cancel" 或 "取消" → 放弃操作

Commit Message 生成规则:

  1. 使用检测到的项目风格(语言、格式)
  2. Subject 长度 ≤ 50 字符
  3. 动词开头(中文:添加/修复/重构;英文:add/fix/refactor)
  4. 不加句号结尾

Step 3: 确认执行

等待用户输入,根据响应执行:

用户输入操作
ok/确认/y/yes执行 git commit -m "..."
修改意见(如"改成fix")根据意见重新生成,返回 Step 2
cancel/取消/n/no输出 🚫 已取消提交 并结束

执行成功后输出:

✅ 提交成功!

📝 feat(api): 添加用户注册接口
🔑 commit: a1b2c3d
🌿 分支: feature/user-auth

Default Conventions

如果项目提交历史不足 5 条,无法判断风格,使用以下默认规范:

格式: <type>(<scope>): <subject>
语言: 中文
动词: 祈使句(添加/修复/更新/重构/删除)

类型:
  feat     新功能
  fix      问题修复
  refactor 重构
  docs     文档
  test     测试
  chore    构建/工具/配置
  style    代码格式
  perf     性能优化

Error Handling

情况输出
暂存区为空❌ 暂存区为空\n💡 请先使用 git add <file> 添加要提交的文件
在保护分支⚠️ 当前在 main 分支\n💡 建议: git checkout -b feature/xxx
检测到敏感文件⚠️ 检测到敏感文件:\n ❌ .env.local\n💡 请使用 git reset HEAD <file> 移除
git 命令失败❌ Git 命令执行失败\n💡 错误信息: <stderr>

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.