pavloglushko/ai-skills · Archived

pavlo-commit-rewriter

Automates Phases 1–3 of the commit rewriting workflow: preparation, analysis & message drafting, and rewriting via git filter-branch. Use when you need to rewrite commit messages on the current branch to improve clarity, follow conventions, and align with a plan.

Installation

$ npx skills add pavloglushko/ai-skills --skill pavlo-commit-rewriter

Stronger alternatives

This repository is archived — consider an actively maintained alternative.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from pavloglushko/ai-skills.

npx skills add pavloglushko/ai-skills

Browse all from pavloglushko/ai-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

License LICENSE
Default branch main
Open issues 0
Status Archived

Skill metadata

Parsed from SKILL.md frontmatter.

Version3.1.1
Allowed toolsRead(${CLAUDE_SKILL_DIR}/*) Bash(python3 ${CLAUDE_SKILL_DIR}/scripts/*.py *) Bash(bash ${CLAUDE_SKILL_DIR}/scripts/*.sh *)
More metadata
author
Pavlo Glushko
version
3.1.1
applies_to
["**\/.github\/skills\/pavlo-commit-rewriter\/**"]
triggers
["rewrite commits phase 1","rewrite commits phase 2","rewrite commits phase 3","rewrite commit messages","improve commit messages","message rewriting"]
capabilities
["verify backup branch, detect branch point, list commits","analyze diff stats and map commits to plan","generate commit messages and produce mapping table (.md)","suggest merge, squash, or delete for noisy commits","reconcile user edits to mapping table before Phase 3","squash\/drop commits via automated interactive rebase","rewrite remaining messages via git filter-branch","verify result and compare against backup"]

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 5,524 B
  • docs SUMMARY.md 294 B

History

  1. First recorded snapshot · 27 installs

SKILL.md

Skill: Commit Rewriter

Rewrite commit messages in three phases: prepare, draft, apply. Follows .github/git-commit-instructions.md.

Scripts

Reusable scripts live in scripts/ relative to this SKILL.md:

Script Purpose
scripts/buildrebasetodo.py Parses commitrewritemapping.md + git log, writes /tmp/rebasetodo.txt and /tmp/commitmsg_mapping.json.
scripts/msg_filter.py Reads /tmp/commitmsgmapping.json; used as git filter-branch --msg-filter.
scripts/verify.sh Checks commit count and diffs against BACKUP branch.

Process Overview

Phase 1 — Preparation

  1. Verify <branch>-BACKUP exists; refuse to proceed if missing.
  2. Detect branch point (merge-base or user-provided).
  3. List commits; locate plan file (e.g., plan-*.md) or ask.
  4. Report findings, wait for confirmation

Phase 2 — Analysis & Message Drafting.

Phase 2 — Analysis & Message Drafting

  1. Analyze git --no-pager diff --stat per commit.
  2. Read the plan as context — diff stats take priority.

Describe what actually changed, not what the plan intended.

  1. Map commits to plan steps (by file overlap and intent):

- At most one actual commit per plan step; unmapped is fine. - Mapped → title starts with Step X:. Unmapped → plain title.

  1. Generate new messages per .github/git-commit-instructions.md.
  2. Write commitrewritemapping.md in the project root:
# Old message New message Plan step Comments
1 feat: add X Step 1: Add X to Y Step 1
2 fix typo Fix typo in Z merge with #1
3 wip delete — empty commit

Comments column: suggest merge/squash/delete where appropriate.

  1. Report table, wait for confirmation

Phase 3 — Rewrite & Verify. User may edit the file before confirming; Phase 3 re-reads it and treats every change as authoritative (renamed titles, accepted/rejected merges, reassigned mappings).

Phase 3 — Rewrite & Verify

All commands below use SCRIPTS=.github/skills/pavlo-commit-rewriter/scripts.

  1. Stash uncommitted changes (rebase and filter-branch require a clean tree):

`` git stash ``

  1. Generate rebase todo and message mapping:

`` python3 -u $SCRIPTS/buildrebasetodo.py \ --mapping commitrewritemapping.md \ --branch-point <hash> ` This writes /tmp/rebasetodo.txt and /tmp/commitmsg_mapping.json`. Review the printed summary (pick/fixup/drop counts).

  1. Rebase (only if fixup or drop rows exist):

`` GITSEQUENCEEDITOR="cp /tmp/rebase_todo.txt" \ git rebase -i <branch-point> `` Commit count decreases after rebase; the build script prints the expected count.

  1. Rewrite messages:

`` cp $SCRIPTS/msgfilter.py /tmp/msgfilter.py FILTERBRANCHSQUELCHWARNING=1 \ git filter-branch -f --msg-filter \ 'python3 /tmp/msgfilter.py /tmp/commitmsgmapping.json' \ <branch-point>..HEAD ``

  1. Verify:

`` bash $SCRIPTS/verify.sh <branch-point> <branch> <expected-count> `` - Checks commit count matches expected. - Lists all rewritten messages. - Diffs against BACKUP; warns if non-empty.

  1. Restore stashed changes:

`` git stash pop ``

Rules

  • No git pager. Every git command must use git --no-pager.

Bare git log / git diff blocks the agent.

  • Match by subject line, not hash (hashes change after rewrite/rebase).
  • Commit count changes after rebase. Verify the new count

(printed by buildrebasetodo.py) before running filter-branch.

  • Named phases. Always name the next phase when asking for confirmation.
  • User edits are authoritative. Phase 3 honours all changes

the user made to commitrewritemapping.md.

  • Stash before rewrite. Phase 3 operations require a clean working tree.

Stash before starting, pop after verification.

Related

  • .github/git-commit-instructions.md — commit message conventions.
  • pavlo-commit-by-commit-execution — execution skill using Step X: naming.