agentsclimarketplace

Pre push test

Skill chienchuanw/chuan-skills/plugins/git/skills/pre-push-test

Personal plugin marketplace of Claude Code skills (slash commands)

Install
npx -y skills add chienchuanw/chuan-skills --skill pre-push-test

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

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).

SKILL.md

5.1 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it

pre-push-test

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.

Step 1: Verify prerequisites

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.

Step 2: Detect the test command

Figure out how this project runs its tests. Check these in order — use the first match:

SignalTest 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 targetmake test
Cargo.toml existscargo test
go.mod existsgo test ./...
pyproject.toml or setup.py or setup.cfg exists, and pytest is importable or listed in dependenciespytest
pyproject.toml or setup.py exists (but no pytest)python -m unittest discover
mix.exs existsmix test
build.gradle or build.gradle.kts exists./gradlew test
pom.xml existsmvn test
Gemfile exists with rspecbundle exec rspec
Rakefile with a test taskrake test

Package manager detection (Node.js projects)

When package.json has a valid test script, pick the right package manager by checking for lock files:

Lock fileTest command
pnpm-lock.yamlpnpm test
yarn.lockyarn test
bun.lockb or bun.lockbun test
package-lock.json (or none of the above)npm test

Fallback detection

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.

Step 3: Check for an existing pre-push hook

ls -la .git/hooks/pre-push 2>/dev/null

If a pre-push hook already exists:

  • Read its contents and show the user a summary
  • Ask whether to replace it, wrap it (run the existing hook first, then tests), or abort
  • If wrapping, back up the original to .git/hooks/pre-push.backup

Step 4: Install the hook

Read 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

Step 5: Verify the installation

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"

Step 6: Confirm to the user

Summarize what was installed:

  • Hook location: .git/hooks/pre-push
  • Test command: the detected command
  • Behavior: runs tests before every git push. If tests fail, Claude attempts to fix the code and retries up to 3 times. If all attempts fail, the push is blocked.
  • To skip (emergency): git push --no-verify
  • To remove: rm .git/hooks/pre-push

Important notes

  • The hook uses --no-verify on its own fix commits to avoid infinite hook recursion.
  • The --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.
  • The hook captures test output and passes it to Claude so it has full context about what broke.
  • If the user's project uses a monorepo with multiple test suites, ask which one(s) to run and adjust the test command accordingly (e.g., pnpm test --filter=packages/core).

What ships with it: 1 file

1.7 KB alongside SKILL.md, 1 of them executable

scripts/

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.