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
Copy file name to clipboardExpand all lines: {{cookiecutter.__package_slug}}/AGENTS.md
+38-38Lines changed: 38 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# Agent Instructions
2
2
3
-
You should always follow the best practices outlined in this document. If there is a valid reason why you cannot follow one of these practices, you should inform the user and document the reasons.
3
+
You must always follow the best practices outlined in this document. If there is a valid reason why you cannot follow one of these practices, you must inform the user and document the reasons.
4
4
5
-
Before beginning any task, make sure you review the documentation (`docs/dev/` and `README.md`), the existing tests to understand the project, and the task runner (Makefile) to understand what dev tools are available and how to use them. You should review code related to your request to understand preferred style: for example, you should review other tests before writing a new test suite, or review existing routers before creating a new one.
5
+
Before beginning any task, make sure you review the documentation (`docs/dev/` and `README.md`), the existing tests to understand the project, and the task runner (Makefile) to understand what dev tools are available and how to use them. You must review code related to your request to understand preferred style: for example, you must review other tests before writing a new test suite, or review existing routers before creating a new one.
6
6
7
7
## Important Commands
8
8
@@ -111,29 +111,29 @@ docker compose exec service_name bash # Open a bash shell in a running service c
111
111
* Prefer existing dependencies over adding new ones when possible.
112
112
* For complex code, always consider using third-party libraries instead of writing new code that has to be maintained.
113
113
* Use keyword arguments instead of positional arguments when calling functions and methods.
114
-
* Do not put `import` statements inside functions unless necessary to prevent circular imports. Imports should be at the top of the file.
114
+
* Do not put `import` statements inside functions unless necessary to prevent circular imports. Imports must be at the top of the file.
115
115
116
116
### Security
117
117
118
118
* Always write secure code.
119
119
* Never hardcode sensitive data.
120
120
* Do not log sensitive data.
121
-
* All user input should be validated.
121
+
* All user input must be validated.
122
122
* Never roll your own cryptography system.
123
123
124
124
### Production Ready
125
125
126
-
* All generated code should be production ready.
127
-
* There should be no stubs "for production".
128
-
* There should not be any non-production logic branches in the main code package itself.
129
-
* Any code or package differences between Development and Production should be avoided unless absolutely necessary.
126
+
* All generated code must be production ready.
127
+
* There must be no stubs "for production".
128
+
* There must not be any non-production logic branches in the main code package itself.
129
+
* Any code or package differences between Development and Production must be avoided unless absolutely necessary.
130
130
131
131
### Logging
132
132
133
133
* Do not use `print` for logging or debugging: use the `getLogger` logger instead.
134
-
* Each file should get its own logger using the `__name__` variable for a name.
134
+
* Each file must get its own logger using the `__name__` variable for a name.
135
135
* Use logging levels to allow developers to enable richer logging while testing than in production.
136
-
* Most caught exceptions should be logged with `logger.exception`.
136
+
* Most caught exceptions must be logged with `logger.exception`.
* Comments should improve code readability and understandability.
157
-
* Comments should not simply exist for the sake of existing.
156
+
* Comments must improve code readability and understandability.
157
+
* Comments must not simply exist for the sake of existing.
158
158
* Examples of good comments include unclear function names/parameters, decisions about settings or function choices, logic descriptions, variable definitions, security risks, edge cases, and advice for developers refactoring or expanding code.
159
-
* Comments should be concise, accurate, and add value to the codebase.
159
+
* Comments must be concise, accurate, and add value to the codebase.
160
160
161
161
### Error Handling
162
162
@@ -183,7 +183,7 @@ except FileNotFoundError:
183
183
184
184
### Typing
185
185
186
-
* Everything should be typed: function signatures (including return values), variables, and anything else.
186
+
* Everything must be typed: function signatures (including return values), variables, and anything else.
187
187
* Use the union operator for multiple allowed types.
188
188
* Do not use `Optional`: use a union with `None` (i.e., `str | None`).
189
189
* Use typing library metaclasses instead of native types for objects and lists (i.e., `Dict[str, str]` and `List[str]` instead of `dict` or `list`).
* Manage application settings with the `pydantic-settings` library.
218
218
* The main Settings class is located in `PACKAGE_NAME/conf/settings.py` - update this existing class rather than creating new ones.
219
-
* Sensitive configuration data should always use Pydantic `SecretStr` or `SecretBytes` types.
220
-
* Settings that are allowed to be unset should default to `None` instead of empty strings.
219
+
* Sensitive configuration data must always use Pydantic `SecretStr` or `SecretBytes` types.
220
+
* Settings that are allowed to be unset must default to `None` instead of empty strings.
221
221
* Define settings with the Pydantic `Field` function and include descriptions for users.
222
222
223
223
```python
@@ -256,10 +256,10 @@ class Settings(BaseSettings):
256
256
257
257
### FastAPI
258
258
259
-
* APIs should adhere as closely as possible to REST principles, including appropriate use of GET/PUT/POST/DELETE HTTP verbs.
260
-
* All routes should use Pydantic models for input and output.
261
-
* Use different Pydantic models for inputs and outputs (i.e., creating a `Post`should require a `PostCreate` and return a `PostRead` model, not reuse the same model).
262
-
* Parameters in Pydantic models for user input should use the Field function with validation and descriptions.
259
+
* APIs must adhere as closely as possible to REST principles, including appropriate use of GET/PUT/POST/DELETE HTTP verbs.
260
+
* All routes must use Pydantic models for input and output.
261
+
* Use different Pydantic models for inputs and outputs (i.e., creating a `Post`must require a `PostCreate` and return a `PostRead` model, not reuse the same model).
262
+
* Parameters in Pydantic models for user input must use the Field function with validation and descriptions.
* Always use async SQLAlchemy APIs with SQLAlchemy 2.0 syntax.
311
311
* Represent database tables with the declarative class system.
312
312
* Use Alembic to define migrations.
313
-
* Migrations should be compatible with both SQLite and PostgreSQL.
313
+
* Migrations must be compatible with both SQLite and PostgreSQL.
314
314
* When creating queries, do not use implicit `and`: instead use the `and_` function (instead of `where(Model.parameter_a == A, Model.parameter_b == B)` do `where(and_(Model.parameter_a == A, Model.parameter_b == B))`).
315
315
316
316
```python
@@ -355,8 +355,8 @@ async def get_user_bad(session: AsyncSession, email: str, name: str) -> User | N
355
355
356
356
### Typer
357
357
358
-
* Any CLI command or script that should be accessible to users should be exposed via the Typer library.
359
-
* The main CLI entrypoint should be `PACKAGE_NAME/cli.py`.
358
+
* Any CLI command or script that must be accessible to users must be exposed via the Typer library.
359
+
* The main CLI entrypoint must be `PACKAGE_NAME/cli.py`.
360
360
* For async commands, use the `@syncify` decorator provided in `cli.py` to convert async functions to sync for Typer compatibility.
361
361
362
362
```python
@@ -397,29 +397,29 @@ if __name__ == "__main__":
397
397
### Testing
398
398
399
399
* Do not wrap test functions in classes unless there is a specific technical reason: instead prefer single functions.
400
-
* All fixtures should be defined or imported in `conftest.py` so they are available to all tests.
400
+
* All fixtures must be defined or imported in `conftest.py` so they are available to all tests.
401
401
* Do not use mocks to replace simple dataclasses or Pydantic models unless absolutely necessary: instead create an instance of the appropriate class with desired parameters.
402
402
* Use the FastAPI Test Client (preferably with a fixture) rather than calling FastAPI router classes directly.
403
403
* Use a test database fixture with memory-backed SQLite for tests requiring a database. Including a dependency override for this test database as part of the FastAPI App fixture is extremely useful.
404
-
* When adding new code, you should also add appropriate tests to cover that new code.
405
-
* The test suite file structure should mirror the main code file structure.
404
+
* When adding new code, you must also add appropriate tests to cover that new code.
405
+
* The test suite file structure must mirror the main code file structure.
406
406
407
407
### Files
408
408
409
-
* Filenames should always be lowercase for better compatibility with case-insensitive filesystems.
409
+
* Filenames must always be lowercase for better compatibility with case-insensitive filesystems.
410
410
* This includes documentation files, except standard files (like `README.md`, `LICENSE`, etc.).
411
-
* Developer documentation should live in `docs/dev`.
412
-
* New developer documents should be added to the table of contents in `docs/dev/README.md`.
413
-
* Files only meant for building containers should live in the `docker/` folder.
414
-
* Database models should live in `PACKAGE_NAME/models/`.
415
-
* The primary settings file should live in `PACKAGE_NAME/conf/settings.py`.
411
+
* Developer documentation must live in `docs/dev`.
412
+
* New developer documents must be added to the table of contents in `docs/dev/README.md`.
413
+
* Files only meant for building containers must live in the `docker/` folder.
414
+
* Database models must live in `PACKAGE_NAME/models/`.
415
+
* The primary settings file must live in `PACKAGE_NAME/conf/settings.py`.
416
416
417
417
### Developer Environments
418
418
419
-
* Common developer tasks should be defined in the `makefile` to easy reuse.
420
-
* Developers should always be able to start a fully functional developer instance with `docker compose up`.
421
-
* Developer environments should be initialized with fake data for easy use.
422
-
* Developer settings should live in the `.env` file, which should be in `.gitignore`.
423
-
* A `.env.example` file should exist as a template for new developers to create their `.env` file and learn what variables to set.
424
-
* Python projects should always use virtual environments at `.venv` in the project root. This should be activated before running tests.
419
+
* Common developer tasks must be defined in the `makefile` to easy reuse.
420
+
* Developers must always be able to start a fully functional developer instance with `docker compose up`.
421
+
* Developer environments must be initialized with fake data for easy use.
422
+
* Developer settings must live in the `.env` file, which must be in `.gitignore`.
423
+
* A `.env.example` file must exist as a template for new developers to create their `.env` file and learn what variables to set.
424
+
* Python projects must always use virtual environments at `.venv` in the project root. This must be activated before running tests.
425
425
* Use `uv` for Python version management and package installation instead of pyenv and pip for significantly faster installations and automatic Python version handling.
0 commit comments