cursorrules

A set of working rules for an AI assistant focused on Python development. The rules cover project structure, type annotations, docstrings, testing, dependency management, code style, error handling, and continuous integration.

In plain words
What is it for?
Use it when asking an AI assistant to create or review Python code in projects using pytest, Ruff, uv, virtual environments, and automated build checks.
Why use it?
It gives coding assistance a consistent standard to follow across Python projects, including how code should be typed, documented, tested, and checked.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/songshgeo/python-project-template/cursorrules
Clone the repo
git clone --depth 1 https://github.com/SongshGeo/Python-Project-Template

Made for: Cursor.

Per session 456 This file is loaded in full into every session.
When invoked 456 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00456 $0.00456
Opus 5 $0.00228 $0.00228
Sonnet 5 $0.00091 $0.00091
Haiku 4.5 $0.00046 $0.00046

Measured 2d ago against content hash c6955b8db13c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cursorrules scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/cursorrules.mdc · 37 lines

What it actually says

You are an AI assistant specialized in Python development. Your approach emphasizes:

  • Clear project structure with separate directories for source code, tests, docs, and config.
  • Modular design with distinct files for models, services, controllers, and utilities.
  • Configuration management using environment variables.
  • Robust error handling and logging, including context capture.
  • Comprehensive testing with pytest.
  • Detailed documentation using docstrings and README files.
  • Dependency management via https://github.com/astral-sh/uv and virtual environments.
  • Code style consistency using Ruff.
  • CI/CD implementation with GitHub Actions or GitLab CI.

AI-friendly coding practices:

  • You provide code snippets and explanations tailored to these principles, optimizing for clarity and AI-assisted development.

Follow the following rules:

  • For any Python file, ALWAYS add typing annotations to each function or class. Include explicit return types (including None where appropriate). Add descriptive docstrings to all Python functions and classes.
  • Please follow PEP 257 docstring conventions. Update existing docstrings as needed.
  • Make sure you keep any comments that exist in a file.
  • When writing tests, ONLY use pytest or pytest plugins (not unittest). All tests should have typing annotations. Place all tests under ./tests. Create any necessary directories. If you create packages under ./tests or ./src/<package_name>, be sure to add an init.py if one does not exist.

All tests should be fully annotated and should contain docstrings. Be sure to import the following if TYPE_CHECKING: from _pytest.capture import CaptureFixture from _pytest.fixtures import FixtureRequest from _pytest.logging import LogCaptureFixture from _pytest.monkeypatch import MonkeyPatch from pytest_mock.plugin import MockerFixture

Before you begin, carefully read all documents in the top-level memory-bank/ (the shared memory bank used by both Cursor and Claude Code). Keep those documents up to date as the project evolves. Avoid using "try...except" syntax to prevent exceptions from being silenced.

Note: these rules are kept in sync with the repository's CLAUDE.md, which is the authoritative source for coding standards and the skill/workflow index. If the two ever diverge, CLAUDE.md wins.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 37 lines · 456 tokens per session scan A c6955b8db13c

Subscribe to this mod's changes

cursorrules is a cursor rule published in the GitHub repository SongshGeo/Python-Project-Template (8 stars, last pushed 2mo ago), licensed MIT. It adds 456 tokens to every session, about $0.0023 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.