Create Before-Push Validation Script

VerifiedSafe

Creates a comprehensive before-push validation script (b4push) for any project by analyzing the project structure, identifying check steps (quality, build, test, doc, e2e), and generating the script, package.json entry, and a Claude skill. Automates the setup of pre-push checks to catch issues before committing.

Sby Skills Guide Bot
DevelopmentIntermediate
506/2/2026
Claude Code
#b4push#validation#pre-push#project-setup#ci

Recommended for

Our review

Generates a comprehensive before-push validation script for a project, including quality checks, builds, tests, and documentation verification.

Strengths

  • Automates pre-push checks comprehensively
  • Adapts to the project's specific structure (package.json, directories)
  • Integrates smoothly with Claude Code as a reusable skill
  • Provides a detailed summary with elapsed time and failure list

Limitations

  • Requires the project to use package.json and follow certain conventions
  • May need manual adjustments for unconventional setups
  • Setting up e2e tests can be complex if a server needs to be managed
When to use it

Use this skill when setting up a new project or standardizing pre-push validation in an existing project.

When not to use it

Avoid using it for projects with no build or test steps, or when the team prefers CI-only validation.

Security analysis

Safe
Quality score90/100

The skill generates a development validation script and does not perform destructive actions, exfiltrate data, or use obfuscated payloads. It only runs project-specific commands like pnpm scripts, all under user control.

No concerns found

Examples

Create b4push for current project
Create a before-push validation script for this project.
Add b4push with e2e tests
Add a b4push script that includes e2e tests with Playwright.
Update existing b4push
Update the b4push script to include documentation checks.

name: dev-create-b4push-script description: >- Create a comprehensive before-push validation script (b4push) and project-level b4push skill for any project. Analyzes the project structure, identifies check steps (quality, build, test, doc site, e2e), generates scripts/run-b4push.sh, adds package.json entry, and creates .claude/skills/b4push/skill.md. Use when: (1) User says 'create b4push', 'add b4push', 'before push script', (2) Setting up a new project's CI/validation workflow, (3) User wants comprehensive pre-push checks for a project. user-invocable: true allowed-tools:

  • Bash
  • Read
  • Write
  • Edit
  • Glob
  • Grep

Create B4Push Script

Generate a comprehensive before-push validation script for the current project.

Workflow

1. Analyze the project

Read package.json to understand:

  • Package manager (pnpm/npm/yarn) - check lockfiles
  • Available scripts: check, build, test, lint, format, typecheck
  • Whether there's a doc site (look for doc/, docs/, website/ directories with their own package.json)
  • Whether there are e2e tests (playwright, cypress)
  • Whether there are data generation scripts (e.g., generate-* scripts in doc)

2. Determine steps

Common step patterns (adapt to project):

| Step | Command | When to include | | --- | --- | --- | | Code quality | pnpm check or pnpm lint && pnpm format | Always | | TypeScript build | pnpm build | If build script exists | | Unit tests | pnpm test | If test script exists | | Doc data generation | cd doc && pnpm run generate-* | If doc site has generate scripts | | Doc quality checks | cd doc && pnpm run check | If doc site has check script | | Doc site build | cd doc && pnpm build | If doc site exists | | E2E tests | Start server + run playwright | If e2e tests exist |

For projects with e2e tests, add server lifecycle management (start, wait for ready, run tests, kill).

3. Create the shell script

Create scripts/run-b4push.sh based on the template in assets/run-b4push-template.sh.

Key patterns:

  • set -euo pipefail for strict error handling
  • FAILURES=() array - continues all steps even if some fail
  • step(), pass(), fail() helper functions
  • Subshell execution (cd "$DIR" && command) to isolate directory changes
  • ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" for reliable path resolution
  • Summary section with elapsed time and failure list
  • Exit 0 on success, exit 1 on any failure

Make the script executable: chmod +x scripts/run-b4push.sh

4. Add package.json script

Add to package.json:

{
  "scripts": {
    "b4push": "./scripts/run-b4push.sh"
  }
}

5. Create project-level b4push skill

Create .claude/skills/b4push/skill.md based on assets/b4push-skill-template.md.

Customize:

  • Step list with project-specific descriptions
  • Estimated duration
  • Fix commands specific to the project (e.g., pnpm check:fix, cd doc && pnpm check:fix)

The skill should have user-invocable: true and allowed-tools: [Bash]. The description must include triggers for automatic invocation on big changes, PR completion, etc.

6. Test

Run pnpm b4push to verify all steps execute correctly. Fix any issues found.

Reference projects

These projects have working b4push setups:

  • mdx-formatter: 6 steps (quality, build, test, doc data, doc quality, doc build), ~40s
  • zmod: 9 steps including e2e with production server, ~3-4 min
  • zpanels: Dual-track (quick 3 steps ~3-5 min, full 6+ steps with e2e ~10-15 min)
Related skills