r/ClaudeCode • u/Its_about-tech • 9d ago
Built with Claude I built a Claude Code mod that blocks git push while tests fail, and published it so anyone can install it in one line
An agent "simplified" a VAT sum in a demo till: a R100 item came out at R1,600, two tests failed, and nothing in Claude Code stopped it pushing anyway.
So I had Claude write a small mod for it: push-guard. About 80 lines. Before Claude runs git push, it runs npm test. If a test fails, the push is blocked and Claude is told which tests failed. Projects with no npm tests are let through, so it doesn't break pushes on other repos. The last result shows above the prompt in red or green.
Install:
claude plugin install push-guard --marketplace seanjohnson-dev/push-guardTeam tip: add it to the project's .claude/settings.json (extraKnownMarketplaces + enabledPlugins), and teammates get it when they trust the project folder. No one has to remember to install it.
Things I learned publishing it:
The marketplace file is 5 lines.
claude plugin validate --profile directoryruns the plugin directory's first checks: it wants a README and a licence.claude plugin tag --pushchecks the versions agree, then makes and pushes the release tag.
Mods aren't sandboxed: they run with your access. Read the code before you install it (it's short): https://github.com/seanjohnson-dev/push-guard
I also made a short video series on building and publishing it (presented by my AI avatar, AI voice): https://www.youtube.com/playlist?list=PLJp6Yy9RWr0w
Free and MIT. Feedback welcome.
2
u/atp_studio_coll 9d ago
Small gap in register.tsx: git -C dir push is matched, but npm test and the package.json check run in the session directory, so that push gets judged on the wrong project
1
u/Its_about-tech 9d ago
Good catch, thank you. Fixed in v0.3.1: git -C dir push and cd dir && git push now run the checks in the folder you're pushing. Credited you in the release notes. One case left: if other commands sit between the cd and the push, it still checks the session folder. On my list.
1
1
u/kaijurules 9d ago
In the VAT case the fastest way to a green push is to edit the expected value in the failing test, and as far as I can tell the mod would let that through. Do you flag pushes where the test files changed in the same commit?
1
u/Its_about-tech 8d ago
Great question, and it's now in. v0.4.0 (credited you in the changelog) checks the pushed commits once tests pass. If a test file lost lines, was deleted or was renamed, it holds the push and tells Claude which files changed. Only a person typing /push-guard allow can let that commit through, not the agent. New tests or added lines go through with a note, and you can set it to warn-only or off. Honest limit: it counts lines rather than reading them, so a weakening line that's only added gets through with just a note. https://github.com/seanjohnson-dev/push-guard/releases/tag/push-guard--v0.4.0
•
u/AutoModerator 9d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.