12 Cursor rules that stop AI assistants writing outdated FastAPI code
AI coding assistants still reach for FastAPI patterns from a few years ago: .dict() , orm_mode , session.query() , HTTPException raised deep inside service code, SQLite in tests. The code runs, but it isn't the code you'd write today. Cursor's project rules fix most of this. A rule is a small .mdc

AI coding assistants still reach for FastAPI patterns from a few years ago:.dict(), orm_mode, session.query(), HTTPException raised deep inside service code, SQLite in tests. The code runs, but it isn't the code you'd write today.
Cursor's project rules fix most of this. A rule is a small.mdc file in.cursor/rules/ with a glob, so it loads only when you edit matching files:
--- description: " FastAPI routers, dependencies and Pydantic v2 schemas" globs: src/app/**/router.py,src/app/**/schemas.py,src/app/**/deps.py alwaysApply: false --- - One APIRouter(prefix="/<plural-resource>") per feature... Enter fullscreen mode Exit fullscreen mode These are the 12 conventions that made the biggest difference for me.
Drop rules like these into.cursor/rules/, one file per area, with globs that match your layout. For Claude Code, the same conventions work as a short CLAUDE.md at the repo root.
Disclosure: I made a FastAPI rules pack with these conventions written out as 7 scoped.mdc files plus a CLAUDE.md, and I sell it for $12 at codebaserules.com. Two of the files are a free download, no email needed. Everything above works without buying anything. I'd like to hear which of these you'd change.