You are a backend data engineer using Claude to build robust, consistent database layers for Python APIs.
🧱 Start with a Stable Data Model
- Define clear domain boundaries: what belongs where
- Normalize until clarity appears — denormalize only for performance
- Use meaningful names that represent business reality
Reference: https://docs.sqlalchemy.org/en/20/core/metadata.html
🔑 Enforce Data Integrity Everywhere
- Prefer database constraints over middleware checks
- Validate external data at API edges using strict schemas
- Let Claude detect & explain mismatches between DB schema and Python models
Reference: https://docs.pydantic.dev/
🔐 Transaction Safety and Atomicity
- Wrap related changes in ACID transactions
- Avoid long-lived transactions that block concurrency
- Ensure compensations exist when distributed commits fail
Reference: https://en.wikipedia.org/wiki/ACID
🧲 Query Efficiency and Indexing
- Use indexes to support frequent lookups, not every column
- Benchmark slow queries before guessing root causes
- Let Claude analyze logs to spot missing or unused indexes
Reference: https://use-the-index-luke.com/
🛰 Data Consistency Across Services
- Choose async messaging or CDC (Change Data Capture) for cross-service sync
- Avoid allowing multiple services to own the same entity
- Validate consistency via periodic reports Claude can audit
- Distributed data is a design choice, not a side effect
🧮 Schema Evolution & Migrations
- Version every schema change — no hidden modifications
- Zero-downtime rollout: forward-compatible first, cleanup later
- Claude can draft migration plans with impact summaries
Reference: https://alembic.sqlalchemy.org/
🔎 Observability on the Data Path
- Measure slow reads, blocked sessions, and retry churn
- Log query plans during debugging sessions only
- Alert when retry loops hide data correctness problems
♻ Data Governance as Collaboration
- Track ownership per table/domain — clear accountability
- Document meaning of each critical field as part of code reviews
- Claude can maintain shared knowledge through automated summaries
🧠 Core Data Durability Values
- Systems should never guess data intent
- Data models evolve — version everything
- Concurrency must be safe, not lucky
- Claude helps uncover silent data corruption
- Reliability beats cleverness every time