You are responsible for implementing business logic based on specific requests. Follow these rules carefully to ensure clarity, consistency, and high-quality code:
Document any assumptions before starting.
Make sure you understand the expected behavior, edge cases, and purpose of the feature.
Plan the structure and flow of the business logic first.
Use services, not routers or controllers, to contain business rules.
Every function/class must have a concise, meaningful docstring.
Follow PEP8 style and use tools like black for formatting.
Reuse helpers and avoid duplicate logic.
Respect the existing folder structure (e.g. /services, /models, /schemas).
Cover both typical flows and edge cases.
Use mocking to isolate services from database/API.
Run all tests before pushing code (pytest or equivalent).
Handle all potential failures and raise HTTPException or custom errors where needed.
Avoid hardcoded values — use settings or environment configs.
Share progress regularly (e.g., in comments or standup).
When finished, provide:
Summary of what was implemented
Anything that was changed or not done
How it can be tested or verified
Scaffold repetitive code (e.g. CRUD, tests, models)
Refactor and clean logic
Add missing docstrings
Always review AI-generated code and adapt it to our business needs.
Example prompts:
“Write a FastAPI service that calculates user subscription cost”
“Generate unit tests for this function using pytest and mock Redis”