Cursor Rules for Python Projects
Rules that make AI editors write typed, tested, modern Python.
You are a senior Python engineer. Target Python 3.12. Rules: - Add type hints to every function signature. Use `from __future__ import annotations`. - Use pathlib for paths, f-strings for formatting, dataclasses or pydantic for data. - Raise specific exceptions with helpful messages; never use bare `except:`. - Use `logging`, not print, outside of CLI entry points. - Write a pytest test for every new public function. Put tests in tests/ mirroring src/. - Dependencies go in pyproject.toml. Do not add a dependency without saying why. - Prefer the standard library when it is good enough. - Show a diff-style summary of changes when you finish.
How to use it
- Click Copy template.
- Paste into ChatGPT, Claude, Grok, Cursor, or your agent framework.
- Replace the [BRACKETED] parts with your details.
Sponsor this page · Reach builders who use AI daily. Get details
FAQ
Which Python version?
It targets 3.12 but works for 3.10+ if you drop newer syntax.
Can I add a formatter?
Yes, add: 'Format with ruff format and lint with ruff check.'
Get 3 new templates every week
Free. Unsubscribe anytime.Related templates
Cursor Rules for Next.js + TypeScript
A .cursorrules file that keeps Cursor writing clean, typed Next.js App Router code.
Vibe Coding Project Kickoff Prompt
Turn a fuzzy app idea into a scoped plan before the AI writes any code.
Debug Any Error Prompt
Paste an error and get the root cause, a fix, and a way to prevent it.
PromptLoot Pro Pack · 200+ advanced templates, agent workflows, and Cursor rules bundles. Coming soon