| description | Global coding standards for this multi-deliverable Python API project |
|---|---|
| alwaysApply | true |
- Keep responses very short.
- Use a professional tone.
- Do not explain unless explicitly requested.
- Apply these rules by default across the workspace.
- If an activity/instruction requires specific names or structure, follow the activity/instruction first.
- Multi-deliverable project building a task management API with AI integrations.
- Entregable 1: REST API with JSON file persistence.
- Entregable 2: AI-powered endpoints (LLM integration via Azure OpenAI or Anthropic).
- Entregable 3: Jinja UI + MySQL database via SQLAlchemy.
- Entregables 4–5: Docker, CI/CD pipelines, and Azure cloud deployment.
- Multi-agent workflow: agents defined in
.agents/, plans inplans/, prompts inprompts/. - Source code lives under
src/, tests undertests/.
- Preserve backward compatibility unless explicitly requested otherwise.
- Prefer minimal diffs and avoid unrelated changes.
- Do not introduce new dependencies unless necessary.
- Never commit secrets or credentials.
- Store configuration in environment variables; never in source code.
- Provide
.env.example; add.envto.gitignore. - Validate all external inputs.
- Use English for file names, function names, class names, variable names, comments, and docstrings.
- Exception: keep required non-English names only when the activity explicitly mandates them.
- Code comments must be brief and descriptive.
- Prefer one-line comments whenever possible.
- Do not add comments that only restate function parameters or return values.
- Follow PEP8.
- Use 4 spaces for indentation.
- Use type hints in all public functions and methods.
- Use strict typing:
- Avoid
Anyunless strictly justified. - Type all parameters and return values.
- Avoid
- Prefer Pydantic models or
dataclassesfor structured data. - Keep functions small and single-purpose.
- Avoid global state unless strictly necessary.
- Use Python
logging(DEBUG,INFO,WARNING,ERROR,CRITICAL). - Do not silently suppress exceptions; raise actionable errors.
- Public modules, classes, and functions must include docstrings.
- All endpoints return JSON responses.
- Use appropriate HTTP status codes (200, 201, 204, 400, 404, 422, 500).
- Validate request data before processing.
- Keep endpoint logic thin; delegate business logic to service/manager classes.
- Prefer auto-generated API documentation when the framework supports it.
- Entregable 1: use
tasks.jsonfor persistence exclusively viaTaskManager. - Never read/write the JSON file directly from endpoint handlers.
- From entregable 3 onwards: SQLAlchemy + MySQL; design models to minimise migration effort.
- Use semantic HTML5 elements.
- Use 4 spaces for indentation.
- Keep structure readable and consistent.
- Use lowercase tags and attributes.
- Use double quotes for attribute values.
- Add
alttext for informative images. - Ensure basic accessibility (
labelfor inputs, logical heading order). - Target WCAG AA minimum for any HTML interface.
- Confirm Bootstrap usage with the user before implementation.
- Use 4 spaces for indentation.
- Prefer class-based selectors over ids for styling.
- Avoid
!importantunless strictly necessary. - Keep selectors simple and maintainable.
- Group related declarations; keep consistent property ordering.
- Prefer responsive layouts and relative units.
- Use 4 spaces for indentation.
- Use
constby default;letonly when reassignment is required; nevervar. - Use strict equality (
===,!==). - Keep functions small and single-purpose.
- Use clear, descriptive English names.
- Handle errors explicitly; do not swallow exceptions.
- Avoid implicit globals and side effects.
- Framework:
pytestfor Python. - Minimum test coverage: 80%.
- Tests must be deterministic, isolated, and fast.
- Add/update tests for any new or changed logic.
- Test structure:
tests/test_<module>.py.
- Keep
README.mdupdated when behavior, setup, or usage changes. - Include objective, installation, execution, and usage examples for deliverables.
- Never execute arbitrary user-provided code.
- Sanitize/validate input data before processing.
- Keep dependencies updated when modifying the project.
- API keys and credentials go in environment variables only.