Use when the user wants to prevent broken code from being pushed, block git push when tests fail, run tests before push, set up push protection, or add a safety net against pushing untested code. Covers any request to gate pushes on test results — whether they mention "hook", "pre-push", or just describe wanting to stop bad code from reaching the remote. Also handles auto-fix/auto-repair of test failures before push. Trigger for: "block push if tests fail", "run tests before pushing", "protect branch from broken pushes", "stop pushing untested code", "catch failures before they reach remote", or any test-gated push workflow regardless of language (npm, pnpm, cargo, go, pytest, etc).
Ships in git. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Set up a git pre-push hook that blocks pushes when tests fail and uses Claude to auto-fix failures.
The hook script template lives at scripts/pre-push.sh in this skill's directory. The installation process copies it, substitutes the detected test command, and makes it executable.
Confirm you're inside a git repository:
git rev-parse --is-inside-work-tree
If not, tell the user and stop.
Check that the claude CLI is available (the hook calls it to fix test failures):
command -v claude
If claude is not found, tell the user they need Claude Code installed (npm install -g @anthropic-ai/claude-code) for the auto-fix feature to work. Offer to install a simpler version of the hook that just blocks the push without auto-fixing.
Figure out how this project runs its tests. Check these in order — use the first match:
| Signal | Test command |
|---|---|
package.json with a "test" script (not the default echo "Error: no test specified") | See package manager detection below |
Makefile or GNUmakefile with a test target | make test |
Cargo.toml exists | cargo test |
go.mod exists | go test ./... |
pyproject.toml or setup.py or setup.cfg exists, and pytest is importable or listed in dependencies | pytest |
pyproject.toml or setup.py exists (but no pytest) | python -m unittest discover |
mix.exs exists | mix test |
build.gradle or build.gradle.kts exists | ./gradlew test |
pom.xml exists | mvn test |
Gemfile exists with rspec | bundle exec rspec |
Rakefile with a test task | rake test |
When package.json has a valid test script, pick the right package manager by checking for lock files:
| Lock file | Test command |
|---|---|
pnpm-lock.yaml | pnpm test |
yarn.lock | yarn test |
bun.lockb or bun.lock | bun test |
package-lock.json (or none of the above) | npm test |
If none of the above match, look for clues in README.md, CONTRIBUTING.md, CLAUDE.md, or Makefile for how to run tests. If you still can't determine it, ask the user what command runs their tests.
Show the user what you detected before proceeding: "I detected pnpm test as your test command. Does that look right?" Wait for confirmation.
ls -la .git/hooks/pre-push 2>/dev/null
If a pre-push hook already exists:
.git/hooks/pre-push.backupRead the hook template from scripts/pre-push.sh (relative to this skill's directory). Copy it to .git/hooks/pre-push, replacing {{TEST_CMD}} with the detected test command. Then make it executable:
# Copy template and substitute the test command
SKILL_DIR="<path to this skill's directory>"
sed "s|{{TEST_CMD}}|<detected test command>|g" "$SKILL_DIR/scripts/pre-push.sh" > .git/hooks/pre-push
chmod +x .git/hooks/pre-push
Run a quick sanity check:
# Confirm the hook is in place and executable
test -x .git/hooks/pre-push && echo "Hook installed successfully" || echo "ERROR: Hook not executable"
Summarize what was installed:
.git/hooks/pre-pushgit push. If tests fail, Claude attempts to fix the code and retries up to 3 times. If all attempts fail, the push is blocked.git push --no-verifyrm .git/hooks/pre-push--no-verify on its own fix commits to avoid infinite hook recursion.--allowedTools flag on the claude invocation limits what Claude can do during auto-fix — it can read, search, and edit files, and run commands, but nothing else.pnpm test --filter=packages/core).What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/git:pre-push-testfrom git
npx claudepluginhub chienchuanw/chuan-skills --plugin git9 skills in this plugin
/branch-reportGenerates a branch-vs-default comparison report with plain-language explanations and senior dev review. Use when the user asks to summarize, compare, review, or explain branch changes, or wants a PR summary before merging. Read-only: it produces a report to read — it does not push the branch or open/update the PR (for that use gh-pr).
/commit-msgSuggests 3 commit messages based on git diff and project conventions. Use when the user asks for commit message ideas, wants help writing a commit message, or has changes ready to commit.
/gh-archiveCapture the current state of a project by updating documentation at the end of a development session. Invokes the readme skill to refresh README.md and the planning-with-files skill to record project status in a doc/ or docs/ directory. Use after merging a PR, finishing a feature, wrapping up a coding session, or any time the user wants to snapshot where the project stands — even implicit phrases like "archive this", "wrap up the session", "document current status", "update project docs", "snapshot this repo", or "I'm done for today". Also use when the user says "end of session" or asks to prepare documentation before stepping away from a project.
/gh-commentPost formatted comments on GitHub PRs or issues, approve PRs, and merge PRs via gh CLI using purpose-specific templates (feedback, question, status, approval, request-changes). Use when commenting on a PR, leaving feedback, asking a question on an issue, posting a status update, approving a pull request, merging a PR, or any intent to interact with an existing PR or issue — even implicit phrases like "tell them", "approve it", "merge this", "LGTM", or "ship it".
/gh-devCreate a branch linked to a GitHub issue via gh issue develop, then implement the work with regular convention-following commits. Use when starting work on an issue, picking up a ticket, developing a feature branch, or any intent to begin coding against a GitHub issue.
/gh-fixRead unresolved review comments on a GitHub PR, deeply evaluate each suggestion, then either fix it (via gh-dev + simplify) and push the result, or push back via gh-comment with a reasoned reply. Use when the user wants to address PR feedback, respond to reviewer comments, fix code-review suggestions, action a review, or any phrasing like "address the comments on PR #N", "respond to the review", "fix what the reviewer asked for", "go through the PR feedback", or "handle the review comments".