# Capability fragment for the `python-dev` bundle. Fires for the `python` tag.

env:
  # No __pycache__ clutter in working trees the agent edits.
  PYTHONDONTWRITEBYTECODE: "1"
  # copy (not hardlink) so uv installs don't break across filesystem boundaries.
  UV_LINK_MODE: "copy"

hooks:
  # Auto-ruff on every Python edit, scoped to the enclosing git repo so
  # rules and excludes from that repo's pyproject.toml apply.
  - event: PostToolUse
    matcher: "^(Edit|Write|MultiEdit)$"
    handler:
      type: command
      command: |
        if git rev-parse --git-dir >/dev/null 2>&1; then
          cd "$(git rev-parse --show-toplevel)" && ruff check --fix --quiet
        else
          ruff check --fix --quiet
        fi
