locus-product-planning 1.0.0 → 1.2.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 (76) hide show
  1. package/.claude-plugin/marketplace.json +31 -0
  2. package/.claude-plugin/plugin.json +32 -0
  3. package/README.md +131 -45
  4. package/agents/engineering/architect-reviewer.md +122 -0
  5. package/agents/engineering/engineering-manager.md +101 -0
  6. package/agents/engineering/principal-engineer.md +98 -0
  7. package/agents/engineering/staff-engineer.md +86 -0
  8. package/agents/engineering/tech-lead.md +114 -0
  9. package/agents/executive/ceo-strategist.md +81 -0
  10. package/agents/executive/cfo-analyst.md +97 -0
  11. package/agents/executive/coo-operations.md +100 -0
  12. package/agents/executive/cpo-product.md +104 -0
  13. package/agents/executive/cto-architect.md +90 -0
  14. package/agents/product/product-manager.md +70 -0
  15. package/agents/product/project-manager.md +95 -0
  16. package/agents/product/qa-strategist.md +132 -0
  17. package/agents/product/scrum-master.md +70 -0
  18. package/dist/index.d.ts +10 -25
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +231 -95
  21. package/dist/lib/skills-core.d.ts +95 -0
  22. package/dist/lib/skills-core.d.ts.map +1 -0
  23. package/dist/lib/skills-core.js +361 -0
  24. package/hooks/hooks.json +15 -0
  25. package/hooks/run-hook.cmd +32 -0
  26. package/hooks/session-start.cmd +13 -0
  27. package/hooks/session-start.sh +70 -0
  28. package/opencode.json +11 -7
  29. package/package.json +18 -4
  30. package/skills/01-executive-suite/ceo-strategist/SKILL.md +132 -0
  31. package/skills/01-executive-suite/cfo-analyst/SKILL.md +187 -0
  32. package/skills/01-executive-suite/coo-operations/SKILL.md +211 -0
  33. package/skills/01-executive-suite/cpo-product/SKILL.md +231 -0
  34. package/skills/01-executive-suite/cto-architect/SKILL.md +173 -0
  35. package/skills/02-product-management/estimation-expert/SKILL.md +139 -0
  36. package/skills/02-product-management/product-manager/SKILL.md +265 -0
  37. package/skills/02-product-management/program-manager/SKILL.md +178 -0
  38. package/skills/02-product-management/project-manager/SKILL.md +221 -0
  39. package/skills/02-product-management/roadmap-strategist/SKILL.md +186 -0
  40. package/skills/02-product-management/scrum-master/SKILL.md +212 -0
  41. package/skills/03-engineering-leadership/architect-reviewer/SKILL.md +249 -0
  42. package/skills/03-engineering-leadership/engineering-manager/SKILL.md +207 -0
  43. package/skills/03-engineering-leadership/principal-engineer/SKILL.md +206 -0
  44. package/skills/03-engineering-leadership/staff-engineer/SKILL.md +237 -0
  45. package/skills/03-engineering-leadership/tech-lead/SKILL.md +296 -0
  46. package/skills/04-developer-specializations/core/api-designer/SKILL.md +579 -0
  47. package/skills/04-developer-specializations/core/backend-developer/SKILL.md +205 -0
  48. package/skills/04-developer-specializations/core/frontend-developer/SKILL.md +233 -0
  49. package/skills/04-developer-specializations/core/fullstack-developer/SKILL.md +202 -0
  50. package/skills/04-developer-specializations/core/mobile-developer/SKILL.md +220 -0
  51. package/skills/04-developer-specializations/data-ai/data-engineer/SKILL.md +316 -0
  52. package/skills/04-developer-specializations/data-ai/data-scientist/SKILL.md +338 -0
  53. package/skills/04-developer-specializations/data-ai/llm-architect/SKILL.md +390 -0
  54. package/skills/04-developer-specializations/data-ai/ml-engineer/SKILL.md +349 -0
  55. package/skills/04-developer-specializations/design/ui-ux-designer/SKILL.md +337 -0
  56. package/skills/04-developer-specializations/infrastructure/cloud-architect/SKILL.md +354 -0
  57. package/skills/04-developer-specializations/infrastructure/database-architect/SKILL.md +430 -0
  58. package/skills/04-developer-specializations/infrastructure/devops-engineer/SKILL.md +306 -0
  59. package/skills/04-developer-specializations/infrastructure/kubernetes-specialist/SKILL.md +419 -0
  60. package/skills/04-developer-specializations/infrastructure/platform-engineer/SKILL.md +289 -0
  61. package/skills/04-developer-specializations/infrastructure/security-engineer/SKILL.md +336 -0
  62. package/skills/04-developer-specializations/infrastructure/sre-engineer/SKILL.md +425 -0
  63. package/skills/04-developer-specializations/languages/golang-pro/SKILL.md +366 -0
  64. package/skills/04-developer-specializations/languages/java-architect/SKILL.md +296 -0
  65. package/skills/04-developer-specializations/languages/python-pro/SKILL.md +317 -0
  66. package/skills/04-developer-specializations/languages/rust-engineer/SKILL.md +309 -0
  67. package/skills/04-developer-specializations/languages/typescript-pro/SKILL.md +251 -0
  68. package/skills/04-developer-specializations/quality/accessibility-tester/SKILL.md +338 -0
  69. package/skills/04-developer-specializations/quality/performance-engineer/SKILL.md +384 -0
  70. package/skills/04-developer-specializations/quality/qa-expert/SKILL.md +413 -0
  71. package/skills/04-developer-specializations/quality/security-auditor/SKILL.md +359 -0
  72. package/skills/04-developer-specializations/quality/test-automation-engineer/SKILL.md +711 -0
  73. package/skills/05-specialists/compliance-specialist/SKILL.md +171 -0
  74. package/skills/05-specialists/technical-writer/SKILL.md +576 -0
  75. package/skills/using-locus/SKILL.md +126 -0
  76. package/.opencode/skills/locus/SKILL.md +0 -299
@@ -0,0 +1,430 @@
1
+ ---
2
+ name: database-architect
3
+ description: Database design, data modeling, query optimization, scalability patterns, and choosing the right database for the job
4
+ metadata:
5
+ version: "1.0.0"
6
+ tier: developer-specialization
7
+ category: infrastructure
8
+ council: code-review-council
9
+ ---
10
+
11
+ # Database Architect
12
+
13
+ You embody the perspective of a senior database architect with expertise in data modeling, query optimization, database selection, and designing scalable data systems.
14
+
15
+ ## When to Apply
16
+
17
+ Invoke this skill when:
18
+ - Designing database schemas
19
+ - Choosing between database technologies
20
+ - Optimizing query performance
21
+ - Planning data migrations
22
+ - Designing for scalability and high availability
23
+ - Implementing data integrity constraints
24
+ - Setting up replication or sharding
25
+ - Reviewing database designs
26
+
27
+ ## Core Competencies
28
+
29
+ ### 1. Data Modeling
30
+ - Entity-relationship design
31
+ - Normalization and denormalization
32
+ - Schema evolution strategies
33
+ - Domain-driven data design
34
+
35
+ ### 2. Query Optimization
36
+ - Query planning and execution
37
+ - Index design and optimization
38
+ - Query profiling and analysis
39
+ - Batch vs. real-time processing
40
+
41
+ ### 3. Database Selection
42
+ - SQL vs. NoSQL trade-offs
43
+ - OLTP vs. OLAP systems
44
+ - Specialized databases (graph, time-series, vector)
45
+ - Multi-model approaches
46
+
47
+ ### 4. Scalability & Reliability
48
+ - Replication strategies
49
+ - Partitioning and sharding
50
+ - Backup and recovery
51
+ - High availability patterns
52
+
53
+ ## Database Selection Guide
54
+
55
+ ### Decision Matrix
56
+
57
+ | Requirement | Best Fit | Examples |
58
+ |-------------|----------|----------|
59
+ | **Strong consistency, relations** | Relational SQL | PostgreSQL, MySQL |
60
+ | **Flexible schema, documents** | Document DB | MongoDB, CouchDB |
61
+ | **High-velocity reads** | Key-Value | Redis, DynamoDB |
62
+ | **Complex relationships** | Graph DB | Neo4j, Neptune |
63
+ | **Time-series data** | Time-series DB | TimescaleDB, InfluxDB |
64
+ | **Full-text search** | Search engine | Elasticsearch, Meilisearch |
65
+ | **Vector/embeddings** | Vector DB | Pinecone, Weaviate, pgvector |
66
+ | **Analytics/OLAP** | Columnar | ClickHouse, BigQuery |
67
+
68
+ ### PostgreSQL as Default Choice
69
+
70
+ When in doubt, start with PostgreSQL because:
71
+ - Full SQL compliance with excellent performance
72
+ - Rich extension ecosystem (PostGIS, pgvector, TimescaleDB)
73
+ - JSONB for document-like flexibility
74
+ - Robust replication and HA options
75
+ - Battle-tested at massive scale
76
+
77
+ ## Data Modeling
78
+
79
+ ### Normalization Levels
80
+
81
+ | Normal Form | Rule | Trade-off |
82
+ |-------------|------|-----------|
83
+ | **1NF** | No repeating groups | Basic structure |
84
+ | **2NF** | No partial dependencies | Reduces redundancy |
85
+ | **3NF** | No transitive dependencies | Optimal for OLTP |
86
+ | **BCNF** | Every determinant is a key | Maximum integrity |
87
+ | **Denormalized** | Strategic redundancy | Read performance |
88
+
89
+ ### When to Denormalize
90
+
91
+ | Scenario | Approach |
92
+ |----------|----------|
93
+ | Read-heavy workloads | Precompute aggregates |
94
+ | Frequent joins on same tables | Embed related data |
95
+ | Caching expensive calculations | Materialized columns |
96
+ | Reporting/analytics | Materialized views |
97
+
98
+ ### Schema Design Checklist
99
+
100
+ - [ ] Primary keys defined (prefer UUIDs or ULIDs for distributed)
101
+ - [ ] Foreign keys with appropriate ON DELETE/UPDATE
102
+ - [ ] Indexes on frequently queried columns
103
+ - [ ] NOT NULL constraints where appropriate
104
+ - [ ] CHECK constraints for data validation
105
+ - [ ] Created/updated timestamps on all tables
106
+ - [ ] Soft delete strategy if needed
107
+
108
+ ## SQL Best Practices
109
+
110
+ ### Query Optimization Techniques
111
+
112
+ #### Use Indexes Effectively
113
+ ```sql
114
+ -- Good: Covering index for common query
115
+ CREATE INDEX idx_orders_user_status
116
+ ON orders(user_id, status)
117
+ INCLUDE (total_amount, created_at);
118
+
119
+ -- Query uses index fully
120
+ SELECT user_id, status, total_amount, created_at
121
+ FROM orders
122
+ WHERE user_id = $1 AND status = 'pending';
123
+ ```
124
+
125
+ #### Avoid N+1 Queries
126
+ ```sql
127
+ -- Bad: Fetching related data in loop
128
+ -- for each user: SELECT * FROM orders WHERE user_id = ?
129
+
130
+ -- Good: Single query with JOIN
131
+ SELECT u.*, o.*
132
+ FROM users u
133
+ LEFT JOIN orders o ON o.user_id = u.id
134
+ WHERE u.id IN ($1, $2, $3);
135
+
136
+ -- Or use lateral join for complex cases
137
+ SELECT u.*, recent_orders.*
138
+ FROM users u
139
+ LEFT JOIN LATERAL (
140
+ SELECT * FROM orders
141
+ WHERE user_id = u.id
142
+ ORDER BY created_at DESC
143
+ LIMIT 5
144
+ ) recent_orders ON true;
145
+ ```
146
+
147
+ #### Use CTEs for Readability
148
+ ```sql
149
+ WITH
150
+ active_users AS (
151
+ SELECT id, email
152
+ FROM users
153
+ WHERE last_login > NOW() - INTERVAL '30 days'
154
+ ),
155
+ user_orders AS (
156
+ SELECT user_id, COUNT(*) as order_count, SUM(total) as total_spent
157
+ FROM orders
158
+ WHERE created_at > NOW() - INTERVAL '30 days'
159
+ GROUP BY user_id
160
+ )
161
+ SELECT
162
+ au.email,
163
+ COALESCE(uo.order_count, 0) as order_count,
164
+ COALESCE(uo.total_spent, 0) as total_spent
165
+ FROM active_users au
166
+ LEFT JOIN user_orders uo ON uo.user_id = au.id
167
+ ORDER BY total_spent DESC;
168
+ ```
169
+
170
+ ### Index Strategy
171
+
172
+ | Query Pattern | Index Type |
173
+ |---------------|------------|
174
+ | Equality (WHERE x = y) | B-tree (default) |
175
+ | Range (WHERE x > y) | B-tree |
176
+ | Text search (LIKE 'prefix%') | B-tree (prefix only) |
177
+ | Full-text search | GIN with tsvector |
178
+ | JSON queries | GIN on jsonb |
179
+ | Array contains | GIN |
180
+ | Geospatial | GiST or SP-GiST |
181
+ | Composite queries | Multi-column index |
182
+
183
+ ### Query Analysis
184
+
185
+ ```sql
186
+ -- Always analyze before optimizing
187
+ EXPLAIN ANALYZE SELECT ...
188
+
189
+ -- Key metrics to check:
190
+ -- - Seq Scan vs Index Scan (prefer index)
191
+ -- - Actual rows vs estimated (if very different, update statistics)
192
+ -- - Nested loops with high iterations (consider batch approach)
193
+ -- - Sort operations (consider index)
194
+ ```
195
+
196
+ ## Schema Evolution
197
+
198
+ ### Migration Best Practices
199
+
200
+ #### Safe Migration Patterns
201
+
202
+ | Change | Safe Approach |
203
+ |--------|---------------|
204
+ | Add column | ADD COLUMN with DEFAULT (or NULL) |
205
+ | Remove column | Deploy code first, then DROP |
206
+ | Rename column | Add new, migrate data, drop old |
207
+ | Add NOT NULL | Add column NULL, backfill, add constraint |
208
+ | Add index | CREATE INDEX CONCURRENTLY |
209
+ | Add foreign key | Add without validation, then validate |
210
+
211
+ #### Example: Safe Column Rename
212
+ ```sql
213
+ -- Step 1: Add new column
214
+ ALTER TABLE users ADD COLUMN full_name TEXT;
215
+
216
+ -- Step 2: Backfill (in batches for large tables)
217
+ UPDATE users SET full_name = name WHERE full_name IS NULL LIMIT 10000;
218
+
219
+ -- Step 3: Deploy code that writes to both, reads from new
220
+ -- Step 4: Complete backfill
221
+ -- Step 5: Deploy code that only uses new column
222
+ -- Step 6: Drop old column
223
+ ALTER TABLE users DROP COLUMN name;
224
+ ```
225
+
226
+ ### Zero-Downtime Migrations
227
+
228
+ 1. **Expand**: Add new schema elements
229
+ 2. **Migrate**: Move/copy data
230
+ 3. **Contract**: Remove old schema elements
231
+
232
+ Never combine expand and contract in one deployment.
233
+
234
+ ## Scalability Patterns
235
+
236
+ ### Replication
237
+
238
+ | Pattern | Use Case | Trade-off |
239
+ |---------|----------|-----------|
240
+ | **Primary-Replica** | Read scaling | Async lag |
241
+ | **Synchronous Replica** | HA failover | Write latency |
242
+ | **Multi-Primary** | Geo-distribution | Conflict resolution |
243
+
244
+ ### Partitioning
245
+
246
+ ```sql
247
+ -- Range partitioning by date
248
+ CREATE TABLE events (
249
+ id UUID,
250
+ created_at TIMESTAMP,
251
+ event_type TEXT,
252
+ data JSONB
253
+ ) PARTITION BY RANGE (created_at);
254
+
255
+ CREATE TABLE events_2024_q1 PARTITION OF events
256
+ FOR VALUES FROM ('2024-01-01') TO ('2024-04-01');
257
+
258
+ CREATE TABLE events_2024_q2 PARTITION OF events
259
+ FOR VALUES FROM ('2024-04-01') TO ('2024-07-01');
260
+ ```
261
+
262
+ #### Partitioning Strategies
263
+
264
+ | Strategy | Best For |
265
+ |----------|----------|
266
+ | **Range** | Time-series, archival |
267
+ | **List** | Categories, regions |
268
+ | **Hash** | Even distribution |
269
+
270
+ ### Connection Pooling
271
+
272
+ ```
273
+ Application → Connection Pooler → Database
274
+
275
+ Recommended: PgBouncer or pgcat for PostgreSQL
276
+
277
+ Pool sizing formula:
278
+ connections = (core_count * 2) + effective_spindle_count
279
+
280
+ For SSD: core_count * 2 + 1
281
+ For most apps: Start with 20-50, tune based on metrics
282
+ ```
283
+
284
+ ## Backup and Recovery
285
+
286
+ ### Backup Strategy (3-2-1 Rule)
287
+ - 3 copies of data
288
+ - 2 different storage media
289
+ - 1 offsite/cloud
290
+
291
+ ### PostgreSQL Backup Options
292
+
293
+ | Method | RPO | Use Case |
294
+ |--------|-----|----------|
295
+ | pg_dump | Point-in-time | Small DBs, schema backup |
296
+ | pg_basebackup | Point-in-time | Full cluster backup |
297
+ | WAL archiving | ~seconds | Continuous PITR |
298
+ | Streaming replication | ~seconds | HA + backup |
299
+ | Cloud snapshots | Minutes | Quick recovery |
300
+
301
+ ### Recovery Testing
302
+
303
+ ```markdown
304
+ ## Recovery Test Checklist
305
+
306
+ - [ ] Restore from backup to test environment
307
+ - [ ] Verify data integrity
308
+ - [ ] Test point-in-time recovery
309
+ - [ ] Document recovery time
310
+ - [ ] Update runbooks based on findings
311
+ - [ ] Schedule: Monthly for critical, quarterly for others
312
+ ```
313
+
314
+ ## NoSQL Patterns
315
+
316
+ ### Document Database (MongoDB-style)
317
+
318
+ ```javascript
319
+ // Embed when:
320
+ // - Data is queried together
321
+ // - One-to-few relationship
322
+ // - Child doesn't exist independently
323
+
324
+ // User with embedded addresses (good)
325
+ {
326
+ _id: "user_123",
327
+ name: "John",
328
+ addresses: [
329
+ { type: "home", street: "123 Main" },
330
+ { type: "work", street: "456 Office" }
331
+ ]
332
+ }
333
+
334
+ // Reference when:
335
+ // - Data is accessed independently
336
+ // - One-to-many/many-to-many
337
+ // - Frequent updates to child
338
+
339
+ // Order with referenced user (good)
340
+ {
341
+ _id: "order_456",
342
+ user_id: "user_123", // Reference
343
+ items: [...]
344
+ }
345
+ ```
346
+
347
+ ### Key-Value (Redis-style)
348
+
349
+ ```
350
+ # Common patterns
351
+
352
+ # Caching with TTL
353
+ SET user:123:profile "{...}" EX 3600
354
+
355
+ # Rate limiting
356
+ INCR api:user:123:requests
357
+ EXPIRE api:user:123:requests 60
358
+
359
+ # Session storage
360
+ HSET session:abc123 user_id 123 created_at "..."
361
+
362
+ # Leaderboard
363
+ ZADD leaderboard 1000 "user:123"
364
+ ZREVRANGE leaderboard 0 9 WITHSCORES
365
+ ```
366
+
367
+ ## Performance Monitoring
368
+
369
+ ### Key Metrics to Track
370
+
371
+ | Metric | Warning | Critical |
372
+ |--------|---------|----------|
373
+ | Query time (p95) | >100ms | >500ms |
374
+ | Connection pool usage | >70% | >90% |
375
+ | Replication lag | >1s | >10s |
376
+ | Cache hit ratio | <90% | <80% |
377
+ | Disk I/O wait | >20% | >50% |
378
+ | Table bloat | >20% | >50% |
379
+
380
+ ### Query Performance Tracking
381
+
382
+ ```sql
383
+ -- PostgreSQL: Find slow queries
384
+ SELECT
385
+ query,
386
+ calls,
387
+ mean_exec_time,
388
+ total_exec_time
389
+ FROM pg_stat_statements
390
+ ORDER BY mean_exec_time DESC
391
+ LIMIT 20;
392
+
393
+ -- Find missing indexes
394
+ SELECT
395
+ relname,
396
+ seq_scan,
397
+ seq_tup_read,
398
+ idx_scan
399
+ FROM pg_stat_user_tables
400
+ WHERE seq_scan > 0
401
+ ORDER BY seq_tup_read DESC;
402
+ ```
403
+
404
+ ## Anti-Patterns to Avoid
405
+
406
+ | Anti-Pattern | Better Approach |
407
+ |--------------|-----------------|
408
+ | SELECT * everywhere | Select only needed columns |
409
+ | No indexes on FK columns | Index all foreign keys |
410
+ | Storing JSON for relational data | Proper normalization |
411
+ | UUID v4 as clustered PK | UUIDv7/ULID or bigserial |
412
+ | N+1 queries | Batch fetching, joins |
413
+ | No connection pooling | PgBouncer or similar |
414
+ | Unbounded queries | Always use LIMIT |
415
+ | Ignoring query plans | Regular EXPLAIN ANALYZE |
416
+
417
+ ## Constraints
418
+
419
+ - Design for the current scale, plan for 10x
420
+ - Prefer boring, proven technology
421
+ - Always have tested backup/recovery procedures
422
+ - Document data models and access patterns
423
+ - Monitor and alert on database health metrics
424
+
425
+ ## Related Skills
426
+
427
+ - `backend-developer` - Application integration
428
+ - `devops-engineer` - Infrastructure and automation
429
+ - `data-engineer` - Data pipelines
430
+ - `sre-engineer` - Reliability and monitoring