Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit 6d6f043

Browse files
staredclaude
andcommitted
Add pre-commit hooks configuration
- Add .pre-commit-config.yaml with exact command matching - Use local hooks to ensure consistency with pyproject.toml settings - Run checks in order: ty → ruff check → ruff format - Add pre-commit setup instructions to CLAUDE.md - Include general file quality checks (trailing whitespace, etc.) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent ebc9a98 commit 6d6f043

File tree

2 files changed

+82
-18
lines changed

2 files changed

+82
-18
lines changed

.pre-commit-config.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Pre-commit hooks configuration
2+
# Install: uv tool install pre-commit pre-commit-uv
3+
# Setup: pre-commit install
4+
#
5+
# IMPORTANT: These hooks use the EXACT same commands as manual runs
6+
# to ensure consistency with pyproject.toml settings
7+
8+
repos:
9+
# uv-specific hooks
10+
- repo: https://github.com/astral-sh/uv-pre-commit
11+
rev: 0.8.11
12+
hooks:
13+
- id: uv-lock
14+
15+
# Run checks in the same order as CI and manual commands
16+
# All use 'local' repo to ensure we use exact commands with pyproject.toml settings
17+
- repo: local
18+
hooks:
19+
# 1. Type checking with ty (first)
20+
- id: ty-check
21+
name: Type check with ty
22+
entry: uv run ty check src
23+
language: system
24+
pass_filenames: false
25+
always_run: true
26+
27+
# 2. Linting with ruff (second)
28+
- id: ruff-check
29+
name: Lint with ruff
30+
entry: uv run ruff check src
31+
language: system
32+
pass_filenames: false
33+
always_run: true
34+
35+
# 3. Formatting with ruff (third)
36+
- id: ruff-format
37+
name: Format with ruff
38+
entry: uv run ruff format src --check
39+
language: system
40+
pass_filenames: false
41+
always_run: true
42+
43+
# General file checks
44+
- repo: https://github.com/pre-commit/pre-commit-hooks
45+
rev: v5.0.0
46+
hooks:
47+
- id: trailing-whitespace
48+
- id: end-of-file-fixer
49+
- id: check-yaml
50+
- id: check-added-large-files
51+
args: ['--maxkb=1000']
52+
- id: check-json
53+
- id: check-toml
54+
- id: check-merge-conflict
55+
- id: mixed-line-ending
56+
args: ['--fix=lf']

CLAUDE.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,6 @@ uv run setup
6767
# Run tests
6868
uv run pentest
6969

70-
# Run red team attack testing
71-
uv run attack # Single attack
72-
73-
# Run adaptive batch campaigns (learns between attempts)
74-
uv run attack --batch 5 # 5 attempts with learning
75-
uv run attack --batch 10 --steps 2 # 10 attempts, 2 turns each
76-
77-
# With different attacker models (default: Claude Opus 4.1)
78-
uv run attack --attacker-model openai/gpt-4o --batch 5
79-
uv run attack --attacker-model meta-llama/llama-3.1-405b-instruct
80-
uv run attack --attacker-model google/gemini-2.0-flash-exp
81-
82-
# Use custom prompts
83-
uv run attack --custom
84-
85-
# View and analyze sessions
86-
uv run sessions
87-
8870
# Code quality checks (ALWAYS run before committing)
8971
uv run ty check src # Type checking first
9072
uv run ruff check src # Then linting
@@ -101,6 +83,32 @@ uv run ruff format src # Finally formatting
10183

10284
If any of these fail, fix the issues before committing. The GitHub Actions CI will run these same checks in this order.
10385

86+
### Pre-Commit Hooks (Automated)
87+
88+
This project uses pre-commit hooks to automatically run checks before each commit.
89+
90+
**Setup (one-time):**
91+
```bash
92+
# Install pre-commit with uv plugin for faster Python hook installation
93+
uv tool install pre-commit --with pre-commit-uv
94+
95+
# Install hooks into git
96+
pre-commit install
97+
```
98+
99+
**Manual run (test all files):**
100+
```bash
101+
pre-commit run --all-files
102+
```
103+
104+
The hooks will automatically run on `git commit` and check:
105+
1. Type checking with `ty` (first)
106+
2. Linting with `ruff` (second)
107+
3. Formatting with `ruff` (third)
108+
4. General file quality (trailing whitespace, file endings, etc.)
109+
110+
Files are checked in the same order as CI: types → lint → format
111+
104112
### Git Workflow
105113

106114
- Create feature branches for significant changes

0 commit comments

Comments
 (0)