database-driver-design

Installation
SKILL.md

Database Driver Design

This skill provides expert guidance on building production-quality database client libraries in Swift, covering wire protocol implementation, connection management, type-safe APIs, and integration with Swift Concurrency. Patterns are derived from exemplary implementations: valkey-swift and postgres-nio.

Agent Behavior Contract (Follow These Rules)

  1. Prefer parameterized queries - Never concatenate user input into SQL/command strings
  2. Use string interpolation for safety - Implement ExpressibleByStringInterpolation to convert values to bindings
  3. Design commands as types - Each command/query should be a struct with associated response type
  4. Implement state machines for protocols - Complex connection lifecycles need explicit state transitions
  5. Support backpressure - Row/result streaming must respect consumer demand
  6. Align actor executors - Use unownedExecutor to align with NIO event loops
  7. Pool connections properly - Implement keep-alive, idle timeout, and graceful shutdown

Core Patterns

Command as Type Pattern

Define commands as types with associated response types for compile-time safety:

Related skills

More from joannis/claude-skills

Installs
30
GitHub Stars
57
First Seen
Feb 3, 2026