帮助你写出更规范、可维护的 Python 代码
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "python-foundational" 技能: 1. 下载 https://raw.githubusercontent.com/microsoft/hve-core/main/.github/skills/coding-standards/python-foundational/SKILL.md 2. 保存为 ~/.claude/skills/python-foundational/SKILL.md 3. 装好后重载技能,告诉我可以用了
请按 Python 基础最佳实践检查这段代码,指出命名、导入顺序、类型标注、异常处理和可维护性问题,并给出修改建议。
列出具体问题,并给出更符合 Python 习惯的修改方案。
请把下面的 Python 代码重构得更简洁、可读、类型更清晰:优先使用上下文管理器、合适的内置类型/数据类、避免可变默认值,并保留现有行为。
输出重构后的代码,并说明关键改动。
请审查这段 Python 代码是否存在 eval/exec/pickle、硬编码密钥、裸 except、静默失败等问题,并说明如何修正。
指出安全风险与错误处理缺陷,并给出替代实现建议。
Python 开发者在做代码审查时,可用它快速检查命名、导入、类型标注、异常处理和函数设计是否符合基础规范。适合把“可读、可维护、可测试”作为统一标准。
当项目里出现臃肿函数、重复逻辑或不一致的写法时,可用它指导重构。它强调最小必要改动、抽取重复逻辑,以及遵循现有架构。
适合把一次性脚本改成更稳健的实现:使用上下文管理器、合适的数据结构、清晰的异常信息和类型标注,降低后续维护成本。
该文档定义了一个 Python 基础编码规范技能,用于在处理 .py 变更时优先检查代码是否符合可读性、Pythonic 习惯、函数设计、类型安全、错误处理、可维护性与架构一致性等标准,并明确列出应避免的反模式。
Foundational Python excellence that every diff must satisfy. This skill is loaded first for any .py change. All higher-order skills build on it.
This content is a skill rather than an instructions file for three reasons: skills are distributed through the CLI plugin and VS Code extension without requiring consumers to copy files into their repo; new language skills can be added without modifying the review agent itself; and skills are loaded on demand, keeping the context window small when the diff contains no Python.
PascalCase classes, snake_case functions/variables, UPPER_SNAKE_CASE constants, _ private members.with for files, locks, DB connections.dataclass / NamedTuple / Enum for data holders.pathlib over os.path; timezone-aware datetime when relevant.* keyword-only arguments for multi-optional functions.global/nonlocal unless strictly required.TypeVar for generics.Any except in thin wrappers.except: (broad except Exception: only at app boundaries with logging).eval, exec, or pickle on untrusted data.print.| File | Covers | Purpose |
|---|---|---|
| design-principles.md | Section 9 | Rationale and examples for the design principles |
| code-style-patterns.md | Sections 1–5 | Concrete code examples for style, idioms, type safety, class design, and error handling |
| Severity | Definition |
…
它聚焦 Python 基础最佳实践、代码风格、类型安全、异常处理、可维护性和架构一致性。目标是让代码更清晰、更稳健、更容易维护。
给定素材未提供安装说明。它是用于 Python 代码处理的技能,不是独立运行时库。
它强调的是基础层面的统一标准:可读性、类型标注、错误处理、避免反模式,以及与现有代码库保持一致。素材中没有说明更高级的专门能力。
为设计思维教练提供身份、流程与状态基线
将设计思维成果整理为可交接的 RPI 输入与上下文
将回复压缩为极简风格,同时保留技术准确性
通过 Python CLI 自动读写 Mural 内容并管理小组件
用 YAML 驱动生成、更新和管理 PowerPoint 幻灯片
从多视角审查代码变更,输出结构化问题与风险。