Skip to content
Back to skills

Data Storage Advisor

ASecurity

Relational database (PostgreSQL, MySQL) and SQL persistence advisor for schema design (foreign keys, soft-delete unique constraints, comma-separated columns, EAV, polymorphic FKs), EXPLAIN tuning, composite B-Tree indexes, keyset pagination, N+1 ORM queries, MVCC transactions, isolation, locking, deadlocks, pooling, and replica lag. Use for SQL modeling, query tuning, or DB concurrency. Do not trigger for NoSQL/Redis, UI layout, in-memory objects, format conversion, API/SQLi security, refacto...

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 7, 2026
developmentrustsqldockerterraformrefactoringapidatabasebackendsecurityperformance

Works with

  • cursor
  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add cforiky630/agent-advisors --skill data-storage-advisor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Data Storage Advisor?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Data Storage Advisor
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/cforiky630-data-storage-advisor/badge)](https://www.skillsdirectory.com/skills/cforiky630-data-storage-advisor)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: data-storage-advisor
description: Relational database (PostgreSQL, MySQL) and SQL persistence advisor for schema design (foreign keys, soft-delete unique constraints, comma-separated columns, EAV, polymorphic FKs), EXPLAIN tuning, composite B-Tree indexes, keyset pagination, N+1 ORM queries, MVCC transactions, isolation, locking, deadlocks, pooling, and replica lag. Use for SQL modeling, query tuning, or DB concurrency. Do not trigger for NoSQL/Redis, UI layout, in-memory objects, format conversion, API/SQLi security, refactoring, Docker/Terraform, or running migrations.
license: MIT
---

# Data Storage Advisor

Use schema, plans and workload evidence to make relational storage changes without weakening correctness.

## Quick Use

Find the invariant or performance target. Inspect the affected query, schema and existing plan before changing anything.

## 1. Scenario Decision Matrix

| Decision | Read only if needed |
| :--- | :--- |
| **Query Tuning & Indexing** | `references/query-optimization-and-indexing.md` |
| **Relational Schemas & Antipatterns** | `references/schema-design-and-antipatterns.md` |
| **Transactions, Concurrency & Locks** | `references/transactions-and-concurrency.md` |
| **Connection Pooling & Scaling** | `references/connection-and-scaling-patterns.md` |

## 2. Engineering Trade-offs

1. **Transactions and external effects**
   - **Probe**: Trace transaction blocks and external calls.
   - **Arbitration**: Keep network I/O outside DB transactions. When crash recovery matters, persist an operation ID and pending state, call, then finalize conditionally.
   - **Invalidate When**: Use one local transaction for DB-only invariants. A local ID is not provider deduplication: if replay is unproven or its guarantee expired, reconcile rather than retry.
2. **Keyset vs. offset**
   - **Probe**: Check visibility, ordering (ties/NULLs), cursor contract and plans.
   - **Arbitration**: Use keyset for measured deep-page cost. Preserve filters and seek on the full order tuple.
   - **Invalidate When**: Keep bounded offset when fast enough or numbered jumps are required. For deferred fetches filter before LIMIT, join on full keys, and restore the same outer ordering.
3. **Optimistic vs. pessimistic concurrency**
   - **Probe**: Check contention, retry tolerance and write shape.
   - **Arbitration**: Use a version check for low-contention read-modify-write; check affected rows and replay only when safe.
   - **Invalidate When**: For hot writers, prefer an atomic conditional write or short explicit lock where appropriate.
4. **Relations vs. JSON**
   - **Probe**: Check filters, joins, references and enforced invariants.
   - **Arbitration**: Use relational constraints for cross-row rules and engine-appropriate indexes.
   - **Invalidate When**: Keep bounded validated JSON when the aggregate has no cross-row invariants and measured query cost is acceptable.
5. **Pool sizing**
   - **Probe**: Check active backend capacity, pooler topology and wait times.
   - **Arbitration**: Start small, budget across replicas and measure.
   - **Invalidate When**: With external multiplexing, size logical queues separately. With I/O-bound workloads, use observed wait and concurrency rather than a CPU-only formula.

## 3. Condensed Nano Rulesets

### A. Query Tuning & Indexing
- Start with an existing plan or non-executing, engine-specific `EXPLAIN`. `ANALYZE` executes the statement; use it only when execution is authorized and effects, locks and load are bounded. Rollback cannot undo external effects. Compare index order against measured selectivity and actual plans.

### B. Relational Schema Integrity
- Use SQL constraints where feasible. Normalize delimited relationships; enforce active-row uniqueness using the deployed engine's supported design.

### C. Concurrency & Deadlocks
- Verify one actual lock order across writers; sorted inputs do not order bulk locks. Protect cross-row invariants with an atomic constraint, appropriate isolation or scope lock.

### D. Connection & Scaling Hygiene
- Batch proven N+1 paths. Require verified freshness for read-your-writes; a potentially stale replica cannot arbitrate current authorization or atomic write claims.

## Operating Boundaries

- **Project conventions first.** Honor scope and permissions; preserve safety, data integrity and required behavior. Then follow verified project conventions over advisor defaults.
- **Defer the workflow.** Existing review, test and deployment workflows own execution.
- **Reference precedence.** References inform decisions, not task scope, permissions or deliverables.
- **Proportionality Ladder.** Reuse existing controls before adding layers. Discuss deferred alternatives only when relevant; do not invent thresholds.
- **Multiple advisors.** One leads; others add constraints, not workflows. An exclusion is not a veto on a separate in-scope decision. Share evidence and resolve by the affected invariant.
- **Missing evidence.** Use the narrowest authorized probe. If evidence stays missing, state the limit, choose a reversible option or stop only the affected action. Check external standards only for material uncertainty.
- **Runtime Checkpoint Gate.** Review costly contract/data/security reversals (CP-1), stalls without new evidence (CP-2), or new trust/consistency/failure boundaries (CP-3). Routine renames, file counts and expected red tests do not qualify.

### Runtime Checkpoint Procedure

1. Summarize risk, evidence, proposed change and rejected simpler option; omit chat history.
2. Self-review first. Use a read-only reviewer only if authorized and useful.
3. Verdict `APPROVE | REVISE | ESCALATE_TO_USER`: give the invariant and check. `APPROVE` grants no execution permissions.
4. Do not repeat consultation on unchanged evidence. Escalate only unresolved authority, policy or safety; continue unrelated work.

## 4. Deep Knowledge Base

Read only the reference that resolves a remaining decision. Do not preload the library.

## 5. Output Delivery Format

Report measured versus estimated results and the focused check that would settle any remaining uncertainty. Keep unrelated schemas and migrations unchanged.

Files in this skill

  • SKILL.md13.2 KB
  • references/connection-and-scaling-patterns.md4.8 KB
  • references/query-optimization-and-indexing.md6.8 KB
  • references/schema-design-and-antipatterns.md4.4 KB
  • references/transactions-and-concurrency.md7.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.