|
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: |
| 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 |
| 27 | + |
| 28 | +- For commits fixing bugs or adding features based on user reports add: |
18 | 29 | ```bash |
19 | | - gh pr create --title "\"my title\"" --body "\"my body\"" |
| 30 | + git commit --trailer "Reported-by:<name>" |
20 | 31 | ``` |
21 | | -- For git commits, use double quotes and escape inner quotes: |
| 32 | + Where `<name>` is the name of the user. |
| 33 | + |
| 34 | +- For commits related to a Github issue, add |
22 | 35 | ```bash |
23 | | - git commit -am "\"fix: my commit message\"" |
| 36 | + git commit --trailer "Github-Issue:#<number>" |
24 | 37 | ``` |
| 38 | +- NEVER ever mention a `co-authored-by` or similar aspects. In particular, never |
| 39 | + mention the tool used to create the commit message or PR. |
| 40 | + |
| 41 | +## Pull Requests |
| 42 | + |
| 43 | +- Create a detailed message of what changed. Focus on the high level description of |
| 44 | + the problem it tries to solve, and how it is solved. Don't go into the specifics of the |
| 45 | + code unless it adds clarity. |
| 46 | + |
| 47 | +- Always add `jerome3o-anthropic` and `jspahrsummers` as reviewer. |
| 48 | + |
| 49 | +- NEVER ever mention a `co-authored-by` or similar aspects. In particular, never |
| 50 | + mention the tool used to create the commit message or PR. |
25 | 51 |
|
26 | 52 | ## Python Tools |
27 | 53 |
|
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 |
41 | | - |
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 |
49 | | - |
50 | | -## Pre-commit Hooks |
51 | | - |
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 | | - |
62 | | -## Best Practices |
63 | | - |
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 |
| 54 | +## Code Formatting |
| 55 | + |
| 56 | +1. Ruff |
| 57 | + - Format: `uv run ruff format .` |
| 58 | + - Check: `uv run ruff check .` |
| 59 | + - Fix: `uv run ruff check . --fix` |
| 60 | + - Critical issues: |
| 61 | + - Line length (88 chars) |
| 62 | + - Import sorting (I001) |
| 63 | + - Unused imports |
| 64 | + - Line wrapping: |
| 65 | + - Strings: use parentheses |
| 66 | + - Function calls: multi-line with proper indent |
| 67 | + - Imports: split into multiple lines |
| 68 | + |
| 69 | +2. Type Checking |
| 70 | + - Tool: `uv run pyright` |
| 71 | + - Requirements: |
| 72 | + - Explicit None checks for Optional |
| 73 | + - Type narrowing for strings |
| 74 | + - Version warnings can be ignored if checks pass |
| 75 | + |
| 76 | +3. Pre-commit |
| 77 | + - Config: `.pre-commit-config.yaml` |
| 78 | + - Runs: on git commit |
| 79 | + - Tools: Prettier (YAML/JSON), Ruff (Python) |
| 80 | + - Ruff updates: |
| 81 | + - Check PyPI versions |
| 82 | + - Update config rev |
| 83 | + - Commit config first |
| 84 | + |
| 85 | +## Error Resolution |
| 86 | + |
| 87 | +1. CI Failures |
| 88 | + - Fix order: |
| 89 | + 1. Formatting |
| 90 | + 2. Type errors |
| 91 | + 3. Linting |
| 92 | + - Type errors: |
| 93 | + - Get full line context |
| 94 | + - Check Optional types |
| 95 | + - Add type narrowing |
| 96 | + - Verify function signatures |
| 97 | + |
| 98 | +2. Common Issues |
| 99 | + - Line length: |
| 100 | + - Break strings with parentheses |
| 101 | + - Multi-line function calls |
| 102 | + - Split imports |
| 103 | + - Types: |
| 104 | + - Add None checks |
| 105 | + - Narrow string types |
| 106 | + - Match existing patterns |
| 107 | + |
| 108 | +3. Best Practices |
| 109 | + - Check git status before commits |
| 110 | + - Run formatters before type checks |
| 111 | + - Keep changes minimal |
| 112 | + - Follow existing patterns |
| 113 | + - Document public APIs |
| 114 | + - Test thoroughly |
0 commit comments