python-dev
БесплатноБез исполняемых скриптовНе проверенPython development guidance with code quality standards, error handling, testing practices, and environment management. Use when writing, reviewing, or…
Об этом скилле
Python Development Rules
Overview
Python development guidance focused on code quality, error handling, testing, and environment management. Apply when working with Python code or Jupyter notebooks.
When to Use This Skill
Use this skill when:
- Writing new Python code or modifying existing Python files
- Creating or updating Jupyter notebooks
- Setting up Python development environments
- Writing or updating tests
- Reviewing Python code for quality and best practices
Code Quality
Principles
- DRY (Don't Repeat Yourself): Avoid code duplication
- Composition over inheritance: Prefer composition patterns
- Pure functions when possible: Functions without side effects
- Simple solutions over clever ones: Prioritize readability and maintainability
- Design for common use cases first: Solve the primary problem before edge cases
Style & Documentation
- Type hints required: All functions must include type annotations
- snake_case naming: Use snake_case for variables, functions, and modules
- Google-style docstrings: Document functions, classes, and modules using Google-style docstrings
- Keep functions small: Single responsibility principle - one function, one purpose
- Preserve existing comments: Maintain and update existing code comments
Example
def calculate_total(items: list[dict[str, float]], tax_rate: float = 0.08) -> float:
"""Calculate total cost including tax.
Args:
items: List of items with 'price' key
tax_rate: Tax rate as decimal (default 0.08)
Returns:
Total cost including tax
Raises:
ValueError: If tax_rate is negative or items list is empty
"""
if not items:
raise ValueError("Items list cannot be empty")
if tax_rate < 0:
raise ValueError("Tax rate cannot be negative")
subtotal = sum(item['price'] for item in items)
return subtotal * (1 + tax_rate)
Error Handling & Efficiency
Error Handling
- Specific exception types: Catch specific exceptions, not bare
except - Validate inputs early: Check inputs at function entry
- No bare except: Always specify exception types
Efficiency Patterns
- f-strings: Use f-strings for string formatting
- Comprehensions: Prefer list/dict/set comprehensions over loops when appropriate
- Context managers: Use
withstatements for resource management
Example
def process_file(file_path: str) -> list[str]:
"""Process file and return lines.
Args:
file_path: Path to file
Returns:
List of non-empty lines
Raises:
FileNotFoundError: If file doesn't exist
PermissionError: If file cannot be read
"""
if not file_path:
raise ValueError("File path cannot be empty")
try:
with open(file_path, 'r', encoding='utf-8') as f:
return [line.strip() for line in f if line.strip()]
except FileNotFoundError:
raise FileNotFoundError(f"File not found: {file_path}")
except PermissionError:
raise PermissionError(f"Permission denied: {file_path}")
Testing (Critical)
Framework & Structure
- pytest only: Use pytest exclusively (no unittest)
- Test location: All tests in
./tests/directory - Test package: Include
__init__.pyin tests directory - TDD approach: Write/update tests for all new/modified code
- All tests must pass: Ensure all tests pass before task completion
Test Structure Example
project/
├── src/
│ └── my_module.py
└── tests/
├── __init__.py
└── test_my_module.py
Example Test
# tests/test_calculations.py
import pytest
from src.calculations import calculate_total
def test_calculate_total_basic():
"""Test basic total calculation."""
items = [{'price': 10.0}, {'price': 20.0}]
result = calculate_total(items, tax_rate=0.1)
assert result == 33.0
def test_calculate_total_empty_list():
"""Test error handling for empty list."""
with pytest.raises(ValueError, match="Items list cannot be empty"):
calculate_total([])
def test_calculate_total_negative_tax():
"""Test error handling for negative tax rate."""
items = [{'price': 10.0}]
with pytest.raises(ValueError, match="Tax rate cannot be negative"):
calculate_total(items, tax_rate=-0.1)
Environment Management
Dependency Management
- Use uv exclusively: All packaging, environment, and script execution via uv
- No pip/venv/conda: Do not use
pip,python3 -m venv, orconda—uvhandles all of this - pyproject.toml is the source of truth: Define all dependencies in
pyproject.toml(notrequirements.txt)
Environment Setup Example
# Install dependencies from pyproject.toml
uv sync
# Install with optional dev dependencies
uv sync --extra dev
# Run a script (no acti
Установить python-dev в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл python-dev?
Python development guidance with code quality standards, error handling, testing practices, and environment management. Use when writing, reviewing, or modifying Python code (.py files) or Jupyter notebooks (.ipynb files).
Как установить скилл python-dev?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл python-dev запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic