Generated banner for Python Foundational
Generated logo for Python Foundational

Python Foundational

MicrosoftOfficialPublished by Microsoft

  • Skill
  • Guidelines
  • Software development
  • MIT
  • No issues found

From the author

Foundational Python best practices, idioms, and code quality fundamentals
— the description by Microsoft

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

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/microsoft/python-foundational/download
  2. Unzip 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: PascalCase classes, snake_case functions/variables, UPPER_SNAKE_CASE constants, _ 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 with for files, locks, DB connections.

  • Prefer dataclass / NamedTuple / Enum for data holders.

  • Use pathlib over os.path; timezone-aware datetime when relevant.

  • Use * keyword-only arguments for multi-optional functions.

  • Never use mutable defaults or global/nonlocal unless 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 TypeVar for generics.

  • Avoid Any except in thin wrappers.

5. Error Handling
  • Raise specific exceptions; never bare except: (broad except 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, or pickle on 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

FileCoversPurpose
design-principles.mdSection 9Rationale and examples for the design principles
code-style-patterns.mdSections 1–5Concrete code examples for style, idioms, type safety, class design, and error handling

Severity Rubric

SeverityDefinition
HighCauses incorrect behavior, data loss, or security exposure at runtime
MediumDegrades maintainability, readability, or violates a project convention with no immediate runtime impact
LowCosmetic, stylistic, or minor improvement opportunity

Troubleshooting

SymptomCheck
Skill not loadedConfirm the diff contains .py files. The agent selects skills by matching file types in the changed files against skill descriptions.
No findings generatedVerify 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 miscalibratedCompare 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 frontmatter description that 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.md

Attribution

This folder is an unmodified copy of the Agent Skill "python-foundational", distributed by AutoGineer (https://autogineer.com/agent-skills).

The skill's own files are unmodified copies. AutoGineer is not affiliated with or endorsed by the author or the publisher.

Files added by AutoGineer

  • ATTRIBUTION.md: this file, written by AutoGineer

  • LICENSE: copied from LICENSE

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