skills/assistant/rewrite-commit-history/SKILL.md
Rewrite a feature branch's commit history into clean conventional commits that tell a progressive, linear story. Handles backup, soft reset, and atomic recommit. Use when: (1) Cleaning up messy WIP commits before PR, (2) Reorganizing commits into logical units, (3) Converting commits to conventional commit format. Triggers on: "rewrite history", "clean up commits", "rewrite commits", "conventional commits", "squash and rewrite", "reorganize commits".
npx skillsauth add ravnhq/ai-toolkit rewrite-commit-historyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Rewrite a feature branch's messy commit history into clean, conventional commits that tell a progressive, linear story — safe to read, review, and bisect.
Abort if the working tree is dirty. A clean rewrite requires a clean state.
git status --porcelain
If output is non-empty: stop. Tell the user to stash or commit pending changes first.
Then detect the parent branch. The entire rewrite depends on using the correct base — a wrong base means wrong diffs and wrong commits.
git log --oneline --decorate --graph --all | head -20
Check if the branch has commits relative to main:
git log --oneline main..HEAD 2>/dev/null | wc -l
If the count is 0 or the command fails, the branch was likely forked from something other than main. Ask the user to confirm the target branch before proceeding. Do not assume main.
Common alternatives: master, develop, staging, origin/main.
Once confirmed, set the base branch for all subsequent steps:
BASE=<confirmed-branch> # e.g. BASE=main or BASE=develop
Create a timestamped backup branch at the current HEAD before touching anything.
BRANCH=$(git rev-parse --abbrev-ref HEAD)
EPOCH=$(date +%s)
git branch backup/${BRANCH}-${EPOCH}
Confirm backup was created. This is the restore point if anything goes wrong.
Read the full diff and log between the base branch and HEAD.
git log --oneline ${BASE}..HEAD
git diff --stat ${BASE}...HEAD
For large branches (many files), start with --stat to see the scope before reading the full diff. Then read individual files as needed to understand the changes in depth.
git diff ${BASE}...HEAD
Identify the logical units of work. Look for:
Group related changes together. A good commit is one logical unit, not one file.
Present the proposed commit sequence to the user. Each entry must include:
Order commits so each builds on the previous — the branch should compile and make sense at every point.
Example plan format:
1. feat(auth): add JWT token generation
Files: src/auth/token.ts, src/auth/types.ts
2. feat(auth): add login endpoint with token issuance
Files: src/routes/auth.ts, src/routes/auth.test.ts
3. chore: update env example with JWT secret
Files: .env.example
Before confirming, verify every file that appears in git diff --stat ${BASE}...HEAD is assigned to at least one commit in the plan. Unassigned files will cause the tree parity check to fail in Step 6.
Wait for user approval before executing. Accept:
Do not proceed until the user confirms the plan.
Soft-reset to the merge base, then create each commit one at a time with selective staging.
git reset --soft $(git merge-base ${BASE} HEAD)
For each planned commit:
git add <specific files for this commit>
git commit -m "<conventional commit message>"
Use selective git add — never git add -A for a batch. Each commit must contain only its planned files.
After all commits, verify tree parity against the backup:
BRANCH=$(git rev-parse --abbrev-ref HEAD)
# Find the backup branch (most recent for this branch).
# sort works correctly here because the epoch timestamp is always 10 digits (valid until 2286).
BACKUP=$(git branch --list "backup/${BRANCH}-*" | sort | tail -1 | tr -d ' ')
git diff HEAD ${BACKUP}
If diff is non-empty: something was lost or corrupted. Restore immediately:
git reset --hard ${BACKUP}
Report the failure and stop.
Confirm success:
git log --oneline ${BASE}..HEAD shows the new clean historygit diff HEAD ${BACKUP} is empty (tree parity confirmed)| Type | Use for |
|------|---------|
| feat | New feature or capability |
| fix | Bug fix |
| refactor | Code change with no behavior change |
| test | Adding or updating tests |
| docs | Documentation only |
| chore | Build, tooling, config, deps |
| perf | Performance improvement |
| ci | CI/CD changes |
| style | Formatting, whitespace (no logic change) |
| revert | Reverts a previous commit |
Format: type(scope): subject — subject is imperative, lowercase, no period.
Breaking changes: Append ! after type/scope, e.g. feat(api)!: rename endpoint.
Default base is main. Override with BASE=<branch> before running, or ask the user if uncertain.
Common alternatives: master, develop, staging, origin/main.
User: "Can you clean up my commits before I open this PR? It's a bunch of WIP saves."
Expected behavior: Use this skill. Start with Step 1 (guard check), then proceed through all steps.
User: "Rewrite my commit history into conventional commits."
Expected behavior: Use this skill. Follow the full 7-step workflow.
User: "Write a commit message for my current changes."
Expected behavior: Do not use this skill. Write a single commit message directly.
User: "Squash my last 3 commits into one."
Expected behavior: Do not use this skill. Use git reset --soft HEAD~3 directly and commit.
git status --porcelain returns output before the rewrite starts.git stash) or commit pending changes, then retry.git merge-base ${BASE} HEAD fails or returns unexpected output.git log --oneline to see branch history.git diff HEAD ${BACKUP} is non-empty after all commits are created.git reset --hard ${BACKUP}. Report which files diverged. Re-plan and retry.git branch --list "backup/${BRANCH}-*" returns empty.git branch --list "backup/*" to locate any backup branches. Do not proceed with verification until the backup is confirmed.testing
Transform user requests into detailed, precise prompts for AI models. Use when users say 'promptify', 'promptify this', 'rewrite this prompt', 'make this prompt better/more specific', or explicitly request prompt engineering or improvement of their request for better AI responses.
tools
Manage AI skills from the Ravn AI Toolkit via corvus CLI — install, update, remove, search, and configure skills for any project. Use when: (1) Installing AI skills into a project, (2) Updating installed skills to latest versions, (3) Browsing or searching available skills, (4) Configuring global or per-project skill sets, (5) Troubleshooting corvus setup. Triggers on: "install skills", "add skills", "update skills", "corvus", "skill manager", "browse skills", "set up AI rules".
development
Generate a gallery of design variations for a UI component. Takes an existing component (referenced by name, pasted code, or screenshot) and produces N distinct rendered alternatives in a single comparison page. Use when exploring visual directions, generating mockups, comparing design approaches for a component, creating A/B candidates, or when anyone says "show me options" or "give me variations" for a UI element.
tools
Create custom QA agent personalities for project-specific testing needs. Guided builder that asks about the specialty, tools, and test scenarios, then generates a personality file and registers it in the QA config. Trigger on "create a QA personality", "add a custom test agent", "build a webhook tester", or when the user needs a project-specific QA agent. Also triggered by /qa-create-personality.