Python Guidelines

VerifiedSafe

Enforces Python coding conventions: imports at the top of the file, underscores for large numbers, minimal __init__.py content, mandatory keyword arguments for functions with more than one parameter, and required parameters without unnecessary defaults. Helps improve readability and consistency in Python codebases.

Sby Skills Guide Bot
DevelopmentIntermediate
1106/2/2026
Claude CodeCursorWindsurfCopilotCodex
#python#coding-style#best-practices#imports#formatting

Recommended for

Our review

This skill provides guidelines for writing clean and consistent Python code, focusing on imports, formatting, and function parameter definitions.

Strengths

  • Encourages imports at the top of the file
  • Uses underscores for large numbers
  • Enforces keyword-only arguments for multi-parameter functions
  • Discourages cluttering __init__.py

Limitations

  • Does not cover naming conventions (PEP8)
  • Can be overly restrictive for some projects
  • Does not address type annotations
When to use it

Use this skill when creating or modifying Python code and want to adhere to a strict, clear style convention.

When not to use it

Avoid this skill if you are working on a project with its own style guide or if flexibility is preferred.

Security analysis

Safe
Quality score85/100

This skill contains only Python style and code organization guidelines. There are no executable commands, destructive operations, or any instructions that could pose a security risk.

No concerns found

Examples

Create a new Python module
Create a new Python file called utils.py. Ensure imports are at the top, use keyword-only arguments for any functions with more than one parameter, and do not add anything to __init__.py.
Refactor existing Python code
Refactor the following Python code to follow best practices: move all imports to the top, enforce keyword arguments in functions with multiple parameters, and use underscores for large numbers where applicable.
Add a function with parameters
Add a function `calculate_tax(*, income: float, rate: float) -> float` that computes tax. Make sure all parameters are keyword-only and required.

name: python description: Guidelines when creating, reading, updating, or deleting Python code

Python Guidelines

Instructions

imports

Imports should ALWAYS be at the top of the file. NEVER have local imports unless it is 100% necessary.

formatting

For big numbers, use _ to make numbers more clear BAD: foo = 1000 GOOD: foo = 1_000

init.py files

Do not add anything inside of __init__.py files unless it is absolutely necessary or you are explicitly asked to. This includes adding __all__; NEVER add that.

function parameters

Functions with more than 1 parameter should ALWAYS use * to enforce keyword arguments. BAD: def foo(a, b, c): ... GOOD: def foo(*, a, b, c): ... Functions should always use required parameters unless making a parameter optional is absolutely necessary. Functions should not set defaults for parameters unless it is an EXTREMELY sane default.

Related skills