一键导入
python-pyproject-toolconfig
Append missing ruff, pyright, and pytest configuration sections to an existing pyproject.toml without overwriting existing settings.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Append missing ruff, pyright, and pytest configuration sections to an existing pyproject.toml without overwriting existing settings.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Name or repair development branches with semantic prefixes, `<type>/<username>/<short-description>` structure, and migration guidance when work has already started on the wrong branch.
Draft or review semantic commit messages from staged changes, including split signals, business-facing subjects, breaking-change markers, and repair commands such as `git add -p`, `git reset`, and `git commit --amend`.
Query step status (pending/done) in plan/<topic>/<topic>.step.md with minimal token cost and explicit blocking when incomplete.
Create an executable Python implementation plan that freezes scope, contracts, decisions, affected files, tests, and validation commands before coding begins. Not a todo list — an implementation contract that executor can follow and reviewer can verify.
Configures pre-commit hooks for uv-based Python projects by producing a valid `.pre-commit-config.yaml` with the canonical hook set. Use this when a uv Python project needs pre-commit setup or an existing config needs hooks merged in.
Create RED tests from an approved Python implementation plan before implementation begins. Use this when a plan is approved, run internal D1 classification, and produce structured verdict-driven test authoring.
| name | python-pyproject-toolconfig |
| description | Append missing ruff, pyright, and pytest configuration sections to an existing pyproject.toml without overwriting existing settings. |
| complexity | medium |
| risk_profile | ["code_modification"] |
| inputs | ["--python-version: Python 版本字串,必須向人類詢問(例如 3.10、3.12)","--package-name: 套件/模組名稱,用於 pyright include 路徑,必須向人類詢問","pyproject.toml: 執行前必須已存在於當前工作目錄"] |
| outputs | ["修改後的 pyproject.toml,補充了缺少的 [tool.ruff]、[tool.pyright]、[tool.pytest.ini_options] section","stdout 報告,列出每個 append 或跳過的 section","若所有 section 已存在,則不做任何修改"] |
| use_when | ["Python 專案有 pyproject.toml,但缺少一個或多個 tool 配置 section","為新專案或現有專案建立 linting、型別檢查、測試配置","跨專案標準化工具設定,同時保留現有客製化設定"] |
| do_not_use_when | ["專案使用 setup.cfg、tox.ini 或個別工具配置檔,而非 pyproject.toml","需要修改或更新現有工具配置(本 skill 只做 append)","需要配置 [tool.coverage]、[tool.mypy] 等本 skill 範圍外的工具"] |
為 Python 專案的 pyproject.toml 補充標準 [tool.ruff]、[tool.pyright]、[tool.pytest.ini_options] 配置 section。只新增缺少的 section;已存在的 section 一律不修改。
使用時機:
pyproject.toml,但缺少一個或多個 tool 配置 section不使用時機:
setup.cfg、tox.ini 或個別工具配置檔,而非 pyproject.toml[tool.coverage]、[tool.mypy] 等本 skill 範圍外的工具| 輸入 | 來源 | 說明 |
|---|---|---|
--python-version | 必須詢問人類 | Python 版本字串,含點號,例如 3.10、3.12 |
--package-name | 必須詢問人類 | 套件/模組名稱,用於 pyright include 路徑,例如 mylib |
pyproject.toml | 當前工作目錄 | 執行前必須已存在 |
重要:--python-version 和 --package-name 必須向人類詢問,不得自行推斷或猜測。
確認 當前工作目錄中 pyproject.toml 存在。
詢問人類 兩個必要值:
--python-version:專案 Python 目標版本,格式含點號(例如 3.10)--package-name:位於 src/ 下的可匯入套件名稱(例如 mylib)執行 script(從專案根目錄):
uv run skills/python-pyproject-toolconfig/scripts/apply_toolconfig.py \
--python-version 3.10 \
--package-name mylib
確認 stdout 輸出:確認哪些 section 被 append(✅ Will append),哪些因已存在而跳過(ℹ️ already exists)。
驗證 pyproject.toml 仍為合法 TOML:
uv run -c "import tomllib; tomllib.load(open('pyproject.toml','rb')); print('TOML valid')"
--python-version 3.11 --package-name mypackage; script detects no existing [tool.*] sections and appends ruff, pyright, and pytest blocks. See examples.md for full expected stdout.--python-version py311 instead of 3.11; this produces target-version = "pypy311" in the ruff section. Always pass bare version strings such as 3.10 or 3.11.pyproject.toml,補充了缺少的 [tool.ruff]、[tool.pyright]、[tool.pytest.ini_options] section[project]、[build-system] 或任何非 [tool.*] section[tool.*] section,只 append 缺少的[tool.ruff] exclude patterns,由使用者自行維護[tool.coverage]、[tool.mypy] 或其他本 skill 範圍外的工具uv 已安裝並可在 PATH 中存取pyproject.toml 必須已存在於當前工作目錄[tool.*] section 的內容;修改現有設定的維護責任由 human 承擔| 項目 | 用途 |
|---|---|
scripts/apply_toolconfig.py | 可執行 script:偵測現有 section,append 缺少的 section |
templates/toolconfig-ruff.toml.tmpl | [tool.ruff] 與 [tool.ruff.lint] section 範本,含 placeholder |
templates/toolconfig-pyright.toml.tmpl | [tool.pyright] section 範本,含 placeholder |
templates/toolconfig-pytest.toml.tmpl | [tool.pytest.ini_options] section 範本 |
tests/ | 單元測試:section 偵測、placeholder 替換、冪等性、既有設定保留 |