Skip to content
Back to skills

Pre Commit Guard

ASecurity

Use before any git commit or PR. Runs format/lint/typecheck/tests, checks for secrets/large files/debug statements, validates commit message. Triggers готов к commit, проверь перед commit, можно ли пушить, ready to merge.

  • 4 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 12, 2026
code-qualitybashgitapi

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 12, 2026

npx -y skills add aibot88/sec_skill_store --skill pre-commit-guard --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pre Commit Guard?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pre Commit Guard
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aibot88-pre-commit-guard/badge)](https://www.skillsdirectory.com/skills/aibot88-pre-commit-guard)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: pre-commit-guard
description: Use before any git commit or PR. Runs format/lint/typecheck/tests, checks for secrets/large files/debug statements, validates commit message. Triggers готов к commit, проверь перед commit, можно ли пушить, ready to merge.
allowed-tools: [Bash, Read]
model: sonnet
---

# Pre-Commit Guard

## Sequence (fail fast — stop on first error)

### 1. Stage check
```bash
git status -s
git diff --cached --stat
```

### 2. Secret scan
```bash
git diff --cached | grep -iE '(api[_-]?key|secret|password|token|bearer)\s*[=:]\s*["'"'"'][^"'"'"']{8,}'
```
If gitleaks installed:
```bash
gitleaks detect --staged --no-banner
```

### 3. Large file check
```bash
git diff --cached --name-only | xargs -I{} sh -c '[ -f "{}" ] && [ $(stat -c%s "{}") -gt 1048576 ] && echo "WARN: {} > 1MB"'
```

### 4. Format
```bash
ruff format --check .
```

### 5. Lint
```bash
ruff check $(git diff --cached --name-only --diff-filter=ACM | grep '\.py$')
```

### 6. Type check
```bash
mypy $(git diff --cached --name-only --diff-filter=ACM | grep '\.py$')
```

### 7. Tests
```bash
pytest -x --ff --tb=short --timeout=60
```

### 8. Forbidden patterns
```bash
git diff --cached -U0 | grep -E '^\+.*(print\(|breakpoint\(|console\.log|debugger;)'
```

### 9. Commit message format
- `<type>(<scope>): <subject>` (max 50 chars)
- type ∈ {feat, fix, refactor, docs, test, chore, perf, build, ci}
- imperative mood, no period

## Output
Single status: ✓ all passed / ⚠ N warnings / ✗ M errors

## Hard rules
- NEVER auto-commit. Only verify and report.
- Run from project root only
- Stop on first ✗

Files in this skill

  • SKILL.md1.6 KB
  • source.json765 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.