omgkit 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/package.json +1 -1
- package/plugin/skills/databases/database-management/SKILL.md +288 -0
- package/plugin/skills/databases/database-migration/SKILL.md +285 -0
- package/plugin/skills/databases/database-schema-design/SKILL.md +195 -0
- package/plugin/skills/databases/mongodb/SKILL.md +60 -776
- package/plugin/skills/databases/prisma/SKILL.md +53 -744
- package/plugin/skills/databases/redis/SKILL.md +53 -860
- package/plugin/skills/databases/supabase/SKILL.md +283 -0
- package/plugin/skills/devops/aws/SKILL.md +68 -672
- package/plugin/skills/devops/github-actions/SKILL.md +54 -657
- package/plugin/skills/devops/kubernetes/SKILL.md +67 -602
- package/plugin/skills/devops/performance-profiling/SKILL.md +59 -863
- package/plugin/skills/frameworks/django/SKILL.md +87 -853
- package/plugin/skills/frameworks/express/SKILL.md +95 -1301
- package/plugin/skills/frameworks/fastapi/SKILL.md +90 -1198
- package/plugin/skills/frameworks/laravel/SKILL.md +87 -1187
- package/plugin/skills/frameworks/nestjs/SKILL.md +106 -973
- package/plugin/skills/frameworks/react/SKILL.md +94 -962
- package/plugin/skills/frameworks/vue/SKILL.md +95 -1242
- package/plugin/skills/frontend/accessibility/SKILL.md +91 -1056
- package/plugin/skills/frontend/frontend-design/SKILL.md +69 -1262
- package/plugin/skills/frontend/responsive/SKILL.md +76 -799
- package/plugin/skills/frontend/shadcn-ui/SKILL.md +73 -921
- package/plugin/skills/frontend/tailwindcss/SKILL.md +60 -788
- package/plugin/skills/frontend/threejs/SKILL.md +72 -1266
- package/plugin/skills/languages/javascript/SKILL.md +106 -849
- package/plugin/skills/methodology/brainstorming/SKILL.md +70 -576
- package/plugin/skills/methodology/defense-in-depth/SKILL.md +79 -831
- package/plugin/skills/methodology/dispatching-parallel-agents/SKILL.md +81 -654
- package/plugin/skills/methodology/executing-plans/SKILL.md +86 -529
- package/plugin/skills/methodology/finishing-development-branch/SKILL.md +95 -586
- package/plugin/skills/methodology/problem-solving/SKILL.md +67 -681
- package/plugin/skills/methodology/receiving-code-review/SKILL.md +70 -533
- package/plugin/skills/methodology/requesting-code-review/SKILL.md +70 -610
- package/plugin/skills/methodology/root-cause-tracing/SKILL.md +70 -646
- package/plugin/skills/methodology/sequential-thinking/SKILL.md +70 -478
- package/plugin/skills/methodology/systematic-debugging/SKILL.md +66 -559
- package/plugin/skills/methodology/test-driven-development/SKILL.md +91 -752
- package/plugin/skills/methodology/testing-anti-patterns/SKILL.md +78 -687
- package/plugin/skills/methodology/token-optimization/SKILL.md +72 -602
- package/plugin/skills/methodology/verification-before-completion/SKILL.md +108 -529
- package/plugin/skills/methodology/writing-plans/SKILL.md +79 -566
- package/plugin/skills/omega/omega-architecture/SKILL.md +91 -752
- package/plugin/skills/omega/omega-coding/SKILL.md +161 -552
- package/plugin/skills/omega/omega-sprint/SKILL.md +132 -777
- package/plugin/skills/omega/omega-testing/SKILL.md +157 -845
- package/plugin/skills/omega/omega-thinking/SKILL.md +165 -606
- package/plugin/skills/security/better-auth/SKILL.md +46 -1034
- package/plugin/skills/security/oauth/SKILL.md +80 -934
- package/plugin/skills/security/owasp/SKILL.md +78 -862
- package/plugin/skills/testing/playwright/SKILL.md +77 -700
- package/plugin/skills/testing/pytest/SKILL.md +73 -811
- package/plugin/skills/testing/vitest/SKILL.md +60 -920
- package/plugin/skills/tools/document-processing/SKILL.md +111 -838
- package/plugin/skills/tools/image-processing/SKILL.md +126 -659
- package/plugin/skills/tools/mcp-development/SKILL.md +85 -758
- package/plugin/skills/tools/media-processing/SKILL.md +118 -735
- package/plugin/stdrules/SKILL_STANDARDS.md +490 -0
- package/plugin/skills/SKILL_STANDARDS.md +0 -743
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: designing-database-schemas
|
|
3
|
+
description: AI agent designs production-grade database schemas with proper normalization, indexing strategies, and data modeling patterns. Use when creating new databases, designing tables, modeling relationships, or reviewing schema architecture.
|
|
4
|
+
category: databases
|
|
5
|
+
triggers:
|
|
6
|
+
- schema design
|
|
7
|
+
- database design
|
|
8
|
+
- data modeling
|
|
9
|
+
- ERD
|
|
10
|
+
- entity relationship
|
|
11
|
+
- table design
|
|
12
|
+
- normalization
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Designing Database Schemas
|
|
16
|
+
|
|
17
|
+
## Purpose
|
|
18
|
+
|
|
19
|
+
Design scalable, maintainable database schemas that balance normalization with query performance:
|
|
20
|
+
|
|
21
|
+
- Apply normalization principles (1NF-BCNF) appropriately
|
|
22
|
+
- Choose optimal data types and constraints
|
|
23
|
+
- Design efficient indexing strategies
|
|
24
|
+
- Implement common patterns (audit trails, soft deletes, multi-tenancy)
|
|
25
|
+
- Create clear entity relationships
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```sql
|
|
30
|
+
-- Well-designed table with proper constraints
|
|
31
|
+
CREATE TABLE users (
|
|
32
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
33
|
+
email VARCHAR(255) NOT NULL UNIQUE,
|
|
34
|
+
username VARCHAR(50) NOT NULL UNIQUE,
|
|
35
|
+
password_hash VARCHAR(255) NOT NULL,
|
|
36
|
+
status VARCHAR(20) NOT NULL DEFAULT 'active' CHECK (status IN ('active', 'suspended', 'deleted')),
|
|
37
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
38
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
39
|
+
deleted_at TIMESTAMPTZ -- Soft delete
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
CREATE INDEX idx_users_email ON users(email);
|
|
43
|
+
CREATE INDEX idx_users_status ON users(status) WHERE deleted_at IS NULL;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
| Feature | Description | Pattern |
|
|
49
|
+
|---------|-------------|---------|
|
|
50
|
+
| Normalization | Eliminate redundancy while maintaining query efficiency | 3NF for OLTP, denormalize for read-heavy |
|
|
51
|
+
| Primary Keys | UUID vs serial, natural vs surrogate keys | UUID for distributed, serial for simple apps |
|
|
52
|
+
| Foreign Keys | Referential integrity with cascade options | CASCADE for owned data, RESTRICT for referenced |
|
|
53
|
+
| Indexes | Query optimization with minimal write overhead | B-tree default, GIN for JSONB/arrays |
|
|
54
|
+
| Constraints | Data integrity at database level | CHECK, UNIQUE, NOT NULL, EXCLUSION |
|
|
55
|
+
| Partitioning | Horizontal scaling for large tables | Range (time), List (category), Hash (even dist) |
|
|
56
|
+
|
|
57
|
+
## Common Patterns
|
|
58
|
+
|
|
59
|
+
### Audit Trail Pattern
|
|
60
|
+
|
|
61
|
+
```sql
|
|
62
|
+
-- Add to every auditable table
|
|
63
|
+
ALTER TABLE orders ADD COLUMN
|
|
64
|
+
created_by UUID REFERENCES users(id),
|
|
65
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
66
|
+
updated_by UUID REFERENCES users(id),
|
|
67
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW();
|
|
68
|
+
|
|
69
|
+
-- Automatic updated_at trigger
|
|
70
|
+
CREATE OR REPLACE FUNCTION update_updated_at()
|
|
71
|
+
RETURNS TRIGGER AS $$
|
|
72
|
+
BEGIN
|
|
73
|
+
NEW.updated_at = NOW();
|
|
74
|
+
RETURN NEW;
|
|
75
|
+
END;
|
|
76
|
+
$$ LANGUAGE plpgsql;
|
|
77
|
+
|
|
78
|
+
CREATE TRIGGER orders_updated_at
|
|
79
|
+
BEFORE UPDATE ON orders
|
|
80
|
+
FOR EACH ROW EXECUTE FUNCTION update_updated_at();
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Multi-Tenancy (Row-Level)
|
|
84
|
+
|
|
85
|
+
```sql
|
|
86
|
+
-- Tenant isolation with RLS
|
|
87
|
+
CREATE TABLE projects (
|
|
88
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
89
|
+
tenant_id UUID NOT NULL REFERENCES tenants(id),
|
|
90
|
+
name VARCHAR(255) NOT NULL,
|
|
91
|
+
-- Always include tenant_id in indexes
|
|
92
|
+
UNIQUE (tenant_id, name)
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
CREATE INDEX idx_projects_tenant ON projects(tenant_id);
|
|
96
|
+
|
|
97
|
+
-- Row Level Security
|
|
98
|
+
ALTER TABLE projects ENABLE ROW LEVEL SECURITY;
|
|
99
|
+
CREATE POLICY tenant_isolation ON projects
|
|
100
|
+
USING (tenant_id = current_setting('app.tenant_id')::uuid);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Polymorphic Associations
|
|
104
|
+
|
|
105
|
+
```sql
|
|
106
|
+
-- Option 1: Separate junction tables (recommended)
|
|
107
|
+
CREATE TABLE comments (
|
|
108
|
+
id UUID PRIMARY KEY,
|
|
109
|
+
body TEXT NOT NULL,
|
|
110
|
+
author_id UUID REFERENCES users(id)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
CREATE TABLE post_comments (
|
|
114
|
+
comment_id UUID PRIMARY KEY REFERENCES comments(id),
|
|
115
|
+
post_id UUID NOT NULL REFERENCES posts(id)
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
CREATE TABLE task_comments (
|
|
119
|
+
comment_id UUID PRIMARY KEY REFERENCES comments(id),
|
|
120
|
+
task_id UUID NOT NULL REFERENCES tasks(id)
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
-- Option 2: JSONB for flexible relations (when schema varies)
|
|
124
|
+
CREATE TABLE activities (
|
|
125
|
+
id UUID PRIMARY KEY,
|
|
126
|
+
subject_type VARCHAR(50) NOT NULL,
|
|
127
|
+
subject_id UUID NOT NULL,
|
|
128
|
+
metadata JSONB DEFAULT '{}',
|
|
129
|
+
CHECK (subject_type IN ('post', 'task', 'comment'))
|
|
130
|
+
);
|
|
131
|
+
CREATE INDEX idx_activities_subject ON activities(subject_type, subject_id);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### JSONB for Semi-Structured Data
|
|
135
|
+
|
|
136
|
+
```sql
|
|
137
|
+
-- Good: Configuration, metadata, varying attributes
|
|
138
|
+
CREATE TABLE products (
|
|
139
|
+
id UUID PRIMARY KEY,
|
|
140
|
+
name VARCHAR(255) NOT NULL,
|
|
141
|
+
base_price DECIMAL(10,2) NOT NULL,
|
|
142
|
+
attributes JSONB DEFAULT '{}' -- Color, size, custom fields
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
CREATE INDEX idx_products_attrs ON products USING GIN (attributes);
|
|
146
|
+
|
|
147
|
+
-- Query JSONB
|
|
148
|
+
SELECT * FROM products
|
|
149
|
+
WHERE attributes @> '{"color": "red"}'
|
|
150
|
+
AND (attributes->>'size')::int > 10;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Use Cases
|
|
154
|
+
|
|
155
|
+
- Greenfield database design for new applications
|
|
156
|
+
- Schema reviews and optimization recommendations
|
|
157
|
+
- Migration from NoSQL to relational or vice versa
|
|
158
|
+
- Multi-tenant SaaS database architecture
|
|
159
|
+
- Audit and compliance requirements implementation
|
|
160
|
+
|
|
161
|
+
## Best Practices
|
|
162
|
+
|
|
163
|
+
| Do | Avoid |
|
|
164
|
+
|----|-------|
|
|
165
|
+
| Use UUID for distributed systems, serial for simple apps | Auto-incrementing IDs exposed to users (enumeration risk) |
|
|
166
|
+
| Apply 3NF for OLTP, denormalize strategically for reads | Over-normalizing lookup tables (country codes, etc.) |
|
|
167
|
+
| Create indexes matching query WHERE/ORDER BY patterns | Indexing every column (write performance penalty) |
|
|
168
|
+
| Use CHECK constraints for enum-like values | Storing booleans as strings or integers |
|
|
169
|
+
| Add NOT NULL unless truly optional | Nullable columns without clear semantics |
|
|
170
|
+
| Prefix indexes with table name: `idx_users_email` | Generic index names like `index1` |
|
|
171
|
+
| Use TIMESTAMPTZ for all timestamps | Storing timestamps without timezone |
|
|
172
|
+
| Design for the 80% use case first | Premature optimization for edge cases |
|
|
173
|
+
|
|
174
|
+
## Schema Review Checklist
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
[ ] All tables have primary keys
|
|
178
|
+
[ ] Foreign keys have appropriate ON DELETE actions
|
|
179
|
+
[ ] Indexes exist for all foreign keys
|
|
180
|
+
[ ] Indexes match common query patterns
|
|
181
|
+
[ ] No nullable columns without clear use case
|
|
182
|
+
[ ] Timestamps use TIMESTAMPTZ
|
|
183
|
+
[ ] Audit columns (created_at, updated_at) present
|
|
184
|
+
[ ] Naming follows consistent convention
|
|
185
|
+
[ ] JSONB used only for truly variable schema
|
|
186
|
+
[ ] Partitioning considered for tables > 10M rows
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Related Skills
|
|
190
|
+
|
|
191
|
+
See also these related skill documents:
|
|
192
|
+
|
|
193
|
+
- **managing-database-migrations** - Safe schema evolution patterns
|
|
194
|
+
- **optimizing-databases** - Query and index optimization
|
|
195
|
+
- **building-with-supabase** - PostgreSQL with RLS patterns
|