Skip to content
Back to skills

Python Best Practices

ASecurity

Write maintainable Python with small functions, explicit boundaries, guard clauses, and readable state flow. Use when refactoring Python services, helpers, modules, or async logic for clarity—not generic test writing, tooling setup, or database transaction implementation.

  • 549 stars
  • 0 votes
  • 0 copies
  • 7 views
  • Added September 5, 2026
developmentpythongodebuggingrefactoringdatabase

Works with

  • terminal

Security analysis

A100/100

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

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --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/hoangnguyen0403-python-best-practices-0665d12d/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-python-best-practices-0665d12d)

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: Write maintainable Python with small functions, explicit boundaries, guard clauses, and readable state flow. Use when refactoring Python services, helpers, modules, or async logic for clarity—not generic test writing, tooling setup, or database transaction implementation.
metadata:
  triggers:
    files:
      - "**/*.py"
    keywords:
      - refactor
      - clean code
      - readability
      - guard clause
      - composition
---

# Python Best Practices

## **Priority: P1 (HIGH)**

## Rules

- Prefer small focused functions over long stateful procedures.
- Push parsing, formatting, transport, and persistence into separate helpers.
- Return early on invalid or terminal states.
- Pass collaborators in; do not hide them behind globals or import-time singletons.
- Keep naming literal and domain-specific.

## Recipe

1. **Split orchestration from transformation**.
2. **Extract repeated shape cleanup** into one helper.
3. **Keep side effects at edges** and pure decisions in the middle.
4. **Use fakes in tests** instead of patching deep internal chains when possible.

## Anti-Patterns

- **No god functions**: break report builders and workflow loops into tested slices.
- **No boolean soup**: name decision helpers instead of stacking flags inline.
- **No hidden retries**: surface retry policy near the call site.
- **No print-debugging in shared runtime code**: use structured logging or test assertions.

## References

- [Framework Map](../references/framework-map.md)

Files in this skill

  • SKILL.md1.5 KB
  • evals/evals.json1.4 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…