.claude/skills/coding-standards-py/SKILL.md
Python 编码规范:PEP 8 命名、mypy strict 类型标注、ruff lint 规则、不可变性模式
npx skillsauth add andyan77/diyu-agent .claude/skills/coding-standards-pyInstall 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.
| 类型 | 风格 | 示例 |
|------|------|------|
| 模块/包 | snake_case | user_service.py |
| 类 | PascalCase | UserService |
| 函数/方法 | snake_case | get_user_by_id() |
| 常量 | UPPER_SNAKE | MAX_RETRY_COUNT |
| 类型变量 | PascalCase | T = TypeVar("T") |
项目使用 mypy strict=true,所有代码必须有完整类型标注:
# 正确
async def find_user(user_id: str) -> User | None:
...
# 错误 — mypy strict 会报错
async def find_user(user_id):
...
使用 Python 3.12 原生语法:
str | None 而不是 Optional[str]list[str] 而不是 List[str]dict[str, int] 而不是 Dict[str, int]配置在 pyproject.toml,行长 120 字符。
自动修复:uv run ruff check --fix src/ tests/
格式化:uv run ruff format src/ tests/
# Pydantic model — frozen
class UserDTO(BaseModel):
model_config = {"frozen": True}
name: str
email: str
# 函数 — 不修改输入
def update_user(user: dict, name: str) -> dict:
return {**user, "name": name} # 新对象,不修改原对象
src/ports/ 只放 ABC 接口src/shared/ 放跨层共享的类型和工具eval(), exec(), __import__() 用于用户输入pickle.loads() 用于不可信数据pip install(只用 uv)print() 留在提交代码中(用 logging)tools
# Skill 层任务卡集 > 架构文档: `docs/architecture/03-Skill层.md` > 里程碑来源: `docs/governance/milestone-matrix-backend.md` Section 4 > 影响门禁: `src/skill/**` -> check_layer_deps > 渐进式组合 Step 3 --- ## Phase 0 -- Port 定义 ### TASK-S0-1: SkillProtocol 基类 | 字段 | 内容 | |------|------| | **目标** | 定义 Skill 层核心协议 (execute() / describe() / validate_params()),使所有 Skill 统一契约 | | **范围 (In Scope)** | `src/skill/core/protocol.py` | | **范围外 (Out of Scope)** | Brain 调度逻辑 / Knowledge Stores 内部实现 / Tool 内部实现 / Memory Core |
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.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.
development
Run, watch, debug, and extend OpenClaw QA testing with qa-lab and qa-channel. Use when Codex needs to execute the repo-backed QA suite, inspect live QA artifacts, debug failing scenarios, add new QA scenarios, or explain the OpenClaw QA workflow. Prefer the live OpenAI lane with regular openai/gpt-5.4 in fast mode; do not use gpt-5.4-pro or gpt-5.4-mini unless the user explicitly overrides that policy.