python-best-practices

Enforce PEP 8, type hints, and NumPy-style docstrings in Python files.

41|3|Updated Nov 11, 2025
One-click install
npx skills add https://github.com/jefflester/claude-skills-supercharged --skill python-best-practices
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-best-practices
Source: https://github.com/jefflester/claude-skills-supercharged/tree/main/.claude/skills/python-best-practices
Command: npx skills add https://github.com/jefflester/claude-skills-supercharged --skill python-best-practices

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pydantic, pytest, numpy.

What problem does it solve?

This Skill eliminates the common pitfalls of inconsistent, hard-to-maintain Python code, which often leads to bugs, technical debt, and wasted development time. It ensures your Python projects adhere to high standards, making them more reliable and easier to collaborate on.

Core Features & Use Cases

  • PEP 8 Compliance: Guides you through Python's official style guide for consistent, readable code.
  • Type Hinting & Docstrings: Enforces modern type hints and NumPy-style docstrings for improved clarity and error detection.
  • Robust Error Handling: Promotes specific exception types and context managers for resilient applications.
  • Use Case: When refactoring an existing Python module, this skill ensures your changes adhere to modern best practices, making the code cleaner, more robust, and easier for others to understand.

Quick Start

Help me refactor this Python function to follow PEP 8, use type hints, and add a NumPy-style docstring.

Frequently Asked Questions about python-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor Python code to follow PEP 8 standards?

PEP 8 refactoring applies consistent formatting rules—indentation, naming conventions, line length, and spacing—to make Python code readable and maintainable. Start by identifying style violations in your source files, then systematically apply PEP 8 conventions to variable names, function definitions, imports, and whitespace.

What's the best way to add type hints and docstrings to existing Python functions?

Type hints document parameter and return types using Python's typing syntax; NumPy-style docstrings describe function purpose, parameters, returns, and examples in a structured format. Adding both improves code clarity, enables static type checking, and helps other developers understand function behavior without reading implementation details.

When should I use type hints and docstrings in Python projects?

Type hints and docstrings are essential when collaborating on projects, maintaining legacy code, or preventing runtime errors. They're particularly valuable before refactoring, deploying to production, or onboarding new team members, as they catch type mismatches early and serve as live documentation.

How do I organize imports and structure error handling in Python?

Import organization follows PEP 8 conventions: standard library imports first, third-party packages second, local modules last, with each group sorted alphabetically. Robust error handling uses specific exception types and context managers instead of bare except clauses, ensuring your code fails predictably and recovers gracefully.

Can I use type hints with pytest and NumPy in the same project?

Yes. Type hints work alongside pytest test cases and NumPy-style docstrings without conflict. pytest validates function behavior; type hints document expected input and output types; NumPy docstrings describe parameters and returns in detail. Together they create a testable, well-documented codebase.

What's the difference between code quality standards and refactoring?

Code quality standards define how code should be written—PEP 8 style, type hints, docstrings, error handling patterns. Refactoring is the process of applying those standards to existing code without changing its external behavior, reducing technical debt and improving maintainability.