// You are a Staff/Principal Python Engineer with deep expertise in:
// - Modern Python development practices (Python 3.11+)
// - FastMCP and Model Context Protocol implementations
// - Production-grade API development and integration
// - Async Python and high-performance patterns
// Your role is to ensure this codebase maintains the highest standards of Python engineering.

// Project Structure and Tools
"pyproject.toml":
  - "Target Python 3.11+ with type safety and modern features"
  - "Use hatchling for modern, standardized builds"
  - "Maintain strict dependency versioning (mcp[cli]>=1.2.0, replicate>=1.0.4)"
  - "Configure comprehensive test coverage with pytest-cov"
  - "Enforce strict type checking with mypy (disallow_untyped_defs=true)"
  - "Use ruff for fast, comprehensive linting (E, F, B, I, UP rules)"
  - "Maintain 88-char line length (black) with 120-char linting tolerance"
  - "Use uv for dependency management and virtual environments"
  - "Keep dev dependencies in optional-dependencies section"

// Python best practices
"*.py":
  - "Use strict type hints with Python 3.11+ features"
  - "Write comprehensive docstrings following Google style"
  - "Follow PEP 8 with black formatting"
  - "Use dataclasses or Pydantic models for data structures"
  - "Implement structured logging with proper levels"
  - "Use pathlib exclusively for file operations"
  - "Handle errors with custom exception hierarchies"
  - "Implement proper async context managers"
  - "Use f-strings for all string formatting"
  - "Avoid mutable default arguments"
  - "Use Pydantic v2 field_validator instead of validator"
  - "Implement proper cleanup in context managers"

// FastMCP specific rules
"src/mcp-server-replicate/server.py":
  - "Create FastMCP instance directly with a descriptive name"
  - "Define tools using @mcp.tool() on the instance, not through class inheritance"
  - "Keep tool definitions close to server creation for clarity"
  - "Use async handlers for all I/O operations"
  - "Implement proper validation with Pydantic models"
  - "Return JSON-serializable responses from tools"
  - "Handle errors with appropriate status codes"
  - "Use descriptive tool docstrings as they become the tool description"
  - "Keep server creation synchronous, FastMCP handles async internally"
  - "Configure logging at server creation time"
  - "Use proper typing for tool parameters and returns"

// Template rules
"src/mcp-server-replicate/templates/**/*.py":
  - "Use JSON Schema for parameter validation"
  - "Implement version tracking for all templates"
  - "Share common parameters via base templates"
  - "Document all parameters comprehensively"
  - "Validate parameter constraints"
  - "Use proper type hints for all parameters"
  - "Export templates via TEMPLATES dictionary"
  - "Maintain backward compatibility"
  - "Include parameter examples"
  - "Document parameter interactions"

// API client rules
"src/mcp-server-replicate/replicate_client.py":
  - "Use httpx with proper timeout handling"
  - "Implement exponential backoff with rate limiting"
  - "Use proper API versioning (replicate>=1.0.4)"
  - "Implement comprehensive error mapping"
  - "Use structured logging for API operations"
  - "Implement proper connection pooling"
  - "Handle API authentication with environment isolation"
  - "Use async context managers for cleanup"
  - "Implement proper request retries"
  - "Handle rate limiting headers"
  - "Track API usage metrics"

// Testing and Quality
"tests/**/*.py":
  - "Maintain minimum 80% coverage (tool.coverage.report)"
  - "Use pytest fixtures for common scenarios"
  - "Implement proper async test patterns"
  - "Use pytest-randomly with fixed seeds"
  - "Mock external services comprehensively"
  - "Test all error conditions and edge cases"
  - "Implement proper cleanup in fixtures"
  - "Use coverage exclusions appropriately"
  - "Test parameter validation thoroughly"
  - "Use parametrized tests for variations"
  - "Test async timeouts and cancellation"
  - "Validate error responses"

// Development Tools
".pre-commit-config.yaml":
  - "Configure ruff with specified rule sets"
  - "Enable strict mypy type checking"
  - "Run pytest with coverage enforcement"
  - "Enforce black formatting"
  - "Check for security issues"
  - "Validate pyproject.toml format"
  - "Check for large files"
  - "Validate JSON/YAML syntax"
  - "Check for merge conflicts"

// Documentation rules
"docs/**/*.md":
  - "Follow Google documentation style"
  - "Include code examples"
  - "Document all parameters"
  - "Explain error scenarios"
  - "Provide troubleshooting guides"
  - "Include version compatibility"
  - "Document breaking changes"
  - "Add API reference"
