Skip to content

Commit be85318

Browse files
authored
agents: add code review and debugging skills (#453)
* agents: add code review and debugging skills * agent: rename debug skill to workflows to clarify intent
1 parent d39d101 commit be85318

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

.claude/skills/review/SKILL.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
name: review
3+
description: Quick-reference checklist for code review conventions in leanSpec
4+
---
5+
6+
# /review - Code Review Checklist
7+
8+
A concise checklist distilled from CLAUDE.md for reviewing leanSpec code.
9+
10+
## Imports
11+
12+
- All imports at file top — no lazy imports inside functions
13+
- No confusing renames — use qualified access (`x25519.X25519PublicKey`)
14+
- `from __future__ import annotations` in every file
15+
16+
## Type Annotations
17+
18+
- Never quote annotations when `from __future__ import annotations` is present
19+
- Prefer narrow domain types (`Bytes32`, `PeerId`, `RequestId`) over raw `bytes`
20+
- Complete type hints on all function signatures
21+
22+
## Code Style
23+
24+
- Line length: 100 characters max
25+
- Google docstring style
26+
- No example code in docstrings — unit tests serve as examples
27+
- No section separator comments (`# ====`, `# ----`)
28+
- Module-level constants use docstrings, not comments
29+
30+
## Documentation
31+
32+
- Never use explicit function or method names in docs — names change
33+
- Write short, scannable sentences — one idea per line
34+
- Use bullet points or numbered lists for multiple items
35+
- Never remove existing documentation unless directly invalidated by a code change
36+
37+
## Testing
38+
39+
- Full equality assertions — assert the whole object, not individual fields
40+
- Descriptive test names explaining the scenario
41+
- Use `pytest.raises(ExceptionType, match=r"...")` for error tests
42+
- Boundary values derived from source constants, never hardcoded
43+
44+
## Architecture
45+
46+
- No backward compatibility code — no shims, aliases, or re-exports
47+
- No unnecessary abstractions — inline is often better for spec code
48+
- Simplicity over abstraction — readers should understand top-to-bottom
49+
- SSZ types: domain-specific names (`Attestations`) over generic (`List4096`)
50+
51+
## Before Committing
52+
53+
```bash
54+
uvx tox -e fix # Auto-fix formatting
55+
uvx tox -e all-checks # Verify all checks pass
56+
```

.claude/skills/workflows/SKILL.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
name: workflows
3+
description: Common developer workflows, commands, and troubleshooting for leanSpec
4+
---
5+
6+
# /workflows - Repository Workflows
7+
8+
Common developer workflows and commands for working in leanSpec.
9+
10+
## Running Specific Tests
11+
12+
```bash
13+
# Single test file
14+
uvx tox -e pytest -- tests/lean_spec/subspecs/networking/discovery/test_transport.py -v
15+
16+
# Single test class or method
17+
uvx tox -e pytest -- -k "TestDiscoveryTransport::test_start" -v
18+
19+
# With print output visible
20+
uvx tox -e pytest -- -s -k "test_name"
21+
```
22+
23+
## Resolving Type Errors
24+
25+
The project uses two type checkers. Run them separately to isolate issues:
26+
27+
```bash
28+
# Full type check (ty — the primary checker used in CI)
29+
uvx tox -e typecheck
30+
31+
# Lint check (ruff — catches style and import issues)
32+
uvx tox -e lint
33+
```
34+
35+
Common type error patterns:
36+
- `invalid-assignment` — Wrong type assigned; check if a domain type (`RequestId`, `PeerId`) is expected instead of raw `bytes`
37+
- `invalid-argument-type` — Function argument type mismatch; verify the function signature
38+
- `union-attr` — Accessing attribute on a possibly-`None` value; add an `assert is not None` guard
39+
40+
## Inspecting Coverage
41+
42+
After running tests, coverage reports are generated:
43+
44+
```bash
45+
# View coverage in terminal
46+
uvx tox -e pytest
47+
48+
# Open HTML report
49+
open htmlcov/index.html
50+
```
51+
52+
## Running Interop Tests
53+
54+
Interop tests are excluded from the default test run. Run them explicitly:
55+
56+
```bash
57+
uv run pytest tests/interop/ -v
58+
```
59+
60+
## Spell Check Failures
61+
62+
```bash
63+
# Run spell check
64+
uvx tox -e spellcheck
65+
66+
# Add legitimate words to the ignore list
67+
echo "newword" >> .codespell-ignore-words.txt
68+
```
69+
70+
## Markdown Formatting
71+
72+
```bash
73+
# Check markdown formatting (docs only)
74+
uvx tox -e mdformat
75+
```
76+
77+
## Common Pitfalls
78+
79+
- **Tests pass locally but CI fails**: CI runs checks across Python 3.12, 3.13, and 3.14. Ensure no version-specific syntax is used.
80+
- **`ruff format` changes after `ruff check --fix`**: Always run format after fix — the fixer doesn't guarantee formatting compliance.
81+
- **Import ordering issues**: Run `uvx tox -e fix` to auto-sort imports.

0 commit comments

Comments
 (0)