database-design
Skill1 starsChanged 31 days agoMITView on GitHub
Design SQL schemas, indexes, migrations and data retention for PostgreSQL and SQLite; evaluate integrity, compatibility and query behavior.
58 other projects use a version of this.
Adopted by
Most recently taken up by
- chaunsin/agent-skillstheir own version, first seen Nov 8, 2026
- kinhluan/skillstheir own version, first seen Nov 8, 2026
- ishandutta2007/Awesome-Claude-Skillstheir own version, first seen Nov 8, 2026
- mahdy-gribkov/arcanatheir own version, first seen Nov 8, 2026
- KbWen/agentic-ostheir own version, first seen Nov 7, 2026
- its-ash/skillstheir own version, first seen Nov 1, 2026
Used with
Projects with it also use intelligent-routing, bash-linux and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SKB3002Skillintelligent-routing
Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.
Also in 6 projects that use this
xenitV1Skillbash-linux
Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.
Also in 7 projects that use this
xenitV1Skillred-team-tactics
Red team tactics principles based on MITRE ATT&CK. Attack phases, detection evasion, reporting.
Also in 7 projects that use this
pepebot-spaceSkillllm-application-dev
Building applications with Large Language Models - prompt engineering, RAG patterns, and LLM integration. Use for AI-powered features, chatbots, or LLM-based automation.
Also in 4 projects that use this
- +8 more from xenitV1
Other versions58 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 58
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- CloudAI-X/claude-workflow★ 1.4ksame name
- CloudAI-X/claude-workflow-v2★ 1.4ksame name
- MoizIbnYousaf/Ai-Agent-Skills★ 1.1ksame name
- skillcreatorai/Ai-Agent-Skills★ 1.1ksame name
- MoizIbnYousaf/ai-agent-skills★ 1.1ksame name
- KbWen/agentic-os★ 229same name
- kid-sid/claude-spellbook★ 190same name
- xenitV1/Antigravity-Workflows★ 130same name
48 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository42 other files it gives its agents.
- ansible-hardeningSkill
- cavetechSkill
- ci-cdSkill
- claude-to-cursorSkill
- code-consistencySkill
- code-qualitySkill
- config-auditorSkill
- container-sandboxSkill
- cpa-tax-specialistSkill
- definition-of-doneSkill
- differential-reviewSkill
- exact-head-reviewSkill
- fast-ciSkill
- grill-meSkill
- inbound-syncSkill
- infosec-architectSkill
- insecure-defaultsSkill
- lonely-sysadminSkill
- mcp-createSkill
- mcp-hardeningSkill
- model-evaluationSkill
- modern-pythonSkill
- ms-office-suiteSkill
- mutation-checkSkill
- plan-to-execution-handoffSkill
- prd-to-planSkill
- property-based-testingSkill
- pr-truth-triageSkill
- repo-hardening-workflowSkill
- resume-writerSkill
- skill-updaterSkill
- software-developerSkill
- software-development-lifecycleSkill
- solutions-architectSkill
- stay-readySkill
- supply-chain-risk-auditorSkill
- systematic-debuggingSkill
- tddSkill
- token-miserSkill
- triage-issueSkill
- verification-before-completionSkill
- write-a-prdSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 8 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 55 edited versions we read keep these.
8
Distinctive
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
- Distinctive: line 29
Rule: If multi-tenant or handling financial/PII data → PostgreSQL.
- Distinctive: line 55
1NF: No repeating groups, no arrays in columns (use junction tables)
- Distinctive: line 56
2NF: Every non-key column depends on the full primary key
- Distinctive: line 57
3NF: No transitive dependencies (column A → column B → column C)
- Distinctive: line 58
Denormalize intentionally: only for proven performance needs, document why
- Distinctive: line 122
Create new table with desired schema
- Distinctive: line 132
When reviewing an existing schema:
- Distinctive: line 157
tdd: Write schema tests first (can I insert valid data?
“Common” is measured: kept by at least 6 in 10 of the 55 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Database Design & Schema Management
When to Use
- Designing a new database schema or adding tables
- Reviewing an existing schema for correctness, performance, or security
- Planning migrations (especially for production data)
- Designing indexes for query patterns
- Defining retention/deletion policies for sensitive data
- Evaluating SQLite vs PostgreSQL for a given use case
SQLite vs PostgreSQL Decision
| Factor | SQLite | PostgreSQL |
| Single-user/process | Yes | Overkill |
| Multi-tenant | No | Yes |
| Multi-process writes | No (WAL helps reads) | Yes |
| Sensitive data needing RBAC | No | Yes (row-level security) |
| Schema migrations needed | Manual/limited | Alembic, full ALTER support |
| Production deployment | Embedded only | Always appropriate |
| Full-text search | FTS5 (basic) | tsvector/tsquery (rich) |
| JSON queries | json_extract (basic) | jsonb (rich, indexed) |
Rule: If multi-tenant or handling financial/PII data → PostgreSQL. No exceptions.
Schema Design Checklist
1. Table Design
□ Every table has a clear, singular purpose
□ Primary key defined (prefer INTEGER AUTOINCREMENT or UUID, not natural keys)
□ Foreign keys declared with ON DELETE behavior (CASCADE, SET NULL, RESTRICT)
□ NOT NULL on every column that should never be empty
□ DEFAULT values for columns with sensible defaults
□ No VARCHAR without length limit on user-facing input
□ Created_at and updated_at timestamps on every mutable table
□ No redundant data that can be derived from joins2. Naming Conventions
□ Tables: plural snake_case (users, audit_events, context_chunks)
□ Columns: singular snake_case (user_id, created_at, token_count)
□ Foreign keys: {referenced_table_singular}_id (user_id, blob_hash)
□ Indexes: idx_{table}_{columns} (idx_users_email, idx_chunks_hash_index)
□ Constraints: {type}_{table}_{columns} (uq_aliases_alias_namespace, fk_chunks_hash)3. Normalization
- 1NF: No repeating groups, no arrays in columns (use junction tables)
- 2NF: Every non-key column depends on the full primary key
- 3NF: No transitive dependencies (column A → column B → column C)
- Denormalize intentionally only for proven performance needs, document why
4. Index Strategy
□ Primary keys are automatically indexed
□ Foreign keys need explicit indexes (PostgreSQL does NOT auto-index FK columns)
□ Add indexes for WHERE, JOIN, ORDER BY columns in hot queries
□ Composite indexes: leftmost column must be the most selective
□ Covering indexes for read-heavy queries (include all SELECT columns)
□ Partial indexes for queries that filter on a constant (WHERE status = 'active')
□ Do NOT index columns with low cardinality (boolean, enum with 3 values)
□ Do NOT index columns that are rarely queried5. Multi-Tenant Isolation
□ Tenant ID column on every tenant-scoped table
□ Every query includes WHERE tenant_id = ? (no exceptions)
□ Composite unique constraints include tenant_id: UNIQUE(alias, tenant_id)
□ Row-level security (PostgreSQL) or application-level enforcement
□ Test: Tenant A cannot read Tenant B's data (explicit cross-tenant test)
□ Indexes include tenant_id as prefix for tenant-scoped queries6. Sensitive Data
□ PII columns identified and documented
□ Encryption-at-rest for SSN, EIN, account numbers (application-level Fernet or PG pgcrypto)
□ No PII in indexes (encrypted columns cannot be indexed — use blind index pattern)
□ Retention policy defined: how long, auto-delete mechanism, audit trail for deletions
□ Audit log table: who accessed what, when, from where (append-only, no DELETE permission)
□ Backup encryption for database dumps containing PIIMigration Strategy
Alembic (Python/SQLAlchemy)
# Initialize
alembic init alembic
# Create migration from model changes
alembic revision --autogenerate -m "add user_roles table"
# Apply
alembic upgrade head
# Rollback
alembic downgrade -1Migration Safety Rules
□ Never DROP COLUMN in production without a deprecation period
□ Add columns as NULLABLE first, backfill, then add NOT NULL constraint
□ Rename via: add new column → copy data → drop old column (not ALTER RENAME)
□ Large data migrations: batch in chunks (1000-10000 rows) to avoid lock contention
□ Always test migration AND rollback on a copy of production data
□ Migrations must be idempotent (safe to run twice)
□ No data-dependent migrations in the same transaction as schema changesSQLite Migrations (No Alembic)
SQLite has limited ALTER TABLE support. For schema changes:
- Create new table with desired schema
- Copy data from old table
- Drop old table
- Rename new table to old name
- Recreate indexes and triggers
Wrap in a transaction. Test on a copy first.
Schema Review Protocol
When reviewing an existing schema:
- Read the migration files or CREATE TABLE statements
- Map entity relationships — draw the FK graph mentally
- Check for missing indexes on FK columns and WHERE clause columns
- Check for missing constraints — can invalid data be inserted?
- Check tenant isolation — is tenant_id on every tenant-scoped table? In every query?
- Check for PII — is sensitive data identified and protected?
- Check for orphans — can rows exist without their parent? (missing ON DELETE CASCADE)
- Check for N+1 patterns — are related entities fetched in loops instead of JOINs?
- Output: findings table with severity (Critical/High/Medium/Low) and recommended fix
Anti-Patterns
| Anti-Pattern | Why It's Bad | Fix |
| EAV (Entity-Attribute-Value) | Unqueryable, no type safety | Proper columns or JSONB |
| Soft deletes everywhere | Accumulates garbage, complicates queries | Hard delete + audit log |
| UUID primary keys on large tables | 4x storage, worse cache locality | BIGINT + UUID as alternate key |
| Storing JSON blobs for structured data | No referential integrity | Normalize into tables |
| Missing ON DELETE behavior | Orphaned rows | Explicit CASCADE/RESTRICT |
| Composite primary keys on 3+ columns | Awkward FK references, join complexity | Surrogate key + unique constraint |
Integration
- tdd: Write schema tests first (can I insert valid data? rejected invalid data?)
- repo-hardening-workflow: Schema review is part of the data governance phase
- code-quality: N+1 queries and missing indexes are performance findings
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
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.

