Skip to content

Commit 8c2d1c6

Browse files
committed
core: add more agentic capabilities
1 parent 6c9fcfe commit 8c2d1c6

File tree

6 files changed

+219
-0
lines changed

6 files changed

+219
-0
lines changed

.claude/hooks.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"hooks": {
3+
"PreToolUse": [
4+
{
5+
"matcher": "Bash",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": ".claude/hooks/intercept-legacy-python.sh"
10+
}
11+
]
12+
}
13+
]
14+
}
15+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/bin/bash
2+
#
3+
# Intercepts legacy Python commands and suggests modern uv alternatives.
4+
#
5+
# This hook runs before Bash tool execution to guide Claude toward
6+
# using uv-based commands instead of legacy pip/python commands.
7+
8+
# Read the tool input from stdin
9+
INPUT=$(cat)
10+
11+
# Extract the command being executed
12+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
13+
14+
# If no command found, allow through
15+
if [ -z "$COMMAND" ]; then
16+
exit 0
17+
fi
18+
19+
# Function to block with a suggestion
20+
block_with_suggestion() {
21+
local suggestion="$1"
22+
echo "BLOCKED: This repository uses uv for package management."
23+
echo ""
24+
echo "Suggested alternative: $suggestion"
25+
echo ""
26+
echo "See CLAUDE.md for the full development workflow."
27+
exit 2
28+
}
29+
30+
# Allow diagnostic commands
31+
if echo "$COMMAND" | grep -qE '^(which python|python --version|python3 --version)'; then
32+
exit 0
33+
fi
34+
35+
# Allow commands that already use uv run
36+
if echo "$COMMAND" | grep -qE '(^|&&|\|)\s*uv run'; then
37+
exit 0
38+
fi
39+
40+
# Allow grep/find/etc. commands that just contain "python" as a search term
41+
if echo "$COMMAND" | grep -qE '^(grep|rg|find|ls|cat|head|tail|awk|sed)\s'; then
42+
exit 0
43+
fi
44+
45+
# Intercept pip install
46+
if echo "$COMMAND" | grep -qE '(^|\s|&&|\|)(pip|pip3)\s+install\s'; then
47+
# Extract package name if present
48+
PKG=$(echo "$COMMAND" | grep -oE '(pip|pip3)\s+install\s+[^&|;]+' | sed 's/.*install\s*//' | awk '{print $1}')
49+
if [ -n "$PKG" ]; then
50+
block_with_suggestion "uv add $PKG"
51+
else
52+
block_with_suggestion "uv add <package>"
53+
fi
54+
fi
55+
56+
# Intercept pip uninstall
57+
if echo "$COMMAND" | grep -qE '(^|\s|&&|\|)(pip|pip3)\s+uninstall\s'; then
58+
PKG=$(echo "$COMMAND" | grep -oE '(pip|pip3)\s+uninstall\s+[^&|;]+' | sed 's/.*uninstall\s*//' | awk '{print $1}')
59+
if [ -n "$PKG" ]; then
60+
block_with_suggestion "uv remove $PKG"
61+
else
62+
block_with_suggestion "uv remove <package>"
63+
fi
64+
fi
65+
66+
# Intercept pip freeze
67+
if echo "$COMMAND" | grep -qE '(^|\s|&&|\|)(pip|pip3)\s+freeze'; then
68+
block_with_suggestion "uv export"
69+
fi
70+
71+
# Intercept python -m pip
72+
if echo "$COMMAND" | grep -qE '(^|\s|&&|\|)python3?\s+-m\s+pip'; then
73+
block_with_suggestion "uv add/remove/sync (depending on operation)"
74+
fi
75+
76+
# Intercept bare python/python3 script execution
77+
if echo "$COMMAND" | grep -qE '(^|\s|&&|\|)python3?\s+[^-].*\.py'; then
78+
# Extract the script path
79+
SCRIPT=$(echo "$COMMAND" | grep -oE 'python3?\s+[^&|;]+\.py' | sed 's/python3\?\s*//')
80+
if [ -n "$SCRIPT" ]; then
81+
block_with_suggestion "uv run python $SCRIPT"
82+
else
83+
block_with_suggestion "uv run python <script.py>"
84+
fi
85+
fi
86+
87+
# Intercept bare python/python3 with module flag (except -m pip which is handled above)
88+
if echo "$COMMAND" | grep -qE '(^|\s|&&|\|)python3?\s+-m\s+(?!pip)'; then
89+
MODULE=$(echo "$COMMAND" | grep -oE 'python3?\s+-m\s+\S+' | sed 's/python3\?\s*-m\s*//')
90+
if [ -n "$MODULE" ]; then
91+
block_with_suggestion "uv run python -m $MODULE"
92+
else
93+
block_with_suggestion "uv run python -m <module>"
94+
fi
95+
fi
96+
97+
# Allow everything else
98+
exit 0

.claude/skills/checks/SKILL.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: checks
3+
description: Run all code quality checks
4+
---
5+
6+
# /checks - Run All Quality Checks
7+
8+
Run the complete quality check suite.
9+
10+
## Command
11+
12+
```bash
13+
uvx tox -e all-checks
14+
```
15+
16+
## What It Runs
17+
18+
1. `ruff check` - Linting
19+
2. `ruff format --check` - Formatting
20+
3. `ty check` - Type checking
21+
4. `codespell` - Spell checking
22+
5. `mdformat` - Markdown formatting
23+
24+
## When to Use
25+
26+
Run this before committing changes to ensure code quality standards are met.
27+
This is the same check that runs in CI.

.claude/skills/fill/SKILL.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: fill
3+
description: Generate consensus layer test fixtures
4+
---
5+
6+
# /fill - Generate Test Fixtures
7+
8+
Run the test filler to generate consensus layer test fixtures.
9+
10+
## Default Usage
11+
12+
```bash
13+
uv run fill --fork=Devnet --clean -n auto
14+
```
15+
16+
## Options
17+
18+
- `--fork=<name>` - Target fork (default: Devnet)
19+
- `--clean` - Clean existing fixtures before generating
20+
- `-n auto` - Auto-detect parallelization
21+
- `--layer=<layer>` - Target layer (consensus is default, execution for future)
22+
23+
## Examples
24+
25+
- `/fill` - Run with defaults
26+
- `/fill --fork=Electra` - Generate for Electra fork
27+
- `/fill path/to/test.py` - Generate fixtures for specific test file

.claude/skills/fix/SKILL.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: fix
3+
description: Auto-fix linting and formatting issues
4+
---
5+
6+
# /fix - Auto-Fix Code Quality Issues
7+
8+
Automatically fix linting and formatting issues.
9+
10+
## Command
11+
12+
```bash
13+
uvx tox -e fix
14+
```
15+
16+
## What It Fixes
17+
18+
1. Import sorting (isort rules)
19+
2. Code formatting (black-compatible)
20+
3. Simple lint errors (auto-fixable)
21+
22+
## When to Use
23+
24+
Run this after making code changes to automatically fix formatting issues.
25+
Then run `/checks` to verify all issues are resolved.

.claude/skills/test/SKILL.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: test
3+
description: Run unit tests with coverage
4+
---
5+
6+
# /test - Run Unit Tests
7+
8+
Run pytest with coverage reporting.
9+
10+
## Default
11+
12+
```bash
13+
uv run pytest
14+
```
15+
16+
## Options
17+
18+
- `/test -v` - Verbose output
19+
- `/test -k <pattern>` - Run matching tests
20+
- `/test <path>` - Run specific test file/directory
21+
- `/test --cov` - With coverage report
22+
23+
## Examples
24+
25+
- `/test` - Run all unit tests
26+
- `/test tests/lean_spec/subspecs/ssz/` - Run SSZ tests only
27+
- `/test -k "test_serialize"` - Run tests matching pattern

0 commit comments

Comments
 (0)