AI coding tools can leave a small but consequential trace in a commit message or pull request: a generated-by footer or an automatic Co-authored-by trailer. If that text does not belong in your project's public history, discovering it in CI is already too late.
This tutorial shows how to add a local, deterministic guardrail with ai-credit-scrub. The tool is a Go CLI that works offline for cleaning and checking text. It can rewrite the temporary commit message, reject an escaped credit before a push, and sanitize pull request text before delegating to your existing GitHub CLI authentication.
The goal is narrow: remove explicit AI-agent credit lines when your policy requires it, while preserving ordinary human attribution and product mentions.
TL;DR
Install the released CLI, run ai-credit-scrub install --git inside a repository, and test it with a message containing an explicit credit. The commit-msg hook rewrites the message before Git creates the commit, while pre-push checks outgoing commit messages. For pull requests, use ai-credit-scrub pr create instead of calling gh pr create directly.
Prerequisites
You need:
- Git installed and a local repository where you can install hooks.
- Go 1.26 or a prebuilt binary from the project's release page.
- The stable
v1.1.0release used in this tutorial. - GitHub CLI only if you want the pull request wrapper. It must already be authenticated locally.
The repository is public, MIT licensed, non-archived, and owned by Fernando Paladini. The release source declares Go 1.26.0 in go.mod.
Install the released CLI
The documented Go installation command is:
go install github.com/paladini/ai-credit-scrub/cmd/ai-credit-scrub@v1.1.0
Check that the executable is available:
ai-credit-scrub --help
The current CLI exposes five relevant entry points: clean, scan, check, install, and pr create. clean rewrites text, scan reports matches, and check is the non-rewriting check used by the push hook.
Install the Git boundary
From the repository you want to protect, run:
ai-credit-scrub install --git
The installer adds two chained hooks:
-
commit-msgreceives Git's temporary message file and cleans it before the commit object is written. -
pre-pushchecks commit messages that are about to leave the machine and rejects a matching explicit credit.
Chaining matters. If the repository already has a hook, the tool preserves and runs it as part of the local hook chain. This makes the guardrail additive instead of silently replacing existing repository behavior.
You can inspect the resulting files with normal Git commands or by looking in .git/hooks. The hook files are local repository state, not files committed to the project.
Reproduce the cleaning behavior
Create a temporary message file with both a line that should be removed and a line that should remain:
cat > /tmp/ai-credit-message.txt <<'EOF'
Document local hooks
Generated with Claude Code
Co-authored-by: Claude <noreply@anthropic.com>
Reviewed in Cursor
EOF
Run the cleaner:
ai-credit-scrub clean /tmp/ai-credit-message.txt
cat /tmp/ai-credit-message.txt
Expected output is equivalent to:
Document local hooks
Reviewed in Cursor
ai-credit-scrub: removed 2 explicit credit block(s)
The important distinction is that the tool matches complete, explicit credit signatures. A product name alone is not treated as a credit, so a sentence such as Reviewed in Cursor remains available for normal review context.
For a read-only check, use:
ai-credit-scrub scan CHANGELOG.md
Use scan when you want findings without changing the file. Use clean --in-place when you intentionally want a source text file rewritten.
Protect pull request text too
Git hooks cover commits and pushes, but a pull request title and body are not part of Git history. Create the pull request through the local wrapper:
ai-credit-scrub pr create \
--title "Document local hooks" \
--body-file pull-request.md
The wrapper cleans the supplied title and body, then delegates to your existing local gh pr create authentication. It does not require an ai-credit-scrub account, a hosted service, or an additional token.
This boundary is easy to miss when working with agents. An agent that calls a separate GitHub-writing integration can create a pull request without invoking local Git at all. In that workflow, the local Git hooks cannot see the request body. The project's integration guide recommends instructing the agent to use this wrapper, or using a local sanitizing proxy that is the only GitHub-writing server available to the agent.
Add a reviewed custom rule
The built-in signatures cover explicit credits for Codex, Claude Code, Cursor, Windsurf, and GitHub Copilot. You can add project-specific patterns with a configuration file:
version: 1
reviewed: true
literals:
- "Internal agent credit"
regex:
- '(?m)^Generated by ExampleBot\\.?$'
exclude:
- "historical example"
The reviewed: true acknowledgement is deliberate. Custom rules can create false positives, so review their matches before enabling them. The project asks contributors to provide both a removal fixture and a false-positive fixture for new signatures.
Install a custom configuration only after reviewing it:
ai-credit-scrub scan --config .ai-credit-scrub.yml CHANGELOG.md
Keep historical examples, legal notices, and human contributor credits out of broad patterns. A conservative rule that misses an ambiguous sentence is safer than a rule that silently removes meaningful attribution.
Why this works
The design places enforcement at three different points in the local publication path:
- Before commit creation,
commit-msgrewrites the temporary message. - Before a remote update,
pre-pushchecks outgoing commit messages. - Before a pull request API call, the wrapper cleans the title and body.
That separation reflects what each interface can actually control. The tool does not pretend that a Git hook can intercept every remote API or rewrite shared history safely. It keeps cleaning and checking local, deterministic, and offline-first. Only the pull request wrapper needs network access, and that call is made by the user's already-authenticated gh installation.
Failure modes and limits
There are several boundaries to understand before treating this as a complete publication policy:
-
git commit --no-verifybypasses the commit hook. The pre-push hook can still catch the escaped credit. -
git push --no-verifybypasses the final local check too. Treat it as an intentional override. - A pull request created directly in the GitHub website or by an independent GitHub MCP server bypasses Git hooks.
- The tool does not rewrite Git author or committer identity.
- Removing a credit may conflict with an organization's contributor agreement, disclosure policy, or applicable law. Confirm the policy before enabling the rule.
- The repository documents local enforcement, not CI enforcement. A CI job can report a problem, but it does not provide the same pre-publication boundary.
The v1.1.0 release also reports its dependency and toolchain status separately from these policy limits. In a clean checkout, go test ./... passed five tests, go vet ./... reported no issues, and the CLI smoke path passed. Those checks demonstrate the documented path, not a security guarantee or coverage of every Git client.
FAQ
Does this remove every mention of an AI tool?
No. It targets explicit credit lines and known trailers. A product name by itself is intentionally preserved.
Does it upload commit messages or source code?
Cleaning and checking require no network access and the project documents no hosted service or prompt upload. The pr create command delegates to your local GitHub CLI, so the normal gh network behavior still applies.
Does installing it destroy existing hooks?
The documented installer preserves and chains an existing hook. Still inspect the local result in a repository with important custom automation.
Can it protect a pull request created by an MCP server?
Not automatically. The MCP server must route through a local sanitizing boundary, or the agent must use ai-credit-scrub pr create.
Takeaway
If your team wants explicit AI credits out of public Git history, enforce that decision where the text is still local. ai-credit-scrub install --git covers commit creation and pushes, while ai-credit-scrub pr create covers the separate pull request boundary. The useful part is not the deletion itself. It is the narrow, reviewable policy and the honest list of places it cannot control.
Have you found more value in sanitizing commit messages, pull request text, or agent-specific configuration files first? Share the boundary that causes the most cleanup in your workflow.
AI assistance disclosure: This tutorial was prepared with AI assistance from the project's public documentation and a clean checkout of the
v1.1.0release. The commands and claims were checked against those sources and smoke-tested locally.
Top comments (0)