skills/python-coding/SKILL.md
Python 代码编写规范和最佳实践。适用于代码生成、代码审查、代码重构场景。
npx skillsauth add jasong98/code-skills python-codingInstall 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 | calculate_total |
| 类名 | CapWords | UserAccount |
| 常量 | UPPER_SNAKE_CASE | MAX_RETRY_COUNT |
| 私有属性 | _leading_underscore | _internal_id |
| 布尔变量 | is_/has_/can_ 前缀 | is_active, has_permission |
# 使用现代语法 (Python 3.10+)
def process(items: list[str]) -> dict[str, int]: ...
def get_user(id: int) -> User | None: ...
# 使用 Protocol 进行结构化类型
from typing import Protocol
class Drawable(Protocol):
def draw(self) -> None: ...
详细指南: style-guide.md#类型注解
# 参数过多时使用 dataclass
@dataclass
class EmailConfig:
to: str
subject: str
body: str
cc: list[str] = field(default_factory=list)
def send_email(config: EmailConfig) -> None: ...
# 分组顺序,每组内按字母排序
import os
import sys
from pathlib import Path
import requests
from dotenv import load_dotenv
from myapp.models import User
from myapp.utils import logger
from module import *# 使用具体异常类型
try:
result = data["key"]
except KeyError:
result = default_value
except requests.Timeout:
logger.warning("Request timed out")
raise
# 禁止裸 except
# Bad: except Exception: pass
def load_config(path: Path) -> dict[str, Any]:
"""加载并校验配置文件.
该函数读取配置文件并返回解析结果, 不修改全局状态.
Args:
path: 配置文件路径.
Returns:
解析后的配置字典.
Raises:
ValueError: 当配置不合法时抛出.
"""
格式规则:
. , :). , ;)使用 LRU 缓存# 使用贪心策略, 因为回溯会导致指数级复杂度
result = greedy_search(data)
() 换行,避免 \except Exception: passdevelopment
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
使用 uv 工具管理 Python 项目的依赖、环境和工作流。适用于项目初始化、依赖管理、环境配置和 CI/CD 设置场景。
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.