Agent skill
core-python-best-practices
Essential guidelines for writing modern, type-safe, and idiomatic Python 3 code.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/core-python-best-practices
Metadata
Additional technical details for this skill
- author
- AI Group
- version
- 1.0.0
- category
- Software_Engineering
SKILL.md
Core Python Best Practices
This skill defines the coding standards for Python development within the project. It emphasizes modern features, type safety, and readability.
When to Use This Skill
- New Scripts: Starting a new agent or tool.
- Refactoring: Modernizing legacy code.
- Library Design: Creating reusable modules.
Core Capabilities
- Type Hinting: Mandatory use of
typingmodule or native types (Python 3.9+). - Data Classes: Using
@dataclassorPydanticfor data containers instead of raw dictionaries/tuples. - Modern Control Flow: Using
match/case(Python 3.10) where appropriate. - Error Handling: Proper use of
try/exceptchains and custom exceptions.
Workflow
- Define Interface: Start with function signatures and type hints.
- Select Structure: Choose between a simple function, a class, or a dataclass.
- Implement: Write logic using list comprehensions and generators where possible.
- Document: Add docstrings (Google or NumPy style).
Example Usage
User: "Write a function to process a list of users."
Agent Action:
- Reads
references/rules.md. - Generates:
python
from dataclasses import dataclass @dataclass class User: id: int name: str def process_users(users: list[User]) -> None: """Processes a list of users.""" for user in users: ...
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?