chore: add more opinions to CLAUDE.md (#1887)

This commit is contained in:
Marcelo Trylesinski 2026-01-16 15:52:33 +01:00 • committed by GitHub
commit c06362126b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,9 +6,9 @@ This document contains critical information about working with this codebase. Fo
1. Package Management 1. Package Management
- ONLY use uv, NEVER pip - ONLY use uv, NEVER pip
- Installation: `uv add package` - Installation: `uv add <package>`
- Running tools: `uv run tool` - Running tools: `uv run <tool>`
- Upgrading: `uv add --dev package --upgrade-package package` - Upgrading: `uv lock --upgrade-package <package>`
- FORBIDDEN: `uv pip install`, `@latest` syntax - FORBIDDEN: `uv pip install`, `@latest` syntax
2. Code Quality 2. Code Quality
@ -21,6 +21,7 @@ This document contains critical information about working with this codebase. Fo
3. Testing Requirements 3. Testing Requirements
- Framework: `uv run --frozen pytest` - Framework: `uv run --frozen pytest`
- Async testing: use anyio, not asyncio - Async testing: use anyio, not asyncio
- Do not use `Test` prefixed classes, use functions
- Coverage: test edge cases and errors - Coverage: test edge cases and errors
- New features require tests - New features require tests
- Bug fixes require regression tests - Bug fixes require regression tests
@ -77,12 +78,11 @@ rather than adding new standalone sections.
- Line wrapping: - Line wrapping:
- Strings: use parentheses - Strings: use parentheses
- Function calls: multi-line with proper indent - Function calls: multi-line with proper indent
- Imports: split into multiple lines - Imports: try to use a single line
2. Type Checking 2. Type Checking
- Tool: `uv run --frozen pyright` - Tool: `uv run --frozen pyright`
- Requirements: - Requirements:
- Explicit None checks for Optional
- Type narrowing for strings - Type narrowing for strings
- Version warnings can be ignored if checks pass - Version warnings can be ignored if checks pass
@ -117,10 +117,6 @@ rather than adding new standalone sections.
- Add None checks - Add None checks
- Narrow string types - Narrow string types
- Match existing patterns - Match existing patterns
- Pytest:
- If the tests aren't finding the anyio pytest mark, try adding PYTEST_DISABLE_PLUGIN_AUTOLOAD=""
to the start of the pytest run command eg:
`PYTEST_DISABLE_PLUGIN_AUTOLOAD="" uv run --frozen pytest`
3. Best Practices 3. Best Practices
- Check git status before commits - Check git status before commits
@ -138,6 +134,4 @@ rather than adding new standalone sections.
- File ops: `except (OSError, PermissionError):` - File ops: `except (OSError, PermissionError):`
- JSON: `except json.JSONDecodeError:` - JSON: `except json.JSONDecodeError:`
- Network: `except (ConnectionError, TimeoutError):` - Network: `except (ConnectionError, TimeoutError):`
- **Only catch `Exception` for**: - **FORBIDDEN** `except Exception:` - unless in top-level handlers
- Top-level handlers that must not crash
- Cleanup blocks (log at debug level)