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.
Some tools share a name with real people (Claude, Devin, Jules, Gemini, Junie). For
those, the name alone is not enough: the line is only removed when it is clearly the
tool, for example Claude Opus 4.5, Devin AI, a noreply@anthropic.com address or
a [bot] address. So Co-authored-by: Devin Smith <devin@example.com> is 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 --undorestores the latest one (--undo --pushrestores GitHub too). See them with--list-backupsand delete them with--drop-backups. --force-with-leaseinstead of a plain force-push: if someone pushed in the meantime, the push is refused instead of overwriting their work.- GitHub checks. If the
ghCLI is installed and logged in,cleanmsgwarns 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
Metadata
Release files for cleanmsg 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cleanmsg-0.1.1.tar.gz | 17.5 kB | With provenance | Details for cleanmsg-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cleanmsg-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for cleanmsg-0.1.1-py3-none-any.whl |
Total release size: 34.0 kB
Release files / cleanmsg-0.1.1.tar.gz
| Download URL | cleanmsg-0.1.1.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2e8a082ecde3cc16f93b71b22ab3a4b3449f3845503b97806f388fc9a17d449
|
|
BLAKE2b-256 checksum How to use checksums |
59f3749bf5a91392e53f0542c2261ef5eca43a3d94b634f7c6a8b899fdfa54d5
|
| 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 logRelease files / cleanmsg-0.1.1-py3-none-any.whl
| Download URL | cleanmsg-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
45a7e64838324e80b610c8e30ea77ce5398d4a1196731ed547b41f987be54f09
|
|
BLAKE2b-256 checksum How to use checksums |
ac982220db9858b0a5f0f927ea067bec4b39580e8da753f25a3cfd56df0e56bb
|
| 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 logSecurity for cleanmsg 0.1.1
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.
Attestation for cleanmsg-0.1.1.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 logA 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.