clean-history
This skill contains shell command directives (!`command`) that may execute system commands. Review carefully before installing.
Clean History
Reimplement the current branch on a new branch with a clean, narrative-quality git commit history.
Context
- Source branch: !
git branch --show-current - Git status: !
git status --short - Default branch: !
git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || git config init.defaultBranch || echo main - Remote branches: !
git branch -r --list 'origin/main' 'origin/master' 2>/dev/null | head -1 | sed 's/.*origin\///'
Task
Reimplement the current branch on a new branch with a clean, narrative-quality git commit history suitable for reviewer comprehension.
New Branch Name: Use $ARGUMENTS if provided, otherwise {source_branch}-clean.
Base Branch: Determine the base branch using this priority:
- The "Default branch" from context above (if available)
- The first available branch from "Remote branches" (
origin/mainororigin/master) - Fall back to
mainif neither is available
Steps
-
Validate the source branch
- Ensure no uncommitted changes or merge conflicts
- Confirm the source branch is not the same as the base branch (error if so)
- Run
git log {base}..HEAD --onelineto see commits to clean - Run
git diff {base}...HEAD --statto see the full diff - Confirm source branch is up to date with the base branch
-
Analyze the diff
- Study all changes between source branch and the base branch
- Form a clear understanding of the final intended state
-
Create the clean branch
- Create a new branch off of the base branch using the new branch name
-
Plan the commit storyline
- Break the implementation into self-contained logical steps
- Each step should reflect a stage of development—as if writing a tutorial
-
Reimplement the work
- Recreate changes in the clean branch, committing step by step
- Each commit must:
- Introduce a single coherent idea
- Include a clear commit message and description
- Use
git commit --no-verifyfor all intermediate commits. Pre-commit hooks check tests, types, and imports that may not pass until the full implementation is complete. Do not waste time fixing issues in intermediate commits that will be resolved by later commits.
-
Verify correctness
- Confirm the final state exactly matches the source branch
- Run the final commit without
--no-verifyto ensure all checks pass
-
Open a pull request
- Create a PR with a summary of the changes
- Include a link to the original branch in the PR description
Rules
- Never add yourself as an author or contributor
- Never include "Generated with Claude Code" or "Co-Authored-By" lines in commits
- The end state of the clean branch must be identical to the source branch
More from montagao/skills
library-ebooks
>-
56plane-api
Internal helper for creating/listing/updating Plane work items.
42llm-seo
Optimize websites and content for AI/LLM discoverability (AIO - AI Optimization). Use when asked to "optimize for AI", "improve AI discoverability", "add LLM SEO", "make site AI-friendly", "help LLMs understand my site", or when implementing llms.txt files, JSON-LD structured data, or AI-focused content strategies.
20supernote-upload
Upload PDF and EPUB files to Supernote Cloud. Use this skill when the user wants to send documents to their Supernote device.
16todo
Create a Plane task in Plane. By default, use the interview skill first to flesh out the issue before creating it; only skip the interview when the user clearly wants a minimal quick capture.
15un-ai-writing
Rewrite and edit existing text to sound natural and human, removing common AI writing tells while preserving meaning and facts. Use when asked to humanize, de-AI-ify, un-AI, make it sound less robotic, polish an AI draft, or remove AI-writing signs in any prose (emails, docs, posts, essays, scripts).
14