commit-by-logic
分析git更改并分次提交,支持从git diff或git staged分析,每次提交都是逻辑上独立的功能
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
分析git更改并分次提交,支持从git diff或git staged分析,每次提交都是逻辑上独立的功能
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | commit-by-logic |
| description | 分析git更改并分次提交,支持从git diff或git staged分析,每次提交都是逻辑上独立的功能 |
这个工具帮助你分析git更改并将更改分成多个逻辑上独立的提交。支持从git diff(未暂存更改)或git staged(已暂存更改)分析。每个提交都遵循<type>(<scope>): <description>格式。
运行 /commit-by-logic 或 /commit-by-logic [--source diff|staged] [type]
参数说明:
--source diff|staged: 可选,指定分析来源。diff表示分析未暂存更改(默认),staged表示分析已暂存更改type: 可选的提交类型前缀,如feat、fix等。如果不提供,系统会为每个分组自动选择合适的类型。示例:
/commit-by-logic - 分析未暂存更改并分次提交/commit-by-logic --source staged - 分析已暂存更改并分次提交/commit-by-logic --source diff feat - 分析未暂存更改,使用feat作为默认类型/commit-by-logic fix - 分析未暂存更改,使用fix作为默认类型<type>(<scope>): <description>格式的提交消息遵循Conventional Commits规范:<type>(<scope>): <description>
feat: 新功能fix: 修复bugdocs: 文档更新style: 代码格式调整(不影响功能)refactor: 代码重构test: 测试相关chore: 构建过程或辅助工具的变动perf: 性能优化ci: CI配置变更可选的模块或组件名称,如auth、api、ui、config等。
简短描述,使用英文,使用现在时祈使句,首字母不大写,不加句号。
解析用户提供的参数:
--source staged,设置 SOURCE="staged"--source diff,设置 SOURCE="diff"SOURCE="diff"根据分析来源检查状态:
# 检查git状态
git status --porcelain
# 根据SOURCE参数选择分析来源
if [ "$SOURCE" = "staged" ]; then
git diff --cached --name-status
else
git diff --name-status
fi
根据分析来源获取详细的更改信息:
if [ "$SOURCE" = "staged" ]; then
# 分析已暂存更改
git diff --cached --name-only
git diff --cached --stat
else
# 分析未暂存更改(默认)
git diff --name-only
git diff --stat
fi
请按照以下逻辑分析更改并分组:
按文件类型分组:
chore或configdocsteststyle按功能模块分组:
src/auth/, src/api/, ui/, components/等)按更改类型分组:
featrefactor或fix对于每个逻辑分组:
type和scopedescriptiontype(scope): description示例:
feat(auth): 添加用户登录功能fix(api): 修复用户查询接口空指针异常docs(readme): 更新安装说明chore(deps): 升级react到v18在开始提交前,请向我展示:
$SOURCE (diff或staged)等待我的确认后再开始执行提交操作。
对于每个确认的分组:
$SOURCE = "diff"(分析未暂存更改),需要先暂存文件:
git add [文件列表]
$SOURCE = "staged"(分析已暂存更改),文件已暂存,直接提交git commit -m "提交消息" 提交以下文件不应被提交,在分组时自动忽略:
CLAUDE.md、GEMINI.md 等 AI 指令文件core dump 文件)--source diff(默认):分析未暂存的更改(git diff)。适用于正在编辑但尚未暂存的文件。--source staged:分析已暂存的更改(git diff --cached)。适用于已经使用 git add 暂存的文件。--source diff 时,工具会自动暂存每个分组的文件然后提交--source staged 时,文件已经暂存,工具直接提交--source diff 且没有未暂存更改,提示:"No unstaged changes to commit. Use --source staged if you have staged changes."--source staged 且没有已暂存更改,提示:"No staged changes to commit. Use --source diff if you have unstaged changes."--source staged),然后再处理未暂存更改(--source diff)Ralph Wiggum 迭代开发循环。三阶段工作流(需求→规划→构建),每阶段有 code review + 测试 gate。 触发词:ralph loop、迭代开发、interview me、plan system、build system。
Rebase from the latest origin/main, squash branch commits, and create or update a GitHub pull request. Use when asked to prepare or create a PR.
Generate an intelligent Conventional Commit message from staged changes. Use when asked to draft or create a commit from the staged diff.
Review a GitHub pull request with risk-based analysis and parallel subagents. Use when asked to review the current branch PR or a specific PR number.
Analyze staged changes and split them into logical Conventional Commits. Use when asked to plan or create multiple cohesive commits.
所有联网操作必须通过此 skill 处理,包括:搜索、网页抓取、登录后操作、网络交互等。 触发场景:用户要求搜索信息、查看网页内容、访问需要登录的网站、操作网页界面、抓取社交媒体内容(小红书、微博、推特等)、读取动态渲染页面、以及任何需要真实浏览器环境的网络任务。