- Primary Language: Python 3.12+
- Framework: FastAPI
- Type Checking: Strictly use Python Type Hints (
mypycompatible). - Documentation: Use Google-style docstrings for all public functions and classes.
- Coding Style: Adhere strictly to PEP 8.
- Async Patterns: Prefer
async/awaitfor all I/O bound operations. - Error Handling: Use custom exception classes; avoid "bare"
except:blocks. - Dependency Injection: Use FastAPI Depends() for services.
- Location: Source code is organized under
src/my_app/folder. - Structure: Logic belongs in
service/, data models inmodel/, external connections inadapter/, exceptions inexception/, configuration inconfig/, static resource files inresources/, and entry points inmain.py. - Refactoring: When modifying existing code, maintain the existing variable naming conventions unless they violate PEP 8.
- Imports: Use relative imports (e.g.,
from .service import ExampleService).
- Framework: Use
pytest. - Coverage: Aim for 80%+ coverage on all new logic.
- Mocks: Use
unittest.mockorpytest-mockfor external API calls. - Location: All tests must reside in the
tests/directory, mirroring the source structure.
- Memory: Avoid loading large datasets into memory; use generators or streaming where possible.
- Efficiency: Prioritize
list comprehensionsover manualforloops for simple transformations.
- Analysis: Before writing code, explain your plan in 2-3 bullet points.
- Context: If a task requires knowledge of a file not currently open, ask me to open it or use your indexing to find it.
- Safety: Do not delete files or large blocks of code without explicit confirmation.