You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **Note**: This file is also available as `CLAUDE.md` (symlink) for Claude Code CLI users.
4
4
>
5
-
> **IMPORTANT**: Before making any code changes, you MUST read [CONTRIBUTING.md](CONTRIBUTING.md) for comprehensive coding standards and design patterns. This file provides essential quick reference only.
6
-
7
-
## When to Read CONTRIBUTING.md
8
-
9
-
**Always read CONTRIBUTING.md before:**
10
-
11
-
- Writing new functions (for type annotation standards)
12
-
- Adding imports (for import organization rules)
13
-
- Creating tests (for testing patterns)
14
-
- Making commits (for commit message format)
15
-
- Adding error handling or logging
5
+
> Read [CONTRIBUTING.md](CONTRIBUTING.md) for comprehensive coding standards, design patterns, and commit message format. This file provides agent-specific quick reference only.
16
6
17
7
## Essential Rules (MUST FOLLOW)
18
8
19
9
### Do
20
10
11
+
- Keep all written text concise and easy to understand — docstrings, comments, commit messages, PR descriptions, and documentation
21
12
- Add docstrings on all public functions and classes
22
13
- Use file-scoped commands for fast feedback (see below)
23
-
- Follow existing patterns - search codebase for similar code
14
+
- Follow existing patterns — search codebase for similar code
24
15
- Chain exceptions: `raise ValueError(...) from err`
25
16
- Use `req_ctxvar_context()` for per-requirement logging
26
-
- Run `hatch run lint:fix` to format code (handles line length, whitespace, etc.)
17
+
- Run `hatch run lint:fix` to format code
27
18
28
19
### Don't
29
20
30
21
- Don't run full test suite for small changes (use file-scoped)
31
22
- Don't create temporary helper scripts or workarounds
32
23
- Don't commit without running quality checks
33
-
- Don't make large speculative changes without asking
24
+
- Don't make large speculative changes — ask first or propose a plan
34
25
- Don't update git config or force push to main
35
-
- Don't use bare `except:` - always specify exception types
26
+
- Don't use bare `except:` — always specify exception types
27
+
- Don't invent new patterns — search the codebase for existing ones
36
28
37
29
## Commands (IMPORTANT: Use File-Scoped First)
38
30
39
-
### Setup Commands (Run Once)
31
+
### Setup (Run Once)
40
32
41
33
```bash
42
-
# Install pre-commit hooks for automatic file formatting
43
-
hatch run lint:install-hooks
34
+
hatch run lint:install-hooks # Pre-commit hooks for automatic formatting
44
35
```
45
36
46
-
### File-Scoped Commands (PREFER THESE)
37
+
### File-Scoped (PREFER THESE)
47
38
48
39
```bash
49
-
# Type check single file
50
-
hatch run mypy:check <filepath>
51
-
52
-
# Format single file
53
-
hatch run lint:fix <filepath>
54
-
55
-
# Test specific file
56
-
hatch run test:test tests/test_<module>.py
57
-
58
-
# Test specific function
59
-
hatch run test:test tests/test_<module>.py::test_function_name
60
-
61
-
# Debug test with verbose output
62
-
hatch run test:test <filepath> --log-level DEBUG
40
+
hatch run mypy:check <filepath># Type check single file
41
+
hatch run lint:fix <filepath># Format single file
42
+
hatch run test:test tests/test_<module>.py # Test specific file
43
+
hatch run test:test tests/test_<module>.py::test_name # Test specific function
44
+
hatch run test:test <filepath> --log-level DEBUG # Debug test
63
45
```
64
46
65
-
### Project-Wide Commands (ASK BEFORE RUNNING)
47
+
### Project-Wide (ASK BEFORE RUNNING)
66
48
67
49
```bash
68
50
hatch run lint:fix # Format all code
69
51
hatch run test:test # Full test suite (slow!)
70
52
hatch run mypy:check # Type check everything
71
53
hatch run lint:check # Final lint check
72
-
hatch run lint:precommit # All linters and other pre-commit hooks
54
+
hatch run lint:precommit # All linters and pre-commit hooks
73
55
```
74
56
75
-
### Pre-commit Hooks
76
-
77
-
Run all linters and formatters via pre-commit:
78
-
79
-
```bash
80
-
hatch run lint:precommit # Run all hooks manually
81
-
```
82
-
83
-
Pre-commit runs automatically on commit after installation with `hatch run lint:install-hooks`.
84
-
85
-
**Markdown formatting:** The mdformat hook formats Markdown files using a pure Python formatter with GitHub Flavored Markdown support.
86
-
87
57
## Safety and Permissions
88
58
89
59
### Allowed Without Asking
@@ -104,14 +74,14 @@ Pre-commit runs automatically on commit after installation with `hatch run lint:
@@ -121,112 +91,33 @@ Pre-commit runs automatically on commit after installation with `hatch run lint:
121
91
122
92
## Code Patterns
123
93
124
-
**Import Guidelines (ALWAYS FOLLOW):**
125
-
126
-
-**PEP 8: imports should be at the top**: All import statements MUST be placed at the top of the file, after module docstrings and before other code. This applies to ALL Python files in the project.
127
-
-**No local imports**: Do not place import statements inside functions, methods, or conditional blocks under any circumstances
128
-
129
-
### Testing Pattern
130
-
131
-
```python
132
-
deftest_behavior(tmp_path: pathlib.Path) -> None:
133
-
"""Verify expected behavior."""
134
-
# Arrange
135
-
config = tmp_path /"config.txt"
136
-
config.write_text("key=value\n")
137
-
# Act
138
-
result = load_config(config)
139
-
# Assert
140
-
assert result["key"] =="value"
141
-
```
142
-
143
-
## Commit Message Format (REQUIRED)
144
-
145
-
Use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format:
146
-
147
-
```text
148
-
<type>(<scope>): <short summary>
149
-
150
-
<body explaining what + why>
94
+
**Import rules:** All imports at the top of the file, no local imports. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
151
95
152
-
<footer: Closes: #123>
153
-
```
96
+
**Testing:** Use Arrange/Act/Assert pattern, name functions `test_<behavior>()`. See `tests/test_context.py` for examples.
154
97
155
-
### Types
98
+
##Commit Messages
156
99
157
-
-**feat**: new functionality
158
-
-**fix**: bug fix
159
-
-**docs**: documentation only
160
-
-**test**: tests only
161
-
-**refactor**: behavioral no-op refactor
162
-
-**perf**: performance improvement
163
-
-**chore**: tooling or dependency change
100
+
Follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) — see [CONTRIBUTING.md](CONTRIBUTING.md) for format, types, and examples.
164
101
165
-
### Good Examples
102
+
When AI agents create or significantly modify code, add attribution:
166
103
167
104
```text
168
-
feat(resolver): add exponential backoff for HTTP retries
169
-
170
-
Improves resilience when PyPI is under load by adding jittered backoff.
0 commit comments