Python 开发规范配置
python-developer
Python 开发者总括技能——一次性安装 Python 编码约定,并捆绑配套技能(最佳实践、测试、依赖管理)完成统一配置。当用户要求建立 Python 开发规范、安装 Python 技能,或说“搭建 Python 开发环境”时使用。
- License 许可
- MIT
- 最近更新
- 2026-10-24
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- python-developer
- description
- Python developer umbrella — installs Python coding conventions and bundles companion skills (best practices, testing, dependency management) in a single setup. Use when the user asks to set up Python development conventions, install Python skills, or says "set up Python development".
02 资源文件 12
- 参考文档.managed-skill.md544 B
- 参考文档references/code-recipes.md6.1 KB
- 参考文档references/ecommerce.md4.1 KB
- 参考文档references/jobs.md3.4 KB
- 参考文档references/local-business.md5.5 KB
- 参考文档references/real-estate.md2.8 KB
- 参考文档references/scraper-jobs.md8.9 KB
- 参考文档references/search.md5.2 KB
- 参考文档references/travel.md8.8 KB
- 参考文档references/web-scraping.md6.6 KB
- 参考文档references/youtube.md7.0 KB
- 参考文档templates/python-developer-rule.md2.8 KB
03 SKILL.md 正文
MANAGED SKILL — Do not edit this file here. It is managed from an external source repository. To make changes, update the source and run "update my skills" to sync.
Python Developer (Umbrella)
One-stop setup for Python development. Installs comprehensive coding conventions as an always-on rule and bundles companion skills for testing, dependency management, and best practices.
Setup Questions (Asked at Install Time)
Q1 — Toolchain
title: "Python Toolchain"
questions:
- id: toolchain
prompt: "Which Python toolchain does this project use?"
options:
- id: uv
label: "uv"
- id: poetry
label: "poetry"
Q2 — Project type
title: "Project Type"
questions:
- id: project_type
prompt: "What type of Python project is this?"
options:
- id: library
label: "Library (installable package)"
- id: cli
label: "CLI application"
- id: web
label: "Web application (Pyramid)"
Q3 — Companion skills
title: "Companion Skills"
questions:
- id: companions
prompt: "Which companion skills should be bundled alongside python-developer?"
allow_multiple: true
options:
- id: python-best-practices
label: "python-best-practices — comprehensive Python coding conventions"
- id: write-pytest
label: "write-pytest — guided test writing workflow"
- id: manage-dependencies
label: "manage-dependencies — dependency add/remove/update"
- id: all
label: "All of the above (recommended)"
If the user selects "All of the above", include all three companion skills. Default to "All of the above" if the user doesn't have a preference.
Install Actions
After collecting answers, perform these actions:
1. Generate the always-on rule
Read templates/python-developer-rule.md. Replace the placeholders:
| Placeholder | Source |
|---|---|
{toolchain} |
Q1 answer: uv or poetry |
{run_prefix} |
uv run if uv, poetry run if poetry |
{project_type_section} |
One of the blocks below, based on Q2 answer |
Project type sections (insert the matching block for {project_type_section}):
If library:
- Source layout: `src/{package_name}/` with `__init__.py` re-exports for the public API
- Keep the public API surface small — expose only what consumers need
If cli:
- Entry point in `src/{package_name}/__main__.py`
- Use `argparse` or `click` for CLI argument parsing
- Separate CLI parsing from business logic — keep commands thin
If web (Pyramid):
- Routes in `routes.py`, views in `views/`
- Use Cornice for REST services
- Context factories for authorization (ACL-based)
- Transaction management via `pyramid_tm` — do not commit manually
Write the result to .cursor/rules/python-developer.mdc in the target project.
2. Bundle companion skills
For each companion skill selected in Q3:
- Copy the entire skill directory from
$REPO_ROOT/skills/<companion>/to$TARGET_DIR/<companion>/ - Write a
.managed-skill.mdfile in the copied directory (follow the standard format from the install-skills skill) - Inject the managed-skill warning at the top of the copied SKILL.md, immediately after the YAML frontmatter closing
---:
> **MANAGED SKILL** — Do not edit this file here. It is managed from an external source repository.
> To make changes, update the source and run "update my skills" to sync.
3. Handle write-pytest companion rule
If write-pytest was selected as a companion, ask the user:
title: "Test Patterns Rule"
questions:
- id: install_test_rule
prompt: "write-pytest includes an optional Cursor rule that enforces test patterns on test files. Install it?"
options:
- id: "yes"
label: "Yes, install the test-patterns rule"
- id: "no"
label: "No, just the skill"
If yes, copy $REPO_ROOT/skills/write-pytest/templates/test-patterns-rule.mdc to .cursor/rules/test-patterns.mdc in the target project.
4. Handle manage-dependencies companion
If manage-dependencies was selected as a companion, use the Q1 toolchain answer to install the matching rule and skill:
- If uv: read
$REPO_ROOT/skills/manage-dependencies/templates/uv-rule.mdanduv-skill.md - If poetry: read
$REPO_ROOT/skills/manage-dependencies/templates/poetry-rule.mdandpoetry-skill.md
Write the rule to .cursor/rules/dependency-management.mdc and the skill to $TARGET_DIR/manage-dependencies/SKILL.md (replacing the generic SKILL.md that was copied in step 2).
Remove the <!-- PRIVATE REGISTRY --> / <!-- /PRIVATE REGISTRY --> section from both files unless the project is known to use a private registry.
Runtime Behavior (After Installation)
When installed, this skill acts as a router for Python development tasks. If the user asks about Python development and a companion skill is relevant, direct them to it.
Companion Skills Catalog
| Skill | When to use | Trigger phrases |
|---|---|---|
| python-best-practices | Coding conventions, style questions, "how should I write this", anti-patterns | "Python conventions", "best practices", "code style", "how to handle errors" |
| write-pytest | Writing new tests, test structure, test patterns | "write tests", "add tests", "test this module" |
| manage-dependencies | Adding, removing, or updating packages | "add a package", "install dependency", "update packages" |
Routing rules
- If the user asks about coding style, conventions, or patterns → direct to
python-best-practices - If the user asks to write or modify tests → direct to
write-pytest - If the user asks to add, remove, or update a dependency → direct to
manage-dependencies - If the question spans multiple areas, answer directly using the conventions from
python-best-practicesand mention the relevant companion skill for follow-up
04 同仓库更多 Skills
pytest 测试编写
write-pytest
为任何 Python 代码库编写 pytest 测试。当用户要求编写测试、创建测试、添加测试,或测试某个模块/服务/端点/函数时使用。与框架无关;当检测到相关信号时会路由到框架专用的辅助工具。遵循“先研究—再讨论—后编写”的流程。
会话质量保障检查
quality-assurance
对当前聊天会话执行质量保障检查——任务前验证、任务后清单和代码审查。在完成任务时、提交前或用户要求进行 QA 审查时使用。
Python 编码最佳实践
python-best-practices
全面的 Python 编码约定与最佳实践。当用户询问 Python 约定、编码模式、最佳实践、代码风格、反模式,或“这段 Python 代码应该怎么写”时使用。
Pyramid 扩展库开发
pyramid-library
库开发者角色:开发独立的 Pyramid 扩展(拥有自己的仓库与包),并向外部使用者暴露 includeme。当用户构建可复用的 Pyramid 库、为使用者设计 includeme、注册自定义指令/tween/请求方法,或使用规范的应用程序测试库时使用。
Pyramid 框架开发规范
pyramid-developer
Pyramid 框架开发约定——配置/注册表、基于 includeme 的模块系统、pyramid_services、模型、Cornice REST、ACL 授权以及事务处理。在为一个项目建立 Pyramid 开发规范时使用。
Pyramid 框架扩展点参考
pyramid-core
Pyramid 框架特性参考——请求方法、自定义指令、事件、补间(tween)、异常视图、视图谓词、视图派生器、回调、渲染器以及静态视图。当用户询问 Pyramid 框架的任何扩展点时使用。