agent-configs 1.0.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 (85) hide show
  1. package/README.md +223 -0
  2. package/agents/architect.md +211 -0
  3. package/agents/code-reviewer.md +104 -0
  4. package/agents/planner.md +119 -0
  5. package/agents/refactor-cleaner.md +306 -0
  6. package/agents/security-reviewer.md +545 -0
  7. package/agents/tdd-guide.md +280 -0
  8. package/bundles/bk-chat-bundle/README.md +48 -0
  9. package/bundles/bk-chat-bundle/manifest.json +10 -0
  10. package/bundles/continuous-learning/.claude/commands/evolve.md +190 -0
  11. package/bundles/continuous-learning/.claude/commands/instinct-status.md +64 -0
  12. package/bundles/continuous-learning/.claude/commands/learn.md +83 -0
  13. package/bundles/continuous-learning/.claude/hooks/learning-end.js +85 -0
  14. package/bundles/continuous-learning/.claude/hooks/observe.js +131 -0
  15. package/bundles/continuous-learning/.claude/lib/learning.js +559 -0
  16. package/bundles/continuous-learning/.claude/lib/utils.js +312 -0
  17. package/bundles/continuous-learning/.claude/skills/continuous-learning/SKILL.md +200 -0
  18. package/bundles/continuous-learning/.cursor/hooks/learning-end.js +102 -0
  19. package/bundles/continuous-learning/.cursor/rules/continuous-learning.mdc +34 -0
  20. package/bundles/continuous-learning/.cursor/skills/continuous-learning/SKILL.md +77 -0
  21. package/bundles/continuous-learning/README.md +159 -0
  22. package/bundles/continuous-learning/manifest.json +51 -0
  23. package/bundles/planning-bundle/README.md +34 -0
  24. package/bundles/planning-bundle/manifest.json +10 -0
  25. package/bundles/review-bundle/README.md +43 -0
  26. package/bundles/review-bundle/manifest.json +11 -0
  27. package/bundles/shared-memory/.claude/commands/list-sessions.md +124 -0
  28. package/bundles/shared-memory/.claude/commands/load-session.md +169 -0
  29. package/bundles/shared-memory/.claude/commands/save-session.md +137 -0
  30. package/bundles/shared-memory/.claude/hooks/memory-compact.js +43 -0
  31. package/bundles/shared-memory/.claude/hooks/memory-end.js +42 -0
  32. package/bundles/shared-memory/.claude/hooks/memory-start.js +59 -0
  33. package/bundles/shared-memory/.claude/lib/memory.js +416 -0
  34. package/bundles/shared-memory/.claude/lib/utils.js +209 -0
  35. package/bundles/shared-memory/.claude/skills/shared-memory/SKILL.md +183 -0
  36. package/bundles/shared-memory/.cursor/hooks/memory-start.js +42 -0
  37. package/bundles/shared-memory/.cursor/rules/shared-memory.mdc +37 -0
  38. package/bundles/shared-memory/.cursor/skills/shared-memory/SKILL.md +183 -0
  39. package/bundles/tdd-bundle/README.md +33 -0
  40. package/bundles/tdd-bundle/manifest.json +10 -0
  41. package/cli.js +978 -0
  42. package/commands/build-fix.md +29 -0
  43. package/commands/code-review.md +40 -0
  44. package/commands/e2e.md +363 -0
  45. package/commands/learn.md +114 -0
  46. package/commands/plan.md +113 -0
  47. package/commands/refactor-clean.md +28 -0
  48. package/commands/tdd.md +326 -0
  49. package/commands/test-coverage.md +27 -0
  50. package/commands/update-codemaps.md +17 -0
  51. package/commands/update-docs.md +31 -0
  52. package/configs.json +158 -0
  53. package/hooks/hooks.json +101 -0
  54. package/package.json +58 -0
  55. package/rules/agents.md +49 -0
  56. package/rules/coding-style.md +70 -0
  57. package/rules/git-workflow.md +45 -0
  58. package/rules/hooks.md +46 -0
  59. package/rules/patterns.md +55 -0
  60. package/rules/performance.md +47 -0
  61. package/rules/security.md +36 -0
  62. package/rules/testing.md +30 -0
  63. package/skills/ai-config-architect/SKILL.md +59 -0
  64. package/skills/ai-config-architect/references/agents.md +77 -0
  65. package/skills/ai-config-architect/references/commands.md +66 -0
  66. package/skills/ai-config-architect/references/hooks.md +70 -0
  67. package/skills/ai-config-architect/references/patterns.md +66 -0
  68. package/skills/ai-config-architect/references/platforms.md +82 -0
  69. package/skills/ai-config-architect/references/rules.md +66 -0
  70. package/skills/ai-config-architect/references/skills.md +67 -0
  71. package/skills/bk-chat-helper/SKILL.md +398 -0
  72. package/skills/bk-chat-helper/references/api-reference.md +606 -0
  73. package/skills/bk-chat-helper/references/examples.md +789 -0
  74. package/skills/bk-chat-helper/references/integration-guide.md +583 -0
  75. package/skills/bk-chat-x/SKILL.md +400 -0
  76. package/skills/bk-chat-x/references/components-api.md +340 -0
  77. package/skills/bk-chat-x/references/examples.md +386 -0
  78. package/skills/bk-chat-x/references/shortcuts-guide.md +375 -0
  79. package/skills/coding-standards/SKILL.md +523 -0
  80. package/skills/security-review/SKILL.md +497 -0
  81. package/skills/security-review/references/cloud-infrastructure-security.md +361 -0
  82. package/skills/strategic-compact/SKILL.md +66 -0
  83. package/skills/strategic-compact/scripts/suggest-compact.sh +52 -0
  84. package/skills/tdd-workflow/SKILL.md +412 -0
  85. package/skills/verification-loop/SKILL.md +128 -0
@@ -0,0 +1,523 @@
1
+ ---
2
+ name: coding-standards
3
+ description: Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development. Use when writing new code, reviewing code quality, or establishing project conventions.
4
+ metadata:
5
+ author: everything-claude-code
6
+ version: "1.0"
7
+ ---
8
+
9
+ # Coding Standards & Best Practices
10
+
11
+ Universal coding standards applicable across all projects.
12
+
13
+ ## Code Quality Principles
14
+
15
+ ### 1. Readability First
16
+ - Code is read more than written
17
+ - Clear variable and function names
18
+ - Self-documenting code preferred over comments
19
+ - Consistent formatting
20
+
21
+ ### 2. KISS (Keep It Simple, Stupid)
22
+ - Simplest solution that works
23
+ - Avoid over-engineering
24
+ - No premature optimization
25
+ - Easy to understand > clever code
26
+
27
+ ### 3. DRY (Don't Repeat Yourself)
28
+ - Extract common logic into functions
29
+ - Create reusable components
30
+ - Share utilities across modules
31
+ - Avoid copy-paste programming
32
+
33
+ ### 4. YAGNI (You Aren't Gonna Need It)
34
+ - Don't build features before they're needed
35
+ - Avoid speculative generality
36
+ - Add complexity only when required
37
+ - Start simple, refactor when needed
38
+
39
+ ## TypeScript/JavaScript Standards
40
+
41
+ ### Variable Naming
42
+
43
+ ```typescript
44
+ // ✅ GOOD: Descriptive names
45
+ const marketSearchQuery = 'election'
46
+ const isUserAuthenticated = true
47
+ const totalRevenue = 1000
48
+
49
+ // ❌ BAD: Unclear names
50
+ const q = 'election'
51
+ const flag = true
52
+ const x = 1000
53
+ ```
54
+
55
+ ### Function Naming
56
+
57
+ ```typescript
58
+ // ✅ GOOD: Verb-noun pattern
59
+ async function fetchMarketData(marketId: string) { }
60
+ function calculateSimilarity(a: number[], b: number[]) { }
61
+ function isValidEmail(email: string): boolean { }
62
+
63
+ // ❌ BAD: Unclear or noun-only
64
+ async function market(id: string) { }
65
+ function similarity(a, b) { }
66
+ function email(e) { }
67
+ ```
68
+
69
+ ### Immutability Pattern (CRITICAL)
70
+
71
+ ```typescript
72
+ // ✅ ALWAYS use spread operator
73
+ const updatedUser = {
74
+ ...user,
75
+ name: 'New Name'
76
+ }
77
+
78
+ const updatedArray = [...items, newItem]
79
+
80
+ // ❌ NEVER mutate directly
81
+ user.name = 'New Name' // BAD
82
+ items.push(newItem) // BAD
83
+ ```
84
+
85
+ ### Error Handling
86
+
87
+ ```typescript
88
+ // ✅ GOOD: Comprehensive error handling
89
+ async function fetchData(url: string) {
90
+ try {
91
+ const response = await fetch(url)
92
+
93
+ if (!response.ok) {
94
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`)
95
+ }
96
+
97
+ return await response.json()
98
+ } catch (error) {
99
+ console.error('Fetch failed:', error)
100
+ throw new Error('Failed to fetch data')
101
+ }
102
+ }
103
+
104
+ // ❌ BAD: No error handling
105
+ async function fetchData(url) {
106
+ const response = await fetch(url)
107
+ return response.json()
108
+ }
109
+ ```
110
+
111
+ ### Async/Await Best Practices
112
+
113
+ ```typescript
114
+ // ✅ GOOD: Parallel execution when possible
115
+ const [users, markets, stats] = await Promise.all([
116
+ fetchUsers(),
117
+ fetchMarkets(),
118
+ fetchStats()
119
+ ])
120
+
121
+ // ❌ BAD: Sequential when unnecessary
122
+ const users = await fetchUsers()
123
+ const markets = await fetchMarkets()
124
+ const stats = await fetchStats()
125
+ ```
126
+
127
+ ### Type Safety
128
+
129
+ ```typescript
130
+ // ✅ GOOD: Proper types
131
+ interface Market {
132
+ id: string
133
+ name: string
134
+ status: 'active' | 'resolved' | 'closed'
135
+ created_at: Date
136
+ }
137
+
138
+ function getMarket(id: string): Promise<Market> {
139
+ // Implementation
140
+ }
141
+
142
+ // ❌ BAD: Using 'any'
143
+ function getMarket(id: any): Promise<any> {
144
+ // Implementation
145
+ }
146
+ ```
147
+
148
+ ## React Best Practices
149
+
150
+ ### Component Structure
151
+
152
+ ```typescript
153
+ // ✅ GOOD: Functional component with types
154
+ interface ButtonProps {
155
+ children: React.ReactNode
156
+ onClick: () => void
157
+ disabled?: boolean
158
+ variant?: 'primary' | 'secondary'
159
+ }
160
+
161
+ export function Button({
162
+ children,
163
+ onClick,
164
+ disabled = false,
165
+ variant = 'primary'
166
+ }: ButtonProps) {
167
+ return (
168
+ <button
169
+ onClick={onClick}
170
+ disabled={disabled}
171
+ className={`btn btn-${variant}`}
172
+ >
173
+ {children}
174
+ </button>
175
+ )
176
+ }
177
+
178
+ // ❌ BAD: No types, unclear structure
179
+ export function Button(props) {
180
+ return <button onClick={props.onClick}>{props.children}</button>
181
+ }
182
+ ```
183
+
184
+ ### Custom Hooks
185
+
186
+ ```typescript
187
+ // ✅ GOOD: Reusable custom hook
188
+ export function useDebounce<T>(value: T, delay: number): T {
189
+ const [debouncedValue, setDebouncedValue] = useState<T>(value)
190
+
191
+ useEffect(() => {
192
+ const handler = setTimeout(() => {
193
+ setDebouncedValue(value)
194
+ }, delay)
195
+
196
+ return () => clearTimeout(handler)
197
+ }, [value, delay])
198
+
199
+ return debouncedValue
200
+ }
201
+
202
+ // Usage
203
+ const debouncedQuery = useDebounce(searchQuery, 500)
204
+ ```
205
+
206
+ ### State Management
207
+
208
+ ```typescript
209
+ // ✅ GOOD: Proper state updates
210
+ const [count, setCount] = useState(0)
211
+
212
+ // Functional update for state based on previous state
213
+ setCount(prev => prev + 1)
214
+
215
+ // ❌ BAD: Direct state reference
216
+ setCount(count + 1) // Can be stale in async scenarios
217
+ ```
218
+
219
+ ### Conditional Rendering
220
+
221
+ ```typescript
222
+ // ✅ GOOD: Clear conditional rendering
223
+ {isLoading && <Spinner />}
224
+ {error && <ErrorMessage error={error} />}
225
+ {data && <DataDisplay data={data} />}
226
+
227
+ // ❌ BAD: Ternary hell
228
+ {isLoading ? <Spinner /> : error ? <ErrorMessage error={error} /> : data ? <DataDisplay data={data} /> : null}
229
+ ```
230
+
231
+ ## API Design Standards
232
+
233
+ ### REST API Conventions
234
+
235
+ ```
236
+ GET /api/markets # List all markets
237
+ GET /api/markets/:id # Get specific market
238
+ POST /api/markets # Create new market
239
+ PUT /api/markets/:id # Update market (full)
240
+ PATCH /api/markets/:id # Update market (partial)
241
+ DELETE /api/markets/:id # Delete market
242
+
243
+ # Query parameters for filtering
244
+ GET /api/markets?status=active&limit=10&offset=0
245
+ ```
246
+
247
+ ### Response Format
248
+
249
+ ```typescript
250
+ // ✅ GOOD: Consistent response structure
251
+ interface ApiResponse<T> {
252
+ success: boolean
253
+ data?: T
254
+ error?: string
255
+ meta?: {
256
+ total: number
257
+ page: number
258
+ limit: number
259
+ }
260
+ }
261
+
262
+ // Success response
263
+ return NextResponse.json({
264
+ success: true,
265
+ data: markets,
266
+ meta: { total: 100, page: 1, limit: 10 }
267
+ })
268
+
269
+ // Error response
270
+ return NextResponse.json({
271
+ success: false,
272
+ error: 'Invalid request'
273
+ }, { status: 400 })
274
+ ```
275
+
276
+ ### Input Validation
277
+
278
+ ```typescript
279
+ import { z } from 'zod'
280
+
281
+ // ✅ GOOD: Schema validation
282
+ const CreateMarketSchema = z.object({
283
+ name: z.string().min(1).max(200),
284
+ description: z.string().min(1).max(2000),
285
+ endDate: z.string().datetime(),
286
+ categories: z.array(z.string()).min(1)
287
+ })
288
+
289
+ export async function POST(request: Request) {
290
+ const body = await request.json()
291
+
292
+ try {
293
+ const validated = CreateMarketSchema.parse(body)
294
+ // Proceed with validated data
295
+ } catch (error) {
296
+ if (error instanceof z.ZodError) {
297
+ return NextResponse.json({
298
+ success: false,
299
+ error: 'Validation failed',
300
+ details: error.errors
301
+ }, { status: 400 })
302
+ }
303
+ }
304
+ }
305
+ ```
306
+
307
+ ## File Organization
308
+
309
+ ### Project Structure
310
+
311
+ ```
312
+ src/
313
+ ├── app/ # Next.js App Router
314
+ │ ├── api/ # API routes
315
+ │ ├── markets/ # Market pages
316
+ │ └── (auth)/ # Auth pages (route groups)
317
+ ├── components/ # React components
318
+ │ ├── ui/ # Generic UI components
319
+ │ ├── forms/ # Form components
320
+ │ └── layouts/ # Layout components
321
+ ├── hooks/ # Custom React hooks
322
+ ├── lib/ # Utilities and configs
323
+ │ ├── api/ # API clients
324
+ │ ├── utils/ # Helper functions
325
+ │ └── constants/ # Constants
326
+ ├── types/ # TypeScript types
327
+ └── styles/ # Global styles
328
+ ```
329
+
330
+ ### File Naming
331
+
332
+ ```
333
+ components/Button.tsx # PascalCase for components
334
+ hooks/useAuth.ts # camelCase with 'use' prefix
335
+ lib/formatDate.ts # camelCase for utilities
336
+ types/market.types.ts # camelCase with .types suffix
337
+ ```
338
+
339
+ ## Comments & Documentation
340
+
341
+ ### When to Comment
342
+
343
+ ```typescript
344
+ // ✅ GOOD: Explain WHY, not WHAT
345
+ // Use exponential backoff to avoid overwhelming the API during outages
346
+ const delay = Math.min(1000 * Math.pow(2, retryCount), 30000)
347
+
348
+ // Deliberately using mutation here for performance with large arrays
349
+ items.push(newItem)
350
+
351
+ // ❌ BAD: Stating the obvious
352
+ // Increment counter by 1
353
+ count++
354
+
355
+ // Set name to user's name
356
+ name = user.name
357
+ ```
358
+
359
+ ### JSDoc for Public APIs
360
+
361
+ ```typescript
362
+ /**
363
+ * Searches markets using semantic similarity.
364
+ *
365
+ * @param query - Natural language search query
366
+ * @param limit - Maximum number of results (default: 10)
367
+ * @returns Array of markets sorted by similarity score
368
+ * @throws {Error} If OpenAI API fails or Redis unavailable
369
+ *
370
+ * @example
371
+ * ```typescript
372
+ * const results = await searchMarkets('election', 5)
373
+ * console.log(results[0].name) // "Trump vs Biden"
374
+ * ```
375
+ */
376
+ export async function searchMarkets(
377
+ query: string,
378
+ limit: number = 10
379
+ ): Promise<Market[]> {
380
+ // Implementation
381
+ }
382
+ ```
383
+
384
+ ## Performance Best Practices
385
+
386
+ ### Memoization
387
+
388
+ ```typescript
389
+ import { useMemo, useCallback } from 'react'
390
+
391
+ // ✅ GOOD: Memoize expensive computations
392
+ const sortedMarkets = useMemo(() => {
393
+ return markets.sort((a, b) => b.volume - a.volume)
394
+ }, [markets])
395
+
396
+ // ✅ GOOD: Memoize callbacks
397
+ const handleSearch = useCallback((query: string) => {
398
+ setSearchQuery(query)
399
+ }, [])
400
+ ```
401
+
402
+ ### Lazy Loading
403
+
404
+ ```typescript
405
+ import { lazy, Suspense } from 'react'
406
+
407
+ // ✅ GOOD: Lazy load heavy components
408
+ const HeavyChart = lazy(() => import('./HeavyChart'))
409
+
410
+ export function Dashboard() {
411
+ return (
412
+ <Suspense fallback={<Spinner />}>
413
+ <HeavyChart />
414
+ </Suspense>
415
+ )
416
+ }
417
+ ```
418
+
419
+ ### Database Queries
420
+
421
+ ```typescript
422
+ // ✅ GOOD: Select only needed columns
423
+ const { data } = await supabase
424
+ .from('markets')
425
+ .select('id, name, status')
426
+ .limit(10)
427
+
428
+ // ❌ BAD: Select everything
429
+ const { data } = await supabase
430
+ .from('markets')
431
+ .select('*')
432
+ ```
433
+
434
+ ## Testing Standards
435
+
436
+ ### Test Structure (AAA Pattern)
437
+
438
+ ```typescript
439
+ test('calculates similarity correctly', () => {
440
+ // Arrange
441
+ const vector1 = [1, 0, 0]
442
+ const vector2 = [0, 1, 0]
443
+
444
+ // Act
445
+ const similarity = calculateCosineSimilarity(vector1, vector2)
446
+
447
+ // Assert
448
+ expect(similarity).toBe(0)
449
+ })
450
+ ```
451
+
452
+ ### Test Naming
453
+
454
+ ```typescript
455
+ // ✅ GOOD: Descriptive test names
456
+ test('returns empty array when no markets match query', () => { })
457
+ test('throws error when OpenAI API key is missing', () => { })
458
+ test('falls back to substring search when Redis unavailable', () => { })
459
+
460
+ // ❌ BAD: Vague test names
461
+ test('works', () => { })
462
+ test('test search', () => { })
463
+ ```
464
+
465
+ ## Code Smell Detection
466
+
467
+ Watch for these anti-patterns:
468
+
469
+ ### 1. Long Functions
470
+ ```typescript
471
+ // ❌ BAD: Function > 50 lines
472
+ function processMarketData() {
473
+ // 100 lines of code
474
+ }
475
+
476
+ // ✅ GOOD: Split into smaller functions
477
+ function processMarketData() {
478
+ const validated = validateData()
479
+ const transformed = transformData(validated)
480
+ return saveData(transformed)
481
+ }
482
+ ```
483
+
484
+ ### 2. Deep Nesting
485
+ ```typescript
486
+ // ❌ BAD: 5+ levels of nesting
487
+ if (user) {
488
+ if (user.isAdmin) {
489
+ if (market) {
490
+ if (market.isActive) {
491
+ if (hasPermission) {
492
+ // Do something
493
+ }
494
+ }
495
+ }
496
+ }
497
+ }
498
+
499
+ // ✅ GOOD: Early returns
500
+ if (!user) return
501
+ if (!user.isAdmin) return
502
+ if (!market) return
503
+ if (!market.isActive) return
504
+ if (!hasPermission) return
505
+
506
+ // Do something
507
+ ```
508
+
509
+ ### 3. Magic Numbers
510
+ ```typescript
511
+ // ❌ BAD: Unexplained numbers
512
+ if (retryCount > 3) { }
513
+ setTimeout(callback, 500)
514
+
515
+ // ✅ GOOD: Named constants
516
+ const MAX_RETRIES = 3
517
+ const DEBOUNCE_DELAY_MS = 500
518
+
519
+ if (retryCount > MAX_RETRIES) { }
520
+ setTimeout(callback, DEBOUNCE_DELAY_MS)
521
+ ```
522
+
523
+ **Remember**: Code quality is not negotiable. Clear, maintainable code enables rapid development and confident refactoring.