Slash Command

/precommit

Install
1
Install the plugin
$
npx claudepluginhub sd0xdev/sd0x-dev-flow --plugin sd0x-dev-flow

Want just this command?

Add to a custom plugin, then install with one command.

Description

Run pre-commit checks: **lint:fix -> build -> test**

Command Content

Task

Run pre-commit checks: lint:fix -> build -> test

Step 1: Check for runner script

Use Glob to check if .claude/scripts/precommit-runner.js exists in the project root.

  • Found → run: node .claude/scripts/precommit-runner.js --mode full --tail 80
    • If runner succeeds, use its output and skip to the Output section.
    • If runner fails, treat as a real precommit failure (do not silently fallback).
  • NOT foundAuto-install attempt:
    1. Node.js gate: Use Glob to check if package.json exists in the project root. If no package.json → skip auto-install, fall through to Step 2.

    2. Locate plugin scripts: 3-level Glob fallback (short-circuit on first match):

      • Glob: ~/.claude/plugins/**/sd0x-dev-flow/scripts/precommit-runner.js
      • Glob: ${REPO_ROOT}/node_modules/sd0x-dev-flow/scripts/precommit-runner.js
      • Plugin-relative: try reading @scripts/precommit-runner.js to confirm accessibility
    3. Plugin not found → fall through to Step 2 (ecosystem fallback).

    4. Plugin found → log > auto-installing missing runner... then copy using node -e (stays within existing Bash(node:*) permission):

      • mkdir -p .claude/scripts/lib

      • Copy precommit-runner.js and lib/utils.js from plugin source to .claude/scripts/

      • Conflict handling per file:

        ScenarioAction
        Target missingCopy
        Target exists, content identicalSkip (already installed)
        Target exists, content differsSkip + warn (no overwrite without --force)
    5. Run newly installed runner: node .claude/scripts/precommit-runner.js --mode full --tail 80

      • If any required file had conflict (runner or lib/utils.js not installed) → fall through to Step 2.
      • If runner fails → treat as a real precommit failure (do not silently fallback).

Step 2: Fallback (no runner script)

If the runner was not found in Step 1, detect the project ecosystem to run steps manually.

Ecosystem detection (check project root for manifest files):

ManifestEcosystemLint-fixBuildTest
package.jsonNode.js{pm} lint:fix{pm} build{pm} test:ci / test / test:fast / test:unit
pyproject.tomlPythonruff check --fix .pytest tests/unit/
Cargo.tomlRustcargo clippy --fixcargo buildcargo test
go.modGogolangci-lint run --fixgo build ./...go test ./...
build.gradleJava (Gradle)./gradlew spotlessApply./gradlew build./gradlew test
build.gradle.ktsJava (Gradle KTS)./gradlew spotlessApply./gradlew build./gradlew test
pom.xmlJava (Maven)mvn spotless:applymvn compilemvn test
GemfileRubybundle exec rubocop -abundle exec rspec

For Node.js projects, auto-detect package manager from lockfile (pnpm-lock.yaml → pnpm, yarn.lock → yarn, else npm).

Read package.json (or equivalent manifest) to check which scripts exist, then run available steps in order:

Steppackage.json scriptIf missing
lint:fixlint:fixSkip with note (not all projects have it)
buildbuildSkip with note
testtest:ci, fallback to test, then test:fast, then test:unitSkip with note

Run each available step sequentially. Report all results even if a step fails.

After lint:fix completes, run git diff --name-only to capture auto-fixed files.

Graceful Skip Rules

ScenarioBehavior
No lint:fix scriptSkip, log "no lint:fix script — skipped"
No build scriptSkip, log "no build script — skipped"
No test script in preference chainSkip, log "no test script — skipped"
No package.jsonReport error, cannot run checks

Output

## Precommit (full)

## Results

| Step      | Status | Notes |
| --------- | ------ | ----- |
| lint:fix  | ✅/❌/⏭️ | skipped if no script |
| build     | ✅/❌/⏭️ | skipped if no script |
| test      | ✅/❌/⏭️ | skipped if no script |

## Changed Files (after lint:fix)

- <files or "(none)">

## Overall: ✅ PASS / ❌ FAIL

## Checklist

- [ ] All available checks pass
- [ ] git status reviewed
Stats
Stars90
Forks12
Last CommitMar 21, 2026
Actions

Other plugins with /precommit