@smicolon/ai-kit 0.3.2 → 0.4.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.
Files changed (155) hide show
  1. package/README.md +73 -40
  2. package/dist/index.js +312 -127
  3. package/package.json +5 -5
  4. package/.claude-plugin/marketplace.json +0 -369
  5. package/packs/architect/CHANGELOG.md +0 -17
  6. package/packs/architect/README.md +0 -58
  7. package/packs/architect/agents/system-architect.md +0 -768
  8. package/packs/architect/commands/diagram-create.md +0 -300
  9. package/packs/better-auth/.mcp.json +0 -14
  10. package/packs/better-auth/CHANGELOG.md +0 -26
  11. package/packs/better-auth/README.md +0 -125
  12. package/packs/better-auth/agents/auth-architect.md +0 -278
  13. package/packs/better-auth/commands/auth-provider-add.md +0 -265
  14. package/packs/better-auth/commands/auth-setup.md +0 -298
  15. package/packs/better-auth/skills/auth-security/SKILL.md +0 -425
  16. package/packs/better-auth/skills/better-auth-patterns/SKILL.md +0 -455
  17. package/packs/dev-loop/CHANGELOG.md +0 -69
  18. package/packs/dev-loop/README.md +0 -155
  19. package/packs/dev-loop/commands/cancel-dev.md +0 -21
  20. package/packs/dev-loop/commands/dev-loop.md +0 -72
  21. package/packs/dev-loop/commands/dev-plan.md +0 -351
  22. package/packs/dev-loop/hooks/hooks.json +0 -15
  23. package/packs/dev-loop/hooks/stop-hook.sh +0 -178
  24. package/packs/dev-loop/scripts/setup-dev-loop.sh +0 -194
  25. package/packs/dev-loop/skills/tdd-planner/SKILL.md +0 -249
  26. package/packs/dev-loop/skills/tdd-planner/references/framework-patterns.md +0 -874
  27. package/packs/dev-loop/skills/tdd-planner/references/good-example.md +0 -260
  28. package/packs/dev-loop/skills/tdd-planner/references/plan-template.md +0 -275
  29. package/packs/django/CHANGELOG.md +0 -39
  30. package/packs/django/README.md +0 -92
  31. package/packs/django/agents/django-architect.md +0 -182
  32. package/packs/django/agents/django-builder.md +0 -250
  33. package/packs/django/agents/django-feature-based.md +0 -420
  34. package/packs/django/agents/django-reviewer.md +0 -253
  35. package/packs/django/agents/django-tester.md +0 -230
  36. package/packs/django/commands/api-endpoint.md +0 -285
  37. package/packs/django/commands/model-create.md +0 -178
  38. package/packs/django/commands/test-generate.md +0 -325
  39. package/packs/django/rules/migrations.md +0 -138
  40. package/packs/django/rules/models.md +0 -167
  41. package/packs/django/rules/serializers.md +0 -126
  42. package/packs/django/rules/services.md +0 -131
  43. package/packs/django/rules/tests.md +0 -140
  44. package/packs/django/rules/views.md +0 -102
  45. package/packs/django/skills/import-convention-enforcer/SKILL.md +0 -226
  46. package/packs/django/skills/import-convention-enforcer/patterns/django-imports.md +0 -343
  47. package/packs/django/skills/migration-safety-checker/SKILL.md +0 -375
  48. package/packs/django/skills/model-entity-validator/SKILL.md +0 -298
  49. package/packs/django/skills/performance-optimizer/SKILL.md +0 -447
  50. package/packs/django/skills/red-phase-verifier/SKILL.md +0 -180
  51. package/packs/django/skills/security-first-validator/SKILL.md +0 -435
  52. package/packs/django/skills/test-coverage-advisor/SKILL.md +0 -394
  53. package/packs/django/skills/test-validity-checker/SKILL.md +0 -194
  54. package/packs/failure-log/CHANGELOG.md +0 -20
  55. package/packs/failure-log/README.md +0 -168
  56. package/packs/failure-log/commands/failure-add.md +0 -106
  57. package/packs/failure-log/commands/failure-list.md +0 -89
  58. package/packs/failure-log/hooks/hooks.json +0 -16
  59. package/packs/failure-log/hooks/scripts/inject-failures.sh +0 -64
  60. package/packs/failure-log/skills/failure-log-manager/SKILL.md +0 -164
  61. package/packs/flutter/CHANGELOG.md +0 -19
  62. package/packs/flutter/README.md +0 -170
  63. package/packs/flutter/agents/flutter-architect.md +0 -166
  64. package/packs/flutter/agents/flutter-builder.md +0 -303
  65. package/packs/flutter/agents/release-manager.md +0 -355
  66. package/packs/flutter/commands/fastlane-setup.md +0 -188
  67. package/packs/flutter/commands/flutter-build.md +0 -90
  68. package/packs/flutter/commands/flutter-deploy.md +0 -133
  69. package/packs/flutter/commands/flutter-test.md +0 -117
  70. package/packs/flutter/commands/signing-setup.md +0 -209
  71. package/packs/flutter/hooks/hooks.json +0 -17
  72. package/packs/flutter/skills/fastlane-knowledge/SKILL.md +0 -193
  73. package/packs/flutter/skills/flutter-architecture/SKILL.md +0 -127
  74. package/packs/flutter/skills/store-publishing/SKILL.md +0 -163
  75. package/packs/hono/CHANGELOG.md +0 -19
  76. package/packs/hono/README.md +0 -143
  77. package/packs/hono/agents/hono-architect.md +0 -240
  78. package/packs/hono/agents/hono-builder.md +0 -285
  79. package/packs/hono/agents/hono-reviewer.md +0 -279
  80. package/packs/hono/agents/hono-tester.md +0 -346
  81. package/packs/hono/commands/middleware-create.md +0 -223
  82. package/packs/hono/commands/project-init.md +0 -306
  83. package/packs/hono/commands/route-create.md +0 -153
  84. package/packs/hono/commands/rpc-client.md +0 -263
  85. package/packs/hono/skills/cloudflare-bindings/SKILL.md +0 -408
  86. package/packs/hono/skills/hono-patterns/SKILL.md +0 -309
  87. package/packs/hono/skills/rpc-typesafe/SKILL.md +0 -388
  88. package/packs/hono/skills/zod-validation/SKILL.md +0 -332
  89. package/packs/nestjs/CHANGELOG.md +0 -29
  90. package/packs/nestjs/README.md +0 -75
  91. package/packs/nestjs/agents/nestjs-architect.md +0 -402
  92. package/packs/nestjs/agents/nestjs-builder.md +0 -301
  93. package/packs/nestjs/agents/nestjs-tester.md +0 -437
  94. package/packs/nestjs/commands/module-create.md +0 -369
  95. package/packs/nestjs/rules/controllers.md +0 -92
  96. package/packs/nestjs/rules/dto.md +0 -124
  97. package/packs/nestjs/rules/entities.md +0 -102
  98. package/packs/nestjs/rules/services.md +0 -106
  99. package/packs/nestjs/skills/barrel-export-manager/SKILL.md +0 -389
  100. package/packs/nestjs/skills/import-convention-enforcer/SKILL.md +0 -365
  101. package/packs/nextjs/CHANGELOG.md +0 -36
  102. package/packs/nextjs/README.md +0 -76
  103. package/packs/nextjs/agents/frontend-tester.md +0 -680
  104. package/packs/nextjs/agents/frontend-visual.md +0 -820
  105. package/packs/nextjs/agents/nextjs-architect.md +0 -331
  106. package/packs/nextjs/agents/nextjs-modular.md +0 -433
  107. package/packs/nextjs/commands/component-create.md +0 -398
  108. package/packs/nextjs/rules/api-routes.md +0 -129
  109. package/packs/nextjs/rules/components.md +0 -106
  110. package/packs/nextjs/rules/hooks.md +0 -132
  111. package/packs/nextjs/skills/accessibility-validator/SKILL.md +0 -445
  112. package/packs/nextjs/skills/import-convention-enforcer/SKILL.md +0 -399
  113. package/packs/nextjs/skills/react-form-validator/SKILL.md +0 -569
  114. package/packs/nuxtjs/CHANGELOG.md +0 -30
  115. package/packs/nuxtjs/README.md +0 -56
  116. package/packs/nuxtjs/agents/frontend-tester.md +0 -680
  117. package/packs/nuxtjs/agents/frontend-visual.md +0 -820
  118. package/packs/nuxtjs/agents/nuxtjs-architect.md +0 -537
  119. package/packs/nuxtjs/commands/component-create.md +0 -223
  120. package/packs/nuxtjs/rules/components.md +0 -101
  121. package/packs/nuxtjs/rules/composables.md +0 -118
  122. package/packs/nuxtjs/rules/server-routes.md +0 -127
  123. package/packs/nuxtjs/skills/accessibility-validator/SKILL.md +0 -183
  124. package/packs/nuxtjs/skills/import-convention-enforcer/SKILL.md +0 -196
  125. package/packs/nuxtjs/skills/veevalidate-form-validator/SKILL.md +0 -190
  126. package/packs/onboard/CHANGELOG.md +0 -22
  127. package/packs/onboard/README.md +0 -103
  128. package/packs/onboard/agents/onboard-guide.md +0 -118
  129. package/packs/onboard/commands/onboard.md +0 -313
  130. package/packs/onboard/skills/onboard-context-provider/SKILL.md +0 -98
  131. package/packs/tanstack-router/CHANGELOG.md +0 -30
  132. package/packs/tanstack-router/README.md +0 -113
  133. package/packs/tanstack-router/agents/tanstack-architect.md +0 -173
  134. package/packs/tanstack-router/agents/tanstack-builder.md +0 -360
  135. package/packs/tanstack-router/agents/tanstack-tester.md +0 -454
  136. package/packs/tanstack-router/commands/form-create.md +0 -313
  137. package/packs/tanstack-router/commands/query-create.md +0 -263
  138. package/packs/tanstack-router/commands/route-create.md +0 -190
  139. package/packs/tanstack-router/commands/table-create.md +0 -413
  140. package/packs/tanstack-router/skills/ai-patterns/SKILL.md +0 -370
  141. package/packs/tanstack-router/skills/db-patterns/SKILL.md +0 -346
  142. package/packs/tanstack-router/skills/devtools-patterns/SKILL.md +0 -415
  143. package/packs/tanstack-router/skills/form-patterns/SKILL.md +0 -425
  144. package/packs/tanstack-router/skills/pacer-patterns/SKILL.md +0 -341
  145. package/packs/tanstack-router/skills/query-patterns/SKILL.md +0 -359
  146. package/packs/tanstack-router/skills/router-patterns/SKILL.md +0 -285
  147. package/packs/tanstack-router/skills/store-patterns/SKILL.md +0 -351
  148. package/packs/tanstack-router/skills/table-patterns/SKILL.md +0 -531
  149. package/packs/tanstack-router/skills/tanstack-conventions/SKILL.md +0 -428
  150. package/packs/tanstack-router/skills/virtual-patterns/SKILL.md +0 -490
  151. package/packs/worktree/CHANGELOG.md +0 -45
  152. package/packs/worktree/README.md +0 -219
  153. package/packs/worktree/commands/wt.md +0 -93
  154. package/packs/worktree/scripts/wt.sh +0 -957
  155. package/packs/worktree/skills/worktree-manager/SKILL.md +0 -113
@@ -1,447 +0,0 @@
1
- ---
2
- name: performance-optimizer
3
- description: This skill should be used when the user asks to "optimize queries", "fix slow queries", "improve performance", "detect N+1", "add indexes", or when writing Django ORM queries that access related objects. Detects and fixes performance issues.
4
- ---
5
-
6
- # Performance Optimizer
7
-
8
- Auto-detects and fixes Django ORM performance issues before they reach production.
9
-
10
- ## Activation Triggers
11
-
12
- This skill activates when:
13
- - Writing ORM queries
14
- - Accessing related objects (foreign keys, M2M)
15
- - Creating views that fetch data
16
- - Mentioning "slow", "performance", "optimization"
17
- - Looping over querysets
18
- - Creating list/detail views
19
-
20
- ## Performance Targets
21
-
22
- - ✅ NO N+1 queries
23
- - ✅ Appropriate indexes on frequently queried fields
24
- - ✅ Pagination for list endpoints
25
- - ✅ `select_related()` for foreign keys
26
- - ✅ `prefetch_related()` for reverse foreign keys and M2M
27
- - ✅ Caching for expensive operations
28
-
29
- ## Auto-Detection Patterns
30
-
31
- ### Pattern 1: N+1 Query Detection
32
-
33
- **❌ INEFFICIENT (N+1 query):**
34
- ```python
35
- # Bad: 1 query for users + N queries for organizations
36
- users = User.objects.all() # 1 query
37
- for user in users: # N queries
38
- print(user.organization.name) # Hits DB each time!
39
- ```
40
-
41
- **✅ OPTIMIZED:**
42
- ```python
43
- # Good: 2 queries total (1 for users + 1 JOIN for organizations)
44
- users = User.objects.select_related('organization').all()
45
- for user in users:
46
- print(user.organization.name) # No DB hit!
47
- ```
48
-
49
- ### Pattern 2: Reverse Foreign Key N+1
50
-
51
- **❌ INEFFICIENT:**
52
- ```python
53
- # Bad: 1 + N queries
54
- organizations = Organization.objects.all() # 1 query
55
- for org in organizations: # N queries
56
- users = org.users.all() # Hits DB each time!
57
- print(f"{org.name}: {users.count()} users")
58
- ```
59
-
60
- **✅ OPTIMIZED:**
61
- ```python
62
- # Good: 2 queries total
63
- organizations = Organization.objects.prefetch_related('users').all()
64
- for org in organizations:
65
- users = org.users.all() # Pre-fetched!
66
- print(f"{org.name}: {users.count()} users")
67
- ```
68
-
69
- ### Pattern 3: Many-to-Many N+1
70
-
71
- **❌ INEFFICIENT:**
72
- ```python
73
- # Bad: 1 + N queries
74
- users = User.objects.all() # 1 query
75
- for user in users: # N queries
76
- roles = user.roles.all() # Hits DB each time!
77
- ```
78
-
79
- **✅ OPTIMIZED:**
80
- ```python
81
- # Good: 2 queries total
82
- users = User.objects.prefetch_related('roles').all()
83
- for user in users:
84
- roles = user.roles.all() # Pre-fetched!
85
- ```
86
-
87
- ### Pattern 4: Missing Indexes
88
-
89
- **❌ SLOW:**
90
- ```python
91
- # Frequent query without index
92
- User.objects.filter(email='test@example.com') # Table scan if no index!
93
- ```
94
-
95
- **✅ FAST:**
96
- ```python
97
- # Model with index
98
- class User(models.Model):
99
- email = models.EmailField(unique=True) # Unique creates index
100
- # OR
101
- class Meta:
102
- indexes = [
103
- models.Index(fields=['email']), # Explicit index
104
- ]
105
- ```
106
-
107
- ### Pattern 5: Missing Pagination
108
-
109
- **❌ DANGEROUS:**
110
- ```python
111
- # Returns ALL records - memory issues with large tables
112
- class UserViewSet(viewsets.ModelViewSet):
113
- queryset = User.objects.all() # No pagination!
114
- ```
115
-
116
- **✅ SAFE:**
117
- ```python
118
- # Paginated automatically
119
- class UserViewSet(viewsets.ModelViewSet):
120
- queryset = User.objects.all()
121
- pagination_class = PageNumberPagination # DRF auto-paginates
122
- ```
123
-
124
- ## Auto-Fix Process
125
-
126
- ### Step 1: Detect Anti-Pattern
127
-
128
- When detecting:
129
- ```python
130
- def get_users_with_organizations(self):
131
- users = User.objects.all()
132
- return [
133
- {'user': u.email, 'org': u.organization.name}
134
- for u in users
135
- ]
136
- ```
137
-
138
- ### Step 2: Analyze Query Pattern
139
-
140
- Identify:
141
- - Queryset: `User.objects.all()` (1 query)
142
- - Foreign key access: `u.organization.name` (N queries)
143
- - **Total:** 1 + N queries = N+1 problem!
144
-
145
- ### Step 3: Suggest Optimization
146
-
147
- Provide:
148
-
149
- > **N+1 Query Detected!**
150
- >
151
- > **Problem:**
152
- > - Query: `User.objects.all()` → 1 query
153
- > - Loop accesses `user.organization.name` → N queries
154
- > - **Total:** 1 + N queries (inefficient!)
155
- >
156
- > **Impact:**
157
- > - 100 users = 101 queries 😱
158
- > - 1000 users = 1001 queries 🔥
159
- >
160
- > **Fix:**
161
- > ```python
162
- > users = User.objects.select_related('organization').all()
163
- > # Now only 2 queries total!
164
- > ```
165
- >
166
- > **Why:**
167
- > - `select_related()` performs SQL JOIN
168
- > - Fetches related data in single query
169
- > - 500x faster for 1000 records!
170
-
171
- ### Step 4: Auto-Apply Fix
172
-
173
- ```python
174
- # Optimized version
175
- def get_users_with_organizations(self):
176
- users = User.objects.select_related('organization').all()
177
- return [
178
- {'user': u.email, 'org': u.organization.name} # No DB hit!
179
- for u in users
180
- ]
181
- ```
182
-
183
- ## Common Optimization Patterns
184
-
185
- ### Foreign Key (One-to-One, Many-to-One)
186
-
187
- ```python
188
- # Use select_related() for foreign keys
189
- User.objects.select_related('organization', 'created_by')
190
-
191
- # Multiple levels
192
- User.objects.select_related('organization__country')
193
- ```
194
-
195
- ### Reverse Foreign Key (One-to-Many)
196
-
197
- ```python
198
- # Use prefetch_related() for reverse FK
199
- Organization.objects.prefetch_related('users')
200
-
201
- # With filtering
202
- from django.db.models import Prefetch
203
- Organization.objects.prefetch_related(
204
- Prefetch('users', queryset=User.objects.filter(is_active=True))
205
- )
206
- ```
207
-
208
- ### Many-to-Many
209
-
210
- ```python
211
- # Use prefetch_related() for M2M
212
- User.objects.prefetch_related('roles', 'permissions')
213
- ```
214
-
215
- ### Combined Optimization
216
-
217
- ```python
218
- # Optimize multiple relations
219
- users = User.objects.select_related(
220
- 'organization', # FK
221
- 'created_by' # FK
222
- ).prefetch_related(
223
- 'roles', # M2M
224
- 'permissions' # M2M
225
- )
226
- ```
227
-
228
- ## Index Recommendations
229
-
230
- Suggest indexes for:
231
-
232
- ### Frequently Filtered Fields
233
-
234
- ```python
235
- class User(models.Model):
236
- email = models.EmailField()
237
- status = models.CharField(max_length=20)
238
-
239
- class Meta:
240
- indexes = [
241
- models.Index(fields=['email']), # WHERE email = ...
242
- models.Index(fields=['status']), # WHERE status = ...
243
- ]
244
- ```
245
-
246
- ### Composite Indexes
247
-
248
- ```python
249
- class Order(models.Model):
250
- user = models.ForeignKey(User)
251
- status = models.CharField(max_length=20)
252
- created_at = models.DateTimeField()
253
-
254
- class Meta:
255
- indexes = [
256
- # Composite index for common query pattern
257
- models.Index(fields=['user', 'status']),
258
- # Index for time-based queries
259
- models.Index(fields=['-created_at']), # DESC order
260
- ]
261
- ```
262
-
263
- ### Foreign Key Indexes
264
-
265
- ```python
266
- # Django automatically creates indexes for:
267
- # - Primary keys
268
- # - Unique fields
269
- # - Foreign keys
270
-
271
- # Manual indexes needed for:
272
- # - Composite queries
273
- # - Ordering fields
274
- # - Search fields
275
- ```
276
-
277
- ## Caching Strategies
278
-
279
- ### Query Caching
280
-
281
- ```python
282
- from django.core.cache import cache
283
-
284
- def get_active_users():
285
- cache_key = 'active_users'
286
- users = cache.get(cache_key)
287
-
288
- if users is None:
289
- users = list(User.objects.filter(is_active=True).values())
290
- cache.set(cache_key, users, 300) # Cache 5 minutes
291
-
292
- return users
293
- ```
294
-
295
- ### Model Method Caching
296
-
297
- ```python
298
- from django.utils.functional import cached_property
299
-
300
- class User(models.Model):
301
- @cached_property
302
- def full_name(self):
303
- """Expensive computation cached per instance."""
304
- return f"{self.first_name} {self.last_name}".strip()
305
- ```
306
-
307
- ## Pagination Patterns
308
-
309
- ```python
310
- # DRF Pagination
311
- from rest_framework.pagination import PageNumberPagination
312
-
313
- class StandardResultsSetPagination(PageNumberPagination):
314
- page_size = 100
315
- page_size_query_param = 'page_size'
316
- max_page_size = 1000
317
-
318
- class UserViewSet(viewsets.ModelViewSet):
319
- pagination_class = StandardResultsSetPagination
320
- ```
321
-
322
- ## Database Query Analysis
323
-
324
- Check queries using Django Debug Toolbar patterns:
325
-
326
- ```python
327
- from django.db import connection
328
- from django.test.utils import override_settings
329
-
330
- @override_settings(DEBUG=True)
331
- def test_user_list_queries(self):
332
- """Test that user list doesn't have N+1 queries."""
333
- with self.assertNumQueries(2): # Should be exactly 2 queries
334
- response = self.client.get('/api/users/')
335
- # 1 query: Fetch users
336
- # 1 query: Fetch organizations (prefetched)
337
- ```
338
-
339
- ## Performance Checklist
340
-
341
- For every queryset, verify:
342
-
343
- - ✅ `select_related()` for accessed foreign keys
344
- - ✅ `prefetch_related()` for reverse FKs and M2M
345
- - ✅ `.only()` or `.defer()` if fetching many fields
346
- - ✅ Indexes on filtered/ordered fields
347
- - ✅ Pagination for lists
348
- - ✅ `.count()` instead of `len(queryset)`
349
- - ✅ `.exists()` instead of `if queryset`
350
- - ✅ Bulk operations instead of loops
351
-
352
- ## Before/After Examples
353
-
354
- ### Example 1: User List with Organization
355
-
356
- **❌ Before (N+1):**
357
- ```python
358
- # views.py
359
- class UserViewSet(viewsets.ModelViewSet):
360
- queryset = User.objects.all() # 1 query
361
- # serializer accesses user.organization.name → N queries
362
- ```
363
-
364
- **✅ After (Optimized):**
365
- ```python
366
- # views.py
367
- class UserViewSet(viewsets.ModelViewSet):
368
- queryset = User.objects.select_related('organization').all() # 2 queries total
369
- ```
370
-
371
- ### Example 2: Organization with Users
372
-
373
- **❌ Before (N+1):**
374
- ```python
375
- def organization_summary(self):
376
- orgs = Organization.objects.all() # 1 query
377
- return [
378
- {
379
- 'name': org.name,
380
- 'user_count': org.users.count() # N queries!
381
- }
382
- for org in orgs
383
- ]
384
- ```
385
-
386
- **✅ After (Optimized):**
387
- ```python
388
- from django.db.models import Count
389
-
390
- def organization_summary(self):
391
- orgs = Organization.objects.annotate(
392
- user_count=Count('users') # Single query with aggregation
393
- ).all()
394
- return [
395
- {
396
- 'name': org.name,
397
- 'user_count': org.user_count # No DB hit!
398
- }
399
- for org in orgs
400
- ]
401
- ```
402
-
403
- ## Integration with Testing
404
-
405
- ```python
406
- # Test that optimizations work
407
- @pytest.mark.django_db
408
- def test_user_list_performance(django_assert_num_queries):
409
- """User list should use select_related to avoid N+1."""
410
- UserFactory.create_batch(100) # Create 100 users
411
-
412
- with django_assert_num_queries(2): # Only 2 queries allowed
413
- users = list(User.objects.select_related('organization').all())
414
- for user in users:
415
- _ = user.organization.name # Should not hit DB
416
- ```
417
-
418
- ## Success Criteria
419
-
420
- ✅ NO N+1 queries in codebase
421
- ✅ All foreign key access uses `select_related()`
422
- ✅ All reverse FK/M2M use `prefetch_related()`
423
- ✅ Appropriate indexes on all models
424
- ✅ Pagination on all list endpoints
425
- ✅ Bulk operations used instead of loops
426
-
427
- ## Behavior
428
-
429
- **Proactive enforcement:**
430
- - Detect N+1 queries automatically
431
- - Suggest optimizations immediately
432
- - Calculate performance impact (queries before/after)
433
- - Add indexes to models
434
- - Explain WHY the optimization matters
435
-
436
- **Never:**
437
- - Require explicit "optimize queries" request
438
- - Wait for production slowness
439
- - Just warn without fixing
440
-
441
- **Block completion if:**
442
- - N+1 queries detected
443
- - Missing indexes on frequently queried fields
444
- - No pagination on list endpoints
445
- - Bulk creates/updates done in loops
446
-
447
- This ensures code is performant from day one.
@@ -1,180 +0,0 @@
1
- ---
2
- name: red-phase-verifier
3
- description: This skill should be used when the user asks to "write tests first", "run TDD", "verify red phase", "check failing tests", or when practicing test-driven development. Ensures tests fail before implementation.
4
- ---
5
-
6
- # Red Phase Verifier
7
-
8
- Ensures tests are written BEFORE implementation and fail initially.
9
-
10
- ## Purpose
11
-
12
- In TDD:
13
- 1. **RED**: Write failing tests
14
- 2. **GREEN**: Implement to pass
15
- 3. **REFACTOR**: Improve while green
16
-
17
- This skill enforces Step 1.
18
-
19
- ## Activation Triggers
20
-
21
- This skill activates when:
22
- - Running /dev-loop command
23
- - Creating test files before implementation
24
- - Mentioning "write tests first"
25
-
26
- ## Verification Process
27
-
28
- ### Step 1: Check Implementation Exists
29
-
30
- ```python
31
- # If implementing UserService.create_user:
32
- # Check if method exists and has logic
33
-
34
- import inspect
35
- from app.services import UserService
36
-
37
- method = getattr(UserService, 'create_user', None)
38
- if method:
39
- source = inspect.getsource(method)
40
- if 'pass' not in source and 'raise NotImplementedError' not in source:
41
- # Implementation exists!
42
- WARN: "Implementation found before tests"
43
- ```
44
-
45
- ### Step 2: Run Tests
46
-
47
- ```bash
48
- pytest tests/test_new_feature.py -v --tb=short
49
- ```
50
-
51
- ### Step 3: Verify Failures
52
-
53
- Expected output:
54
- ```
55
- FAILED tests/test_new_feature.py::test_create - AssertionError
56
- FAILED tests/test_new_feature.py::test_validate - AttributeError
57
- ```
58
-
59
- ### Step 4: Report
60
-
61
- ```
62
- RED PHASE VERIFICATION
63
-
64
- Tests written: 5
65
- Tests failing: 5
66
-
67
- Red phase confirmed!
68
- Implementation may now proceed.
69
- ```
70
-
71
- ## Warning Cases
72
-
73
- ### Case 1: Tests Pass Before Implementation
74
-
75
- ```
76
- WARNING: Tests passed before implementation!
77
-
78
- Failing tests: 0/5
79
-
80
- This indicates:
81
- 1. Tests don't test new functionality
82
- 2. Tests have trivial assertions
83
- 3. Implementation already exists
84
-
85
- Action: Regenerate stricter tests
86
- ```
87
-
88
- ### Case 2: Partial Failures
89
-
90
- ```
91
- PARTIAL RED PHASE
92
-
93
- Tests failing: 3/5
94
- Tests passing: 2/5
95
-
96
- Passing tests may be:
97
- 1. Testing existing functionality (OK)
98
- 2. Trivial assertions (NOT OK)
99
-
100
- Review passing tests:
101
- - test_helper_exists: assert helper <- TRIVIAL
102
- - test_constant: assert X == X <- TRIVIAL
103
-
104
- Action: Strengthen or remove trivial tests
105
- ```
106
-
107
- ### Case 3: Wrong Failure Type
108
-
109
- ```
110
- UNEXPECTED FAILURE TYPE
111
-
112
- test_create_user: SyntaxError in test file
113
-
114
- Tests should fail due to:
115
- - AssertionError (expected behavior not met)
116
- - AttributeError (method doesn't exist yet)
117
- - NotImplementedError (placeholder)
118
-
119
- NOT due to:
120
- - SyntaxError (test file broken)
121
- - ImportError (missing dependency)
122
- - TypeError (wrong arguments)
123
-
124
- Action: Fix test file syntax
125
- ```
126
-
127
- ## Enforcement
128
-
129
- When red phase not verified:
130
-
131
- ```
132
- CANNOT PROCEED TO GREEN PHASE
133
-
134
- Red phase requirements not met:
135
- - 2 tests passed before implementation
136
- - 1 test has syntax error
137
-
138
- Fix issues, then run verification again.
139
- ```
140
-
141
- ## Expected Failure Types
142
-
143
- ### Good Failures (Proceed)
144
-
145
- - `AssertionError` - Assertion failed (expected)
146
- - `AttributeError` - Method/attribute doesn't exist yet
147
- - `NotImplementedError` - Placeholder implementation
148
- - `ModuleNotFoundError` - Module not created yet
149
-
150
- ### Bad Failures (Fix First)
151
-
152
- - `SyntaxError` - Test code is broken
153
- - `IndentationError` - Test code formatting issue
154
- - `NameError` - Undefined variable in test
155
- - `TypeError` - Wrong arguments in test setup
156
-
157
- ## Dev Loop Integration
158
-
159
- When integrated with /dev-loop:
160
-
161
- 1. Tests written -> Run red phase verifier
162
- 2. If all fail correctly -> Proceed to implementation
163
- 3. If some pass -> Warn and suggest fixes
164
- 4. If wrong failures -> Block until fixed
165
-
166
- ```
167
- TDD LOOP: RED PHASE
168
-
169
- Running red phase verification...
170
-
171
- test_create_user: FAILED (AttributeError)
172
- test_validate_email: FAILED (AssertionError)
173
- test_duplicate_email: FAILED (AssertionError)
174
- test_get_user: FAILED (NotImplementedError)
175
- test_list_users: FAILED (NotImplementedError)
176
-
177
- Red phase: 5/5 tests failing correctly
178
-
179
- Proceeding to GREEN phase...
180
- ```