Not loaded · from fastmcp-engineering
Evidence-first database engineering for production Python systems using SQLAlchemy 2.x and PostgreSQL, with explicit transaction ownership, async session discipline, schema/migration design, concurrency, RLS, performance and integration testing.
Claude Code won't load this skill
It ships in fastmcp-engineering at skills/, but Claude Code only loads skills/<name>/SKILL.md and folders listed under skills in plugin.json. Installing the plugin doesn't add it.
Treat the database as a correctness boundary, not merely persistence plumbing. Design schemas, transactions, queries, concurrency and authorization so correctness is enforced as close to the data as practical without leaking database concerns into domain logic.
Scope / When to use: database engineering for production Python systems using SQLAlchemy 2.x and PostgreSQL, with explicit transaction ownership, async session discipline, schema/migration design, concurrency, RLS, performance and integration testing. Trigger: designing or changing schemas, transactions, sessions, queries, concurrency, RLS/tenancy, migrations, or PostgreSQL-specific behavior. Upstream / Prerequisite: repository architecture, security, resilience, testing and configuration contracts read; identified exact versions; evidence, assumptions and unresolved questions recorded. Mission / Goal: treat the database as a correctness boundary; enforce correctness as close to the data as practical without leaking database concerns into domain logic. Research / Evidence: read current official SQLAlchemy documentation for Engine, pooling, Session/AsyncSession, transactions, ORM/Core querying, relationships, loading, concurrency and async behavior; read current PostgreSQL documentation for MVCC, isolation, locks/deadlocks, constraints, indexes, RLS, transactions and query planning; read migration-tool documentation and repository migration conventions; inspect official examples/source/tests; do not rely on remembered SQLAlchemy 1.x patterns. Decision / Selection rules: keep domain entities independent of SQLAlchemy unless persistence-aware domain modeling is chosen with evidence; use session-per-logical-operation/task and never share AsyncSession across concurrent tasks; prefer explicit transaction framing; introduce repositories/Unit of Work only when they protect a real boundary; use database constraints for invariants; use row locks/advisory locks/serializable transactions only for demonstrated concurrency requirements; design indexes from real access patterns; use PostgreSQL RLS as defense-in-depth when tenant isolation is required. Version / Compatibility: identify exact Python, SQLAlchemy, PostgreSQL, async driver and migration-tool versions; current SQLAlchemy 2.x semantics must be verified from official sources.
Deliverables / Artifacts: schema/domain mapping, repository/port decision, transaction map, session lifecycle, concurrency/locking model, migration plan, index/query plan, pooling budget, RLS/tenant policy where applicable, error taxonomy, integration test matrix, implementation and verification report. Verification / Testing: use real PostgreSQL integration tests for transaction, constraint, locking, isolation, RLS, migration and query-plan behavior that mocks cannot prove; use unit tests for pure mapping/query construction/business orchestration; test concurrent scenarios explicitly where correctness depends on them. Failure / Stop conditions: reject if sessions are shared across concurrent tasks, repositories commit unexpectedly, transactions span remote LLM/MCP calls without justification, integrity depends only on Python validation, migrations ignore operational locking, tenant boundaries exist only in prompts, N+1/lazy I/O is unexamined, pool capacity is unbounded, or database behavior is claimed based solely on mocks. Positive scenario: correctness is enforced at the database boundary and verified against real PostgreSQL including concurrency and RLS. Negative scenario: sessions are shared across concurrent tasks and integrity depends only on Python validation.
Before implementation:
Do not rely on remembered SQLAlchemy 1.x patterns. Current SQLAlchemy 2.x semantics must be verified from official sources.
Application Use Case
│
▼
Database Port / Repository Contract
│
▼
SQLAlchemy Adapter
┌────┴────┐
│ │
AsyncSession SQLAlchemy Core/ORM
│ │
└────┬────┘
▼
PostgreSQL
Domain entities must not inherit from SQLAlchemy or depend on session/query infrastructure unless the architecture explicitly chooses persistence-aware domain modeling with evidence. Keep mapping and database-specific errors at the infrastructure boundary.
A Session/AsyncSession represents mutable transactional state. It is not a general cache and must not be shared concurrently. Use session-per-logical-operation/task and make transaction boundaries explicit. Keep transactions short and never hold them open while waiting on LLM, MCP or unrelated network work unless explicitly justified. SQLAlchemy's current guidance states AsyncSession is not safe to share across concurrent asyncio tasks and recommends AsyncSession per task.
Prefer explicit transaction framing such as async with session.begin() where appropriate. Understand autobegin, commit/rollback, expiration and nested/SAVEPOINT semantics before choosing a pattern.
Do not create generic repositories or Unit of Work abstractions automatically. Introduce a port when it protects application/domain independence, enables a meaningful alternative adapter, or materially improves testing. A repository should express domain/application intent, not duplicate SQLAlchemy's API.
Transaction ownership belongs to the application/use-case boundary or an explicitly documented infrastructure transaction manager. Repositories should not independently commit unless their contract explicitly makes them transaction owners.
Prefer SQLAlchemy 2.x select(), insert(), update(), delete() and explicit execution APIs. Avoid legacy Query patterns. Choose ORM vs Core based on the access pattern, not ideology. Use typed mapped models and explicit relationships/configuration.
Be deliberate about loading strategy. Prevent accidental lazy I/O in async code. Detect and eliminate N+1 queries. Use selectinload, joinedload, explicit joins or projections according to cardinality and query shape; verify with SQL/query-count tests.
Do not expose ORM entities outside boundaries merely because mapping is convenient. Map to application/domain DTOs where this prevents persistence lifecycle leakage or accidental lazy loads.
Use database constraints for invariants that must hold regardless of application path: primary/foreign keys, unique constraints, check constraints and appropriate NOT NULL constraints. Application validation is complementary, not a replacement for database integrity.
Understand PostgreSQL MVCC and the selected isolation level. Use row-level locks (SELECT... FOR UPDATE variants), advisory locks or serializable transactions only for demonstrated concurrency requirements. Design lock ordering to minimize deadlocks. Handle documented serialization/deadlock failures with bounded, idempotent retry at the appropriate application boundary.
Indexes are workload-specific. Design them from real access predicates, ordering, joins and selectivity. Use EXPLAIN/EXPLAIN ANALYZE in controlled environments. Avoid speculative indexes and redundant indexes. For large production tables, evaluate PostgreSQL CREATE INDEX CONCURRENTLY where operationally appropriate; it has different locking/transaction requirements and must be researched before migration use.
Avoid SELECT * when a projection is sufficient. Paginate deterministically. For large datasets choose keyset pagination where offset pagination becomes unsuitable.
Configure pool size, overflow, timeouts and recycling based on actual deployment concurrency and PostgreSQL capacity. Never multiply pool sizes blindly across workers/processes. Instrument pool exhaustion and checkout latency. Each AsyncSession/task must release its connection promptly.
Schema changes are versioned artifacts. Follow repository migration conventions. Separate backward-compatible expand/contract changes when zero-downtime deployment requires them. Consider lock duration, table rewrites, index build strategy and rollback feasibility. Never modify production schema manually when the repository migration system is authoritative.
When tenant isolation is a requirement, evaluate PostgreSQL RLS as a defense-in-depth data boundary. RLS is default-deny once enabled without applicable policies, but table owners and privileged roles have important exceptions that must be understood.
Application authorization and RLS solve different layers; neither should be assumed to replace the other. Define tenant context propagation and prevent connection/session state leakage between requests.
Never share an AsyncSession across concurrent tasks. If concurrent DB operations are genuinely needed, use independent sessions/transactions and understand the loss of transactional atomicity. SQLAlchemy's own concurrency example warns that gathering ORM statements across multiple sessions adds overhead and can lose transactional safety.
Avoid implicit blocking I/O in async paths. Use the documented async driver and SQLAlchemy async APIs.
Translate infrastructure exceptions at the application boundary. Distinguish integrity violations, not-found conditions, serialization/deadlock failures, connectivity failures, timeouts and programming errors. Do not catch Exception and convert everything to a generic database error.
Use real PostgreSQL integration tests for transaction, constraint, locking, isolation, RLS, migration and query-plan behavior that mocks cannot prove. Use unit tests for pure mapping/query construction/business orchestration. Test concurrent scenarios explicitly where correctness depends on them.
For tests requiring externally managed transactions, use SQLAlchemy's documented transaction-joining patterns and verify driver/database SAVEPOINT behavior rather than assuming SQLite is equivalent to PostgreSQL.
What SKILL.md sets; muted values are Claude Code's defaults
58 skills in this plugin
/pydantic-ai-agent-integrationEngineer PydanticAI agents behind explicit application boundaries and integrate them with FastMCP without leaking agent state, prompts, model concerns, or provider details into domain logic./api-contract-schema-engineeringEvidence-first API and MCP contract engineering with Pydantic v2 and JSON Schema./api-lifecycle-versioningEvidence-first API lifecycle, schema evolution and compatibility engineering for FastMCP/MCP servers.Other plugins' skills for the same job
Generated from the plugin's indexed repository (evgenygurin/fastmcp-engineering) — no native marketplace selected
npx claudepluginhub p/evgenygurin-fastmcp-engineering