clean-branch
Clean branch
Build the smallest complete feature diff on a fresh branch, preserving the source branch, index, and working files. This changes the selected content; it is not a history-only cleanup.
Identify the feature and base
Infer the intended behavior and scope from the request, conversation, and relevant issue or PR. Inspect the actual committed diff, staged and unstaged changes, and untracked files. Record the source HEAD and status before extraction. If multiple features are equally plausible, ask which one to extract before creating a branch.
Use the user's chosen base, otherwise the current PR's base, otherwise the repository's default branch. Resolve it to a commit; refresh a remote-tracking ref when possible and disclose any freshness limitation. If no base can be established, ask rather than guessing. Inspect source changes since the merge base, but create the destination at the selected base tip so newer base changes survive.