---
name: anilsoylu-commit-gate
title: commit gate
kind: skill
version: 0.2.0
description: >
  Pre-commit gate: /perf, /optimize, then /security-audit on the current diff,
  one go/no-go report. Never commits. For "ready to commit", "check before I
  commit". A standalone perf or security question goes to that skill.
updated: 2026-12-05
authored_by: anilsoylu
author_url: https://github.com/anilsoylu
source_url: https://github.com/anilsoylu/famiglia-agent-skills/tree/HEAD/skills/commit-gate
brought_by: kt
license: Apache-2.0
---

# Commit gate

Three checks, always in this order, on the code that's about to be committed. Perf finds what's slow, optimize rewrites
only what perf measured, security reviews the final diff (including the optimize rewrite). Don't ask between steps.
Stop only on a blocker or when a fix needs the user's decision.

Run each skill for real. This file is the sequence, not a replacement for their contents. Inside the gate, `/perf` and
`/optimize` stop once they have their after numbers: their own closing steps (clean, review, pr-update, commits) don't
run here, because the gate never commits.

## 0. Scope the diff

`scripts/classify-diff.py` scopes and classifies the diff. If a `CLASSIFY-DIFF` block appears below, use it. Otherwise
run `python3 <this skill's folder>/scripts/classify-diff.py` from the project directory and use its output. If the user
named a range or branch, run it again with that as the argument (`... classify-diff.py main` diffs `main...HEAD`).

!`python3 ${CLAUDE_SKILL_DIR}/scripts/classify-diff.py || true`

- Default scope: staged + unstaged changes vs `HEAD`, plus untracked files. Each file lands in **runtime** (code that
  executes in the app, server, worker or build), **assets** (images, CSS, JS bundles, fonts, HTML, build/bundler config)
  or **docs** (markdown, comment-only code edits, CI yaml, lockfiles, env and data files, other config).
- `unknown` files count as runtime unless reading them shows they are data or docs. Move a file between groups when
  its content says the script guessed wrong, and say so in the report.
- `perf:` and `perf-web-assets:` feed step 1. `result: no diff`: say so and stop. Every file is Markdown
  or plain text (`.md`, `.mdx`, `.txt`): report `commit-gate: docs-only diff, nothing to gate` and stop; don't run
  `/perf`, `/optimize` or `/security-audit`. CI files, env files, lockfiles and config still get `/security-audit`. An `error:` line, or no output at
  all (no `python3`): fix the cause, or classify by hand from `git diff HEAD --stat` and
  `git ls-files --others --exclude-standard` with the same three groups.

## 1. Perf → `/perf`

- No runtime code or web assets in the diff: log `perf: skipped, no runtime code` and go on.
- Otherwise run `/perf` scoped to the changed paths. Use `../dev-flow/references/perf-checklist.md` as the checklist
  (app section always; web-assets section when web assets changed), if it exists.
- Output: the measured hot spots (with before numbers), or "no hot path in this diff".

## 2. Optimize → `/optimize`

- Only on routines perf measured as hot. No hot spot means `optimize: nothing to do`, and that's a normal result.
- Exact parity: harness first, bitwise by default. If parity can't hold, revert the rewrite and report why.
- Output: before/after numbers per routine, or the reason it was skipped.

## 3. Security → `/security-audit`

- Runs whenever step 0 didn't stop the gate, including on assets-only diffs.
- Use its **guidance mode** as a focused review of this diff. Don't start the full six-phase audit (that's for project end).
- Check at least: secrets or tokens added, authz on new/changed routes, input validation, injection, unsafe
  deserialization/file paths, new dependencies, CI/workflow permission changes.
- A hardcoded credential-looking literal (`sk_live_`, `AKIA`, `ghp_`, a private key) is a blocker until the user confirms
  it's fake. Don't downgrade it on a guess.
- Output: confirmed findings with `file:line`, severity, and the fix.

## 4. Report

```
commit-gate: PASS | PASS WITH NOTES | BLOCKED
diff: <n files> (<runtime/assets/docs counts>)
1 perf:      <result + numbers, or skipped + reason>
2 optimize:  <result + before/after, or nothing to do>
3 security:  <findings by severity, or none in reviewed scope>
changes made by the gate: <files>, tests run: <command → result>
blockers: <list, or none>
```

BLOCKED = any Critical/High security finding, a failing test, or a parity break that couldn't be reverted. Fixes the gate makes
stay inside the diff's files. If a fix needs a wider change, report it as a blocker instead.

## Don't

- Commit, push or amend. The user (or `/cpr`) does that.
- Report speedups without numbers, or call the diff "secure". Say "no material issue found in the reviewed scope".

## If a skill isn't installed

- No `/perf`: baseline → profile the changed path → fix the measured hot spot → re-measure, by hand.
- No `/optimize`: skip rewrites and list the hot spots as notes.
- No `/security-audit`: review the diff against `../dev-flow/references/guardian/A-appsec-identity.md` and `../dev-flow/references/guardian/E-http-api.md`
  if present, otherwise the checklist in step 3.
Say which fallback you used.

## If something fails

| Failure | Fix |
|---|---|
| No `CLASSIFY-DIFF` block, or it shows the literal `!` line | Run `python3 <this skill's folder>/scripts/classify-diff.py` by hand from the project directory. |
| `git` isn't runnable or this isn't a repo | Report `BLOCKED: no diff to gate` and stop; there is nothing to scope. |
| The repo has no tests | Write `tests run: none in repo` in the report and lean on the security review; don't add a test framework without asking. |
| `/optimize` can't build a parity harness | Skip the rewrite, list the hot spot as a note, and keep the original code. |
