agentleFS
leaf76leaf76/agent-skills/database-data-guardrails/SKILL.md

database-data-guardrails

Skill0 starsChanged 3 months agoMITView on GitHub

Use when database, SQL, ORM, query builder, migration, transaction, cache, index, EXPLAIN, backfill, data repair, data integrity, or shared data access work is in scope.

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 10 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Prefer the existing ORM, query builder, or repository pattern.

    line 12
  2. Very specific:

    Never put user input directly into SQL identifiers, table names, column names, ORDER BY, LIMIT, or OFFSET.

    line 14
  3. Distinctive:

    Do not use silent fallback to hide DB, model, query, or transaction failures.

    line 17
  4. Distinctive:

    Avoid magic SQL, hidden side effects, and multi-purpose data helpers.

    line 18
  5. Distinctive:

    Keep transactions to the smallest set of operations that must succeed or fail together.

    line 22
  6. Distinctive:

    Do not include long-running work, external API calls, or unnecessary reads inside transactions.

    line 23
  7. Distinctive:

    Avoid N+1 queries, full table scans, and unconstrained bulk writes.

    line 25
  8. Distinctive:

    Prefer backward-compatible expand/contract migrations: support compatible reads/writes first, then remove old paths later.

    line 30
  9. Distinctive:

    Do not rewrite queries, add cache, or add indexes based only on intuition.

    line 33
  10. Distinctive:

    Do not use cache to hide slow queries, data-model issues, or DB errors.

    line 39
  11. Very specific:

    Use KV only for read-heavy data where eventual consistency is acceptable.

    line 41
  12. Very specific:

    Use Durable Objects when stateful coordination, atomic updates, centralized invalidation, or Redis-like primitives are needed.

    line 42
  13. Distinctive:

    Use managed Redis / Valkey when broad Redis / Valkey compatibility is required.

    line 43

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Database Data Guardrails

This is a domain-specific expansion of the project's AGENTS.md (or equivalent agent rules). It may add database and data requirements, but it must never weaken AGENTS.md, SECURITY, parameterized SQL, input validation, production safety, or destructive-command restrictions.

Data Access

  • Prefer the existing ORM, query builder, or repository pattern. Use raw SQL only when the existing pattern is insufficient.
  • SQL must be parameterized; never concatenate strings to build SQL.
  • Never put user input directly into SQL identifiers, table names, column names, ORDER BY, LIMIT, or OFFSET.
  • Dynamic identifiers, sort keys, pagination values, and filter fields must use allowlists or mappings.
  • Query and transaction failures must be handled explicitly and retain traceable context.
  • Do not use silent fallback to hide DB, model, query, or transaction failures.
  • Avoid magic SQL, hidden side effects, and multi-purpose data helpers. Complex queries should be split into named steps or helpers.

Transactions And Integrity

  • Keep transactions to the smallest set of operations that must succeed or fail together.
  • Do not include long-running work, external API calls, or unnecessary reads inside transactions.
  • For balances, inventory, state transitions, or shared resources, use transactions, locking, unique constraints, or idempotency to prevent race conditions.
  • Avoid N+1 queries, full table scans, and unconstrained bulk writes.
  • Large reads/writes should use batches, pagination, or chunking.

Migrations, Backfills, And Indexes

  • Prefer backward-compatible expand/contract migrations: support compatible reads/writes first, then remove old paths later.
  • For DROP, broad DELETE/UPDATE, backfill, index rebuild, or high-lock-risk work, state blast radius, rollback/restore path, and verification.
  • Database optimization must be based on measurements such as query latency, row scan, index usage, lock wait, EXPLAIN, or query plan.
  • Do not rewrite queries, add cache, or add indexes based only on intuition.
  • Index design must follow real WHERE, JOIN, ORDER BY, and frequent query patterns. Call out write, storage, and read trade-offs.

Cache Policy

  • Cache must define eligible data, cache key, TTL, invalidation strategy, and consistency requirements.
  • Do not use cache to hide slow queries, data-model issues, or DB errors.
  • Cloudflare HTTP/page cache should prefer Cloudflare cache, fetch cache controls, or Cache API.
  • Use KV only for read-heavy data where eventual consistency is acceptable.
  • Use Durable Objects when stateful coordination, atomic updates, centralized invalidation, or Redis-like primitives are needed.
  • Use managed Redis / Valkey when broad Redis / Valkey compatibility is required.
  • For permissions, personalized content, balances, inventory, or high-consistency data, state stale-data protection against cache poisoning, cache stampede, and cross-user leakage.

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.