初始化一个规范的 Python 项目,包含依赖管理、代码规范检查、测试框架、版本管理等。当用户需要创建新的 Python 项目时触发此 skill。
与用户确认以下信息:
使用 uv 初始化项目,启用 git 版本控制:
uv init \
# 项目名称
--name={{project_name}} \
# 项目描述
--description="{{project_description}}" \
# 初始化 src/{{project_name}} 包目录
--package \
# 初始化 git
--vcs=git \
# Python 最低支持版本
--python={{python_version}}
添加 pre-commit、代码格式化工具和类型检查工具:
uv add --dev pre-commit black flake8 flake8-import-order ruff mypy
将 assets/templates/pre-commit-config.yaml 内容写入项目根目录的 .pre-commit-config.yaml 文件
使用模板 assets/templates/flake8 生成 .flake8 文件
安装 pre-commit hooks:
uv run pre-commit install
创建 PEP-561 类型标记文件(标识该包支持类型检查):
touch src/{{project_name}}/py.typed
使用模板 assets/templates/mypy.toml 生成项目根目录的 mypy.toml 文件
添加 pytest 和 pytest-cov 开发依赖:
uv add --dev pytest pytest-cov
创建 tests 目录和初始测试文件:
mkdir -p tests
touch tests/__init__.py
使用模板 assets/templates/pytest.ini 生成项目根目录的 pytest.ini 文件
使用模板 assets/templates/coveragerc 生成项目根目录的 .coveragerc 文件
添加 .gitignore
curl https://raw.githubusercontent.com/github/gitignore/refs/heads/main/Python.gitignore -o .gitignore
添加 bumpversion 依赖:
uv add --dev bumpversion
配置版本元信息
使用模板 assets/templates/_version.py 生成 src/{{project_name}}/_version.py
使用模板 assets/templates/init.py 生成 src/{{project_name}}/__init__.py
使用模板 assets/templates/test_version.py 生成 tests/test_version.py
使用模板 assets/templates/bumpversion.cfg 生成 .bumpversion.cfg 文件
uv add --dev ipython
安装所有依赖:
uv sync
验证配置:
# 验证 pytest
uv run pytest
# 验证 pre-commit
uv run pre-commit run --all-files
# 验证 bumpversion
uv run bumpversion --help
# 验证版本元信息
uv run python -c 'from {{project_name}} import __version__; print(__version__)'
# 验证 mypy
uv run mypy src/{{project_name}}/
使用模板 assets/templates/README.md 生成 README.md 文件
git add .
git commit -m "Initial project setup"
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer