skills/python-project/SKILL.md
使用 uv 工具管理 Python 项目的依赖、环境和工作流。适用于项目初始化、依赖管理、环境配置和 CI/CD 设置场景。
npx skillsauth add jasong98/code-skills python-projectInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
代码编写规范参见 python-coding skill。
创建新项目:
uv init myproject --package # 创建库/包项目
uv init myapp # 创建应用项目
标准项目结构:
myproject/
├── pyproject.toml # 依赖声明的唯一真相源
├── uv.lock # 锁定文件(必须提交到 git)
├── .python-version # 固定 Python 版本(可选)
├── src/myproject/ # 源代码
├── tests/ # 测试代码
└── README.md
添加依赖:
uv add requests # 添加生产依赖
uv add --dev pytest ruff # 添加开发依赖
uv add "fastapi>=0.100" # 指定版本约束
同步与锁定:
uv lock # 更新 uv.lock
uv sync # 同步环境(安装所有依赖)
uv sync --frozen # CI 中使用:使用现有锁定,不更新
移除依赖:
uv remove requests
uv python install 3.12 # 安装 Python 3.12
uv python pin 3.12 # 固定项目使用 3.12
uv venv # 创建 .venv
uv sync # 自动创建并同步环境
不要手动激活 - 使用 uv run 代替。
uv run python script.py # 自动同步后运行
uv run pytest # 运行测试
uv run --no-sync python app.py # 跳过同步
在 pyproject.toml 中定义脚本:
[project.scripts]
myapp = "myproject.main:cli"
[tool.uv.scripts]
dev = "uvicorn myapp:app --reload"
test = "pytest tests/"
lint = "ruff check ."
使用方式:uv run dev、uv run test、uv run lint
开发流程:
# 1. 克隆项目
git clone <repo> && cd myproject
# 2. 同步环境
uv sync
# 3. 开发
uv run python -m myproject
# 4. 添加依赖
uv add newpackage
git add pyproject.toml uv.lock
git commit -m "Add newpackage"
CI/CD 模板:
# .github/workflows/test.yml
- uses: astral-sh/setup-uv@v1
- run: uv sync --frozen
- run: uv run pytest
pyproject.toml 是唯一的依赖声明处uv.lock 确保可重现性uv run 执行所有命令以自动管理环境.python-version 或 requires-python--dev 标志或 tool.uv.dev-dependencies更新依赖:
uv lock --upgrade-package requests # 更新单个包
uv lock --upgrade # 更新所有包
导出兼容格式:
uv pip compile pyproject.toml -o requirements.txt
安装可选依赖组:
uv sync --extra dev
uv.lockpip install.venv/ 目录pyproject.toml 外声明依赖requirements.txt 作为主要依赖源当被要求:
uv inituv adduv runuv lock --upgradeuv sync --frozen始终优先使用 uv 命令而非传统的 pip/virtualenv 工作流。
development
A full project lifecycle methodology covering two phases: fast exploration (vibe coding) followed by systematic rebuild (clean architecture). Use this skill whenever the user mentions starting a new project, wants to explore an idea without committing to architecture, says "MVP is done" or "validation complete" and is thinking about a refactor or rebuild, asks how to approach a large-scale refactor, wants to transition from messy prototype to clean system, mentions "vibe coding" or exploratory development, or asks about system design after building a working prototype. This skill applies even when the user doesn't explicitly ask for it — if they're showing signs of being between exploration and architecture, step in.
development
Python 代码编写规范和最佳实践。适用于代码生成、代码审查、代码重构场景。
development
根据今日 Claude Code 历史对话生成日报。输出两个版本:详细版(供个人阅读复盘)和简洁版(可直接提交)。日报追加写入桌面"日报"文件夹,每周一个 md 文件。当用户说"生成日报"、"写日报"、"今日总结"、"daily report"、"做日报"时触发此技能。
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.