Skip to main content

cleanmsg

Remove AI attribution lines, or any text, from your git commit messages. Safely.

AI coding tools like to sign their work. After a while your history looks like this:

Add login form

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Whether you keep those lines is your call (some projects require them). If you don't want them, cleanmsg strips them out of existing commits: it shows you what will change first, keeps a backup, and can force-push the result to GitHub.

It works for any text, too: WIP, [skip ci], a ticket number, a typo you repeated in 40 commits.

Example

$ cleanmsg --ai
3 commit message(s) to change in branch 'main':
  88912d10  Add password reset flow
            - 🤖 Generated with [Claude Code](https://claude.com/claude-code)
            - Co-Authored-By: Claude <noreply@anthropic.com>
  d4de968e  Validate e-mail on submit
            - Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
  52744c5d  Add login form
            - 🤖 Generated with [Claude Code](https://claude.com/claude-code)
            - Co-Authored-By: Claude <noreply@anthropic.com>

Preview only, nothing changed. Add --apply to rewrite (and --push to update GitHub).

$ cleanmsg --ai --apply --push
...
Rewrite and force-push branch 'main'? [y/N] y
Rewriting with git filter-repo...
Done. Backup saved as 20261127-135715 (undo with: cleanmsg --undo)
Force-pushing main -> origin/main

Afterwards the commit reads just:

Add login form

Removing your own text works the same way:

$ cleanmsg "my change"
1 commit message(s) to change in branch 'main':
  169560e2  fix login my change
            - fix login my change
            + fix login

Install

pipx install "cleanmsg[fast]"      # or: uv tool install "cleanmsg[fast]"

[fast] also installs git-filter-repo, which makes rewriting large repos much faster. Without it, cleanmsg falls back to the git filter-branch command that ships with git. Both give the same result.

Needs Python 3.10+ and git. It installs both a cleanmsg command and git cleanmsg.

From source:

git clone https://github.com/enikakis/cleanmsg && cd cleanmsg
pipx install ".[fast]"

Usage

Run it inside a repository. Nothing is changed unless you pass --apply.

cleanmsg --ai                          # preview: which AI lines would go
cleanmsg --ai --apply                  # rewrite the current branch locally
cleanmsg --ai --apply --push           # ... and force-push to GitHub
cleanmsg "WIP" --last 5 --apply        # only the last 5 commits
cleanmsg -e "[skip ci]" -e "fixup" --unpushed --apply
cleanmsg -E 'JIRA-\d+' --apply         # regular expression
cleanmsg --undo                        # put the old history back

What to remove

Option
TEXT / -e TEXT text to remove; give as many as you like
--ai AI attribution lines (see below)
-E, --regex treat TEXT as a regular expression, matched per line
-i, --ignore-case match regardless of case

A line that only contained the removed text is deleted entirely. Leftover double spaces are collapsed. If a message would end up empty, it is left as is. Messages without a match are not touched, so those commits keep their hash.

Which commits

Option
(default) the whole current branch
--last N only the last N commits
--unpushed only commits that aren't on the upstream branch yet (no force-push needed)
--all every local branch and tag

Actions

Option
--apply actually rewrite (otherwise: preview only)
--push force-push the rewritten branches (and tags) to their remote
-y don't ask for confirmation
-v list every affected commit (the preview shows the first 20)
-C PATH run on another repository

What --ai removes

Whole lines like these (case-insensitive):

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: aider (gpt-4o) <noreply@aider.chat>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Generated by GitHub Copilot

Also Codex, ChatGPT, Gemini, Devin, Windsurf, Codeium, Amazon Q, Jules, Junie, Cline, Roo Code and opencode. Human co-authors (Co-authored-by: Jane <jane@example.com>) are kept. Run cleanmsg --show-ai-patterns for the exact regular expressions. Missing a tool? Open an issue or PR.

Safety

Rewriting history is the scary part, so cleanmsg is careful about it:

  • Preview by default. You see every line that will go before anything happens.
  • Confirmation before rewriting or pushing (skip with -y).
  • Backups. Before every rewrite the old branches and tags are saved under refs/cleanmsg-backup/<time>/. cleanmsg --undo restores the latest one (--undo --push restores GitHub too). See them with --list-backups and delete them with --drop-backups.
  • --force-with-lease instead of a plain force-push: if someone pushed in the meantime, the push is refused instead of overwriting their work.
  • GitHub checks. If the gh CLI is installed and logged in, cleanmsg warns you before pushing to a protected branch or a branch with open pull requests (turn off with --no-github-checks).
  • Refuses to run with uncommitted changes.

Things to know

  • Changing a commit message changes that commit's hash and the hash of every commit after it. That is why a force-push is needed, and why anyone else with a clone needs to reset to the new history (git fetch && git reset --hard origin/main). It's best on your own repos or branches.
  • Rewritten commits lose their GPG/SSH signatures.
  • This is not a way to scrub secrets. GitHub can keep old commits reachable by their hash, and pull requests keep their own copies. If you committed a password or key, rotate it, and follow GitHub's guide to removing sensitive data.

How it works

cleanmsg reads the messages with git log to build the preview. When you apply, it hands the same cleaning function to git filter-repo (if installed) or git filter-branch, limited to the commits you chose. Authors, dates and file contents stay exactly the same; only the messages change.

Development

python -m pip install pytest git-filter-repo
python -m pytest            # runs the end-to-end tests with both engines
./bin/cleanmsg --help       # run from the checkout without installing

License

MIT

Metadata

Release files for cleanmsg 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cleanmsg 0.1.0
File Size Uploaded Provenance Actions
cleanmsg-0.1.0.tar.gz 16.6 kB With provenance Details for cleanmsg-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cleanmsg 0.1.0
File Interpreter ABI Platform Actions
cleanmsg-0.1.0-py3-none-any.whl Python 3 none any Details for cleanmsg-0.1.0-py3-none-any.whl

Total release size: 32.5 kB

Release files / cleanmsg-0.1.0.tar.gz

Download URL cleanmsg-0.1.0.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
701627f180a85fbde5e98a7421a2ef888b41782dabd00159e7f468db07d29d02
BLAKE2b-256 checksum
How to use checksums
15606048dd2fdc6227002827a4b9b608e214c028672a65c9ca198117983a4076
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / cleanmsg-0.1.0-py3-none-any.whl

Download URL cleanmsg-0.1.0-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2d159239623d15bd8d57b19f0c0c4ea5b17b096e2f93e43f5c0e7d3d20cf9e3
BLAKE2b-256 checksum
How to use checksums
b585d4c8b729c808de8fe63504d5dcd844c0e692e0a1d872b31384dc32c1cd00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for cleanmsg 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cleanmsg-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page