Skip to content

Instantly share code, notes, and snippets.

@arunsanna
Created February 23, 2026 15:17
Show Gist options
  • Select an option

  • Save arunsanna/b3724b90ad59ecdbff4cb5316041fffb to your computer and use it in GitHub Desktop.

Select an option

Save arunsanna/b3724b90ad59ecdbff4cb5316041fffb to your computer and use it in GitHub Desktop.
AI coding guardrails: pre-commit and pre-push hooks

AI Coding Needs Guardrails: Pre-Commit + Pre-Push

When AI helps generate code, velocity goes up. So does the chance of shipping something you did not fully inspect.

Tweet Draft

If AI writes your code, hooks should gate your push.

  • pre-commit: staged secret scan + SAST + API smoke tests
  • pre-push: full secret scan + vulnerability/misconfig scan + coverage gate

AI makes output faster. Hooks keep quality and security non-optional.

Why This Matters

  • AI can produce plausible code that hides subtle security or logic risks.
  • Teams under deadline pressure skip manual checks.
  • Hooks convert "I should check" into "it must pass first".

Practical Baseline

  • Secret scanning (trufflehog) on staged changes and full repo before push.
  • Security scanning (trivy/semgrep) with fail-on-high severity.
  • Fast API-focused tests at commit time.
  • Full coverage gate at push time.

Tweet (X-ready, <=280 chars)

If AI writes your code, hooks should gate every push: pre-commit (staged secrets + SAST + API smoke tests) and pre-push (full secrets + vuln/misconfig scan + coverage gate). AI speeds output; hooks make security and quality non-optional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment