Skip to content

Commit 84e92e5

Browse files
committed
docs(agents): add pre-commit hooks section
Document pre-commit setup, checks, and usage in AGENTS.md. Includes: - Installation instructions for commit-msg and pre-push hooks - Table of all pre-commit checks with purposes - Usage commands (run, run --all-files) - Troubleshooting steps for failed checks - Emergency bypass option - Pre-push protection explanation
1 parent 945130b commit 84e92e5

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,57 @@ annotations:
222222
ignore-check.kube-linter.io/unset-memory-requirements: "No limits on single-node cluster"
223223
```
224224

225+
## Pre-commit Hooks
226+
227+
This repository uses [pre-commit](https://pre-commit.com/) to enforce code quality and catch issues before they reach the repository.
228+
229+
### Setup
230+
231+
```bash
232+
# Install pre-commit hooks (run once after cloning)
233+
pre-commit install --hook-type commit-msg --hook-type pre-push
234+
235+
# Verify hooks are installed
236+
ls -la .git/hooks/pre-commit .git/hooks/pre-push
237+
```
238+
239+
### Pre-commit Checks
240+
241+
| Hook | Purpose |
242+
|------|---------|
243+
| `conventional-pre-commit` | Validates conventional commit message format |
244+
| `check-yaml` | Validates YAML syntax |
245+
| `detect-private-key` | Prevents accidental commit of private keys |
246+
| `kube-linter` | Validates Kubernetes manifests |
247+
| `trailing-whitespace` | Removes trailing whitespace |
248+
| `end-of-file-fixer` | Ensures files end with newline |
249+
250+
### Usage
251+
252+
**Before committing:**
253+
```bash
254+
# Run all checks on changed files
255+
pre-commit run
256+
257+
# Run all checks on all files
258+
pre-commit run --all-files
259+
```
260+
261+
**If pre-commit fails:**
262+
1. Fix the reported issues
263+
2. Stage your changes (`git add`)
264+
3. Run `pre-commit run` again to verify
265+
4. Then commit
266+
267+
**Bypass (emergencies only):**
268+
```bash
269+
git commit --no-verify # Skips pre-commit hooks
270+
```
271+
272+
### Pre-push Protection
273+
274+
The pre-push hook runs all checks before allowing `git push`. This prevents broken code from reaching the remote repository.
275+
225276
## Common Gotchas
226277

227278
1. **OpenShift operators reconcile routes** - Manual patches to routes get reverted. Use proper config resources (`ingress.config.openshift.io`, etc.)

0 commit comments

Comments
 (0)