From ai_dev
Applies Python formatting standards, linting rules, and code quality best practices aligned with flake8, ruff, and pylint. Covers indentation, imports, naming, type hints, error handling, logging, and security.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ai_dev:format_pythonThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- Use exactly 4 spaces for indentation (never tabs)
snake_case for variables/functions, PascalCase for classes, UPPER_CASE for constantsValueError, FileNotFoundError_ for intentionally unused values to prevent F841 errorsdict[str, Any] instead of Dict[str, Any], str | None instead of Optional[str]typing module when possibleis/is not for None comparisons, use in/not in for membership testinglist, dict, str, id, typewith statements) for all file operations and resource cleanuplogger = logging.getLogger(__name__) for module-level logging@classmethod, @staticmethod) for class methodsis None instead of == None to prevent E711 comparison errorisinstance() for type comparisons instead of type() checkspath.open() instead of open(path) when working with Path objectslogger.exception() in except blocks for better error trackingraise ... from e to preserve stack tracesenumerate() instead of manual index trackingcollections.defaultdict and collections.Counter for common patternsfunctools.lru_cache for expensive pure functionscollections.namedtuple for immutable data structures__str__ and __repr__ methods for custom classes__slots__ for memory-efficient classes with many instancestyping.Protocol for structural subtypingtyping.Literal for fixed value setseval() or exec() with user inputsecrets module for cryptographic operations"""Module docstring."""
import logging
from typing import Any
# Constants
DEFAULT_TIMEOUT = 30
logger = logging.getLogger(__name__)
class ExampleClass:
"""Example class demonstrating proper patterns."""
def __init__(self, name: str, value: int | None = None) -> None:
"""Initialize with name and optional value."""
self.name = name
self.value = value
def process_data(self, data: list[dict[str, Any]]) -> bool:
"""Process data and return success status."""
if not data:
return False
for item in data:
if not isinstance(item, dict):
return False
return True
def get_info(self) -> dict[str, Any]:
"""Get class information."""
return {
"name": self.name,
"value": self.value,
"has_value": self.value is not None,
}
def main() -> None:
"""Execute main function."""
example = ExampleClass("test")
result = example.process_data([{"id": 1, "name": "item"}])
logger.info("Result: %s", result)
if __name__ == "__main__":
main()
Provides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub theafh/ai-modules --plugin ai_dev