krishujeniya/aegis/architecture-database-design
- community
Checking that the SKILL.md file is still in the repository.
Master of PostgreSQL schema design, optimization, and safe migrations. Enforces strict conventions for IDs, indexes, JSONB, and transactional DDL. Use whenever modifying the data layer.
Install
npx vskill@latest install krishujeniya/aegis/architecture-database-designSKILL.md
Architecture: Database Design
Purpose
This skill establishes strict architectural and optimization guidelines for the PostgreSQL database. It complements the database-asyncpg-qdrant skill by enforcing robust schema design, proper indexing, safe migrations, and efficient data access patterns.
When to Use
- Gate 3 (PLAN): When designing table schemas or planning data migrations.
- Gate 4 (IMPLEMENT): When writing complex SQL queries, creating indexes, or adding JSONB columns.
Core Database Doctrine (Non-Negotiable)
1. Schema Design Conventions
- Identifiers: Use
snake_casestrictly for tables and columns (unquoted). - Primary Keys: For reference tables (users, orders), prefer
BIGINT GENERATED ALWAYS AS IDENTITY. UseUUIDv7ONLY when global uniqueness or opacity is strictly required. Noserial. - Foreign Keys: PostgreSQL does NOT auto-index FK columns. You MUST add them manually.
- Nullability: Add
NOT NULLeverywhere it’s semantically required. - Timestamps: ONLY use
TIMESTAMPTZ. Never useTIMESTAMPwithout timezone.
2. Indexing Strategy
Create indexes for access paths you actually query:
- B-tree: Default for equality/range queries (
=,<,>,ORDER BY). - Partial Indexes: Excellent for hot subsets (
WHERE status = 'active'). - Expression Indexes: Useful for case-insensitive searches (
LOWER(email)). - GIN Indexes: Mandatory for JSONB containment (
@>), existence (?), and Arrays.
3. JSONB Best Practices
- Prefer
JSONBoverJSON. Focus on optional/variable attributes, keep core relations in regular columns. - Keep JSONB indexed with GIN:
CREATE INDEX ON tbl USING GIN (jsonb_col). - Use generated columns for frequently accessed JSONB scalar fields:
price INT GENERATED ALWAYS AS ((jsonb_col->>'price')::INT) STORED
4. Safe Schema Evolution (Migrations)
- Always write reversible migrations (
upanddown). - Most operations can and should be wrapped in
BEGIN; ... COMMIT;. - Avoid adding
NOT NULLcolumns with volatile defaults (it rewrites the entire table). - For large tables, avoid table locks: Use
CREATE INDEX CONCURRENTLY.
Operator Checklist (PRE-ACT)
- [ ] Is
snake_casestrictly used? - [ ] Are Foreign Keys manually indexed?
- [ ] Is
TIMESTAMPTZused instead ofTIMESTAMP? - [ ] Are JSONB columns supported by a GIN index?
- [ ] Is the migration safely reversible?
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinglibrary/experts/skills/architecture-database-design/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 8
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/krishujeniya/aegis/architecture-database-design)