← 返回
未分类 中文

Commit Tidy

Analyze staged/committed changes and recommend splitting or squashing strategy. interactive-amend - worktree-based amend+rebase loop for commits ahead of HEA...
分析暂存/已提交变更,推荐拆分或压缩策略;interactive-amend - 基于工作树的 amend+rebase 循环,用于处理领先于 HEA 的提交...
drumrobot
未分类 clawhub v0.3.0 3 版本 100000 Key: 无需
★ 1
Stars
📥 568
下载
💾 1
安装
3
版本
#latest

概述

Commit Tidy

Topics

TopicDescriptionGuide
---------------------------
interactive-amendWorktree-based amend+rebase loop for earlier/multiple commitsinteractive-amend.md
soft-reset-amendSoft-reset top N commits and selectively re-commit (simpler than worktree rebase)soft-reset-amend.md

Analyze staged/unstaged changes and recommend whether to split into multiple commits.

When to use

  • Before committing large changesets
  • User asks "should I split this commit?"
  • Reviewing changes that touch many files
  • Ensuring atomic, reviewable commits

Split Decision Criteria

Split when

  1. Unrelated functionality changes
    • Feature A + Bug fix B → 2 commits
    • UI change + API change (if independent) → 2 commits
  1. Wide file spread
    • Changes span 5+ directories with no common purpose
    • Frontend + Backend + Config all modified
  1. Mixed change types
    • Refactoring + New feature → 2 commits
    • Formatting + Logic change → 2 commits
    • Dependency update + Code change → 2 commits
  1. Large diff size
    • 500+ lines changed across unrelated areas
    • Multiple components modified independently
  1. Different reviewers needed
    • Changes require different domain expertise
    • Security-sensitive + general changes

Keep together when

  1. Single logical change
    • Feature requires touching multiple files
    • Refactoring that must be atomic
  1. Dependent changes
    • API change + caller updates
    • Schema change + migration + model update
  1. Related cleanup
    • Feature + directly related tests
    • Bug fix + regression test

Squash Criteria

When analyzing multiple commits, recommend squashing as well as splitting.

Squash when

  1. Same type + same purpose
    • test: A test + test: B test (tests for the same feature) → squash into 1
    • fix: typo A + fix: typo B (same review feedback) → squash into 1
  1. Commits split per loop by automated agents
    • Autonomous agents like Ralph commit per loop → squash if same purpose
    • Example: proxy test in loop 1, OIDC test in loop 2 → test: add unit tests
  1. Consecutive WIP commits
    • wip: in progress + feat: complete → squash into one feat

Don't squash

  1. Commits with different types — keep test + chore + feat separate
  2. Commits belonging to different PRs/issues
  3. Independent changes that may need to be reverted

Output format (when recommending squash)

### Recommendation: Squash 2 commits → 1

**Before** (2 commits):
- 441b966a test(dt): OIDC auth, proxy, SSO tests
- e2b6503a test(dt): OIDC route tests (login, callback, me)

**After** (1 commit):
- test(dt): add OIDC auth unit tests

**Reasoning**: Same type (test), same feature (OIDC auth), agent loop split

Instructions

Step 0: Determine scope

When ARGUMENTS specify a range (e.g., "since main", "last 3 commits", "PR #N"), analyze all changes in that range — both committed and uncommitted.

# Range specified (e.g., "X changes since main")
git log --oneline <base>..HEAD -- <path>     # committed changes
git diff <base>..HEAD --stat -- <path>        # committed diff
git diff HEAD --stat -- <path>                # uncommitted diff

The analysis must cover committed commits (squash/split candidates) + uncommitted changes (new commit candidates) as a single unified view. Do not analyze only uncommitted changes when a range is specified.

When no range is specified, default to staged + unstaged changes only.

Step 1: Analyze changes

# Check staged changes
git diff --cached --stat
git diff --cached --name-only

# Check unstaged changes
git diff --stat
git status

Step 2: Categorize files

Group changed files by:

  • Feature/Component: Which feature does this belong to?
  • Change type: feat, fix, refactor, style, test, docs, chore
  • Directory: Are changes localized or spread out?

Step 3: Identify boundaries

Look for natural split points:

  • Different conventional commit types
  • Independent functionality
  • Separate test files from implementation (if tests are for different features)

Step 4: Recommend split strategy

Provide specific recommendations:

## Analysis Results

### Changed Files (N files)
- src/api/... (3 files) - API endpoints
- src/components/... (2 files) - UI components
- tests/... (2 files) - Tests

### Recommendation: Split into N commits

**Commit 1**: feat: add user profile API
- src/api/user.ts
- src/api/types.ts
- tests/api/user.test.ts

**Commit 2**: feat: add profile UI component
- src/components/Profile.tsx
- src/components/Profile.css
- tests/components/Profile.test.tsx

### Reasoning
- API and UI can function independently
- Each can be reviewed by different reviewers

Step 5: Execute split (if requested)

# Unstage all
git reset HEAD

# Stage first commit files
git add src/api/ tests/api/
git commit -m "feat: add user profile API"

# Stage second commit files
git add src/components/ tests/components/
git commit -m "feat: add profile UI component"

Quick Reference

File spread heuristic

FilesDirectoriesRecommendation
------------------------------------
1-51-2Usually single commit
5-102-3Review for split
10+4+Likely needs split

Change type combinations to split

CombinationSplit?
---------------------
feat + feat (unrelated)✅ Yes
feat + related test❌ No
fix + unrelated refactor✅ Yes
refactor + style (same files)❌ No
chore(deps) + feat✅ Yes

Output Format

Analysis results should include:

  1. List of changed files with categories
  2. Whether split is needed and why
  3. Specific commit splitting plan
  4. Suggested commit messages for each
  5. Execution commands (if requested)

版本历史

共 3 个版本

  • v0.3.0 当前
    2026-06-04 13:13
  • v0.1.2
    2026-05-21 13:07 安全 安全
  • v0.1.1
    2026-05-03 07:10 安全 安全

安全检测

腾讯云安全 (Keen)

队列中

腾讯云安全 (Sanbu)

队列中

🔗 相关推荐

Tdd

drumrobot
用于编码和缺陷修复的测试驱动开发(TDD),包括 Red→Green→Refactor 循环、预期行为定义、缺陷修复 TDD、反模式 [cycle.md]、运行...
★ 0 📥 1,173

Claude Session

drumrobot
Claude Code session management. Topics — id (current session UUID), list (enumerate sessions), search (keyword + result
★ 0 📥 659

Git Repo

drumrobot
Git 仓库与 SourceGit 集成:克隆(ghq get + 自动注册 SourceGit),修复工作树(裸仓库恢复),合并重复(同源处理)
★ 0 📥 633