# Gate Pre Commit

> Shift-left quality gate triggered on git-commit events. Runs lint + typecheck on changed files only, unit tests for changed files only, lightweight dependency vulnerability check, and blocks on failure within a 10s budget.

- Skill: `quantumquirkxyz/gate-pre-commit` (Agent Skill)
- Install (CLI): `npx get-skill add quantumquirkxyz/gate-pre-commit`
- Raw SKILL.md: https://api.skillmd.com/api/skills/quantumquirkxyz/gate-pre-commit/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Finance & Business
- License: MIT
- Author: quantumquirkxyz (https://skillmd.com/u/quantumquirkxyz)
- Updated: 2026-11-15
- Page: https://skillmd.com/skills/quantumquirkxyz/gate-pre-commit

---


## Contract

- Input: git-commit event, staged diff, project tooling config.
- Output: `GatePreCommitArtifact` with per-check results and terminal state.
- Scope: pre-commit checks only — lint/typecheck on changed files, unit tests on changed files, lightweight dependency vuln check.
- Rule: enforce maxDuration of 10 seconds; skip slow checks rather than exceed budget.
- Rule: scope to changed files only — do not run full suite here.
- Rule: block on failure; commit must not proceed if any check fails.

## Provenance

| Question | Answer |
|---|---|
| What is the source of truth? | The git-commit event and staged diff |
| What is in scope? | Changed files since last commit; lint, typecheck, unit tests, dependency vuln check |
| What is explicitly out of scope? | Full integration suite, security scan, performance tests, E2E tests |
| Who or what consumes this artifact afterward? | `gate-ci` or commit process |
| What evidence proves it is done? | All checks completed within 10s budget, structured result returned, terminal state determined |
| What risk remains? | Skipped checks due to time budget; lightweight vuln check may miss transitive vulnerabilities |

## Artifact

Return `GatePreCommitArtifact` as structured output in the current response. Do not write local artifact files unless the user explicitly asks for an export.

## Process

### 1. Capture staged diff
Run `git diff --cached --name-only` to get the list of staged files. If no staged files, report idle.

### 2. Run lint + typecheck on changed files
Execute linter and type checker against only the staged files. Use project-native tooling (eslint, tsc --noEmit, etc.).

### 3. Run unit tests for changed files
Map changed files to their corresponding test files. Run only those unit tests. If no test files map, skip with reason.

### 4. Run lightweight dependency vulnerability check
Execute a fast dependency check (npm audit --audit-level=high, pip-audit, etc.). Limit to direct dependencies only.

### 5. Enforce time budget
Track elapsed time. If any check risks exceeding 10 seconds total, skip remaining checks and mark them as `skipped` with reason `time-budget-exceeded`.

### 6. Aggregate results
Compile all check results into `GatePreCommitArtifact`. Terminal state:
- Any `failed` → `blocked` (commit prevented)
- All `passed` → `completed`
- Error → `failed`

### 7. Enforce blockOnFailure
If terminal state is `blocked`, return exit code 1 to prevent the commit.

## Completion

- all applicable checks have run or been skipped with reason
- total duration within 10s budget
- structured result returned
- commit blocked if any check failed

