agentleFS
sivaprasadreddysivaprasadreddy/sivalabs-agent-skills/skills/data-access-and-migrations/SKILL.md

data-access-and-migrations

Skill198 starsChanged 4 days agoMITView on GitHub

Define safe persistence access, transaction boundaries, concurrency behavior, and database schema migration practices across technology stacks.

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 17 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈17

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep persistence behavior correct, efficient, secure, and evolvable regardless of database or application framework.

    line 9
  2. Distinctive:

    Use when implementing data access, multi-step writes, transactions, concurrent updates, background jobs, or schema changes.

    line 12
  3. Distinctive:

    Keep persistence concerns behind clear application boundaries.

    line 15
  4. Distinctive:

    Use parameterized queries or safe query APIs.

    line 16
  5. Distinctive:

    Keep transactions short; avoid network calls or long-running work while holding locks.

    line 20
  6. Distinctive:

    Do not assume a transaction spans multiple databases or remote services.

    line 23
  7. Distinctive:

    Treat caches as derived state with explicit invalidation or freshness rules.

    line 24
  8. Distinctive:

    Treat schema changes as versioned, reviewed application changes.

    line 27
  9. Distinctive:

    Never rely on an undocumented manual production database edit.

    line 28
  10. Distinctive:

    Prefer small, deterministic, forward-only migrations unless rollback is demonstrably safe.

    line 29
  11. Distinctive:

    Do not rewrite migrations that may already have been applied in shared or production environments.

    line 30
  12. Distinctive:

    Use expand-and-contract for changes that must coexist with old and new application versions.

    line 31
  13. Distinctive:

    Test migrations against realistic prior schema states and representative data.

    line 33
  14. Distinctive:

    Check compatibility with currently running and rolling-deployment versions.

    line 39
  15. Distinctive:

    Add compatible structures first (expand).

    line 40
  16. Distinctive:

    Remove obsolete structures only after compatibility is confirmed (contract).

    line 44
  17. Distinctive:

    Verify constraints, row counts, application behavior, and rollback/recovery options.

    line 45

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Data Access and Migrations

Purpose

Keep persistence behavior correct, efficient, secure, and evolvable regardless of database or application framework.

When to use

Use when implementing data access, multi-step writes, transactions, concurrent updates, background jobs, or schema changes.

Data access principles

  • Keep persistence concerns behind clear application boundaries; do not leak storage-specific details throughout the domain.
  • Use parameterized queries or safe query APIs.
  • Fetch only the data needed; avoid unbounded reads and accidental N+1 access patterns.
  • Paginate potentially large result sets and define stable ordering.
  • Make transaction boundaries explicit around business operations that require atomicity.
  • Keep transactions short; avoid network calls or long-running work while holding locks.
  • Understand isolation level, locking, optimistic concurrency, and lost-update risks.
  • Make retry behavior safe; a retried operation must not accidentally duplicate side effects.
  • Do not assume a transaction spans multiple databases or remote services.
  • Treat caches as derived state with explicit invalidation or freshness rules.

Migration principles

  1. Treat schema changes as versioned, reviewed application changes.
  2. Never rely on an undocumented manual production database edit.
  3. Prefer small, deterministic, forward-only migrations unless rollback is demonstrably safe.
  4. Do not rewrite migrations that may already have been applied in shared or production environments.
  5. Use expand-and-contract for changes that must coexist with old and new application versions.
  6. Separate large data backfills from schema changes when that improves safety and operability.
  7. Test migrations against realistic prior schema states and representative data.
  8. Define backup and recovery expectations for high-risk changes.

Safe migration workflow

  1. Inspect the current schema, migration history, data volume, and deployed application versions.
  2. Describe the intended schema and data transformation.
  3. Check compatibility with currently running and rolling-deployment versions.
  4. Add compatible structures first (expand).
  5. Deploy code that can work with both old and new structures where needed.
  6. Backfill in bounded, observable, restartable batches.
  7. Switch reads/writes to the new representation.
  8. Remove obsolete structures only after compatibility is confirmed (contract).
  9. Verify constraints, row counts, application behavior, and rollback/recovery options.

Review checklist

  • Are queries safe, bounded, and aligned with indexes?
  • Are transaction boundaries correct?
  • Can concurrent requests corrupt or overwrite state?
  • Are retries idempotent?
  • Can the migration run safely with existing data?
  • Is it compatible with rolling deployments?
  • Is the backfill restartable and observable?
  • Is recovery possible if the migration fails?

For destructive or irreversible operations, require explicit risk communication and a tested recovery plan.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.