python

A collection of conventions for structuring Python projects and packages, including configuration, source code, tests, and dependencies.

In plain words
What is it for?
Use it when starting or reorganizing a Python project and when deciding where application code, models, services, APIs, and configuration belong.
Why use it?
It gives Python code a predictable layout so developers can find files, install the project, and maintain it consistently.

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/mywand/cusrsor-do-it/python
Clone the repo
git clone --depth 1 https://github.com/mywand/cusrsor-do-it

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 8,838 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00000 $0.08838
Opus 5 $0.00000 $0.04419
Sonnet 5 $0.00000 $0.01768
Haiku 4.5 $0.00000 $0.00884

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

Security

Grade A, and why

python scanned grade A with 1 finding 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 yesterday.

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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

@patch('requests.get')
.cursor/rules/languages/python.mdc · 1,280 lines

How it starts

The opening of the file, as written. The whole thing — 1,280 lines — stays where its author put it; the contents beside it link to each section on GitHub.

最近更新: 2025-10-10

Python 专属实践规范

1. 项目结构规范

1.1 标准项目结构

my_project/
├── README.md                    # 项目说明
├── pyproject.toml              # 项目配置(推荐)
├── requirements.txt            # 依赖列表(可选)
├── setup.py                    # 安装脚本(传统方式)
├── .gitignore                  # Git忽略文件
├── .env.example                # 环境变量示例
├── Dockerfile                  # Docker配置
├── docker-compose.yml          # Docker编排
├── Makefile                    # 构建脚本
├── src/                        # 源代码目录(推荐)
│   └── my_project/
│       ├── __init__.py
│       ├── main.py             # 程序入口
│       ├── config/             # 配置模块
│       │   ├── __init__.py
│       │   ├── settings.py     # 配置设置
│       │   └── database.py     # 数据库配置
│       ├── models/             # 数据模型
│       │   ├── __init__.py
│       │   ├── user.py
│       │   └── base.py
│       ├── services/           # 业务逻辑层
│       │   ├── __init__.py
│       │   ├── user_service.py
│       │   └── auth_service.py
│       ├── repositories/       # 数据访问层
│       │   ├── __init__.py
│       │   ├── user_repository.py
│       │   └── base_repository.py
│       ├── api/                # API层
│       │   ├── __init__.py
│       │   ├── routes/
│       │   │   ├── __init__.py
│       │   │   ├── users.py
│       │   │   └── auth.py
│       │   ├── middleware/
│       │   └── schemas/        # API模式定义
│       ├── utils/              # 工具函数
│       │   ├── __init__.py
│       │   ├── helpers.py
│       │   └── validators.py
│       ├── exceptions/         # 自定义异常
│       │   ├── __init__.py
│       │   └── custom_exceptions.py
│       └── constants/          # 常量定义
│           ├── __init__.py
│           └── app_constants.py
├── tests/                      # 测试目录
│   ├── __init__.py
│   ├── conftest.py            # pytest配置
│   ├── unit/                  # 单元测试
│   │   ├── test_models.py
│   │   ├── test_services.py
│   │   └── test_utils.py
│   ├── integration/           # 集成测试
│   │   ├── test_api.py
│   │   └── test_database.py
│   └── fixtures/              # 测试数据
│       └── sample_data.json
├── docs/                      # 文档目录
│   ├── api.md                 # API文档
│   ├── deployment.md          # 部署文档
│   └── development.md         # 开发文档
├── scripts/                   # 脚本目录
│   ├── migrate.py             # 数据库迁移
│   ├── seed_data.py           # 数据初始化
│   └── deploy.sh              # 部署脚本
├── migrations/                # 数据库迁移文件
├── static/                    # 静态文件(Web项目)
├── templates/                 # 模板文件(Web项目)
└── logs/                      # 日志目录

Read the full file on GitHub · 1,280 lines

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. yesterday First seen · 1,280 lines · 0 tokens per session scan A f5c33cd01b14

Subscribe to this mod's changes

python is a cursor rule published in the GitHub repository mywand/cusrsor-do-it (2 stars, last pushed 7mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 8,838 tokens. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.