/ardent:split-commitsfrom ardent
This skill should be used when splitting a branch's commits into small, atomic commits. It creates a backup branch, squashes all commits, analyzes changes to identify logical groupings, then recreates the branch with clean atomic commits that each pass lint/typecheck/tests. Triggers on "split commits", "atomic commits", "clean up commit history", "reorganize commits", or requests to break down large commits.
Ships in ardent. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Transform a messy commit history into clean, atomic commits. This skill creates a safe working branch, squashes all changes, analyzes them to identify logical groupings, and recreates the commit history with small, focused commits that each pass all validation checks.
NEVER use git commands that require user input or open an editor. These will hang indefinitely in an automated context.
Forbidden commands:
git rebase -i (interactive rebase)git add -i or git add -p (interactive staging)git commit without -m flag (opens editor)git merge without --no-edit when it might promptgit rebase without --no-edit for conflict resolutiongit cherry-pick without handling conflicts non-interactivelySafe alternatives:
git add -p: Use the Edit tool to modify files directly, then git add <file>git rebase -i: Use git reset --soft + selective commitsgit checkout --ours/--theirs or edit files directlygit commit -m "message" with the message inlineIf a conflict occurs:
git statusgit add <file>git rebase --continue or git commitNever rely on git opening an editor or prompting for input.
Important: The original branch is NEVER modified. All work happens on a new working branch. The original branch remains as a backup/reference.
Capture current state
# Get current branch name and base branch
CURRENT_BRANCH=$(git branch --show-current)
BASE_BRANCH=$(git merge-base HEAD main || git merge-base HEAD master)
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
WORK_BRANCH="${CURRENT_BRANCH}_split_commits_${TIMESTAMP}"
Create working branch
# Create the new working branch from current state (original branch untouched)
git checkout -b "$WORK_BRANCH"
Squash all commits into one
# Reset to base while keeping all changes staged
git reset --soft "$BASE_BRANCH"
git commit -m "WIP: Squashed commits for atomic splitting"
Create documentation directory
.untracked/split-commits-${TIMESTAMP}/Generate comprehensive diff
git diff "$BASE_BRANCH"...HEAD > .untracked/split-commits-${TIMESTAMP}/full_diff.patch
git diff --stat "$BASE_BRANCH"...HEAD > .untracked/split-commits-${TIMESTAMP}/diff_stat.txt
Identify PR-worthy units of work
Using the big picture understanding from Part 0 of your dependency analysis, think about what would make sense as standalone PRs:
Analyze changes by category
Examine the diff to identify logical groupings. Look for:
Choose the right grouping strategy:
| Strategy | When to use | Example |
|---|---|---|
| By feature (vertical) | Multiple independent features | "Add auth" then "Add billing" |
| By layer (horizontal) | Single feature, clear layers | "Add schemas" then "Add services" then "Add UI" |
| Hybrid | Large feature with some independent parts | "Add core data model" then "Add feature A" then "Add feature B" |
Prefer vertical (by feature) when:
Do NOT create separate commits for:
Identify file-level splits
For files with changes that belong to multiple commits:
Build the dependency graph document (REQUIRED)
Before proposing ANY commits, create DEPENDENCY_ANALYSIS.md in the temp folder.
This is NOT optional. The structured analysis forces thorough understanding.
# Dependency Analysis for [branch-name]
## Part 0: Big Picture Understanding
Before analyzing individual files, understand what this branch accomplishes AS A WHOLE.
**What does this branch do?** (2-3 sentences, as you'd explain to a colleague)
> Example: "This branch adds skill versioning support. Users can now install specific versions of skills and switch between them. The backend tracks version history and the UI shows a version selector."
**What are the major components being added/changed?**
- [Component 1]: [brief description]
- [Component 2]: [brief description]
- [Component 3]: [brief description]
**What's the architectural change?** (if any)
> Example: "Skills change from single-instance to multi-version. New tables track versions and installations. Frontend stores need to manage version state."
**What would the PR title/description be for the ENTIRE branch?**
> This helps frame the scope and guides how to split it into smaller PRs (commits).
---
## Part 1: File-Level Analysis
For EACH changed file, document:
- **Code dependencies**: What it imports from other changed files
- **Feature/behavior**: What this file DOES (what feature it enables)
| File | Imports From | Exports Used By | Feature/Behavior |
|------|--------------|-----------------|------------------|
| SkillRecord.ts | (none) | SkillService, SkillStore, SkillCard | Defines skill data shape |
| SkillVersionRecord.ts | (none) | SkillService, SkillStore | Defines version data shape |
| SkillService.ts | SkillRecord, SkillVersion | LibraryService, CatalogService | Core skill version management logic |
| getSkill.ts | SkillRecord | - | API: fetch single skill |
| LibraryService.ts | SkillService | - | Integrates versioning into library |
| CatalogService.ts | SkillService | - | Integrates versioning into catalog |
| SkillStore.ts | SkillService (types) | SkillCard | Frontend state for skill versions |
| SkillCard.tsx | SkillStore, SkillRecord | - | UI: displays skill with version selector |
## Part 2: Feature/Behavior Groupings
Group files by WHAT THEY DO, not just what they import:
| Feature | Files | Description |
|---------|-------|-------------|
| Data model | SkillRecord.ts, SkillVersionRecord.ts | Define the shape of data |
| Core versioning logic | SkillService.ts | The main business logic |
| API access | getSkill.ts | External access to skills |
| Library integration | LibraryService.ts | Makes library version-aware |
| Catalog integration | CatalogService.ts | Makes catalog version-aware |
| Frontend | SkillStore.ts, SkillCard.tsx | User-facing version selection |
This helps identify which files are part of the same "story" even if they don't directly import each other.
## Part 3: Code Dependency Matrix
Does FILE IN ROW depend on FILE IN COLUMN? (Only showing files with dependencies)
| File | SkillRecord | SkillVersion | SkillService | getSkill | LibraryService | SkillStore |
|------|-------------|--------------|--------------|----------|----------------|------------|
| SkillService | YES | YES | - | no | no | no |
| getSkill | YES | no | no | - | no | no |
| LibraryService | YES | no | YES | YES* | - | no |
| CatalogService | YES | no | YES | YES* | no | no |
| SkillStore | YES | YES | YES | YES* | no | - |
| SkillCard | YES | no | no | no | no | YES |
*Calls API endpoint
## Part 4: Deriving Commit Groups
Looking at the matrix, identify clusters of files that:
- Have no external dependencies (can be first)
- Depend only on each other (can be grouped)
- Have clear dependency chains
Analysis:
- SkillRecord, SkillVersionRecord: No deps → Foundation, commit together
- SkillService: Depends only on schemas → Can be next
- getSkill: Depends only on schemas → Can be parallel with SkillService
- LibraryService, CatalogService: Depend on SkillService AND getSkill → Must come after both
- SkillStore: Depends on SkillService AND getSkill → Must come after both
- SkillCard: Depends on SkillStore → Must come last
## Part 5: Proposed Commit Groups
Combining code dependencies (Part 3) with feature groupings (Part 2):
| Commit | Files | Why grouped | Feature story |
|--------|-------|-------------|---------------|
| 1. schemas | SkillRecord.ts, SkillVersionRecord.ts | No dependencies | "Here's the data model" |
| 2. core-service | SkillService.ts | Depends only on schemas | "Here's the core logic" |
| 3. api | getSkill.ts | Depends only on schemas | "Here's how to fetch a skill" |
| 4. integration | LibraryService.ts, CatalogService.ts | Both need service + api | "Now existing features are version-aware" |
| 5. frontend | SkillStore.ts, SkillCard.tsx | UI layer | "Here's the user-facing UI" |
## Part 6: Validate Order
Checking each commit can compile given previous commits:
- After commit 1: SkillRecord, SkillVersionRecord available ✓
- After commit 2: SkillService can import schemas ✓
- After commit 3: getSkill can import schemas ✓
- After commit 4: LibraryService can import SkillService ✓, can call getSkill ✓
- After commit 5: SkillStore can import all ✓, SkillCard can import SkillStore ✓
Final order: 1 → 2 → 3 → 4 → 5 ✓
DO NOT proceed to step 6 until this document exists and is complete.
The file-level matrix is the foundation. Commit groups are DERIVED from it, not invented first.
Create commit plan document
Write to .untracked/split-commits-${TIMESTAMP}/COMMIT_PLAN.md:
# Commit Plan for ${CURRENT_BRANCH}
Created: ${TIMESTAMP}
Original branch: ${CURRENT_BRANCH}
Working branch: ${WORK_BRANCH}
Base commit: ${BASE_BRANCH}
**Dependency analysis**: See DEPENDENCY_ANALYSIS.md (created in step 5)
## Commit Order Rationale
Based on the dependency matrix in DEPENDENCY_ANALYSIS.md:
- Commit 1 has no dependencies → can be first
- Commit 2 depends on 1 → must come after 1
- Commit 3 depends on 1 → can be parallel with 2 or after
- [etc.]
Chosen order: 1 → 2 → 3 → ...
## Planned Commits (in order)
### Commit 1: [Short description]
**Purpose**: [Why this change exists - what PR story does this tell?]
**Files**:
- path/to/file1.ts
- path/to/file2.ts
**Provides**: [What types/functions/APIs this commit makes available]
**Requires**: None (or list what this commit imports from earlier commits)
**Absorbed**: [minor changes included: lint fixes, exports, etc.]
**Validation**: [ ] lint [ ] typecheck [ ] tests
### Commit 2: [Short description]
...
Sanity check the plan
Before proceeding, verify:
CRITICAL: Validate the order by mentally executing each commit:
For commit 1: What files exist after this commit? What can be imported?
For commit 2: Given commit 1 exists, can commit 2's code compile?
Does it import anything not yet committed?
For commit 3: Given commits 1-2 exist, can commit 3's code compile?
... and so on
If ANY commit would fail because it imports/uses something from a LATER commit, the order is wrong. Fix it before presenting to user.
Decide whether to confirm with the user
Only ask for confirmation when the split is genuinely ambiguous — i.e., there are multiple reasonable ways to group the changes and the right choice depends on user preference.
Signs you should ask:
Signs you should just proceed:
If you do ask, present concrete options:
I see a few ways to split these commits:
Option A (by layer):
1. feat(schema): add all new types
2. feat(backend): add all services
3. feat(frontend): add all UI
Option B (by feature):
1. feat: add skill versioning core
2. feat: add skill installation flow
3. feat: add version selection UI
Which approach do you prefer? [A / B / Other]
If the split is obvious, just proceed to Phase 3.
Reset to base for clean slate
git reset --hard "$BASE_BRANCH"
For each planned commit:
a. Apply the specific changes
git checkout <squashed-commit> -- path/to/fileb. Stage the changes
git add <specific-files>
c. Check for multiple migrations (REQUIRED)
If this commit includes multiple migration files, STOP and merge them first:
# Check staged migrations
git diff --cached --name-only | grep -E "migrations/.*\.sql"
If more than one migration file appears:
One commit = One migration (max). This is not optional.
d. Run tests (REQUIRED before committing)
npm test
Note: Lint and typecheck are enforced by the pre-commit hook, but tests are not. Running tests first ensures the commit will work and helps identify missing dependencies.
DO NOT proceed to step (f) until tests pass.
e. If tests fail:
f. Commit with descriptive message (only after all checks pass)
git commit -m "feat: [description of atomic change]"
g. Record success in plan
Handle complex file splits
When a single file has changes for multiple commits:
a. Read the full version from squashed commit
git show <squashed-sha>:path/to/file.ts
b. Read the base version
git show "$BASE_BRANCH":path/to/file.ts
c. Use the Edit tool to apply only the specific changes needed for this commit
d. Stage and commit
git add path/to/file.ts
git commit -m "feat: [description]"
Verify final state matches original
# Compare working tree to original branch
git diff "$CURRENT_BRANCH" --stat
git diff "$CURRENT_BRANCH"
# Should show NO differences
If differences exist:
Review commit history
git log --oneline "$BASE_BRANCH"..HEAD
Audit each commit
For each commit in the new history:
git checkout <commit-sha>
npm test
git checkout "$WORK_BRANCH"
Note: Lint/typecheck are enforced by the pre-commit hook, so if the commits exist, they passed. Tests verify runtime correctness.
Generate final report
Append to COMMIT_PLAN.md:
## Final Report
- Total commits: X
- All validations passed: Yes/No
- Final state matches original: Yes/No
### Commit Summary
| # | SHA | Message | Lint | Types | Tests |
|---|-----|---------|------|-------|-------|
| 1 | abc123 | feat: add types | ✓ | ✓ | ✓ |
| 2 | def456 | feat: add logic | ✓ | ✓ | ✓ |
...
By default, both branches are kept:
$CURRENT_BRANCH - Original branch (untouched, serves as backup)$WORK_BRANCH - New branch with clean atomic commitsReplace the original branch
Delete the original and rename the working branch:
git branch -D "$CURRENT_BRANCH"
git branch -m "$WORK_BRANCH" "$CURRENT_BRANCH"
Keep documentation
.untracked/split-commits-${TIMESTAMP}/ folder remains for referenceEach commit should be something you'd be comfortable submitting as its own PR for review.
Ask yourself: "Could this commit stand alone as a small, focused PR that a reviewer could easily understand and approve?"
Every commit must leave the codebase in a working state. Never create commits like:
BAD:
1. feat: add user authentication (has a bug)
2. fix: fix authentication bug
Instead, the fix belongs in the original commit:
GOOD:
1. feat: add user authentication (complete and working)
If you discover a bug while splitting commits, absorb the fix into the commit that introduced the broken code. The commit history should read as if you got it right the first time.
A commit should represent a complete, meaningful unit of work:
Absorb these into related commits:
NEVER commit multiple migration files in the same commit. Always merge them first.
This is checked in Phase 3 step (c) before every commit. If you have:
migrations/
001_create_skill_versions.sql
002_create_skill_installs.sql
003_add_skill_selections.sql
You MUST combine them into one:
migrations/
001_add_skill_versioning.sql (contains all three tables)
Why this matters:
BAD - Over-split (each would be a trivial/confusing PR):
1. feat: add SkillVersion schema
2. feat: add SkillInstall schema
3. chore: update index exports
4. feat: add skill_versions migration
5. feat: add skill_installs migration
6. refactor: minor button tweak
7. chore: fix lint error
GOOD - PR-worthy units:
1. feat(schema): add skill versioning data model
- All related schemas together
- Index exports included
- "Here's the new data model for skill versioning"
2. feat(backend): add skill versioning services
- Services + interfaces + tests
- "Here's the backend implementation"
3. feat(frontend): add skill version selection UI
- Components + stores + screens
- Button tweak absorbed if related
- "Here's the user-facing feature"
A slightly larger commit that tells a coherent story is better than multiple tiny commits that are confusing to review separately.
This is the most common mistake. When you discover that schemas and services are coupled, the WRONG response is:
❌ "Schema and services are coupled → combine ALL backend changes into one commit"
The RIGHT response is to be SURGICAL:
✅ "Schema field X is used by Service Y → those specific pieces go together"
Example of bad reasoning:
"The schema changes break existing code because the tools field was removed.
The schema and service changes are tightly coupled - they can't be split.
Let me combine all backend changes into one commit."
Example of good reasoning:
"The tools field removal in SkillRecord breaks SkillService.getTools().
ONLY those two changes are coupled:
- SkillRecord.tools removal
- SkillService.getTools() removal/update
The OTHER schema changes (SkillVersion, SkillInstall) and OTHER service
methods are NOT coupled to this. They can still be separate commits."
Ask these questions:
The goal is the MINIMUM viable grouping, not the MAXIMUM convenient grouping.
DO NOT immediately bundle everything together. Take time to understand the dependency and find the minimal fix.
When a commit fails validation:
Identify exactly what's missing
Error: Cannot find name 'SkillVersion'
→ The type SkillVersion is defined in a later commit
Understand the dependency relationship
Choose the RIGHT fix (in order of preference):
Option A: Reorder commits (best if possible)
Option B: Pull in ONLY the missing piece (surgical fix)
SkillVersion interface, not the entire schema fileOption C: Move the dependent code to a later commit
Option D: Merge two specific commits (targeted merge)
Option E: Rethink the split (not a last resort - often the RIGHT answer)
Example of bad vs good grouping:
BAD (causes dependency issues):
1. All types/schemas
2. All services
3. All UI components
→ Services need types, UI needs services = constant dependency problems
GOOD (self-contained):
1. Feature A: types + service + UI for feature A
2. Feature B: types + service + UI for feature B
→ Each commit is complete and independent
NEVER do this:
Before panicking, ask:
When a file has changes that logically belong to different commits but are interleaved:
If the final state differs from the original:
git diff "$CURRENT_BRANCH" to see what's differentWhat SKILL.md sets; muted values are Claude Code's defaults
24 skills in this plugin
/address_pr_feedbackAnalyze PR changes and comments, create a plan, and implement feedback/archiveUpload HTML docs to the team's GitHub Pages archive for permanent browsing and sharing. Use when the user says "archive this", "upload to archive", or /archive./brainstormExplore requirements and approaches through collaborative dialogue before planning/cleanupSimplify and refine recently modified code for clarity and maintainability while preserving behavior. Use for requests like "simplify this", "clean this up", "reduce complexity", or readability-focused refactors.npx claudepluginhub ardent-ai/ardent-claude-plugins --plugin ardentOther plugins' skills for the same job