|
1 |
| -# Tool Usage Learnings |
| 1 | +# Development Guidelines |
2 | 2 |
|
3 |
| -This file is intended to be used by an LLM such as Claude. |
| 3 | +This document contains critical information about working with this codebase. Follow these guidelines precisely. |
4 | 4 |
|
5 |
| -## UV Package Manager |
| 5 | +## Core Development Rules |
6 | 6 |
|
7 |
| -- Use `uv run` to run Python tools without activating virtual environments |
8 |
| -- For formatting: `uv run ruff format .` |
9 |
| -- For type checking: `uv run pyright` |
10 |
| -- For upgrading packages: |
11 |
| - - `uv add --dev package --upgrade-package package` to upgrade a specific package |
12 |
| - - Don't use `@latest` syntax - it doesn't work |
13 |
| - - Be careful with `uv pip install` as it may downgrade packages |
| 7 | +1. Package Management |
| 8 | + - ONLY use uv, NEVER pip |
| 9 | + - Installation: `uv add package` |
| 10 | + - Running tools: `uv run tool` |
| 11 | + - Upgrading: `uv add --dev package --upgrade-package package` |
| 12 | + - FORBIDDEN: `uv pip install`, `@latest` syntax |
14 | 13 |
|
15 |
| -## Git and GitHub CLI |
| 14 | +2. Code Quality |
| 15 | + - Type hints required for all code |
| 16 | + - Public APIs must have docstrings |
| 17 | + - Functions must be focused and small |
| 18 | + - Follow existing patterns exactly |
| 19 | + - Line length: 88 chars maximum |
16 | 20 |
|
17 |
| -- When using gh CLI for PRs, always quote title and body: |
18 |
| - ```bash |
19 |
| - gh pr create --title "\"my title\"" --body "\"my body\"" |
20 |
| - ``` |
21 |
| -- For git commits, use double quotes and escape inner quotes: |
22 |
| - ```bash |
23 |
| - git commit -am "\"fix: my commit message\"" |
24 |
| - ``` |
| 21 | +3. Testing Requirements |
| 22 | + - Framework: `uv run pytest` |
| 23 | + - Async testing: use anyio, not asyncio |
| 24 | + - Coverage: test edge cases and errors |
| 25 | + - New features require tests |
| 26 | + - Bug fixes require regression tests |
25 | 27 |
|
26 |
| -## Python Tools |
| 28 | +4. Version Control |
| 29 | + - Commit messages: conventional format (fix:, feat:) |
| 30 | + - PR scope: minimal, focused changes |
| 31 | + - PR requirements: description, test plan |
| 32 | + - Always include issue numbers |
| 33 | + - Quote handling: |
| 34 | + ```bash |
| 35 | + git commit -am "\"fix: message\"" |
| 36 | + gh pr create --title "\"title\"" --body "\"body\"" |
| 37 | + ``` |
27 | 38 |
|
28 |
| -### Ruff |
29 |
| -- Handles both formatting and linting |
30 |
| -- For formatting: `uv run ruff format .` |
31 |
| -- For checking: `uv run ruff check .` |
32 |
| -- For auto-fixing: `uv run ruff check . --fix` |
33 |
| -- Common issues: |
34 |
| - - Line length (default 88 chars) |
35 |
| - - Import sorting (I001 errors) |
36 |
| - - Unused imports |
37 |
| -- When line length errors occur: |
38 |
| - - For strings, use parentheses and line continuation |
39 |
| - - For function calls, use multiple lines with proper indentation |
40 |
| - - For imports, split into multiple lines |
| 39 | +## Code Formatting |
41 | 40 |
|
42 |
| -### Pyright |
43 |
| -- Type checker |
44 |
| -- Run with: `uv run pyright` |
45 |
| -- Version warnings can be ignored if type checking passes |
46 |
| -- Common issues: |
47 |
| - - Optional types need explicit None checks |
48 |
| - - String operations need type narrowing |
| 41 | +1. Ruff |
| 42 | + - Format: `uv run ruff format .` |
| 43 | + - Check: `uv run ruff check .` |
| 44 | + - Fix: `uv run ruff check . --fix` |
| 45 | + - Critical issues: |
| 46 | + - Line length (88 chars) |
| 47 | + - Import sorting (I001) |
| 48 | + - Unused imports |
| 49 | + - Line wrapping: |
| 50 | + - Strings: use parentheses |
| 51 | + - Function calls: multi-line with proper indent |
| 52 | + - Imports: split into multiple lines |
49 | 53 |
|
50 |
| -## Pre-commit Hooks |
| 54 | +2. Type Checking |
| 55 | + - Tool: `uv run pyright` |
| 56 | + - Requirements: |
| 57 | + - Explicit None checks for Optional |
| 58 | + - Type narrowing for strings |
| 59 | + - Version warnings can be ignored if checks pass |
51 | 60 |
|
52 |
| -- Configuration in `.pre-commit-config.yaml` |
53 |
| -- Runs automatically on git commit |
54 |
| -- Includes: |
55 |
| - - Prettier for YAML/JSON formatting |
56 |
| - - Ruff for Python formatting and linting |
57 |
| -- When updating ruff version: |
58 |
| - - Check available versions on PyPI |
59 |
| - - Update `rev` in config to match available version |
60 |
| - - Add and commit config changes before other changes |
| 61 | +3. Pre-commit |
| 62 | + - Config: `.pre-commit-config.yaml` |
| 63 | + - Runs: on git commit |
| 64 | + - Tools: Prettier (YAML/JSON), Ruff (Python) |
| 65 | + - Ruff updates: |
| 66 | + - Check PyPI versions |
| 67 | + - Update config rev |
| 68 | + - Commit config first |
61 | 69 |
|
62 |
| -## Best Practices |
| 70 | +## Error Resolution |
63 | 71 |
|
64 |
| -1. Always check git status and diff before committing |
65 |
| -2. Run formatters before type checkers |
66 |
| -3. When fixing CI: |
67 |
| - - Start with formatting issues |
68 |
| - - Then fix type errors |
69 |
| - - Then address any remaining linting issues |
70 |
| -4. For type errors: |
71 |
| - - Get full context around error lines |
72 |
| - - Consider optional types |
73 |
| - - Add type narrowing checks when needed |
| 72 | +1. CI Failures |
| 73 | + - Fix order: |
| 74 | + 1. Formatting |
| 75 | + 2. Type errors |
| 76 | + 3. Linting |
| 77 | + - Type errors: |
| 78 | + - Get full line context |
| 79 | + - Check Optional types |
| 80 | + - Add type narrowing |
| 81 | + - Verify function signatures |
| 82 | + |
| 83 | +2. Common Issues |
| 84 | + - Line length: |
| 85 | + - Break strings with parentheses |
| 86 | + - Multi-line function calls |
| 87 | + - Split imports |
| 88 | + - Types: |
| 89 | + - Add None checks |
| 90 | + - Narrow string types |
| 91 | + - Match existing patterns |
| 92 | + |
| 93 | +3. Best Practices |
| 94 | + - Check git status before commits |
| 95 | + - Run formatters before type checks |
| 96 | + - Keep changes minimal |
| 97 | + - Follow existing patterns |
| 98 | + - Document public APIs |
| 99 | + - Test thoroughly |
0 commit comments