cp-toolkit 2.2.13 → 2.2.14

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cp-toolkit",
3
- "version": "2.2.13",
3
+ "version": "2.2.14",
4
4
  "description": "Copilot Toolkit - AI Agent framework for GitHub Copilot, Claude, Gemini CLI, and other AI assistants",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -83,13 +83,12 @@ export async function initCommand(directory, options) {
83
83
  await fs.ensureDir(agentsTargetDir);
84
84
  await fs.copy(agentsSourceDir, agentsTargetDir, { overwrite: true });
85
85
 
86
- // 2. Setup .github/instructions/ (from skills that have instruction content)
86
+ // 2. Setup .github/instructions/
87
87
  spinner.text = 'Copying instructions...';
88
+ const instructionsSourceDir = path.join(templatesDir, 'instructions');
88
89
  const instructionsTargetDir = path.join(targetDir, '.github', 'instructions');
89
90
  await fs.ensureDir(instructionsTargetDir);
90
-
91
- // Create standard instruction files
92
- await createInstructionFiles(instructionsTargetDir);
91
+ await fs.copy(instructionsSourceDir, instructionsTargetDir, { overwrite: true });
93
92
 
94
93
  // 4. Setup .github/skills/ (essential skills referenced by agents)
95
94
  spinner.text = 'Copying essential skills...';
@@ -263,432 +262,4 @@ export async function initCommand(directory, options) {
263
262
  }
264
263
  }
265
264
 
266
- async function createInstructionFiles(instructionsDir) {
267
- const instructions = {
268
- 'typescript-development.instructions.md': `---
269
- name: typescript-development
270
- description: Strict guidelines for TypeScript development including type safety, modules, and error handling.
271
- version: 1.0
272
- applyTo: "**/*.ts,**/*.tsx,**/*.mts,**/*.cts"
273
- ---
274
-
275
- # TypeScript Development Guidelines
276
-
277
- ## Strict Mode & Type Safety
278
- - Enable \`strict: true\` in tsconfig.json
279
- - No \`any\` types - use \`unknown\` and narrow with type guards
280
- - Explicit return types for public functions
281
- - Use \`strictNullChecks\` and \`noImplicitAny\`
282
-
283
- ## Code Patterns
284
- - Prefer \`interface\` over \`type\` for object shapes
285
- - Use \`as const\` for literal types and enums
286
- - Leverage discriminated unions for state management
287
- - Use mapped types for transformations
288
- - Prefer \`readonly\` for immutable data
289
-
290
- ## Imports & Modules
291
- - Use type-only imports: \`import type { X } from 'y'\`
292
- - Barrel exports for public APIs only
293
- - Avoid relative imports with \`../\` - use absolute paths
294
-
295
- ## Error Handling
296
- - Use custom error classes extending \`Error\`
297
- - Prefer Result types over throwing exceptions
298
- - Use try/catch only for external operations
299
- `,
300
-
301
- 'javascript-development.instructions.md': `---
302
- name: javascript-development
303
- description: Best practices for modern JavaScript development including ES6+ features and functional patterns.
304
- version: 1.0
305
- applyTo: "**/*.js,**/*.mjs,**/*.cjs"
306
- ---
307
-
308
- # JavaScript Development Guidelines
309
-
310
- ## ES6+ Features
311
- - Use \`const\` and \`let\` instead of \`var\`
312
- - Arrow functions for callbacks and anonymous functions
313
- - Template literals over string concatenation
314
- - Destructuring for objects and arrays
315
- - Spread/rest operators for manipulation
316
-
317
- ## Code Patterns
318
- - Prefer functional programming approaches
319
- - Use async/await over Promises for readability
320
- - Implement proper error handling with try/catch
321
- - Use Map/Set for collections when appropriate
322
- - Leverage object destructuring for configuration
323
-
324
- ## Best Practices
325
- - Strict mode: \`'use strict'\` at file/module level
326
- - Consistent naming: camelCase for variables/functions
327
- - Meaningful variable names over abbreviations
328
- - Single responsibility principle for functions
329
-
330
- ## Performance
331
- - Avoid global variables
332
- - Use efficient algorithms and data structures
333
- - Minimize DOM manipulation
334
- - Cache expensive operations
335
- `,
336
-
337
- 'react-development.instructions.md': `---
338
- name: react-development
339
- description: Component patterns, state management, and accessibility standards for React development.
340
- version: 1.0
341
- applyTo: "**/*.jsx,**/*.tsx,**/*react*"
342
- ---
343
-
344
- # React Development Guidelines
345
-
346
- ## Component Patterns
347
- - Functional components with hooks over class components
348
- - Custom hooks for reusable logic
349
- - Compound components for complex UI patterns
350
- - Container/Presentational separation when appropriate
351
-
352
- ## State Management
353
- - useState for local component state
354
- - useReducer for complex state logic
355
- - Context API for theme/configuration
356
- - External libraries (Zustand, Redux) for app-wide state
357
-
358
- ## Performance
359
- - React.memo for expensive components
360
- - useMemo for expensive calculations
361
- - useCallback for event handlers
362
- - Lazy loading with React.lazy and Suspense
363
- - Code splitting for large applications
364
-
365
- ## Hooks Best Practices
366
- - Custom hooks for side effects
367
- - useEffect cleanup functions
368
- - Dependency arrays correctly specified
369
- - Avoid conditional hook calls
370
-
371
- ## Accessibility
372
- - Semantic HTML elements
373
- - ARIA attributes when needed
374
- - Keyboard navigation support
375
- - Screen reader compatibility
376
- `,
377
-
378
- 'nextjs-development.instructions.md': `---
379
- name: nextjs-development
380
- description: Guidelines for Next.js development including App Router, Server Components, and SEO optimization.
381
- version: 1.0
382
- applyTo: "**/app/**,**/components/**,**/lib/**,**/utils/**"
383
- ---
384
-
385
- # Next.js Development Guidelines
386
-
387
- ## App Router (App Directory)
388
- - Server Components by default
389
- - Client Components with 'use client' directive
390
- - Server Actions for form handling
391
- - Route Groups for organization: (auth), (dashboard)
392
-
393
- ## File Structure
394
- - \`app/\` for routing and layouts
395
- - \`components/\` for reusable UI
396
- - \`lib/\` for utilities and configurations
397
- - \`utils/\` for helper functions
398
- - \`types/\` for TypeScript definitions
399
-
400
- ## Data Fetching
401
- - Server Components for initial data
402
- - Client Components for interactive data
403
- - SWR or React Query for client-side fetching
404
- - Server Actions for mutations
405
-
406
- ## Performance
407
- - Image optimization with next/image
408
- - Font optimization with next/font
409
- - Code splitting automatic
410
- - Static generation when possible
411
- - ISR for dynamic content
412
-
413
- ## SEO & Metadata
414
- - Metadata API for dynamic meta tags
415
- - Static metadata exports
416
- - Open Graph and Twitter cards
417
- - Structured data with JSON-LD
418
- `,
419
-
420
- 'python-development.instructions.md': `---
421
- name: python-development
422
- description: Best practices for Python development including type hints, async/await, and testing.
423
- version: 1.0
424
- applyTo: "**/*.py"
425
- ---
426
-
427
- # Python Development Guidelines
428
-
429
- ## Type Hints & Annotations
430
- - Use type hints for all function signatures
431
- - Use \`from __future__ import annotations\` for forward refs
432
- - Prefer \`typing.Optional\` over \`X | None\` for Python 3.9 compat
433
- - Generic types with \`TypeVar\` when needed
434
-
435
- ## Code Patterns
436
- - Use dataclasses or Pydantic for data structures
437
- - Async/await for I/O bound operations
438
- - Context managers (\`with\` statements) for resource management
439
- - List/dict comprehensions for transformations
440
- - Generator functions for large datasets
441
-
442
- ## Best Practices
443
- - Follow PEP 8 style guidelines
444
- - Use Black for code formatting
445
- - Google/NumPy style docstrings
446
- - Meaningful variable names
447
- - Single responsibility principle
448
-
449
- ## Error Handling
450
- - Custom exception classes
451
- - Specific exception types over generic Exception
452
- - Proper exception chaining
453
- - Logging with appropriate levels
454
-
455
- ## Testing
456
- - pytest framework preferred
457
- - Unit tests for functions/classes
458
- - Integration tests for workflows
459
- - Mock external dependencies
460
- `,
461
-
462
- 'security-development.instructions.md': `---
463
- name: security-development
464
- description: Comprehensive security guidelines including auth, data protection, and web security.
465
- version: 1.0
466
- applyTo: "**/auth/**,**/security/**,**/*auth*,**/*token*,**/*session*,**/middleware/**"
467
- ---
468
-
469
- # Security Development Guidelines
470
-
471
- ## Authentication & Authorization
472
- - JWT with short expiry + refresh tokens
473
- - HttpOnly cookies for web sessions
474
- - Rate limiting on authentication endpoints
475
- - RBAC or ABAC patterns implemented
476
- - Server-side permission checks always
477
-
478
- ## Data Protection
479
- - Input sanitization and validation
480
- - Output encoding by context (HTML, SQL, JSON)
481
- - Never log sensitive data (passwords, tokens, PII)
482
- - Encryption at rest and in transit
483
- - Secure password hashing (bcrypt, Argon2)
484
-
485
- ## Web Security
486
- - CSRF tokens for state-changing operations
487
- - Content Security Policy (CSP) headers
488
- - HTTPS enforcement (HSTS)
489
- - Secure headers (X-Frame-Options, etc.)
490
- - XSS prevention with proper escaping
491
-
492
- ## API Security
493
- - API versioning for breaking changes
494
- - Request/response validation schemas
495
- - CORS configuration for allowed origins
496
- - API rate limiting and throttling
497
- - Proper error messages (no sensitive info)
498
-
499
- ## OWASP Top 10
500
- - Injection prevention (parameterized queries)
501
- - Broken authentication handling
502
- - Sensitive data exposure protection
503
- - XML external entity prevention
504
- - Access control enforcement
505
- `,
506
-
507
- 'database-development.instructions.md': `---
508
- name: database-development
509
- description: Standards for schema design, query optimization, and database migrations.
510
- version: 1.0
511
- applyTo: "**/prisma/**,**/*.sql,**/migrations/**,**/schema.*,**/db/**,**/models/**"
512
- ---
513
-
514
- # Database Development Guidelines
515
-
516
- ## Schema Design
517
- - UUID or ULID for primary keys (not auto-increment)
518
- - Timestamps: createdAt, updatedAt on all tables
519
- - Soft delete with deletedAt when needed
520
- - Proper foreign key relationships
521
- - Normalized schemas with good indexing
522
-
523
- ## Query Optimization
524
- - Use parameterized queries only (never string concat)
525
- - Select only needed fields (avoid SELECT *)
526
- - Use cursor-based pagination for large datasets
527
- - Proper indexing on frequently queried fields
528
- - Query execution plan analysis
529
-
530
- ## ORM Best Practices
531
- - Use transactions for multi-table operations
532
- - N+1 query problem avoidance
533
- - Proper eager/lazy loading
534
- - Migration scripts for schema changes
535
- - Database constraints and validations
536
-
537
- ## Migration Safety
538
- - One migration per feature/change
539
- - Never modify already-applied migrations
540
- - Test migrations on production-like data
541
- - Rollback scripts for emergency recovery
542
- - Version control for migration files
543
-
544
- ## Performance
545
- - Connection pooling configuration
546
- - Query result caching strategies
547
- - Database indexing strategy
548
- - Read/write splitting when appropriate
549
- - Monitoring and alerting setup
550
- `,
551
-
552
- 'testing-development.instructions.md': `---
553
- name: testing-development
554
- description: Guidelines for test structure, frameworks, and code coverage best practices.
555
- version: 1.0
556
- applyTo: "**/*.test.*,**/*.spec.*,**/tests/**,**/__tests__/**"
557
- ---
558
-
559
- # Testing Development Guidelines
560
-
561
- ## Test Structure
562
- - Unit tests for individual functions/classes
563
- - Integration tests for component interactions
564
- - End-to-end tests for user workflows
565
- - Performance tests for critical paths
566
- - Accessibility tests for UI components
567
-
568
- ## Testing Frameworks
569
- - Jest for JavaScript/TypeScript
570
- - pytest for Python
571
- - RSpec for Ruby
572
- - JUnit for Java
573
- - Appropriate framework per language
574
-
575
- ## Test Patterns
576
- - Arrange-Act-Assert (AAA) pattern
577
- - Descriptive test names (not test1, test2)
578
- - One assertion per test when possible
579
- - Mock external dependencies
580
- - Test edge cases and error conditions
581
-
582
- ## Code Coverage
583
- - Aim for 80%+ coverage on critical code
584
- - Focus on business logic over getters/setters
585
- - Integration tests for coverage gaps
586
- - Coverage reports in CI/CD pipeline
587
-
588
- ## Best Practices
589
- - Tests run independently (no shared state)
590
- - Fast execution for developer experience
591
- - CI/CD integration with quality gates
592
- - Test data management and cleanup
593
- - Documentation of test scenarios
594
- `,
595
-
596
- 'api-development.instructions.md': `---
597
- name: api-development
598
- description: RESTful API design standards including versioning, error handling, and documentation.
599
- version: 1.0
600
- applyTo: "**/api/**,**/routes/**,**/controllers/**,**/services/**,**/*api*,**/*endpoint*"
601
- ---
602
-
603
- # API Development Guidelines
604
-
605
- ## RESTful Design
606
- - Proper HTTP methods (GET, POST, PUT, DELETE)
607
- - Resource-based URLs (/users, /users/{id})
608
- - Status codes: 200, 201, 400, 401, 403, 404, 500
609
- - Content-Type and Accept headers
610
- - Idempotent operations where appropriate
611
-
612
- ## API Versioning
613
- - URL versioning: /api/v1/users
614
- - Header versioning when needed
615
- - Backward compatibility maintenance
616
- - Deprecation notices for breaking changes
617
- - Version documentation
618
-
619
- ## Request/Response
620
- - JSON as primary format
621
- - Consistent response structure
622
- - Pagination for list endpoints
623
- - Filtering and sorting parameters
624
- - Rate limiting headers
625
-
626
- ## Error Handling
627
- - Consistent error response format
628
- - Appropriate HTTP status codes
629
- - User-friendly error messages
630
- - Error logging and monitoring
631
- - Graceful degradation
632
-
633
- ## Documentation
634
- - OpenAPI/Swagger specifications
635
- - Interactive API documentation
636
- - Authentication examples
637
- - Rate limiting information
638
- - Changelog for API versions
639
- `,
640
-
641
- 'github-actions.instructions.md': `---
642
- name: github-actions
643
- description: Standards for GitHub Actions workflows including security, performance, and best practices.
644
- version: 1.0
645
- applyTo: ".github/workflows/**/*.yml,.github/workflows/**/*.yaml"
646
- ---
647
-
648
- # GitHub Actions Development Guidelines
649
-
650
- ## Workflow Structure
651
- - Descriptive workflow names and jobs
652
- - Matrix builds for multiple environments
653
- - Proper job dependencies with needs
654
- - Conditional execution with if statements
655
- - Timeout settings for long-running jobs
656
-
657
- ## Security
658
- - Use trusted actions from GitHub Marketplace
659
- - Pin action versions to specific SHAs
660
- - Use secrets for sensitive data
661
- - CodeQL for security scanning
662
- - Dependency review for PRs
663
-
664
- ## Best Practices
665
- - Cache dependencies for faster builds
666
- - Use self-hosted runners when appropriate
667
- - Proper artifact management
668
- - Notification configuration
669
- - Workflow reusability with composite actions
670
-
671
- ## CI/CD Pipeline
672
- - Build → Test → Deploy stages
673
- - Parallel job execution
674
- - Failure handling and notifications
675
- - Rollback capabilities
676
- - Environment-specific configurations
677
-
678
- ## Performance
679
- - Efficient caching strategies
680
- - Minimal artifact sizes
681
- - Parallel job execution
682
- - Resource optimization
683
- - Build time monitoring
684
- `
685
- };
686
-
687
- for (const [filename, content] of Object.entries(instructions)) {
688
- await fs.writeFile(path.join(instructionsDir, filename), content);
689
- }
690
- }
691
-
692
265
  export default initCommand;
693
-
694
-
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: api-development
3
+ description: RESTful API design standards including versioning, error handling, and documentation.
4
+ version: 1.0
5
+ applyTo: "**/api/**,**/routes/**,**/controllers/**,**/services/**,**/*api*,**/*endpoint*"
6
+ ---
7
+
8
+ # API Development Guidelines
9
+
10
+ ## RESTful Design
11
+ - Proper HTTP methods (GET, POST, PUT, DELETE)
12
+ - Resource-based URLs (/users, /users/{id})
13
+ - Status codes: 200, 201, 400, 401, 403, 404, 500
14
+ - Content-Type and Accept headers
15
+ - Idempotent operations where appropriate
16
+
17
+ ## API Versioning
18
+ - URL versioning: /api/v1/users
19
+ - Header versioning when needed
20
+ - Backward compatibility maintenance
21
+ - Deprecation notices for breaking changes
22
+ - Version documentation
23
+
24
+ ## Request/Response
25
+ - JSON as primary format
26
+ - Consistent response structure
27
+ - Pagination for list endpoints
28
+ - Filtering and sorting parameters
29
+ - Rate limiting headers
30
+
31
+ ## Error Handling
32
+ - Consistent error response format
33
+ - Appropriate HTTP status codes
34
+ - User-friendly error messages
35
+ - Error logging and monitoring
36
+ - Graceful degradation
37
+
38
+ ## Documentation
39
+ - OpenAPI/Swagger specifications
40
+ - Interactive API documentation
41
+ - Authentication examples
42
+ - Rate limiting information
43
+ - Changelog for API versions
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: database-development
3
+ description: Standards for schema design, query optimization, and database migrations.
4
+ version: 1.0
5
+ applyTo: "**/prisma/**,**/*.sql,**/migrations/**,**/schema.*,**/db/**,**/models/**"
6
+ ---
7
+
8
+ # Database Development Guidelines
9
+
10
+ ## Schema Design
11
+ - UUID or ULID for primary keys (not auto-increment)
12
+ - Timestamps: createdAt, updatedAt on all tables
13
+ - Soft delete with deletedAt when needed
14
+ - Proper foreign key relationships
15
+ - Normalized schemas with good indexing
16
+
17
+ ## Query Optimization
18
+ - Use parameterized queries only (never string concat)
19
+ - Select only needed fields (avoid SELECT *)
20
+ - Use cursor-based pagination for large datasets
21
+ - Proper indexing on frequently queried fields
22
+ - Query execution plan analysis
23
+
24
+ ## ORM Best Practices
25
+ - Use transactions for multi-table operations
26
+ - N+1 query problem avoidance
27
+ - Proper eager/lazy loading
28
+ - Migration scripts for schema changes
29
+ - Database constraints and validations
30
+
31
+ ## Migration Safety
32
+ - One migration per feature/change
33
+ - Never modify already-applied migrations
34
+ - Test migrations on production-like data
35
+ - Rollback scripts for emergency recovery
36
+ - Version control for migration files
37
+
38
+ ## Performance
39
+ - Connection pooling configuration
40
+ - Query result caching strategies
41
+ - Database indexing strategy
42
+ - Read/write splitting when appropriate
43
+ - Monitoring and alerting setup
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: github-actions
3
+ description: Standards for GitHub Actions workflows including security, performance, and best practices.
4
+ version: 1.0
5
+ applyTo: ".github/workflows/**/*.yml,.github/workflows/**/*.yaml"
6
+ ---
7
+
8
+ # GitHub Actions Development Guidelines
9
+
10
+ ## Workflow Structure
11
+ - Descriptive workflow names and jobs
12
+ - Matrix builds for multiple environments
13
+ - Proper job dependencies with needs
14
+ - Conditional execution with if statements
15
+ - Timeout settings for long-running jobs
16
+
17
+ ## Security
18
+ - Use trusted actions from GitHub Marketplace
19
+ - Pin action versions to specific SHAs
20
+ - Use secrets for sensitive data
21
+ - CodeQL for security scanning
22
+ - Dependency review for PRs
23
+
24
+ ## Best Practices
25
+ - Cache dependencies for faster builds
26
+ - Use self-hosted runners when appropriate
27
+ - Proper artifact management
28
+ - Notification configuration
29
+ - Workflow reusability with composite actions
30
+
31
+ ## CI/CD Pipeline
32
+ - Build → Test → Deploy stages
33
+ - Parallel job execution
34
+ - Failure handling and notifications
35
+ - Rollback capabilities
36
+ - Environment-specific configurations
37
+
38
+ ## Performance
39
+ - Efficient caching strategies
40
+ - Minimal artifact sizes
41
+ - Parallel job execution
42
+ - Resource optimization
43
+ - Build time monitoring
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: javascript-development
3
+ description: Best practices for modern JavaScript development including ES6+ features and functional patterns.
4
+ version: 1.0
5
+ applyTo: "**/*.js,**/*.mjs,**/*.cjs"
6
+ ---
7
+
8
+ # JavaScript Development Guidelines
9
+
10
+ ## ES6+ Features
11
+ - Use `const` and `let` instead of `var`
12
+ - Arrow functions for callbacks and anonymous functions
13
+ - Template literals over string concatenation
14
+ - Destructuring for objects and arrays
15
+ - Spread/rest operators for manipulation
16
+
17
+ ## Code Patterns
18
+ - Prefer functional programming approaches
19
+ - Use async/await over Promises for readability
20
+ - Implement proper error handling with try/catch
21
+ - Use Map/Set for collections when appropriate
22
+ - Leverage object destructuring for configuration
23
+
24
+ ## Best Practices
25
+ - Strict mode: `'use strict'` at file/module level
26
+ - Consistent naming: camelCase for variables/functions
27
+ - Meaningful variable names over abbreviations
28
+ - Single responsibility principle for functions
29
+
30
+ ## Performance
31
+ - Avoid global variables
32
+ - Use efficient algorithms and data structures
33
+ - Minimize DOM manipulation
34
+ - Cache expensive operations
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: nextjs-development
3
+ description: Guidelines for Next.js development including App Router, Server Components, and SEO optimization.
4
+ version: 1.0
5
+ applyTo: "**/app/**,**/components/**,**/lib/**,**/utils/**"
6
+ ---
7
+
8
+ # Next.js Development Guidelines
9
+
10
+ ## App Router (App Directory)
11
+ - Server Components by default
12
+ - Client Components with 'use client' directive
13
+ - Server Actions for form handling
14
+ - Route Groups for organization: (auth), (dashboard)
15
+
16
+ ## File Structure
17
+ - `app/` for routing and layouts
18
+ - `components/` for reusable UI
19
+ - `lib/` for utilities and configurations
20
+ - `utils/` for helper functions
21
+ - `types/` for TypeScript definitions
22
+
23
+ ## Data Fetching
24
+ - Server Components for initial data
25
+ - Client Components for interactive data
26
+ - SWR or React Query for client-side fetching
27
+ - Server Actions for mutations
28
+
29
+ ## Performance
30
+ - Image optimization with next/image
31
+ - Font optimization with next/font
32
+ - Code splitting automatic
33
+ - Static generation when possible
34
+ - ISR for dynamic content
35
+
36
+ ## SEO & Metadata
37
+ - Metadata API for dynamic meta tags
38
+ - Static metadata exports
39
+ - Open Graph and Twitter cards
40
+ - Structured data with JSON-LD
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: python-development
3
+ description: Best practices for Python development including type hints, async/await, and testing.
4
+ version: 1.0
5
+ applyTo: "**/*.py"
6
+ ---
7
+
8
+ # Python Development Guidelines
9
+
10
+ ## Type Hints & Annotations
11
+ - Use type hints for all function signatures
12
+ - Use `from __future__ import annotations` for forward refs
13
+ - Prefer `typing.Optional` over `X | None` for Python 3.9 compat
14
+ - Generic types with `TypeVar` when needed
15
+
16
+ ## Code Patterns
17
+ - Use dataclasses or Pydantic for data structures
18
+ - Async/await for I/O bound operations
19
+ - Context managers (`with` statements) for resource management
20
+ - List/dict comprehensions for transformations
21
+ - Generator functions for large datasets
22
+
23
+ ## Best Practices
24
+ - Follow PEP 8 style guidelines
25
+ - Use Black for code formatting
26
+ - Google/NumPy style docstrings
27
+ - Meaningful variable names
28
+ - Single responsibility principle
29
+
30
+ ## Error Handling
31
+ - Custom exception classes
32
+ - Specific exception types over generic Exception
33
+ - Proper exception chaining
34
+ - Logging with appropriate levels
35
+
36
+ ## Testing
37
+ - pytest framework preferred
38
+ - Unit tests for functions/classes
39
+ - Integration tests for workflows
40
+ - Mock external dependencies
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: react-development
3
+ description: Component patterns, state management, and accessibility standards for React development.
4
+ version: 1.0
5
+ applyTo: "**/*.jsx,**/*.tsx,**/*react*"
6
+ ---
7
+
8
+ # React Development Guidelines
9
+
10
+ ## Component Patterns
11
+ - Functional components with hooks over class components
12
+ - Custom hooks for reusable logic
13
+ - Compound components for complex UI patterns
14
+ - Container/Presentational separation when appropriate
15
+
16
+ ## State Management
17
+ - useState for local component state
18
+ - useReducer for complex state logic
19
+ - Context API for theme/configuration
20
+ - External libraries (Zustand, Redux) for app-wide state
21
+
22
+ ## Performance
23
+ - React.memo for expensive components
24
+ - useMemo for expensive calculations
25
+ - useCallback for event handlers
26
+ - Lazy loading with React.lazy and Suspense
27
+ - Code splitting for large applications
28
+
29
+ ## Hooks Best Practices
30
+ - Custom hooks for side effects
31
+ - useEffect cleanup functions
32
+ - Dependency arrays correctly specified
33
+ - Avoid conditional hook calls
34
+
35
+ ## Accessibility
36
+ - Semantic HTML elements
37
+ - ARIA attributes when needed
38
+ - Keyboard navigation support
39
+ - Screen reader compatibility
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: security-development
3
+ description: Comprehensive security guidelines including auth, data protection, and web security.
4
+ version: 1.0
5
+ applyTo: "**/auth/**,**/security/**,**/*auth*,**/*token*,**/*session*,**/middleware/**"
6
+ ---
7
+
8
+ # Security Development Guidelines
9
+
10
+ ## Authentication & Authorization
11
+ - JWT with short expiry + refresh tokens
12
+ - HttpOnly cookies for web sessions
13
+ - Rate limiting on authentication endpoints
14
+ - RBAC or ABAC patterns implemented
15
+ - Server-side permission checks always
16
+
17
+ ## Data Protection
18
+ - Input sanitization and validation
19
+ - Output encoding by context (HTML, SQL, JSON)
20
+ - Never log sensitive data (passwords, tokens, PII)
21
+ - Encryption at rest and in transit
22
+ - Secure password hashing (bcrypt, Argon2)
23
+
24
+ ## Web Security
25
+ - CSRF tokens for state-changing operations
26
+ - Content Security Policy (CSP) headers
27
+ - HTTPS enforcement (HSTS)
28
+ - Secure headers (X-Frame-Options, etc.)
29
+ - XSS prevention with proper escaping
30
+
31
+ ## API Security
32
+ - API versioning for breaking changes
33
+ - Request/response validation schemas
34
+ - CORS configuration for allowed origins
35
+ - API rate limiting and throttling
36
+ - Proper error messages (no sensitive info)
37
+
38
+ ## OWASP Top 10
39
+ - Injection prevention (parameterized queries)
40
+ - Broken authentication handling
41
+ - Sensitive data exposure protection
42
+ - XML external entity prevention
43
+ - Access control enforcement
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: testing-development
3
+ description: Guidelines for test structure, frameworks, and code coverage best practices.
4
+ version: 1.0
5
+ applyTo: "**/*.test.*,**/*.spec.*,**/tests/**,**/__tests__/**"
6
+ ---
7
+
8
+ # Testing Development Guidelines
9
+
10
+ ## Test Structure
11
+ - Unit tests for individual functions/classes
12
+ - Integration tests for component interactions
13
+ - End-to-end tests for user workflows
14
+ - Performance tests for critical paths
15
+ - Accessibility tests for UI components
16
+
17
+ ## Testing Frameworks
18
+ - Jest for JavaScript/TypeScript
19
+ - pytest for Python
20
+ - RSpec for Ruby
21
+ - JUnit for Java
22
+ - Appropriate framework per language
23
+
24
+ ## Test Patterns
25
+ - Arrange-Act-Assert (AAA) pattern
26
+ - Descriptive test names (not test1, test2)
27
+ - One assertion per test when possible
28
+ - Mock external dependencies
29
+ - Test edge cases and error conditions
30
+
31
+ ## Code Coverage
32
+ - Aim for 80%+ coverage on critical code
33
+ - Focus on business logic over getters/setters
34
+ - Integration tests for coverage gaps
35
+ - Coverage reports in CI/CD pipeline
36
+
37
+ ## Best Practices
38
+ - Tests run independently (no shared state)
39
+ - Fast execution for developer experience
40
+ - CI/CD integration with quality gates
41
+ - Test data management and cleanup
42
+ - Documentation of test scenarios
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: typescript-development
3
+ description: Strict guidelines for TypeScript development including type safety, modules, and error handling.
4
+ version: 1.0
5
+ applyTo: "**/*.ts,**/*.tsx,**/*.mts,**/*.cts"
6
+ ---
7
+
8
+ # TypeScript Development Guidelines
9
+
10
+ ## Strict Mode & Type Safety
11
+ - Enable `strict: true` in tsconfig.json
12
+ - No `any` types - use `unknown` and narrow with type guards
13
+ - Explicit return types for public functions
14
+ - Use `strictNullChecks` and `noImplicitAny`
15
+
16
+ ## Code Patterns
17
+ - Prefer `interface` over `type` for object shapes
18
+ - Use `as const` for literal types and enums
19
+ - Leverage discriminated unions for state management
20
+ - Use mapped types for transformations
21
+ - Prefer `readonly` for immutable data
22
+
23
+ ## Imports & Modules
24
+ - Use type-only imports: `import type { X } from 'y'`
25
+ - Barrel exports for public APIs only
26
+ - Avoid relative imports with `../` - use absolute paths
27
+
28
+ ## Error Handling
29
+ - Use custom error classes extending `Error`
30
+ - Prefer Result types over throwing exceptions
31
+ - Use try/catch only for external operations