owflow 0.1.0 → 0.1.2

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 (103) hide show
  1. package/README.md +8 -1
  2. package/dist/agents/bottleneck-analyzer.md +329 -0
  3. package/dist/agents/code-quality-pragmatist.md +354 -0
  4. package/dist/agents/code-reviewer.md +239 -0
  5. package/dist/agents/codebase-analysis-reporter.md +246 -0
  6. package/dist/agents/docs-operator.md +23 -0
  7. package/dist/agents/e2e-test-verifier.md +448 -0
  8. package/dist/agents/gap-analyzer.md +502 -0
  9. package/dist/agents/implementation-completeness-checker.md +220 -0
  10. package/dist/agents/implementation-planner.md +309 -0
  11. package/dist/agents/information-gatherer.md +691 -0
  12. package/dist/agents/production-readiness-checker.md +279 -0
  13. package/dist/agents/project-analyzer.md +404 -0
  14. package/dist/agents/reality-assessor.md +366 -0
  15. package/dist/agents/research-planner.md +447 -0
  16. package/dist/agents/research-synthesizer.md +401 -0
  17. package/dist/agents/solution-brainstormer.md +257 -0
  18. package/dist/agents/solution-designer.md +372 -0
  19. package/dist/agents/spec-auditor.md +298 -0
  20. package/dist/agents/specification-creator.md +334 -0
  21. package/dist/agents/task-classifier.md +462 -0
  22. package/dist/agents/task-group-implementer.md +284 -0
  23. package/dist/agents/test-suite-runner.md +195 -0
  24. package/dist/agents/ui-mockup-generator.md +369 -0
  25. package/dist/agents/user-docs-generator.md +509 -0
  26. package/dist/commands/development.md +37 -0
  27. package/dist/commands/flow-init.md +37 -0
  28. package/dist/commands/migration.md +37 -0
  29. package/dist/commands/performance.md +37 -0
  30. package/dist/commands/product-design.md +37 -0
  31. package/dist/commands/quick-bugfix.md +37 -0
  32. package/dist/commands/quick-dev.md +140 -0
  33. package/dist/commands/quick-plan.md +132 -0
  34. package/dist/commands/research.md +37 -0
  35. package/dist/commands/reviews-code.md +90 -0
  36. package/dist/commands/reviews-pragmatic.md +99 -0
  37. package/dist/commands/reviews-production-readiness.md +113 -0
  38. package/dist/commands/reviews-reality-check.md +110 -0
  39. package/dist/commands/reviews-spec-audit.md +114 -0
  40. package/dist/commands/standards-discover.md +37 -0
  41. package/dist/commands/standards-update.md +37 -0
  42. package/dist/commands/work.md +284 -0
  43. package/dist/skills/codebase-analyzer/SKILL.md +162 -0
  44. package/dist/skills/codebase-analyzer/references/code-analysis.md +63 -0
  45. package/dist/skills/codebase-analyzer/references/combined.md +31 -0
  46. package/dist/skills/codebase-analyzer/references/context-discovery.md +63 -0
  47. package/dist/skills/codebase-analyzer/references/file-discovery.md +51 -0
  48. package/dist/skills/codebase-analyzer/references/migration-target.md +23 -0
  49. package/dist/skills/codebase-analyzer/references/pattern-mining.md +22 -0
  50. package/dist/skills/development/SKILL.md +669 -0
  51. package/dist/skills/docs-manager/SKILL.md +379 -0
  52. package/dist/skills/docs-manager/docs/INDEX.md +199 -0
  53. package/dist/skills/docs-manager/docs/standards/backend/api.md +25 -0
  54. package/dist/skills/docs-manager/docs/standards/backend/migrations.md +22 -0
  55. package/dist/skills/docs-manager/docs/standards/backend/models.md +25 -0
  56. package/dist/skills/docs-manager/docs/standards/backend/queries.md +22 -0
  57. package/dist/skills/docs-manager/docs/standards/frontend/accessibility.md +25 -0
  58. package/dist/skills/docs-manager/docs/standards/frontend/components.md +28 -0
  59. package/dist/skills/docs-manager/docs/standards/frontend/css.md +16 -0
  60. package/dist/skills/docs-manager/docs/standards/frontend/responsive.md +28 -0
  61. package/dist/skills/docs-manager/docs/standards/global/coding-style.md +25 -0
  62. package/dist/skills/docs-manager/docs/standards/global/commenting.md +10 -0
  63. package/dist/skills/docs-manager/docs/standards/global/conventions.md +31 -0
  64. package/dist/skills/docs-manager/docs/standards/global/error-handling.md +22 -0
  65. package/dist/skills/docs-manager/docs/standards/global/minimal-implementation.md +22 -0
  66. package/dist/skills/docs-manager/docs/standards/global/validation.md +28 -0
  67. package/dist/skills/docs-manager/docs/standards/testing/test-writing.md +25 -0
  68. package/dist/skills/docs-manager/references/claude-md-template.md +29 -0
  69. package/dist/skills/docs-manager/references/index-md-template.md +73 -0
  70. package/dist/skills/flow-init/SKILL.md +198 -0
  71. package/dist/skills/flow-init/references/architecture-template.md +45 -0
  72. package/dist/skills/flow-init/references/roadmap-templates.md +93 -0
  73. package/dist/skills/flow-init/references/tech-stack-template.md +70 -0
  74. package/dist/skills/flow-init/references/vision-templates.md +75 -0
  75. package/dist/skills/implementation-plan-executor/SKILL.md +378 -0
  76. package/dist/skills/implementation-verifier/SKILL.md +307 -0
  77. package/dist/skills/migration/SKILL.md +380 -0
  78. package/dist/skills/migration/references/migration-strategies.md +397 -0
  79. package/dist/skills/migration/references/migration-types.md +437 -0
  80. package/dist/skills/orchestrator-framework/SKILL.md +65 -0
  81. package/dist/skills/orchestrator-framework/references/orchestrator-creation-checklist.md +47 -0
  82. package/dist/skills/orchestrator-framework/references/orchestrator-patterns.md +329 -0
  83. package/dist/skills/performance/SKILL.md +418 -0
  84. package/dist/skills/performance/references/performance-optimization-guide.md +365 -0
  85. package/dist/skills/product-design/SKILL.md +843 -0
  86. package/dist/skills/product-design/references/characteristic-detection.md +92 -0
  87. package/dist/skills/product-design/references/interaction-patterns.md +206 -0
  88. package/dist/skills/product-design/references/visual-companion.md +190 -0
  89. package/dist/skills/product-design/server/index.ts +359 -0
  90. package/dist/skills/product-design/server/template.html +256 -0
  91. package/dist/skills/quick-bugfix/SKILL.md +241 -0
  92. package/dist/skills/research/SKILL.md +493 -0
  93. package/dist/skills/research/references/brainstorming-techniques.md +84 -0
  94. package/dist/skills/research/references/design-techniques.md +40 -0
  95. package/dist/skills/research/references/research-methodologies.md +710 -0
  96. package/dist/skills/standards-discover/SKILL.md +236 -0
  97. package/dist/skills/standards-discover/references/aggregation-strategy.md +76 -0
  98. package/dist/skills/standards-discover/references/code-pattern-prompt.md +68 -0
  99. package/dist/skills/standards-discover/references/config-analyzer-prompt.md +67 -0
  100. package/dist/skills/standards-discover/references/docs-extractor-prompt.md +65 -0
  101. package/dist/skills/standards-discover/references/external-analyzer-prompt.md +75 -0
  102. package/dist/skills/standards-update/SKILL.md +159 -0
  103. package/package.json +14 -6
@@ -0,0 +1,365 @@
1
+ # Performance Optimization Guide
2
+
3
+ Reference covering performance metrics knowledge, optimization patterns, and static analysis detection strategies.
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Performance Metrics](#performance-metrics)
8
+ 2. [Optimization Patterns](#optimization-patterns)
9
+ 3. [Static Analysis Detection Patterns](#static-analysis-detection-patterns)
10
+
11
+ ---
12
+
13
+ # Performance Metrics
14
+
15
+ ## Response Time Metrics
16
+
17
+ **p50 (Median)**: 50% of requests faster than this value
18
+ **p95**: 95% of requests faster (typical SLA target)
19
+ **p99**: 99% of requests faster (worst-case for most users)
20
+ **Max**: Slowest request (often outlier, less important)
21
+
22
+ **Interpretation Thresholds**:
23
+ - p95 < 100ms: Excellent
24
+ - p95 100-500ms: Good
25
+ - p95 500-1000ms: Acceptable
26
+ - p95 > 1000ms: Slow (optimization needed)
27
+
28
+ ## Throughput Metrics
29
+
30
+ **Requests/sec**: Total requests handled per second
31
+ **Transactions/sec**: Completed transactions per second
32
+ **Saturation Point**: Concurrency level where throughput plateaus
33
+
34
+ ## CPU Metrics
35
+
36
+ **Usage %**: Overall CPU utilization
37
+ **Hot Functions**: Top functions by CPU time
38
+ **Complexity**: O(n), O(n log n), O(n^2), etc.
39
+
40
+ **Thresholds**:
41
+ - < 70%: Good headroom
42
+ - 70-90%: Acceptable
43
+ - \> 90%: Saturated
44
+
45
+ ## Memory Metrics
46
+
47
+ **Heap Size**: Current memory usage
48
+ **Heap Growth**: Memory increase over time (leak indicator)
49
+ **GC Frequency**: Garbage collection frequency
50
+
51
+ **Leak Detection**: Heap grows continuously without plateau
52
+
53
+ ## Database Metrics
54
+
55
+ **Queries/Request**: Total database queries per request
56
+ **Query Time**: Time spent in database
57
+ **N+1 Pattern**: 1 query + N related queries in loop
58
+ **Missing Indexes**: Full table scans
59
+
60
+ ---
61
+
62
+ # Optimization Patterns
63
+
64
+ ## Database Optimizations
65
+
66
+ ### Fix N+1 Queries
67
+
68
+ **Problem**: 1 query to fetch list + N queries for related data
69
+
70
+ **Bad** (N+1 pattern):
71
+ ```javascript
72
+ const users = await User.findAll(); // 1 query
73
+ for (let user of users) {
74
+ user.profile = await Profile.findByPk(user.id); // N queries
75
+ }
76
+ ```
77
+
78
+ **Good** (eager loading):
79
+ ```javascript
80
+ const users = await User.findAll({
81
+ include: [{ model: Profile }] // Single JOIN query
82
+ });
83
+ ```
84
+
85
+ ### Add Missing Indexes
86
+
87
+ **Detection**: Query filters/sorts on unindexed columns
88
+
89
+ ```sql
90
+ -- Before (slow - sequential scan)
91
+ SELECT * FROM orders WHERE user_id = 123;
92
+
93
+ -- Add index
94
+ CREATE INDEX CONCURRENTLY idx_orders_user_id ON orders(user_id);
95
+
96
+ -- After (fast - index scan)
97
+ ```
98
+
99
+ ### Connection Pooling
100
+
101
+ ```javascript
102
+ // Bad: New connection per query
103
+ const connection = await mysql.createConnection(config);
104
+
105
+ // Good: Connection pool
106
+ const pool = mysql.createPool({
107
+ connectionLimit: 10,
108
+ ...config
109
+ });
110
+ ```
111
+
112
+ ## Algorithm Optimizations
113
+
114
+ ### Replace O(n^2) with O(n)
115
+
116
+ **Bad** (nested loops):
117
+ ```javascript
118
+ // O(n^2)
119
+ for (let user of users) {
120
+ for (let order of orders) {
121
+ if (order.userId === user.id) {
122
+ user.orders.push(order);
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ **Good** (hash map):
129
+ ```javascript
130
+ // O(n)
131
+ const ordersByUser = {};
132
+ for (let order of orders) {
133
+ if (!ordersByUser[order.userId]) ordersByUser[order.userId] = [];
134
+ ordersByUser[order.userId].push(order);
135
+ }
136
+ for (let user of users) {
137
+ user.orders = ordersByUser[user.id] || [];
138
+ }
139
+ ```
140
+
141
+ ### Memoization
142
+
143
+ **Bad** (repeated calculations):
144
+ ```javascript
145
+ function fibonacci(n) {
146
+ if (n <= 1) return n;
147
+ return fibonacci(n - 1) + fibonacci(n - 2); // Exponential time
148
+ }
149
+ ```
150
+
151
+ **Good** (memoized):
152
+ ```javascript
153
+ const memo = {};
154
+ function fibonacci(n) {
155
+ if (n <= 1) return n;
156
+ if (memo[n]) return memo[n];
157
+ memo[n] = fibonacci(n - 1) + fibonacci(n - 2);
158
+ return memo[n];
159
+ }
160
+ ```
161
+
162
+ ## Caching Strategies
163
+
164
+ ### Cache Expensive Operations
165
+
166
+ ```javascript
167
+ // Bad: Calculate every time
168
+ app.get('/stats', async (req, res) => {
169
+ const stats = await calculateExpensiveStats(); // 5 seconds
170
+ res.json(stats);
171
+ });
172
+
173
+ // Good: Cache results
174
+ const cache = new Map();
175
+ app.get('/stats', async (req, res) => {
176
+ let stats = cache.get('stats');
177
+ if (!stats) {
178
+ stats = await calculateExpensiveStats();
179
+ cache.set('stats', stats);
180
+ setTimeout(() => cache.delete('stats'), 60000); // TTL: 1 min
181
+ }
182
+ res.json(stats);
183
+ });
184
+ ```
185
+
186
+ ### Redis Caching
187
+
188
+ ```javascript
189
+ const redis = require('redis');
190
+ const client = redis.createClient();
191
+
192
+ // Cache expensive query
193
+ async function getUser(id) {
194
+ const cached = await client.get(`user:${id}`);
195
+ if (cached) return JSON.parse(cached);
196
+
197
+ const user = await db.query('SELECT * FROM users WHERE id = ?', [id]);
198
+ await client.setex(`user:${id}`, 3600, JSON.stringify(user)); // TTL: 1 hour
199
+ return user;
200
+ }
201
+ ```
202
+
203
+ ## I/O Optimizations
204
+
205
+ ### Async vs Sync
206
+
207
+ **Bad** (blocking):
208
+ ```javascript
209
+ const data = fs.readFileSync('large-file.json'); // Blocks event loop
210
+ ```
211
+
212
+ **Good** (non-blocking):
213
+ ```javascript
214
+ const data = await fs.promises.readFile('large-file.json'); // Async
215
+ ```
216
+
217
+ ### Parallel API Calls
218
+
219
+ **Bad** (sequential):
220
+ ```javascript
221
+ const user = await fetchUser(id); // 200ms
222
+ const orders = await fetchOrders(id); // 200ms
223
+ const profile = await fetchProfile(id); // 200ms
224
+ // Total: 600ms
225
+ ```
226
+
227
+ **Good** (parallel):
228
+ ```javascript
229
+ const [user, orders, profile] = await Promise.all([
230
+ fetchUser(id),
231
+ fetchOrders(id),
232
+ fetchProfile(id)
233
+ ]);
234
+ // Total: 200ms (slowest of the three)
235
+ ```
236
+
237
+ ## Memory Optimizations
238
+
239
+ ### Streaming Large Data
240
+
241
+ **Bad** (load all):
242
+ ```javascript
243
+ const data = await fs.promises.readFile('large-file.csv'); // 1GB in memory
244
+ processCSV(data);
245
+ ```
246
+
247
+ **Good** (stream):
248
+ ```javascript
249
+ const stream = fs.createReadStream('large-file.csv');
250
+ stream.pipe(csvParser()).on('data', processRow); // Constant memory
251
+ ```
252
+
253
+ ### Object Pooling
254
+
255
+ ```javascript
256
+ // Bad: Create new objects constantly
257
+ for (let i = 0; i < 1000000; i++) {
258
+ const obj = { x: i, y: i * 2 }; // 1M allocations
259
+ process(obj);
260
+ }
261
+
262
+ // Good: Reuse objects
263
+ const pool = { x: 0, y: 0 };
264
+ for (let i = 0; i < 1000000; i++) {
265
+ pool.x = i;
266
+ pool.y = i * 2; // 1 allocation, reused
267
+ process(pool);
268
+ }
269
+ ```
270
+
271
+ ---
272
+
273
+ # Static Analysis Detection Patterns
274
+
275
+ Strategies for detecting performance bottlenecks by reading code rather than running profiling tools.
276
+
277
+ ## Database Pattern Detection
278
+
279
+ ### N+1 Query Detection by Framework
280
+
281
+ **Generic ORM-in-loop patterns** (Grep heuristics):
282
+ - Query call inside `for`/`forEach`/`map`/`while` body
283
+ - `await` + model method inside iteration callback
284
+ - Lazy-loaded relationship access inside loop
285
+
286
+ **Framework-specific indicators**:
287
+
288
+ | Framework | N+1 Pattern | Fix Pattern |
289
+ |-----------|-------------|-------------|
290
+ | Sequelize | `.findByPk()`/`.findOne()` in loop | `include: [{ model: X }]` |
291
+ | Prisma | `prisma.x.findUnique()` in loop | `include: { x: true }` |
292
+ | TypeORM | `repository.findOne()` in loop | `relations: ['x']` or QueryBuilder `.leftJoinAndSelect()` |
293
+ | Django | Attribute access in template `{% for %}` | `.select_related()`/`.prefetch_related()` |
294
+ | Rails | Association call without `.includes()` | `.includes(:association)` |
295
+ | SQLAlchemy | Relationship access in loop | `joinedload()`/`subqueryload()` |
296
+ | Hibernate | `@ManyToOne` lazy access in loop | `@Fetch(FetchMode.JOIN)` or JPQL `JOIN FETCH` |
297
+
298
+ ### Missing Index Detection
299
+
300
+ **Cross-reference strategy**:
301
+ 1. Find all index definitions in schema/migration files
302
+ 2. Find all query patterns (WHERE, ORDER BY, JOIN columns)
303
+ 3. Flag columns queried but not indexed
304
+
305
+ **Where to find indexes by framework**:
306
+ - **Rails**: `add_index` in `db/migrate/` files
307
+ - **Django**: `db_index=True` in model fields, `indexes` in Meta
308
+ - **Sequelize**: `indexes` array in model definition
309
+ - **Prisma**: `@@index` and `@@unique` in schema.prisma
310
+ - **TypeORM**: `@Index()` decorator
311
+ - **SQL migrations**: `CREATE INDEX` statements
312
+
313
+ ### Slow Query Pattern Indicators
314
+
315
+ Patterns detectable from code without running queries:
316
+ - `SELECT *` on tables with many columns
317
+ - Missing `LIMIT`/`TOP` on queries against known-large tables
318
+ - `LIKE '%...'` (leading wildcard prevents index use)
319
+ - `OR` conditions on different columns (prevents single index use)
320
+ - Subqueries in WHERE that could be JOINs
321
+ - `DISTINCT` masking a JOIN issue
322
+
323
+ ## Algorithm Pattern Detection
324
+
325
+ ### Nested Loop / O(n^2) Heuristics
326
+
327
+ **Search patterns**:
328
+ - Nested `for`/`forEach`/`while` loops over same or related collections
329
+ - `.find()`/`.filter()`/`.some()`/`.includes()` inside `.map()`/`.forEach()`/`for`
330
+ - `.indexOf()` inside loop (linear search repeated)
331
+ - `.sort()` inside loop (O(n log n) per iteration)
332
+
333
+ **Fix indicators**: Can be resolved by pre-building a Map/Set/index before the loop
334
+
335
+ ### Blocking I/O Patterns
336
+
337
+ **Node.js sync operations**:
338
+ - `readFileSync`, `writeFileSync`, `readdirSync`, `statSync`, `existsSync`
339
+ - `execSync`, `spawnSync`
340
+ - `crypto.pbkdf2Sync`, `crypto.randomBytesSync`
341
+
342
+ **Sequential awaits** (should be `Promise.all`):
343
+ - Multiple `await` statements on independent operations in same function
344
+ - Sequential HTTP/fetch calls to different endpoints
345
+ - Sequential database queries with no data dependency between them
346
+
347
+ ## Memory Pattern Detection
348
+
349
+ **Unbounded growth indicators**:
350
+ - `Map`/`Set`/`Object`/`Array` in module or class scope with `.set()`/`push()` but no `.delete()`/eviction
351
+ - No size limit check before adding to collection
352
+ - No TTL or expiration mechanism
353
+
354
+ **Leak-prone patterns**:
355
+ - `addEventListener`/`.on()` without paired `removeEventListener`/`.off()`
356
+ - `setInterval` without `clearInterval` in cleanup/destroy/unmount
357
+ - Closures in long-lived callbacks capturing large objects
358
+
359
+ ## Caching Opportunity Detection
360
+
361
+ **Indicators**:
362
+ - Same query/function called multiple times with same parameters in a request lifecycle
363
+ - Database query in a loop that could be batched and cached
364
+ - External API call returning reference/config data (infrequent changes)
365
+ - Expensive computation (sort, aggregate, transform) on data that doesn't change per-request