clean-branch

Extract essential feature changes from mixed commits and working-tree state into a fresh branch.

Updated Aug 6, 2026
One-click install
npx skills add https://github.com/wkentaro/skills --skill clean-branch-wkentaro
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: clean-branch
Source: https://github.com/wkentaro/skills/tree/main/skills/engineering/clean-branch
Command: npx skills add https://github.com/wkentaro/skills --skill clean-branch-wkentaro

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Feature work often ends up tangled with unrelated refactors, debug logging, and experiments across commits, staged changes, and untracked files. This Skill isolates only the intended feature into a clean branch on a chosen base without touching the original branch, index, or working tree. ## Core Features & Use Cases - Selective feature extraction: Selects changes by feature dependency rather than whole commits or files, separating mixed hunks and reimplementing them against the destination base. - Isolated worktree workflow: Builds the destination in a separate git worktree so the source HEAD, index, and working files remain untouched, and accounts for worktree copy settings that might carry over ignored files. - Verification and handoff: Reviews the complete destination diff, runs feature tests and repository checks, and reports the branch, base commit, kept and omitted changes, and check results while leaving changes uncommitted unless authorized. - Use Case: A developer has a branch mixing a CSV export feature with debug logging and an unrelated theme change, plus staged and untracked files. The Skill extracts only the CSV feature onto a fresh branch based on the latest main, preserving a newer security fix and including the required untracked test file. ## Quick Start Ask the assistant to extract only the CSV export feature from the current work into a clean branch based on origin/main.

Frequently Asked Questions about clean-branch

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract one feature from a messy git branch?▼

Identify the intended feature and base, then select changes by feature dependency rather than whole commits or files. Build the extraction in a separate git worktree so the source branch, index, and working files stay untouched, and verify the destination diff with tests.

How to split mixed commits into a clean feature branch?▼

Inspect the committed diff, staged and unstaged changes, and untracked files, then reimplement only the feature-related hunks against the destination base. Leave unrelated refactors, formatting, and experiments behind, and include the tests and dependencies the feature needs.

What is the difference between clean-branch and recommit?▼

Clean-branch changes the selected content by extracting a minimal feature diff onto a fresh branch. Use recommit instead when only the commit history should change and the underlying content stays the same.

Does extracting a feature branch modify my current working tree?▼

No. The extraction happens in a separate worktree created with git-wt or git worktree add, so the source HEAD, index, and working files remain unchanged and are verified after extraction.

What happens if the feature or base branch is ambiguous?▼

The workflow asks which feature to extract and which base to use before creating any branch. It never guesses when multiple features are equally plausible or no base can be established, and it never mutates the source first.