aiskillstore/marketplace/python-style-guide
Claude Code and agent skill by aiskillstore/marketplace
- community
- ext:[{"type":"context","description":"Custom context provider definitions"}]
Checking that the SKILL.md file is still in the repository.
Author "aiskillstore" has blocked skill(s)
Comprehensive Python programming guidelines based on Google's Python Style Guide. Use when Claude needs to write Python code, review Python code for style issues, refactor Python code, or provide Python programming guidance. Covers language rules (imports, exceptions, type annotations), style rules (naming conventions, formatting, docstrings), and best practices for clean, maintainable Python code.
Install
npx vskill@latest install aiskillstore/marketplace/python-style-guideSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as aiskillstore/marketplace/python-style-guide.
Python Style Guide
Comprehensive guidelines for writing clean, maintainable Python code based on Google's Python Style Guide.
Core Philosophy
BE CONSISTENT. Match the style of the code around you. Use these guidelines as defaults, but always prioritize consistency with existing code.
Language Rules
Imports
Use import statements for packages and modules only, not for individual classes or functions.
Yes:
No:
Import Formatting
- Group imports: standard library, third-party, application-specific
- Alphabetize within each group
- Use absolute imports (not relative imports)
- One import per line (except for multiple items from
typingorcollections.abc)
Exceptions
Use exceptions appropriately. Do not suppress errors with bare except: clauses.
Yes:
No:
Type Annotations
Annotate all function signatures. Type annotations improve code readability and catch errors early.
General rules:
- Annotate all public APIs
- Use built-in types (
list,dict,set) instead oftyping.List, etc. (Python 3.9+) - Import typing symbols directly:
from typing import Any, Union - Use
Noneinstead oftype(None)orNoneType
Default Argument Values
Never use mutable objects as default values in function definitions.
Yes:
No:
True/False Evaluations
Use implicit false where possible. Empty sequences, None, and 0 are false in boolean contexts.
Yes:
No:
Comprehensions & Generators
Use comprehensions and generators for simple cases. Keep them readable.
Yes:
No:
Lambda Functions
Use lambdas for one-liners only. For anything complex, define a proper function.
Yes:
Acceptable but prefer named function:
Style Rules
Line Length
Maximum line length: 80 characters. Exceptions allowed for imports, URLs, and long strings that can't be broken.
Indentation
Use 4 spaces per indentation level. Never use tabs.
For hanging indents, align wrapped elements vertically or use 4-space hanging indent:
Blank Lines
- Two blank lines between top-level definitions
- One blank line between method definitions
- Use blank lines sparingly within functions to show logical sections
Naming Conventions
| Type | Convention | Examples | |
|---|---|---|---|
| Packages/Modules | lower_with_under | my_module.py | |
| Classes | CapWords | MyClass | |
| Functions/Methods | lower_with_under() | my_function() | |
| Constants | CAPS_WITH_UNDER | MAX_SIZE | |
| Variables | lower_with_under | my_var | |
| Private | _leading_underscore | _private_var |
Avoid:
- Single character names except for counters/iterators (
i,j,k) - Dashes in any name
__double_leading_and_trailing_underscore__(reserved for Python)
Comments and Docstrings
Docstring Format
Use Google-style docstrings for all public modules, functions, classes, and methods.
Function docstring:
Class docstring:
Block and Inline Comments
- Use complete sentences with proper capitalization
- Block comments indent to the same level as the code
- Inline comments should be separated by at least 2 spaces
- Use inline comments sparingly
Strings
Use f-strings for formatting (Python 3.6+).
Yes:
Acceptable:
No:
Logging
Use % formatting for logging, not f-strings (allows lazy evaluation):
Files and Resources
Always use context managers (with statements) for file operations:
Statements
Generally avoid multiple statements on one line.
Yes:
No:
Main
For executable scripts, use:
Function Length
Keep functions focused and reasonably sized. If a function exceeds about 40 lines, consider splitting it unless it remains very readable.
Type Annotation Details
Forward Declarations
Use string quotes for forward references:
Type Aliases
Create aliases for complex types:
TypeVars
Use descriptive names for TypeVars:
Generics
Always specify type parameters for generic types:
Yes:
No:
Imports for Typing
Import typing symbols directly:
Common Patterns
Properties
Use properties for simple attribute access:
Conditional Expressions
Use ternary operators for simple conditions:
Context Managers
Create custom context managers when appropriate:
Linting
Run pylint on all Python code. Suppress warnings only when necessary with clear explanations:
Summary
When writing Python code:
- Use type annotations for all functions
- Follow naming conventions consistently
- Write clear docstrings for all public APIs
- Keep functions focused and reasonably sized
- Use comprehensions for simple cases
- Prefer implicit false in boolean contexts
- Use f-strings for formatting
- Always use context managers for resources
- Run pylint and fix issues
- BE CONSISTENT with existing code
Additional Resources
For detailed reference on specific topics, see:
- references/advanced_types.md - Advanced type annotation patterns including Protocol, TypedDict, Literal, ParamSpec, and more
- references/antipatterns.md - Common Python mistakes and their fixes
- references/docstring_examples.md - Comprehensive docstring examples for all Python constructs
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/codingkaiser/python-style-guide/SKILL.md
Popularity
- Repository stars
- 429
- Repository forks
- 45
- 7-day trend score
- 30
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
contextCustom context provider definitions
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/aiskillstore/marketplace/python-style-guide)