Python Foundational
MicrosoftOfficialPublished by Microsoft
- Skill
- Guidelines
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The python-foundational skill provides a core checklist of best practices for Python development. It covers naming conventions, import organization, Pythonic idioms, function and class design, type safety, error handling, and architectural principles. Designed to be loaded automatically for Python changes, it serves as a baseline for maintaining readable, maintainable, and robust codebases by establishing shared expectations for code structure and design.
What it does
- Defines standard naming conventions for classes, functions, variables, and constants.
- Provides guidelines for organizing imports and using Pythonic idioms like comprehensions and context managers.
- Establishes requirements for type hinting and documentation via docstrings.
- Outlines principles for error handling, such as raising specific exceptions and avoiding bare except clauses.
- Promotes design principles like DRY (Don't Repeat Yourself) and simplicity-first development.
- Offers a severity rubric to help distinguish between runtime issues and maintainability improvements.
When to use it
- During code reviews to ensure new Python code aligns with project standards.
- When establishing a baseline for Python code quality in a new or existing repository.
- To provide consistent guidance on Pythonic patterns and anti-patterns.
- When refactoring code to improve maintainability and adherence to design principles.
Advantages
- Promotes consistency across the codebase by providing a unified set of standards.
- Reduces maintenance overhead by encouraging self-documenting code and shared helpers.
- Helps catch potential issues early through type safety and robust error handling practices.
- Prevents premature complexity by advocating for simple, direct implementations.
Usage examples
- “Review this Python function for adherence to foundational standards.”
- The agent evaluates the function against the checklist, checking for proper naming, type hints, docstrings, and error handling, providing feedback based on the severity rubric.
- “Does this code follow the DRY principle?”
- The agent analyzes the logic for duplication and suggests extracting repeated code into a shared helper function if applicable.
- “How should I structure my imports in this module?”
- The agent provides the standard three-tier grouping pattern: standard library, third-party packages, and local project imports.
- “Is this use of a mutable default argument acceptable?”
- The agent flags the use of mutable defaults as an anti-pattern and suggests a safer alternative, such as using None as a default.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/microsoft/python-foundational/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip python-foundational.zip -d .agents/skills
Documentation by Microsoft
Python Foundational Coding Standards Skill
Overview
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.
Core Checklist
1. Readability & Style
Use Python naming:
PascalCaseclasses,snake_casefunctions/variables,UPPER_SNAKE_CASEconstants,_private members.Group imports: stdlib → third-party → local (blank line between groups, no trailing whitespace).
2. Pythonic Idioms
Prefer comprehensions for simple transforms; use explicit loops for complex logic/side-effects.
Always use
withfor files, locks, DB connections.Prefer
dataclass/NamedTuple/Enumfor data holders.Use
pathliboveros.path; timezone-awaredatetimewhen relevant.Use
*keyword-only arguments for multi-optional functions.Never use mutable defaults or
global/nonlocalunless strictly required.
3. Function & Class Design
Keep functions small and single-responsibility.
Add docstrings to all public APIs (follow repo style).
Document unavoidable side-effects.
Follow codebase’s class-member ordering (if defined).
4. Type Safety Foundations
Add type hints to all public APIs, module vars, and class attributes.
Use PEP 695 (3.12+) or
TypeVarfor generics.Avoid
Anyexcept in thin wrappers.
5. Error Handling
Raise specific exceptions; never bare
except:(broadexcept Exception:only at app boundaries with logging).No silent failures or generic error messages.
Provide context, expected state, and guidance in every exception.
6. Anti-Patterns to Avoid
Never use
eval,exec, orpickleon untrusted data.Never hard-code secrets.
7. Maintainability
Prefer self-documenting code; comments only for "why".
Use structured logging instead of
print.Flag overly long/complex functions that resist testing.
8. Architectural Fit
Align with existing patterns; do not re-implement shared functionality or bypass established layers.
Place code in the correct module/package.
9. Design Principles
Eliminate duplication: extract repeated logic into a shared helper so fixes propagate automatically.
Prefer the simplest implementation that satisfies current requirements. Introduce abstractions only when a second concrete use case appears.
Limit change breadth: every modified line should trace to the stated purpose of the change.
Before flagging seemingly unused code, verify it is not a protocol implementation, framework hook, public API, or entry point invoked externally.
Match solution complexity to problem complexity. A duplicated function warrants a shared helper, not an event-driven architecture.
References
| 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 Rubric
| Severity | Definition |
|---|---|
| High | Causes incorrect behavior, data loss, or security exposure at runtime |
| Medium | Degrades maintainability, readability, or violates a project convention with no immediate runtime impact |
| Low | Cosmetic, stylistic, or minor improvement opportunity |
Troubleshooting
| Symptom | Check |
|---|---|
| Skill not loaded | Confirm the diff contains .py files. The agent selects skills by matching file types in the changed files against skill descriptions. |
| No findings generated | Verify the Skills Loaded footer in the review output lists python-foundational. If listed but no findings appear, the diff may already satisfy the checklist. |
| Severity seems miscalibrated | Compare against the Severity Rubric above. High requires runtime impact; medium is maintainability-only. |
Contributing
Follow these conventions when extending this skill:
Checklist items belong in SKILL.md. Each bullet is a single, actionable check an agent or reviewer can apply to a diff. Keep bullets concise: one sentence, no code.
Reference files live in
references/and provide examples or rationale for the covered checklist items. Each reference file covers a contiguous range of sections. Update the References table when adding a new file.Before adding a new checklist item, confirm it does not duplicate an existing bullet in any section. Place it in the section that matches its primary concern. If it spans concerns, prefer the more specific section.
Name new reference files after the topic they cover (e.g.,
async-patterns.md). Include a frontmatterdescriptionthat states which sections the file supports. Add a row to the References table in SKILL.md.Checklist items and examples must be portable across codebases. Use generic module names and describe anti-patterns by their behavior, not by specific directory or file names.
Files
- ATTRIBUTION.mdAdded by AutoGineer851 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md6.6 KiB
- references/code-style-patterns.md6.6 KiB
- references/design-principles.md4.0 KiB
SKILL.md
Python Foundational Coding Standards Skill
Overview
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.
Core Checklist
1. Readability & Style
Use Python naming:
PascalCaseclasses,snake_casefunctions/variables,UPPER_SNAKE_CASEconstants,_private members.Group imports: stdlib → third-party → local (blank line between groups, no trailing whitespace).
2. Pythonic Idioms
Prefer comprehensions for simple transforms; use explicit loops for complex logic/side-effects.
Always use
withfor files, locks, DB connections.Prefer
dataclass/NamedTuple/Enumfor data holders.Use
pathliboveros.path; timezone-awaredatetimewhen relevant.Use
*keyword-only arguments for multi-optional functions.Never use mutable defaults or
global/nonlocalunless strictly required.
3. Function & Class Design
Keep functions small and single-responsibility.
Add docstrings to all public APIs (follow repo style).
Document unavoidable side-effects.
Follow codebase’s class-member ordering (if defined).
4. Type Safety Foundations
Add type hints to all public APIs, module vars, and class attributes.
Use PEP 695 (3.12+) or
TypeVarfor generics.Avoid
Anyexcept in thin wrappers.
5. Error Handling
Raise specific exceptions; never bare
except:(broadexcept Exception:only at app boundaries with logging).No silent failures or generic error messages.
Provide context, expected state, and guidance in every exception.
6. Anti-Patterns to Avoid
Never use
eval,exec, orpickleon untrusted data.Never hard-code secrets.
7. Maintainability
Prefer self-documenting code; comments only for "why".
Use structured logging instead of
print.Flag overly long/complex functions that resist testing.
8. Architectural Fit
Align with existing patterns; do not re-implement shared functionality or bypass established layers.
Place code in the correct module/package.
9. Design Principles
Eliminate duplication: extract repeated logic into a shared helper so fixes propagate automatically.
Prefer the simplest implementation that satisfies current requirements. Introduce abstractions only when a second concrete use case appears.
Limit change breadth: every modified line should trace to the stated purpose of the change.
Before flagging seemingly unused code, verify it is not a protocol implementation, framework hook, public API, or entry point invoked externally.
Match solution complexity to problem complexity. A duplicated function warrants a shared helper, not an event-driven architecture.
References
| 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 Rubric
| Severity | Definition |
|---|---|
| High | Causes incorrect behavior, data loss, or security exposure at runtime |
| Medium | Degrades maintainability, readability, or violates a project convention with no immediate runtime impact |
| Low | Cosmetic, stylistic, or minor improvement opportunity |
Troubleshooting
| Symptom | Check |
|---|---|
| Skill not loaded | Confirm the diff contains .py files. The agent selects skills by matching file types in the changed files against skill descriptions. |
| No findings generated | Verify the Skills Loaded footer in the review output lists python-foundational. If listed but no findings appear, the diff may already satisfy the checklist. |
| Severity seems miscalibrated | Compare against the Severity Rubric above. High requires runtime impact; medium is maintainability-only. |
Contributing
Follow these conventions when extending this skill:
Checklist items belong in SKILL.md. Each bullet is a single, actionable check an agent or reviewer can apply to a diff. Keep bullets concise: one sentence, no code.
Reference files live in
references/and provide examples or rationale for the covered checklist items. Each reference file covers a contiguous range of sections. Update the References table when adding a new file.Before adding a new checklist item, confirm it does not duplicate an existing bullet in any section. Place it in the section that matches its primary concern. If it spans concerns, prefer the more specific section.
Name new reference files after the topic they cover (e.g.,
async-patterns.md). Include a frontmatterdescriptionthat states which sections the file supports. Add a row to the References table in SKILL.md.Checklist items and examples must be portable across codebases. Use generic module names and describe anti-patterns by their behavior, not by specific directory or file names.
Requirements and compatibility
Written for: GitHub Copilot, Claude Code
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Claude Code frontmatter, Needs Python
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/hve-core · .github/skills/coding-standards/python-foundational · commit f425e94
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download python-foundational.zip