/python-standards
Python code quality standards covering PEP 8, Black formatting, type hints, Google-style docstrings, and error handling. Use when writing or reviewing Python code. TRIGGER when: python, formatting, type hints, docstrings, PEP 8, black, isort. DO NOT TRIGGER when: non-Python
$ npx -y skills add akaszubski/autonomous-dev --skill python-standards --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/python-standards
Context preview
The summary Claude sees to decide when to auto-load this skill.
Python code quality standards covering PEP 8, Black formatting, type hints, Google-style docstrings, and error handling. Use when writing or reviewing Python code. TRIGGER when: python, formatting, type hints, docstrings, PEP 8, black, isort. DO NOT TRIGGER when: non-Python
SKILL.md
python-standards.SKILL.mdname: python-standards
description: "Python code quality standards covering PEP 8, Black formatting, type hints, Google-style docstrings, and error handling. Use when writing or reviewing Python code. TRIGGER when: python, formatting, type hints, docstrings, PEP 8, black, isort. DO NOT TRIGGER when: non-Python files, markdown, config, shell scripts."
allowed-tools: [Read]
Python Standards Skill
Python code quality standards for autonomous-dev project.
When This Activates
- Writing Python code
- Code formatting
- Type hints
- Docstrings
- Keywords: "python", "format", "type", "docstring"
---
Code Style (PEP 8 + Black)
| Setting | Value | |---------|-------| | Line length | 100 characters | | Indentation | 4 spaces (no tabs) | | Quotes | Double quotes | | Imports | Sorted with isort |
black --line-length=100 src/ tests/
isort --profile=black --line-length=100 src/ tests/
---
Type Hints (Required)
**Rule:** All public functions must have type hints on parameters and return.
def process_file(
input_path: Path,
output_path: Optional[Path] = None,
*,
max_lines: int = 1000
) -> Dict[str, any]:
"""Type hints on all parameters and return."""
pass---
Docstrings (Google Style)
**Rule:** All public functions/classes need docstrings with Args, Returns, Raises.
def process_data(data: List[Dict], *, batch_size: int = 32) -> ProcessResult:
"""Process data with validation.
Args:
data: Input data as list of dicts
batch_size: Items per batch (default: 32)
Returns:
ProcessResult with items and metrics
Raises:
ValueError: If data is empty
"""---
Error Handling
**Rule:** Error messages must include context + expected + docs link.
# ✅ GOOD
raise FileNotFoundError(
f"Config file not found: {path}\n"
f"Expected: YAML with keys: model, data\n"
f"See: docs/guides/configuration.md"
)
# ❌ BAD
raise FileNotFoundError("File not found")Exception Hierarchy
Define a project-level exception hierarchy for structured error handling:
class AppError(Exception):
"""Base exception for the application."""
pass
class ConfigError(AppError):
"""Configuration loading or validation error."""
pass
class ValidationError(AppError):
"""Input or data validation error."""
pass
class ExternalServiceError(AppError):
"""Error communicating with external service."""
pass**When to use custom vs built-in exceptions:**
- Use **built-in** (`ValueError`, `TypeError`, `FileNotFoundError`) for standard programming errors
- Use **custom** exceptions when callers need to catch specific application-level failures
- Always inherit from a project base exception for catch-all handling
Error Message Format
Every error message should follow this three-part format:
1. **Context** - What happened and where 2. **Expected** - What was expected instead 3. **Docs link** - Where to find more information
raise ValidationError(
f"Invalid config key '{key}' in {config_path}\n"
f"Expected one of: {', '.join(valid_keys)}\n"
f"See: docs/configuration.md#valid-keys"
)Graceful Degradation
When a non-critical operation fails, log and continue rather than crashing:
try:
optional_result = enhance_with_cache(data)
except CacheError:
logging.warning("Cache unavailable, proceeding without cache")
optional_result = None---
Naming Conventions
| Type | Convention | Example | |------|------------|---------| | Classes | PascalCase | `ModelTrainer` | | Functions | snake_case | `train_model()` | | Constants | UPPER_SNAKE | `MAX_LENGTH` | | Private | _underscore | `_helper()` |
---
Best Practices
1. **Keyword-only args** - Use `*` for clarity 2. **Pathlib** - Use `Path` not string paths 3. **Context managers** - Use `with` for resources 4. **Dataclasses** - For configuration objects
# Keyword-only args
def train(data: List, *, learning_rate: float = 1e-4):
pass
# Pathlib
config = Path("config.yaml").read_text()---
Code Quality Commands
flake8 src/ --max-line-length=100 # Linting
mypy src/[project_name]/ # Type checking
pytest --cov=src --cov-fail-under=80 # Coverage
---
Key Takeaways
1. **Type hints** - Required on all public functions 2. **Docstrings** - Google style, with Args/Returns/Raises 3. **Black formatting** - 100 char line length 4. **isort imports** - Sorted and organized 5. **Helpful errors** - Context + expected + docs link 6. **Pathlib** - Use Path not string paths 7. **Keyword args** - Use `*` for clarity 8. **Dataclasses** - For configuration objects
---
Related Skills
- **testing-guide** - Testing patterns and TDD methodology
- **error-handling-patterns** - Error handling best practices
---
Hard Rules
**FORBIDDEN**:
- Public functions without type hints on parameters and return values
- Bare `except:` or `except Exception:` without re-raising or specific handling
- Mutable default arguments (`def f(items=[])`)
- Using `os.path` when `pathlib.Path` is available
**REQUIRED**:
- All public APIs MUST have Google-style docstrings with Args/Returns/Raises
- All code MUST pass black formatting (100 char line length)
- Imports MUST be sorted with isort (profile=black)
- Keyword-only arguments MUST be used for functions with 2+ optional parameters
Read more
name: python-standards description: "Python code quality standards covering PEP 8, Black formatting, type hints, Google-style docstrings, and error handling. Use when writing or reviewing Python code. TRIGGER when: python, formatting, type hints, docstrings, PEP 8, black, isort. DO NOT TRIGGER when: non-Python files, markdown, config, shell scripts." allowed-tools: [Read]
Python Standards Skill
Python code quality standards for autonomous-dev project.
When This Activates
- Writing Python code
- Code formatting
- Type hints
- Docstrings
- Keywords: "python", "format", "type", "docstring"
---
Code Style (PEP 8 + Black)
| Setting | Value | |---------|-------| | Line length | 100 characters | | Indentation | 4 spaces (no tabs) | | Quotes | Double quotes | | Imports | Sorted with isort |
black --line-length=100 src/ tests/ isort --profile=black --line-length=100 src/ tests/
---
Type Hints (Required)
**Rule:** All public functions must have type hints on parameters and return.
def process_file(
input_path: Path,
output_path: Optional[Path] = None,
*,
max_lines: int = 1000
) -> Dict[str, any]:
"""Type hints on all parameters and return."""
pass---
Docstrings (Google Style)
**Rule:** All public functions/classes need docstrings with Args, Returns, Raises.
def process_data(data: List[Dict], *, batch_size: int = 32) -> ProcessResult:
"""Process data with validation.
Args:
data: Input data as list of dicts
batch_size: Items per batch (default: 32)
Returns:
ProcessResult with items and metrics
Raises:
ValueError: If data is empty
"""---
Error Handling
**Rule:** Error messages must include context + expected + docs link.
# ✅ GOOD
raise FileNotFoundError(
f"Config file not found: {path}\n"
f"Expected: YAML with keys: model, data\n"
f"See: docs/guides/configuration.md"
)
# ❌ BAD
raise FileNotFoundError("File not found")Exception Hierarchy
Define a project-level exception hierarchy for structured error handling:
class AppError(Exception):
"""Base exception for the application."""
pass
class ConfigError(AppError):
"""Configuration loading or validation error."""
pass
class ValidationError(AppError):
"""Input or data validation error."""
pass
class ExternalServiceError(AppError):
"""Error communicating with external service."""
pass**When to use custom vs built-in exceptions:**
- Use **built-in** (`ValueError`, `TypeError`, `FileNotFoundError`) for standard programming errors
- Use **custom** exceptions when callers need to catch specific application-level failures
- Always inherit from a project base exception for catch-all handling
Error Message Format
Every error message should follow this three-part format:
1. **Context** - What happened and where 2. **Expected** - What was expected instead 3. **Docs link** - Where to find more information
raise ValidationError(
f"Invalid config key '{key}' in {config_path}\n"
f"Expected one of: {', '.join(valid_keys)}\n"
f"See: docs/configuration.md#valid-keys"
)Graceful Degradation
When a non-critical operation fails, log and continue rather than crashing:
try:
optional_result = enhance_with_cache(data)
except CacheError:
logging.warning("Cache unavailable, proceeding without cache")
optional_result = None---
Naming Conventions
| Type | Convention | Example | |------|------------|---------| | Classes | PascalCase | `ModelTrainer` | | Functions | snake_case | `train_model()` | | Constants | UPPER_SNAKE | `MAX_LENGTH` | | Private | _underscore | `_helper()` |
---
Best Practices
1. **Keyword-only args** - Use `*` for clarity 2. **Pathlib** - Use `Path` not string paths 3. **Context managers** - Use `with` for resources 4. **Dataclasses** - For configuration objects
# Keyword-only args
def train(data: List, *, learning_rate: float = 1e-4):
pass
# Pathlib
config = Path("config.yaml").read_text()---
Code Quality Commands
flake8 src/ --max-line-length=100 # Linting mypy src/[project_name]/ # Type checking pytest --cov=src --cov-fail-under=80 # Coverage
---
Key Takeaways
1. **Type hints** - Required on all public functions 2. **Docstrings** - Google style, with Args/Returns/Raises 3. **Black formatting** - 100 char line length 4. **isort imports** - Sorted and organized 5. **Helpful errors** - Context + expected + docs link 6. **Pathlib** - Use Path not string paths 7. **Keyword args** - Use `*` for clarity 8. **Dataclasses** - For configuration objects
---
Related Skills
- **testing-guide** - Testing patterns and TDD methodology
- **error-handling-patterns** - Error handling best practices
---
Hard Rules
**FORBIDDEN**:
- Public functions without type hints on parameters and return values
- Bare `except:` or `except Exception:` without re-raising or specific handling
- Mutable default arguments (`def f(items=[])`)
- Using `os.path` when `pathlib.Path` is available
**REQUIRED**:
- All public APIs MUST have Google-style docstrings with Args/Returns/Raises
- All code MUST pass black formatting (100 char line length)
- Imports MUST be sorted with isort (profile=black)
- Keyword-only arguments MUST be used for functions with 2+ optional parameters
A harness that wraps Claude Code with enforcement, specialist agents, and alignment gates to deliver consistent, production-grade software engineering outcomes.
Repo: akaszubski/autonomous-dev
Other skills on autonomous-dev.
- /api-design
REST API design best practices covering versioning, error handling, pagination, and OpenAPI documentation. Use when designing or implementing REST APIs or HTTP endpoints. TRIGGER when: API design, REST endpoint, HTTP route, OpenAPI, swagger, pagination. DO NOT TRIGGER when:
Open skill - /api-integration-patterns
Subprocess safety, GitHub CLI integration, retry logic, authentication, rate limiting, and timeout handling. Use when integrating external APIs or CLI tools. TRIGGER when: subprocess, gh cli, API call, retry logic, rate limiting, authentication. DO NOT TRIGGER when: internal
Open skill - /architecture-patterns
File-by-file architecture planning with ADR format, dependency ordering, and testability gates. Use when designing system architecture or creating ADRs. TRIGGER when: architecture plan, system design, ADR, file breakdown, component design. DO NOT TRIGGER when: simple config
Open skill - /code-review
10-point code review checklist covering correctness, tests, error handling, type hints, naming, security, and performance. Use when reviewing PRs or evaluating code quality. TRIGGER when: code review, PR review, review checklist, code quality check. DO NOT TRIGGER when: writing
Open skill - /content-allocation
One topic, one home. Routes content to its canonical store (CLAUDE.md, PROJECT.md, MEMORY.md, docs/, memory/) and audits for duplication. TRIGGER when: auditing CLAUDE.md/PROJECT.md/MEMORY.md sizes, deduplicating docs, applying the content-allocation pattern to a new repo,
Open skill - /debugging-workflow
Systematic debugging methodology — reproduce, isolate, bisect, fix, verify. Use when diagnosing failures, tracing errors, or investigating unexpected behavior. TRIGGER when: debug, error, traceback, stack trace, bisect, breakpoint, failing test, unexpected behavior. DO NOT
Open skill

