smart-commit
Analyze staged changes and split them into logical Conventional Commits. Use when asked to plan or create multiple cohesive commits.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Analyze staged changes and split them into logical Conventional Commits. Use when asked to plan or create multiple cohesive commits.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
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.
所有联网操作必须通过此 skill 处理,包括:搜索、网页抓取、登录后操作、网络交互等。 触发场景:用户要求搜索信息、查看网页内容、访问需要登录的网站、操作网页界面、抓取社交媒体内容(小红书、微博、推特等)、读取动态渲染页面、以及任何需要真实浏览器环境的网络任务。
诊断并激活长期停滞的项目文档。Use when: (1) 项目状态为 active 但周记录/里程碑/工作日志大面积空白, (2) 项目已进行多周但文档未更新,(3) 用户感到"做了很多但看不到成果",(4) 项目文档沦为空模板。 核心方法:从已有记录反推补全进展 → 定义阶段性里程碑 → 建立同步闭环。
| name | smart-commit |
| description | Analyze staged changes and split them into logical Conventional Commits. Use when asked to plan or create multiple cohesive commits. |
Analyze all currently staged git changes, group them by logical concern, and create multiple well-structured commits following Conventional Commits v1.0.0.
$smart-commit [--dry-run]
Arguments:
--dry-run: Only show the proposed commit plan without executingEvery commit message MUST follow this format:
<type>[optional scope][optional !]: <description>
[optional body]
[optional footer(s)]
| Type | When to Use |
|---|---|
feat | A new feature (correlates with MINOR in SemVer) |
fix | A bug fix (correlates with PATCH in SemVer) |
docs | Documentation only changes |
style | Formatting, missing semi-colons, etc. (not CSS) |
refactor | Code change that neither fixes a bug nor adds a feature |
perf | Performance improvement |
test | Adding or correcting tests |
build | Changes to build system or external dependencies |
ci | Changes to CI configuration files and scripts |
chore | Other changes that don't modify src or test files |
revert | Reverts a previous commit |
Subject line (first line):
git log --oneline, git shortlog, etc.<type>(scope): — e.g., feat(auth): Add JWT refresh, NOT feat(auth): add JWT refreshBody:
Scope & Breaking Changes:
scope: noun describing the section of the codebase (e.g., auth, api, parser)! after type/scope: indicates a BREAKING CHANGE (correlates with MAJOR in SemVer)BREAKING CHANGE: footer for breaking change detailsCloses #123 / Refs #456 in footer to reference issues# List all staged files
git diff --cached --name-only
# Get full staged diff
git diff --cached
# Get staged file stats (additions/deletions per file)
git diff --cached --stat
If no staged changes exist, stop and inform the user.
For each staged file, read the full diff carefully. Understand:
Analyze all staged changes and group them by logical concern. Each group becomes one commit.
Grouping Principles (priority order):
feat and fix in the same commit; don't mix docs with code changesCommon Grouping Patterns:
| Pattern | Example |
|---|---|
| Feature + its tests | feat(auth): Add JWT token refresh (includes both src/auth/refresh.ts and test/auth/refresh.test.ts) |
| Config/dependency change | build(deps): Upgrade axios to v1.6 |
| Documentation update | docs(api): Update authentication examples |
| Independent bug fixes | Each fix = separate commit |
| Refactor + affected tests | refactor(parser): Simplify AST traversal |
| Style/formatting batch | style: Apply prettier formatting (can batch unrelated files) |
Anti-Patterns (DO NOT do these):
Order commits so that:
Display the plan in this format:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Commit Plan: N commits from M staged files
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Commit 1/N
Message: fix(parser): Handle empty input without panic
Files:
- src/parser/input.go
- src/parser/input_test.go
Commit 2/N
Message: feat(api): Add batch processing endpoint
Files:
- src/api/batch.go
- src/api/batch_test.go
- src/api/routes.go
Commit 3/N
Message: docs(api): Document batch processing endpoint
Files:
- docs/api/batch.md
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
If --dry-run was specified, stop here.
Ask user to confirm the plan. If user wants to adjust grouping, re-plan.
For each commit in order:
Unstage everything first (only before the first commit):
git reset HEAD -- .
Stage only the files for this commit:
git add <file1> <file2> ...
If a file has both related and unrelated changes (i.e., partial staging needed), use:
git add -p <file>
and guide the user through hunk selection, OR stage the whole file if all changes belong to this commit.
Create the commit:
git commit -m "$(cat <<'EOF'
<type>(<scope>): <description>
<body if needed>
EOF
)"
Verify the commit succeeded:
git log --oneline -1
After all commits are created:
# Show the commit log
git log --oneline -N # where N = number of commits created
# Verify no staged changes remain
git diff --cached --name-only
# Show working tree status
git status
Display summary:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Done! Created N commits:
abc1234 fix(parser): Handle empty input without panic
def5678 feat(api): Add batch processing endpoint
ghi9012 docs(api): Document batch processing endpoint
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
If all staged changes belong to ONE logical concern, create a single commit. Don't split artificially.
When a file contains changes for multiple commits, use git add -p for patch-level staging. Explain to the user which hunks belong to which commit.
If a commit fails due to pre-commit hooks:
If there are also unstaged changes in the working tree:
Staged files:
src/auth/login.ts (bug fix: null check)src/auth/login.test.ts (test for the fix)src/api/users.ts (new endpoint)src/api/users.test.ts (tests for new endpoint)docs/api/users.md (documentation)package.json (new dependency)Commit Plan:
Commit 1/4: build(deps): Add zod validation library
→ package.json
Commit 2/4: fix(auth): Add null check for user in login flow
→ src/auth/login.ts, src/auth/login.test.ts
Commit 3/4: feat(api): Add user listing endpoint
→ src/api/users.ts, src/api/users.test.ts
Commit 4/4: docs(api): Add user endpoint documentation
→ docs/api/users.md
Staged files:
src/utils/string.ts (extracted helper)src/parser/tokenizer.ts (uses new helper)src/parser/tokenizer.test.ts (updated tests)Commit Plan:
Commit 1/1: refactor(parser): Extract string utilities from tokenizer
→ src/utils/string.ts, src/parser/tokenizer.ts, src/parser/tokenizer.test.ts
(Single commit because all changes are part of one refactor.)