@neyugn/agent-kits 0.1.0

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.
Files changed (158) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +514 -0
  3. package/README.vi.md +410 -0
  4. package/README.zh.md +410 -0
  5. package/dist/cli.d.ts +1 -0
  6. package/dist/cli.js +422 -0
  7. package/kits/coder/ARCHITECTURE.md +289 -0
  8. package/kits/coder/agents/ai-engineer.md +344 -0
  9. package/kits/coder/agents/backend-specialist.md +270 -0
  10. package/kits/coder/agents/cloud-architect.md +363 -0
  11. package/kits/coder/agents/code-reviewer.md +284 -0
  12. package/kits/coder/agents/data-engineer.md +401 -0
  13. package/kits/coder/agents/database-specialist.md +251 -0
  14. package/kits/coder/agents/debugger.md +209 -0
  15. package/kits/coder/agents/devops-engineer.md +281 -0
  16. package/kits/coder/agents/documentation-writer.md +296 -0
  17. package/kits/coder/agents/frontend-specialist.md +298 -0
  18. package/kits/coder/agents/i18n-specialist.md +348 -0
  19. package/kits/coder/agents/integration-specialist.md +314 -0
  20. package/kits/coder/agents/mobile-developer.md +271 -0
  21. package/kits/coder/agents/multi-tenant-architect.md +281 -0
  22. package/kits/coder/agents/orchestrator.md +263 -0
  23. package/kits/coder/agents/performance-analyst.md +327 -0
  24. package/kits/coder/agents/project-planner.md +277 -0
  25. package/kits/coder/agents/queue-specialist.md +282 -0
  26. package/kits/coder/agents/realtime-specialist.md +267 -0
  27. package/kits/coder/agents/security-auditor.md +253 -0
  28. package/kits/coder/agents/test-engineer.md +315 -0
  29. package/kits/coder/agents/ux-researcher.md +388 -0
  30. package/kits/coder/rules/.cursorrules +287 -0
  31. package/kits/coder/rules/CLAUDE.md +287 -0
  32. package/kits/coder/rules/CODEX.md +287 -0
  33. package/kits/coder/rules/GEMINI.md +287 -0
  34. package/kits/coder/scripts/checklist.py +318 -0
  35. package/kits/coder/scripts/kit_status.py +292 -0
  36. package/kits/coder/scripts/skills_manager.py +243 -0
  37. package/kits/coder/scripts/verify_all.py +391 -0
  38. package/kits/coder/skills/accessibility-patterns/SKILL.md +372 -0
  39. package/kits/coder/skills/accessibility-patterns/scripts/a11y_checker.py +211 -0
  40. package/kits/coder/skills/ai-rag-patterns/SKILL.md +444 -0
  41. package/kits/coder/skills/api-patterns/SKILL.md +316 -0
  42. package/kits/coder/skills/api-patterns/assets/.gitkeep +1 -0
  43. package/kits/coder/skills/api-patterns/references/deep-dive.md +21 -0
  44. package/kits/coder/skills/api-patterns/scripts/api_validator.py +253 -0
  45. package/kits/coder/skills/api-patterns/scripts/validate.py +56 -0
  46. package/kits/coder/skills/auth-patterns/SKILL.md +267 -0
  47. package/kits/coder/skills/aws-patterns/SKILL.md +576 -0
  48. package/kits/coder/skills/brainstorming/SKILL.md +370 -0
  49. package/kits/coder/skills/brainstorming/assets/.gitkeep +1 -0
  50. package/kits/coder/skills/brainstorming/references/deep-dive.md +21 -0
  51. package/kits/coder/skills/brainstorming/scripts/validate.py +56 -0
  52. package/kits/coder/skills/clean-code/SKILL.md +240 -0
  53. package/kits/coder/skills/clean-code/assets/.gitkeep +1 -0
  54. package/kits/coder/skills/clean-code/references/deep-dive.md +21 -0
  55. package/kits/coder/skills/clean-code/scripts/lint_runner.py +186 -0
  56. package/kits/coder/skills/clean-code/scripts/validate.py +56 -0
  57. package/kits/coder/skills/database-design/SKILL.md +255 -0
  58. package/kits/coder/skills/database-design/assets/.gitkeep +1 -0
  59. package/kits/coder/skills/database-design/references/deep-dive.md +21 -0
  60. package/kits/coder/skills/database-design/scripts/schema_validator.py +272 -0
  61. package/kits/coder/skills/database-design/scripts/validate.py +56 -0
  62. package/kits/coder/skills/docker-patterns/SKILL.md +240 -0
  63. package/kits/coder/skills/documentation-templates/SKILL.md +441 -0
  64. package/kits/coder/skills/e2e-testing/SKILL.md +457 -0
  65. package/kits/coder/skills/flutter-patterns/SKILL.md +330 -0
  66. package/kits/coder/skills/frontend-design/SKILL.md +127 -0
  67. package/kits/coder/skills/github-actions/SKILL.md +349 -0
  68. package/kits/coder/skills/gitlab-ci-patterns/SKILL.md +466 -0
  69. package/kits/coder/skills/graphql-patterns/SKILL.md +558 -0
  70. package/kits/coder/skills/i18n-localization/SKILL.md +345 -0
  71. package/kits/coder/skills/i18n-localization/scripts/i18n_checker.py +267 -0
  72. package/kits/coder/skills/kubernetes-patterns/SKILL.md +357 -0
  73. package/kits/coder/skills/mermaid-diagrams/SKILL.md +351 -0
  74. package/kits/coder/skills/mobile-design/SKILL.md +305 -0
  75. package/kits/coder/skills/monitoring-observability/SKILL.md +458 -0
  76. package/kits/coder/skills/multi-tenancy/SKILL.md +317 -0
  77. package/kits/coder/skills/multi-tenancy/assets/.gitkeep +1 -0
  78. package/kits/coder/skills/multi-tenancy/references/deep-dive.md +21 -0
  79. package/kits/coder/skills/multi-tenancy/scripts/validate.py +56 -0
  80. package/kits/coder/skills/nodejs-best-practices/SKILL.md +220 -0
  81. package/kits/coder/skills/performance-profiling/SKILL.md +333 -0
  82. package/kits/coder/skills/performance-profiling/assets/.gitkeep +1 -0
  83. package/kits/coder/skills/performance-profiling/references/deep-dive.md +21 -0
  84. package/kits/coder/skills/performance-profiling/scripts/validate.py +56 -0
  85. package/kits/coder/skills/plan-writing/SKILL.md +360 -0
  86. package/kits/coder/skills/plan-writing/assets/.gitkeep +1 -0
  87. package/kits/coder/skills/plan-writing/references/deep-dive.md +21 -0
  88. package/kits/coder/skills/plan-writing/scripts/validate.py +56 -0
  89. package/kits/coder/skills/postgres-patterns/SKILL.md +361 -0
  90. package/kits/coder/skills/prompt-engineering/SKILL.md +277 -0
  91. package/kits/coder/skills/queue-patterns/SKILL.md +359 -0
  92. package/kits/coder/skills/queue-patterns/assets/.gitkeep +1 -0
  93. package/kits/coder/skills/queue-patterns/references/deep-dive.md +21 -0
  94. package/kits/coder/skills/queue-patterns/scripts/validate.py +56 -0
  95. package/kits/coder/skills/react-native-patterns/SKILL.md +393 -0
  96. package/kits/coder/skills/react-patterns/SKILL.md +319 -0
  97. package/kits/coder/skills/realtime-patterns/SKILL.md +506 -0
  98. package/kits/coder/skills/realtime-patterns/assets/.gitkeep +1 -0
  99. package/kits/coder/skills/realtime-patterns/references/deep-dive.md +21 -0
  100. package/kits/coder/skills/realtime-patterns/scripts/validate.py +56 -0
  101. package/kits/coder/skills/redis-patterns/SKILL.md +484 -0
  102. package/kits/coder/skills/security-fundamentals/SKILL.md +363 -0
  103. package/kits/coder/skills/security-fundamentals/assets/.gitkeep +1 -0
  104. package/kits/coder/skills/security-fundamentals/references/deep-dive.md +21 -0
  105. package/kits/coder/skills/security-fundamentals/scripts/security_scan.py +326 -0
  106. package/kits/coder/skills/security-fundamentals/scripts/validate.py +56 -0
  107. package/kits/coder/skills/seo-patterns/SKILL.md +262 -0
  108. package/kits/coder/skills/seo-patterns/scripts/seo_checker.py +211 -0
  109. package/kits/coder/skills/systematic-debugging/SKILL.md +478 -0
  110. package/kits/coder/skills/systematic-debugging/assets/.gitkeep +1 -0
  111. package/kits/coder/skills/systematic-debugging/references/deep-dive.md +21 -0
  112. package/kits/coder/skills/systematic-debugging/scripts/validate.py +56 -0
  113. package/kits/coder/skills/tailwind-patterns/SKILL.md +395 -0
  114. package/kits/coder/skills/terraform-patterns/SKILL.md +470 -0
  115. package/kits/coder/skills/testing-patterns/SKILL.md +285 -0
  116. package/kits/coder/skills/testing-patterns/assets/.gitkeep +1 -0
  117. package/kits/coder/skills/testing-patterns/references/deep-dive.md +21 -0
  118. package/kits/coder/skills/testing-patterns/scripts/test_runner.py +219 -0
  119. package/kits/coder/skills/testing-patterns/scripts/validate.py +56 -0
  120. package/kits/coder/skills/typescript-patterns/SKILL.md +417 -0
  121. package/kits/coder/skills/ui-ux-pro-max/SKILL.md +364 -0
  122. package/kits/coder/skills/ui-ux-pro-max/data/charts.csv +26 -0
  123. package/kits/coder/skills/ui-ux-pro-max/data/colors.csv +97 -0
  124. package/kits/coder/skills/ui-ux-pro-max/data/icons.csv +101 -0
  125. package/kits/coder/skills/ui-ux-pro-max/data/landing.csv +31 -0
  126. package/kits/coder/skills/ui-ux-pro-max/data/products.csv +97 -0
  127. package/kits/coder/skills/ui-ux-pro-max/data/prompts.csv +24 -0
  128. package/kits/coder/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  129. package/kits/coder/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  130. package/kits/coder/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  131. package/kits/coder/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  132. package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  133. package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  134. package/kits/coder/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  135. package/kits/coder/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  136. package/kits/coder/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  137. package/kits/coder/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  138. package/kits/coder/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  139. package/kits/coder/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  140. package/kits/coder/skills/ui-ux-pro-max/data/styles.csv +59 -0
  141. package/kits/coder/skills/ui-ux-pro-max/data/typography.csv +58 -0
  142. package/kits/coder/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  143. package/kits/coder/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  144. package/kits/coder/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  145. package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-314.pyc +0 -0
  146. package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-314.pyc +0 -0
  147. package/kits/coder/skills/ui-ux-pro-max/scripts/core.py +257 -0
  148. package/kits/coder/skills/ui-ux-pro-max/scripts/design_system.py +488 -0
  149. package/kits/coder/skills/ui-ux-pro-max/scripts/search.py +76 -0
  150. package/kits/coder/workflows/.gitkeep +20 -0
  151. package/kits/coder/workflows/create.md +152 -0
  152. package/kits/coder/workflows/debug.md +223 -0
  153. package/kits/coder/workflows/deploy.md +283 -0
  154. package/kits/coder/workflows/orchestrate.md +243 -0
  155. package/kits/coder/workflows/plan.md +134 -0
  156. package/kits/coder/workflows/test.md +237 -0
  157. package/kits/coder/workflows/ui-ux-pro-max.md +109 -0
  158. package/package.json +49 -0
@@ -0,0 +1,361 @@
1
+ ---
2
+ name: postgres-patterns
3
+ description: PostgreSQL-specific optimization and advanced features. Use when designing PostgreSQL schemas, optimizing queries, implementing RLS, partitioning, or troubleshooting performance. Database-agnostic concepts are in database-design skill.
4
+ allowed-tools: Read, Write, Edit, Glob, Grep
5
+ version: 2.0
6
+ ---
7
+
8
+ # PostgreSQL Patterns - Advanced Optimization
9
+
10
+ > **Philosophy:** PostgreSQL is not just a database—it's a platform. Master its unique features to build performant, secure systems.
11
+
12
+ ---
13
+
14
+ ## When to Use This Skill
15
+
16
+ | ✅ Use | ❌ Don't Use |
17
+ | ------------------------------- | ---------------------------- |
18
+ | PostgreSQL schema design | Database-agnostic design |
19
+ | Query optimization with EXPLAIN | Choosing between databases |
20
+ | Row-Level Security (RLS) | ORM selection |
21
+ | Partitioning strategies | Non-PostgreSQL databases |
22
+ | PostgreSQL-specific data types | Basic normalization concepts |
23
+ | JSONB, arrays, range types | N+1 query patterns (use ORM) |
24
+
25
+ ➡️ For general database concepts, see `database-design` skill.
26
+
27
+ ---
28
+
29
+ ## Core Rules (Non-Negotiable)
30
+
31
+ 1. **TIMESTAMPTZ only** - Never use `TIMESTAMP` without timezone
32
+ 2. **TEXT over VARCHAR** - Use `TEXT` with `CHECK` constraints
33
+ 3. **IDENTITY over SERIAL** - Use `GENERATED ALWAYS AS IDENTITY`
34
+ 4. **FK indexes are manual** - PostgreSQL does NOT auto-index foreign keys
35
+ 5. **EXPLAIN ANALYZE first** - Measure before optimizing
36
+
37
+ ---
38
+
39
+ ## Data Type Selection
40
+
41
+ ### Preferred Types
42
+
43
+ | Data Type | ✅ Use | ❌ Avoid |
44
+ | --------------- | --------------------- | ------------------------------------ |
45
+ | **IDs** | `BIGINT IDENTITY` | `SERIAL`, `INTEGER` |
46
+ | **Distributed** | `UUID` (v7 preferred) | `VARCHAR(36)` |
47
+ | **Strings** | `TEXT` | `VARCHAR(n)`, `CHAR(n)` |
48
+ | **Money** | `NUMERIC(p,s)` | `FLOAT`, `DOUBLE PRECISION`, `MONEY` |
49
+ | **Timestamps** | `TIMESTAMPTZ` | `TIMESTAMP`, `TIMETZ` |
50
+ | **Booleans** | `BOOLEAN NOT NULL` | `INTEGER`, `CHAR(1)` |
51
+ | **JSON** | `JSONB` | `JSON` (no indexing) |
52
+
53
+ ### Special Types
54
+
55
+ ```sql
56
+ -- Arrays: Tags, categories
57
+ tags TEXT[] NOT NULL DEFAULT '{}'
58
+ CREATE INDEX ON table USING GIN (tags);
59
+
60
+ -- Range types: Scheduling, versioning
61
+ booking_period TSTZRANGE NOT NULL
62
+ EXCLUDE USING GIST (room_id WITH =, booking_period WITH &&)
63
+
64
+ -- Network types
65
+ ip_address INET NOT NULL
66
+ CREATE INDEX ON table USING GIST (ip_address inet_ops);
67
+
68
+ -- Full-text search
69
+ search_vector TSVECTOR GENERATED ALWAYS AS (
70
+ to_tsvector('english', title || ' ' || content)
71
+ ) STORED
72
+ CREATE INDEX ON table USING GIN (search_vector);
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Indexing Strategy
78
+
79
+ ### Index Type Decision Tree
80
+
81
+ ```
82
+ What query pattern?
83
+
84
+ ├─ Equality/Range (=, <, >, BETWEEN)?
85
+ │ └─ → B-Tree (default)
86
+
87
+ ├─ JSONB containment (@>, ?, ?|)?
88
+ │ └─ → GIN (jsonb_ops or jsonb_path_ops)
89
+
90
+ ├─ Full-text search (@@)?
91
+ │ └─ → GIN on TSVECTOR
92
+
93
+ ├─ Array containment (@>, &&)?
94
+ │ └─ → GIN
95
+
96
+ ├─ Range overlap/containment?
97
+ │ └─ → GiST
98
+
99
+ ├─ Time-series (huge tables, ordered inserts)?
100
+ │ └─ → BRIN (minimal storage)
101
+
102
+ └─ Partial index (subset of rows)?
103
+ └─ → Partial B-Tree with WHERE clause
104
+ ```
105
+
106
+ ### Index Patterns
107
+
108
+ ```sql
109
+ -- Composite: Order matters! (Equality → Range → Sort)
110
+ CREATE INDEX ON orders (user_id, status, created_at);
111
+
112
+ -- Partial: Hot subset indexing
113
+ CREATE INDEX ON orders (created_at)
114
+ WHERE status = 'pending';
115
+
116
+ -- Expression: Case-insensitive search
117
+ CREATE INDEX ON users (LOWER(email));
118
+
119
+ -- Covering: Index-only scans
120
+ CREATE INDEX ON orders (user_id) INCLUDE (status, total);
121
+
122
+ -- BRIN: Time-series (1000x smaller than B-tree)
123
+ CREATE INDEX ON events USING BRIN (created_at) WITH (pages_per_range = 128);
124
+ ```
125
+
126
+ ### JSONB Indexing
127
+
128
+ ```sql
129
+ -- Default GIN: All operators (@>, ?, ?|, ?&)
130
+ CREATE INDEX ON products USING GIN (metadata);
131
+
132
+ -- jsonb_path_ops: Smaller, faster BUT only @> containment
133
+ CREATE INDEX ON products USING GIN (metadata jsonb_path_ops);
134
+
135
+ -- Extract hot path to B-tree column
136
+ ALTER TABLE products ADD COLUMN price NUMERIC
137
+ GENERATED ALWAYS AS ((metadata->>'price')::NUMERIC) STORED;
138
+ CREATE INDEX ON products (price);
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Query Optimization
144
+
145
+ ### EXPLAIN ANALYZE Cheatsheet
146
+
147
+ ```sql
148
+ EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
149
+ SELECT * FROM orders WHERE user_id = 123;
150
+
151
+ -- Key metrics:
152
+ -- ✅ Index Scan / Index Only Scan
153
+ -- ❌ Seq Scan on large tables (>10k rows)
154
+ -- ✅ Low "actual time"
155
+ -- ❌ High "shared hit" + "shared read" (I/O bound)
156
+ ```
157
+
158
+ ### Common Optimizations
159
+
160
+ | Problem | Solution |
161
+ | ------------------------ | ------------------------------------ |
162
+ | Seq Scan on filtered col | Add index on WHERE columns |
163
+ | Slow ORDER BY | Index matches ORDER BY columns |
164
+ | Low selectivity | Partial index on common filter |
165
+ | JSONB field queries | Extract to generated column + B-tree |
166
+ | LIKE '%pattern%' | pg_trgm extension + GIN index |
167
+ | Cross-table queries | Covering index with INCLUDE |
168
+
169
+ ### Join Optimization
170
+
171
+ ```sql
172
+ -- ❌ Slow: No index on FK
173
+ SELECT * FROM orders o
174
+ JOIN users u ON u.id = o.user_id;
175
+
176
+ -- ✅ Fast: Index on FK column
177
+ CREATE INDEX ON orders (user_id);
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Row-Level Security (RLS)
183
+
184
+ ```sql
185
+ -- Enable RLS
186
+ ALTER TABLE documents ENABLE ROW LEVEL SECURITY;
187
+
188
+ -- Policy: Users see only their documents
189
+ CREATE POLICY user_documents ON documents
190
+ FOR ALL
191
+ TO app_users
192
+ USING (user_id = current_setting('app.current_user_id')::BIGINT);
193
+
194
+ -- Multi-tenant: Tenant isolation
195
+ CREATE POLICY tenant_isolation ON orders
196
+ FOR ALL
197
+ USING (tenant_id = current_setting('app.tenant_id')::BIGINT);
198
+
199
+ -- Force RLS for table owner too
200
+ ALTER TABLE documents FORCE ROW LEVEL SECURITY;
201
+ ```
202
+
203
+ ---
204
+
205
+ ## Partitioning Strategy
206
+
207
+ ### When to Partition
208
+
209
+ | Criteria | Threshold |
210
+ | -------------- | ---------------- |
211
+ | Table size | > 100M rows |
212
+ | Query filter | Always on date |
213
+ | Data lifecycle | Retention policy |
214
+ | Maintenance | Bulk deletes |
215
+
216
+ ### Partition Types
217
+
218
+ ```sql
219
+ -- RANGE: Time-series data
220
+ CREATE TABLE events (
221
+ id BIGINT GENERATED ALWAYS AS IDENTITY,
222
+ created_at TIMESTAMPTZ NOT NULL,
223
+ data JSONB
224
+ ) PARTITION BY RANGE (created_at);
225
+
226
+ CREATE TABLE events_2024_01 PARTITION OF events
227
+ FOR VALUES FROM ('2024-01-01') TO ('2024-02-01');
228
+
229
+ -- LIST: Regional/categorical data
230
+ CREATE TABLE orders (
231
+ id BIGINT PRIMARY KEY,
232
+ region TEXT NOT NULL
233
+ ) PARTITION BY LIST (region);
234
+
235
+ CREATE TABLE orders_us PARTITION OF orders
236
+ FOR VALUES IN ('us-east', 'us-west');
237
+
238
+ -- HASH: Even distribution
239
+ CREATE TABLE sessions (
240
+ user_id BIGINT NOT NULL
241
+ ) PARTITION BY HASH (user_id);
242
+
243
+ CREATE TABLE sessions_0 PARTITION OF sessions
244
+ FOR VALUES WITH (MODULUS 4, REMAINDER 0);
245
+ ```
246
+
247
+ ### Partition Gotchas
248
+
249
+ - **No global UNIQUE** - PK must include partition key
250
+ - **No FK from partitioned** - Use triggers instead
251
+ - **Query must filter** - Include partition key in WHERE
252
+
253
+ ---
254
+
255
+ ## Upsert Patterns
256
+
257
+ ```sql
258
+ -- Basic upsert
259
+ INSERT INTO users (email, name)
260
+ VALUES ('test@example.com', 'Test')
261
+ ON CONFLICT (email)
262
+ DO UPDATE SET name = EXCLUDED.name, updated_at = NOW();
263
+
264
+ -- Upsert with conditions
265
+ INSERT INTO inventory (product_id, quantity)
266
+ VALUES (1, 10)
267
+ ON CONFLICT (product_id)
268
+ DO UPDATE SET quantity = inventory.quantity + EXCLUDED.quantity
269
+ WHERE inventory.quantity < 100;
270
+
271
+ -- Bulk upsert
272
+ INSERT INTO products (id, name, price)
273
+ SELECT * FROM UNNEST(
274
+ ARRAY[1, 2, 3]::BIGINT[],
275
+ ARRAY['A', 'B', 'C']::TEXT[],
276
+ ARRAY[10.0, 20.0, 30.0]::NUMERIC[]
277
+ )
278
+ ON CONFLICT (id) DO UPDATE
279
+ SET name = EXCLUDED.name, price = EXCLUDED.price;
280
+ ```
281
+
282
+ ---
283
+
284
+ ## Safe Schema Evolution
285
+
286
+ | Operation | Risk | Safe Approach |
287
+ | ------------- | ------ | -------------------------------------------- |
288
+ | Add column | Low | `ADD COLUMN` with DEFAULT (PG11+ is instant) |
289
+ | Add NOT NULL | Medium | Add column → backfill → set NOT NULL |
290
+ | Drop column | High | Stop reading → deploy → drop |
291
+ | Add index | Medium | `CREATE INDEX CONCURRENTLY` |
292
+ | Change type | High | Add new → migrate → swap → drop old |
293
+ | Rename column | High | Add alias → migrate code → drop old |
294
+
295
+ ```sql
296
+ -- Safe index creation (no locks)
297
+ CREATE INDEX CONCURRENTLY idx_orders_user ON orders (user_id);
298
+
299
+ -- Safe NOT NULL addition
300
+ ALTER TABLE users ADD COLUMN phone TEXT;
301
+ UPDATE users SET phone = '' WHERE phone IS NULL;
302
+ ALTER TABLE users ALTER COLUMN phone SET NOT NULL;
303
+ ```
304
+
305
+ ---
306
+
307
+ ## Essential Extensions
308
+
309
+ | Extension | Use Case | Key Functions |
310
+ | ------------- | ---------------------------- | ------------------------------- |
311
+ | `pgcrypto` | Password hashing, encryption | `crypt()`, `gen_random_uuid()` |
312
+ | `pg_trgm` | Fuzzy text search | `%`, `similarity()`, GIN index |
313
+ | `TimescaleDB` | Time-series data | Auto-partitioning, compression |
314
+ | `PostGIS` | Geospatial | `ST_Distance()`, `ST_Within()` |
315
+ | `pgvector` | Vector embeddings | `<=>`, `<->` operators |
316
+ | `pgaudit` | Audit logging | Statement/object-level auditing |
317
+
318
+ ---
319
+
320
+ ## Performance Checklist
321
+
322
+ Before production:
323
+
324
+ - [ ] All FK columns indexed?
325
+ - [ ] Queries use EXPLAIN ANALYZE?
326
+ - [ ] Partial indexes for hot filters?
327
+ - [ ] JSONB hot paths extracted?
328
+ - [ ] RLS policies tested?
329
+ - [ ] Partitioning for large tables?
330
+ - [ ] Connection pooling configured?
331
+ - [ ] Vacuum/autovacuum tuned?
332
+
333
+ ---
334
+
335
+ ## Anti-Patterns
336
+
337
+ | ❌ Don't | ✅ Do |
338
+ | ---------------------------- | ----------------------------------- |
339
+ | Use TIMESTAMP without TZ | Use TIMESTAMPTZ |
340
+ | VARCHAR(n) for variable text | TEXT with CHECK constraints |
341
+ | SERIAL for IDs | BIGINT GENERATED ALWAYS AS IDENTITY |
342
+ | JSON type | JSONB (indexable, smaller) |
343
+ | Index every column | Index query patterns |
344
+ | Ignore EXPLAIN output | Analyze before optimizing |
345
+ | Store arrays for relations | Use junction tables |
346
+ | Mixed-case identifiers | snake_case (unquoted) |
347
+
348
+ ---
349
+
350
+ ## Related Skills
351
+
352
+ | Need | Skill |
353
+ | ----------------- | ----------------------- |
354
+ | General DB design | `database-design` |
355
+ | API integration | `api-patterns` |
356
+ | Query performance | `performance-profiling` |
357
+ | Security patterns | `security-fundamentals` |
358
+
359
+ ---
360
+
361
+ > **Remember:** PostgreSQL rewards those who understand its features. EXPLAIN everything, index strategically, and leverage its unique capabilities.
@@ -0,0 +1,277 @@
1
+ ---
2
+ name: prompt-engineering
3
+ description: Prompt engineering principles for AI systems. Use when writing system prompts, agent personas, optimizing AI interactions, or debugging agent behavior. Covers few-shot learning, chain-of-thought, template design, and best practices.
4
+ allowed-tools: Read, Write, Edit
5
+ version: 1.0
6
+ priority: CRITICAL
7
+ ---
8
+
9
+ # Prompt Engineering - AI Communication Excellence
10
+
11
+ > **Philosophy:** Prompts are code. They should be **specific, structured, and testable**. Vague prompts produce vague results.
12
+
13
+ ---
14
+
15
+ ## Core Principles
16
+
17
+ | Principle | Rule |
18
+ | -------------- | -------------------------------------------------- |
19
+ | **Specific** | Ambiguity causes inconsistent outputs |
20
+ | **Structured** | Clear sections: Context → Task → Format → Examples |
21
+ | **Testable** | Evaluate on diverse inputs, measure consistency |
22
+ | **Iterative** | Start simple, add complexity only when needed |
23
+ | **Versioned** | Treat prompts as code with proper version control |
24
+
25
+ ---
26
+
27
+ ## Prompt Structure
28
+
29
+ ### Universal Template
30
+
31
+ ```
32
+ [ROLE/PERSONA] → Who the AI should be
33
+ [CONTEXT] → Background information
34
+ [TASK] → What to do
35
+ [CONSTRAINTS] → Rules and boundaries
36
+ [FORMAT] → Expected output structure
37
+ [EXAMPLES] → Input-output demonstrations
38
+ ```
39
+
40
+ ### System Prompt Example
41
+
42
+ ```markdown
43
+ # Role
44
+
45
+ You are a senior backend engineer specializing in API design.
46
+
47
+ # Rules
48
+
49
+ - Always consider scalability and performance
50
+ - Suggest RESTful patterns by default
51
+ - Flag security concerns immediately
52
+ - Use early return pattern in code
53
+
54
+ # Output Format
55
+
56
+ 1. Analysis
57
+ 2. Recommendation
58
+ 3. Code example
59
+ 4. Trade-offs
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Key Techniques
65
+
66
+ ### 1. Few-Shot Learning
67
+
68
+ | When to Use | Examples Needed |
69
+ | -------------------------- | ------------------ |
70
+ | Consistent formatting | 2-3 examples |
71
+ | Complex reasoning patterns | 3-5 examples |
72
+ | Edge case handling | Include edge cases |
73
+ | Simple tasks | 0-1 examples |
74
+
75
+ ```markdown
76
+ Extract key information:
77
+
78
+ Input: "Login error 403, can't access dashboard"
79
+ Output: {"issue": "auth", "code": 403, "priority": "high"}
80
+
81
+ Input: "Feature request: add dark mode"
82
+ Output: {"issue": "feature", "code": null, "priority": "low"}
83
+
84
+ Now process: "Can't upload files, timeout after 10s"
85
+ ```
86
+
87
+ ### 2. Chain-of-Thought (CoT)
88
+
89
+ Force step-by-step reasoning for complex problems:
90
+
91
+ ```markdown
92
+ Analyze this bug report.
93
+
94
+ Think step by step:
95
+
96
+ 1. What is the expected behavior?
97
+ 2. What is the actual behavior?
98
+ 3. What changed recently?
99
+ 4. What components are involved?
100
+ 5. What is the most likely root cause?
101
+
102
+ Bug: "Users can't save drafts after cache update"
103
+ ```
104
+
105
+ | CoT Type | Trigger | Accuracy Boost |
106
+ | -------------- | -------------------------- | -------------- |
107
+ | **Zero-shot** | "Let's think step by step" | +10-20% |
108
+ | **Few-shot** | Show reasoning examples | +30-50% |
109
+ | **Self-check** | "Verify your reasoning" | +10-15% |
110
+
111
+ ### 3. Progressive Disclosure
112
+
113
+ Start simple, add complexity only when needed:
114
+
115
+ | Level | Prompt | Use When |
116
+ | ----- | --------------------------------------------- | ---------------- |
117
+ | 1 | "Summarize this article" | Testing baseline |
118
+ | 2 | "Summarize in 3 bullet points" | Need structure |
119
+ | 3 | "Identify main findings, then summarize each" | Need reasoning |
120
+ | 4 | Include 2-3 example summaries | Need consistency |
121
+
122
+ ---
123
+
124
+ ## Agent Prompt Patterns
125
+
126
+ ### Persona Definition
127
+
128
+ ```markdown
129
+ # Identity
130
+
131
+ You are [ROLE] with expertise in [DOMAIN].
132
+
133
+ # Philosophy
134
+
135
+ > "[CORE BELIEF]"
136
+
137
+ # Behavioral Traits
138
+
139
+ - [Trait 1]
140
+ - [Trait 2]
141
+ - [Trait 3]
142
+
143
+ # Anti-Patterns (What NOT to do)
144
+
145
+ - ❌ [Bad behavior 1]
146
+ - ❌ [Bad behavior 2]
147
+ ```
148
+
149
+ ### Decision Framework
150
+
151
+ ```markdown
152
+ When [SITUATION]:
153
+
154
+ 1. First, check [CONDITION_1]
155
+ 2. If true → [ACTION_1]
156
+ 3. If false → Check [CONDITION_2]
157
+ 4. Default → [FALLBACK_ACTION]
158
+ ```
159
+
160
+ ### Error Recovery
161
+
162
+ ```markdown
163
+ If uncertain:
164
+
165
+ - Request clarification with specific questions
166
+ - Provide confidence score (1-10)
167
+ - Offer alternative interpretations
168
+ - Indicate missing information clearly
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Optimization Techniques
174
+
175
+ | Technique | Purpose | Example |
176
+ | --------------------- | ----------------------- | ----------------------------- |
177
+ | **Constraints** | Limit output scope | "Max 100 words" |
178
+ | **Format specs** | Ensure parseable output | "Respond in JSON" |
179
+ | **Role priming** | Set expertise level | "As a senior engineer..." |
180
+ | **Negative examples** | What NOT to do | "Do NOT include explanations" |
181
+ | **Confidence scores** | Measure certainty | "Rate your confidence 1-10" |
182
+
183
+ ### Token Efficiency
184
+
185
+ | Inefficient | Efficient |
186
+ | ---------------------------------- | -------------------------------- |
187
+ | Long verbose instructions | Concise, direct commands |
188
+ | Repeating context in every message | System prompt for stable context |
189
+ | 10 examples when 3 suffice | Minimal effective examples |
190
+
191
+ ---
192
+
193
+ ## Decision Trees
194
+
195
+ ### When to Use Few-Shot?
196
+
197
+ ```
198
+ Is output format critical?
199
+ ├── Yes → Add 2-3 format examples
200
+ └── No → Is task complex?
201
+ ├── Yes → Add reasoning examples
202
+ └── No → Zero-shot often sufficient
203
+ ```
204
+
205
+ ### How Many Examples?
206
+
207
+ ```
208
+ Task complexity?
209
+ ├── Simple formatting → 2 examples
210
+ ├── Complex reasoning → 3-5 examples
211
+ └── Novel task → Start with 5, reduce if consistent
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Anti-Patterns (DON'T)
217
+
218
+ | ❌ Anti-Pattern | ✅ Correct Approach |
219
+ | ------------------------------ | --------------------------------- |
220
+ | Vague instructions | Specific, measurable requirements |
221
+ | Complex prompt from start | Start simple, iterate |
222
+ | Examples that don't match task | Representative, diverse examples |
223
+ | No output format specified | Clear format expectations |
224
+ | Ignoring edge cases | Test on boundary inputs |
225
+ | Same prompt for all tasks | Task-specific optimized prompts |
226
+ | No version control | Git-track prompts like code |
227
+
228
+ ---
229
+
230
+ ## Testing Prompts
231
+
232
+ | Test Type | Purpose | Method |
233
+ | --------------- | ------------------------ | ------------------------------- |
234
+ | **Consistency** | Same input → same output | Run 5x, check variance |
235
+ | **Edge cases** | Handle unusual inputs | Test empty, long, special chars |
236
+ | **Adversarial** | Resist manipulation | Test injection attempts |
237
+ | **Performance** | Speed and token usage | Measure latency, token count |
238
+
239
+ ### Prompt Evaluation Checklist
240
+
241
+ ```
242
+ □ Clear role/persona defined?
243
+ □ Task instructions specific?
244
+ □ Output format specified?
245
+ □ Constraints explicit?
246
+ □ Examples representative?
247
+ □ Edge cases handled?
248
+ □ Error recovery defined?
249
+ ```
250
+
251
+ ---
252
+
253
+ ## 🔴 Self-Check Before Completing
254
+
255
+ | Check | Question |
256
+ | ---------------------- | ---------------------------------- |
257
+ | ✅ **Specific?** | No ambiguous instructions? |
258
+ | ✅ **Structured?** | Role → Task → Format → Examples? |
259
+ | ✅ **Tested?** | Evaluated on diverse inputs? |
260
+ | ✅ **Versioned?** | Prompt tracked in version control? |
261
+ | ✅ **Optimized?** | Minimal tokens, maximum clarity? |
262
+ | ✅ **Error handling?** | Handles uncertain/edge cases? |
263
+
264
+ ---
265
+
266
+ ## Related Skills
267
+
268
+ | Need | Skill |
269
+ | ----------------------- | ------------------------ |
270
+ | Agent design | `agent-creator` (future) |
271
+ | Skill creation | `skill-creator` (future) |
272
+ | AI application patterns | `ai-patterns` (future) |
273
+ | User communication | `brainstorming` |
274
+
275
+ ---
276
+
277
+ > **Remember:** A well-crafted prompt is invisible - the AI just does what you need without confusion. If you're constantly rephrasing or clarifying, the prompt needs work.