Pythonコードのリーダブルコード原則に基づくレビュー・改善・リファクタリングを行う際に使用。「コードレビュー」「コードを読みやすくして」「リーダブルコードの観点でチェック」「命名を改善して」「保守性を向上」「可読性を改善」「リファクタリング」「ベストプラクティスを適用」という依頼で起動。AI駆動開発時代における「理解速度最大化」を重視し、命名・制御フロー・コメント・構造・責務分離の改善を提案。
『リーダブルコード』の原則に基づき、Pythonコードの可読性を向上させる。AI駆動開発での「理解速度」を最大化する改善を提案する。
「他人が理解するまでの時間」を最小化する
コードレビュー・改善は次の順で進める:
timeout_ms, age_years, size_bytesget_adult_users (>= 20), is_valid_emailfetch_user_profile (何を取得するか明確に)v, t, get)is_enabled (not disable_flag)get_adult_users (not filter_users)min_length (>= or >?)# 新規ユーザーを先に処理しないと無料枠判定が誤作動するため昇順固定NG:
def charge(user, amount: int) -> bool:
if user:
if amount > 0:
if not user.is_banned:
return payment.charge(user.id, amount)
return False
OK:
def charge(user, amount: int) -> bool:
if user is None:
return False
if amount <= 0:
return False
if user.is_banned:
return False
return payment.charge(user.id, amount)
NG: 複数条件を1行に詰め込む
OK:
is_active_user = not user.is_deleted
can_access_team_doc = user.role == "admin" or user.team_id == doc.team_id
is_publishable_doc = not doc.is_archived
if is_active_user and can_access_team_doc and is_publishable_doc:
publish(doc)
final, const相当の意識)for ループより sum(... for ...) 等NG: 検証・作成・通知・メトリクスを1関数に混在
OK:
def validate_register_input(input_data) -> None:
if "@" not in input_data.email:
raise ValueError("invalid email")
async def create_user(input_data):
password_hash = await hash_password(input_data.password)
return await db.user.create(...)
async def register(input_data):
validate_register_input(input_data)
user = await create_user(input_data)
await mailer.send_welcome_mail(user.email)
metrics.increment("user_registered")
return user
{u.id: u for u in users}.values()test_shipping_fee_is_free_for_member_domestic_orderamount=10_000, is_member=True 等チーム運用で即効性のある6原則:
以下の質問で素早くチェック:
references/principles.md: 各原則の詳細説明references/before_after_examples.md: Before/After 実例集(記事から抽出)references/review_checklist.md: 詳細レビューチェックリストnpx skills add studiogadget/python-readable-code下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
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