Créer un script de validation avant push

VérifiéSûr

Crée un script de validation complet avant push (b4push) pour tout projet en analysant la structure, identifiant les étapes de vérification (qualité, build, test, documentation, e2e), et générant le script, l'entrée package.json et une compétence Claude. Automatise la mise en place des vérifications pré-push pour détecter les problèmes avant le commit.

Spar Skills Guide Bot
DeveloppementIntermédiaire
6002/06/2026
Claude Code
#b4push#validation#pre-push#project-setup#ci

Recommandé pour

Notre avis

Génère un script complet de validation avant push pour un projet, incluant vérifications de qualité, builds, tests et documentation.

Points forts

  • Automatise les vérifications pré-push de manière exhaustive
  • S'adapte à la structure spécifique du projet (package.json, dossiers)
  • S'intègre facilement à Claude Code en tant que compétence réutilisable
  • Fournit un rapport détaillé avec le temps écoulé et la liste des échecs

Limites

  • Nécessite que le projet utilise package.json et respecte certaines conventions
  • Peut nécessiter des ajustements manuels pour des configurations non standard
  • La mise en place des tests e2e peut être complexe si un serveur est requis
Quand l'utiliser

Utilisez cette compétence lors de la configuration d'un nouveau projet ou pour standardiser les validations avant push dans un projet existant.

Quand l'éviter

Évitez de l'utiliser pour des projets sans étapes de build ou de test, ou lorsque l'équipe préfère une validation via CI uniquement.

Analyse de sécurité

Sûr
Score qualité90/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.

Aucun point d'attention détecté

Exemples

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)
Skills similaires