# Teaching Claude Code Quality Patterns with a Custom Skill


Dagster's [dignified-python-313 skill](https://github.com/dagster-io/erk/tree/d0e3c177edc5f5013d149794f5cbee459c7b9ccd/.claude/skills/dignified-python-313) guides Claude Code to write Python 3.13 code that matches their project conventions.

## What It Covers

Modern Python 3.13 Patterns: Use native type syntax (`list[str]`, `str | None`) instead of older alternatives. Skip `from __future__ import annotations` since Python 3.13 doesn't need it.

CLI Development: Build Click interfaces with proper error handling. Use `click.echo()` for output, direct errors to stderr, and treat CLI commands as error boundaries that catch exceptions and exit with `SystemExit(1)`.

Subprocess Safety: Always use `check=True` with `subprocess.run()` to catch failures. Capture both stdout and stderr. Set timeouts to prevent hangs.

## Project-Specific Guidance

AI assistants understand Python but lack context for project conventions. This skill provides machine-readable instructions for consistent code generation.

The approach works alongside broader resources like the handbook's [Modern Python Project Setup Guide for AI Assistants](https://pydevtools.com/handbook/explanation/modern-python-project-setup-guide-for-ai-assistants.md).

## Example Patterns

For subprocess calls:

```python
# Always use check=True
result = subprocess.run(
    ["command", "arg"],
    check=True,
    capture_output=True,
    text=True
)
```

For CLI error handling:

```python
# Catch exceptions at command boundary
@click.command()
def main():
    try:
        # domain logic here
    except DomainError as e:
        click.echo(f"Error: {e}", err=True)
        raise SystemExit(1)
```


## Learn More

- [dignified-python-313 skill repository](https://github.com/dagster-io/erk/tree/d0e3c177edc5f5013d149794f5cbee459c7b9ccd/.claude/skills/dignified-python-313)
- [Modern Python Project Setup Guide for AI Assistants](https://pydevtools.com/handbook/explanation/modern-python-project-setup-guide-for-ai-assistants.md)
- [Claude Code Hooks for uv](https://pydevtools.com/blog/claude-code-hooks-for-uv.md)
