Skip to content
Back to skills

Python Best Practices

ASecurity

Python best practices across design patterns, error handling, project structure, and testing. Use when writing Python code, structuring new Python projects, designing APIs for libraries, implementing error handling, or setting up pytest test suites.

  • 69 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 5, 2026
ai-agentspythontestingapi

Works with

  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add The-AIOS/aios --skill python-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Python Best Practices?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Python Best Practices
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/the-aios-python-best-practices/badge)](https://www.skillsdirectory.com/skills/the-aios-python-best-practices)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: python-best-practices
description: Python best practices across design patterns, error handling, project structure, and testing. Use when writing Python code, structuring new Python projects, designing APIs for libraries, implementing error handling, or setting up pytest test suites.
---

# Python Best Practices

Curated reference for writing production-quality Python — opinionated where it matters, undogmatic where it doesn't.

## When to load which reference

| Working on | Read |
|---|---|
| Module layout, public APIs, package structure | [references/project-structure.md](references/project-structure.md) |
| Design patterns (KISS, SRP, composition, DI) | [references/design-patterns.md](references/design-patterns.md) |
| Validation, exception hierarchies, partial-failure handling | [references/error-handling.md](references/error-handling.md) |
| pytest, fixtures, mocking, parameterization, TDD | [references/testing-patterns.md](references/testing-patterns.md) |

Each reference is an in-depth guide — load only the one relevant to the current task.

## Core principles (all references share)

- **Explicit over implicit** — type hints, named arguments, no magic.
- **Small over abstract** — one function per concept, no premature inheritance.
- **Fail loud at boundaries, validate at the edge** — Pydantic/dataclasses at API surfaces, raw types internally.
- **Test the behavior, not the implementation** — pytest fixtures over class-based setUp, parameterize for variants.

For test-first discipline beyond Python specifics, see [superpowers/test-driven-development](../../superpowers/test-driven-development/SKILL.md).

Files in this skill

  • SKILL.md1.6 KB
  • references/design-patterns.md12.8 KB
  • references/error-handling.md10.5 KB
  • references/project-structure.md6.6 KB
  • references/testing-patterns.md25.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…