/fastmcp-engineering:data-persistence-engineeringfrom fastmcp-engineering
Evidence-first PostgreSQL and persistence engineering for production FastMCP systems.
Ships in fastmcp-engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Make persistence correct, secure, observable, performant and evolvable. PostgreSQL is the reference relational system when relational persistence is required; conclusions about transactional behavior must use the actual production-class database.
Scope / When to use: PostgreSQL and persistence engineering for production FastMCP systems. Trigger: designing or changing persistence, data ownership, transactions, isolation, migrations, queries, RLS/tenant isolation, backups, or data lifecycle. Upstream / Prerequisite: identified exact Python, SQLAlchemy, PostgreSQL, migration-tool and driver versions; evidence recorded. Mission / Goal: make persistence correct, secure, observable, performant and evolvable; conclusions about transactional behavior must use the actual production-class database. Research / Evidence: identify exact versions; read current official PostgreSQL and SQLAlchemy documentation first, then exact-version migration/driver/framework source and tests; verify transaction, isolation, locking, pooling, async and migration behavior rather than relying on memory. Decision / Selection rules: every table/entity has an explicit owner and lifecycle; define transaction boundaries at the application/use-case level; use a Unit of Work only when it clarifies atomicity; choose isolation levels and locking intentionally; enforce critical invariants in the database; version and review all migrations; verify PostgreSQL-specific behavior against PostgreSQL; prefer deterministic keyset pagination; use one application-level engine/pool; enforce tenant isolation in RLS or an equivalent DB boundary; prefer DB-enforced idempotency keys; test backups/restores. Version / Compatibility: identify exact versions of Python, SQLAlchemy, PostgreSQL, migration tool and driver; use the actual production-class database for transactional conclusions.
Deliverables / Artifacts: data ownership model; schema/invariant catalog; transaction/UoW map; isolation/locking policy; migration strategy; PostgreSQL verification matrix; query/index plan; pagination policy; pool/session lifecycle; RLS/tenant model; idempotency/outbox strategy; backup/restore plan; data lifecycle policy; test matrix; evidence ledger; rejected alternatives; verification report. Verification / Testing: use PostgreSQL for integration tests requiring transactions, RLS, locking, query plans, JSONB, extensions or PostgreSQL types; provide EXPLAIN/EXPLAIN ANALYZE evidence for critical queries; test rollback, constraint violations, concurrency, N+1, pagination and migration compatibility; a backup is not reliable until restore is tested. Failure / Stop conditions: reject ORM-only integrity assumptions, per-repository commits that break atomicity, shared async sessions, unbounded queries/pages, untested PostgreSQL-specific behavior, unsafe migrations, application-only tenant isolation where DB isolation is required, blind retries and untested backups/restores. Positive scenario: persistence is verified against real PostgreSQL and migrations and restores are tested. Negative scenario: ORM-only integrity assumptions and untested PostgreSQL-specific behavior ship silently.
Identify exact Python, SQLAlchemy, PostgreSQL, migration-tool and driver versions. Read current official PostgreSQL and SQLAlchemy documentation first, then exact-version migration/driver/framework source and tests. Verify transaction, isolation, locking, pooling, async and migration behavior rather than relying on memory.
Every table/entity has an explicit owner and lifecycle. Separate domain concepts from persistence models. Do not leak ORM/session objects across architectural boundaries. Define identity, uniqueness, nullability and referential integrity explicitly.
Define transaction boundaries at the application/use-case level. A transaction must have a clear owner. Keep transactions short and deterministic. Never hold a DB transaction across external network/LLM calls unless there is an explicit, justified design and timeout strategy.
Use a Unit of Work abstraction only when it clarifies transaction ownership across multiple repositories/operations. Repositories must not silently commit independently when the use case requires atomicity. Rollback behavior must be explicit.
Choose isolation levels based on required invariants. Analyze lost updates, write skew, phantom reads, deadlocks and serialization failures. Use optimistic/pessimistic locking intentionally. Retry only documented transient serialization/deadlock failures and only when the operation is safe to retry.
Enforce critical invariants in the database with NOT NULL, UNIQUE, CHECK, FOREIGN KEY and appropriate indexes. Application validation improves UX but must not be the only protection for invariants that concurrent writers can violate.
All schema changes are versioned, deterministic and reviewable. Migrations must be safe for the deployment strategy and dataset size. Separate expand/contract changes when zero-downtime compatibility is required. Never edit an already-applied migration silently. Test migrations on representative schemas/data.
SQLite or in-memory databases may be useful for narrow unit tests but cannot prove PostgreSQL-specific semantics. Integration tests requiring transactions, RLS, locking, query plans, JSONB, extensions or PostgreSQL types must run against PostgreSQL.
Avoid N+1 queries, accidental Cartesian products and unbounded result sets. Select only required columns where material. Use stable pagination. Critical queries require EXPLAIN/EXPLAIN ANALYZE evidence under representative data. Indexes must have a query/use case rationale and write/storage cost considered.
Prefer deterministic keyset pagination for large/changing datasets where appropriate. Offset pagination is acceptable for bounded/simple cases. Every paginated query must have a stable ordering and bounded page size. Never accept arbitrary client-controlled page sizes without limits.
One application-level engine/pool per intended process/lifetime. Size pools from measured workload and PostgreSQL capacity. Monitor pool wait time and saturation. Never create engines/sessions inside repositories or per-request without an explicit lifecycle reason.
Use SQLAlchemy async APIs correctly for the installed version. AsyncSession is a unit-of-work resource and must not be concurrently shared across independent asyncio tasks. Define commit/rollback/close ownership explicitly.
When tenant isolation is required, enforce it in PostgreSQL RLS or an equivalent database boundary in addition to application authorization. Test direct/indirect access paths, joins, background jobs and elevated roles. Never rely on a caller-supplied tenant ID as proof of authorization.
Soft deletion is not automatically superior. If used, define uniqueness, foreign-key, query-default, restoration and retention semantics. Audit/history tables need explicit event ownership, immutable fields and retention policy. Avoid accidental exposure of deleted/archived records.
Sensitive or externally-triggered writes need an idempotency strategy where duplicate delivery is possible. Prefer database-enforced uniqueness/idempotency keys over in-memory deduplication. Define behavior for concurrent duplicate requests and ambiguous outcomes.
Do not assume DB transaction rollback can undo external side effects. For DB + message/event workflows consider transactional outbox/inbox patterns. Define delivery semantics, deduplication and recovery before implementing distributed workflows.
Define backup strategy, retention, encryption/access, restore procedure, RPO and RTO. A backup is not considered reliable until restore is tested. Migration compatibility with rollback/restore procedures must be considered.
Define retention, archival, deletion and legal/security requirements. Minimize stored sensitive data. Deletion must cover indexes, caches, search projections and derived stores where applicable.
Factories/builders must create valid domain state without hidden global fixtures. Production data must never be copied into tests without approved anonymization. Integration tests must isolate state and be order-independent.
Never log credentials, tokens, sensitive bind values or full sensitive rows. Parameterize SQL. Restrict DB roles by least privilege. Separate application roles from migration/admin roles. Secrets arrive through configuration boundaries, not repositories.
Instrument query latency, pool saturation, transaction failures, deadlocks and migration health through the observability layer. Avoid high-cardinality SQL text or parameter logging.
Persistence decisions must satisfy performance and resilience policies: bounded queries/results, timeouts, retry-safe transient failure handling, backpressure and graceful degradation. Never retry arbitrary transactions containing non-idempotent side effects.
What SKILL.md sets; muted values are Claude Code's defaults
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-engineering58 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.