Files
myagents/.claude/skills/coding.md
T
Zhengshou Lai b98d35c387 feat: add mybot CLI with update, chat, and Claude project config
- Click entrypoint: mybot update (make install / pip -e), mybot chat (claude in repo)
- Optional --dangerously-skip-permissions for Claude Code
- Makefile install; hatchling package layout
- .gitignore: venv, build artifacts, workspace (local symlinks)

Made-with: Cursor
2026-04-06 13:11:10 +08:00

1.1 KiB

编程技能 (Coding Skill)

代码风格

  • Python: Black (80字符), Ruff, MyPy
  • 优先可读性,其次简洁
  • 有意义的命名 > 注释解释命名

编码原则

  1. 单一职责: 每个函数/类只做一件事
  2. 类型注解: 使用类型提示提高可维护性
  3. 错误处理: 显式处理边界情况和异常
  4. 测试友好: 代码结构便于单元测试

代码审查清单

  • 是否有类型注解?
  • 错误处理是否完善?
  • 命名是否清晰?
  • 是否有过度工程?
  • 是否符合项目现有风格?

常用模式

异步代码

async def process_items(items: list[T]) -> list[R]:
    tasks = [process_one(item) for item in items]
    return await asyncio.gather(*tasks)

错误处理

from typing import TypeVar, Generic

T = TypeVar('T')

class Result(Generic[T]):
    def __init__(self, ok: bool, value: T | None = None, error: str | None = None):
        self.ok = ok
        self.value = value
        self.error = error

禁忌

  • 不要用 except: 捕获所有异常
  • 不要修改全局状态
  • 不要有副作用的 property