metacoding 1.0.0 → 1.1.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 (46) hide show
  1. package/CHANGELOG.md +68 -43
  2. package/LICENSE +1 -1
  3. package/lib/services/template-manager.d.ts +3 -0
  4. package/lib/services/template-manager.d.ts.map +1 -1
  5. package/lib/services/template-manager.js +126 -9
  6. package/lib/services/template-manager.js.map +1 -1
  7. package/lib/services/vscode.js +1 -1
  8. package/lib/services/vscode.js.map +1 -1
  9. package/package.json +4 -4
  10. package/templates/general/code-review.instructions.md +265 -0
  11. package/templates/general/{files/copilot-instructions.md.template → copilot-instructions.md} +97 -140
  12. package/templates/{python/files → general}/docs-update.instructions.md +45 -32
  13. package/templates/general/release.instructions.md +242 -0
  14. package/templates/general/test-runner.instructions.md +188 -0
  15. package/templates/node/nodejs.coding.instructions.md +249 -0
  16. package/templates/node/nodejs.docs.instructions.md +234 -0
  17. package/templates/node/nodejs.testing.instructions.md +373 -0
  18. package/templates/python/python.coding.instructions.md +339 -0
  19. package/templates/python/python.docs.instructions.md +1147 -0
  20. package/templates/python/python.testing.instructions.md +1074 -0
  21. package/templates/react/react.coding.instructions.md +695 -0
  22. package/templates/react/react.docs.instructions.md +427 -0
  23. package/templates/react/react.testing.instructions.md +193 -0
  24. package/templates/react/test-runner.instructions.md +135 -0
  25. package/templates/typescript/template.json +16 -0
  26. package/templates/typescript/typescript.coding.instructions.md +368 -0
  27. package/templates/typescript/typescript.docs.instructions.md +734 -0
  28. package/templates/typescript/typescript.testing.instructions.md +740 -0
  29. package/templates/general/files/code-review.instructions.md +0 -111
  30. package/templates/general/files/docs-update.instructions.md +0 -203
  31. package/templates/general/files/release.instructions.md +0 -72
  32. package/templates/general/files/test-runner.instructions.md +0 -107
  33. package/templates/node/files/code-review.instructions.md +0 -222
  34. package/templates/node/files/copilot-instructions.md.template +0 -391
  35. package/templates/node/files/docs-update.instructions.md +0 -203
  36. package/templates/node/files/release.instructions.md +0 -72
  37. package/templates/node/files/test-runner.instructions.md +0 -108
  38. package/templates/python/files/code-review.instructions.md +0 -215
  39. package/templates/python/files/copilot-instructions.md.template +0 -418
  40. package/templates/python/files/release.instructions.md +0 -72
  41. package/templates/python/files/test-runner.instructions.md +0 -108
  42. package/templates/react/files/code-review.instructions.md +0 -160
  43. package/templates/react/files/copilot-instructions.md.template +0 -472
  44. package/templates/react/files/docs-update.instructions.md +0 -203
  45. package/templates/react/files/release.instructions.md +0 -72
  46. package/templates/react/files/test-runner.instructions.md +0 -108
@@ -0,0 +1,249 @@
1
+ ---
2
+ description: 'Node.js backend development coding standards and best practices'
3
+ applyTo: 'src/**/*.{ts,js}'
4
+ ---
5
+
6
+ # Node.js Backend Development Guidelines
7
+
8
+ ## Core Node.js Principles
9
+
10
+ - **Event Loop Awareness:** Understand the event loop and avoid blocking operations
11
+ - **Asynchronous Programming:** Use async/await for I/O operations, avoid callback hell
12
+ - **Module System:** Leverage ES modules with proper import/export patterns
13
+ - **Process Management:** Handle process signals and graceful shutdowns
14
+ - **Error Handling:** Implement comprehensive error handling with proper stack traces
15
+
16
+ ## API Development Standards
17
+
18
+ ### RESTful API Design
19
+
20
+ - **Resource-Based URLs:** Use nouns for endpoints (`/users`, `/orders`, not `/getUsers`)
21
+ - **HTTP Methods:** Use appropriate HTTP verbs (GET, POST, PUT, DELETE, PATCH)
22
+ - **Status Codes:** Return meaningful HTTP status codes (200, 201, 400, 401, 404, 500)
23
+ - **Consistent Response Format:** Standardize API response structure
24
+ - **Versioning:** Implement API versioning (`/api/v1/users`)
25
+
26
+ ```typescript
27
+ // Good: RESTful endpoint structure
28
+ app.get('/api/v1/users/:id', async (req, res) => {
29
+ try {
30
+ const user = await userService.findById(req.params.id);
31
+ res.status(200).json({ data: user, success: true });
32
+ } catch (error) {
33
+ res.status(404).json({ error: 'User not found', success: false });
34
+ }
35
+ });
36
+ ```
37
+
38
+ ### Middleware Architecture
39
+
40
+ - **Authentication Middleware:** Centralize auth logic in reusable middleware
41
+ - **Validation Middleware:** Validate request data before processing
42
+ - **Error Handling Middleware:** Implement global error handling
43
+ - **Logging Middleware:** Log requests, responses, and errors
44
+ - **Rate Limiting:** Protect APIs from abuse
45
+
46
+ ```typescript
47
+ // Example middleware pattern
48
+ const authenticate = (req: Request, res: Response, next: NextFunction) => {
49
+ const token = req.headers.authorization?.split(' ')[1];
50
+ if (!token) {
51
+ return res.status(401).json({ error: 'No token provided' });
52
+ }
53
+ // Verify token logic
54
+ next();
55
+ };
56
+ ```
57
+
58
+ ## Database Integration
59
+
60
+ ### Connection Management
61
+
62
+ - **Connection Pooling:** Use connection pools for database connections
63
+ - **Transaction Handling:** Implement proper transaction management
64
+ - **Migration Strategy:** Use database migrations for schema changes
65
+ - **Environment Configuration:** Separate configs for dev/staging/production
66
+
67
+ ### ORM/Query Builder Best Practices
68
+
69
+ - **Model Relationships:** Define clear model relationships
70
+ - **Query Optimization:** Avoid N+1 queries, use eager loading appropriately
71
+ - **Data Validation:** Validate data at the model level
72
+ - **Soft Deletes:** Implement soft deletes for audit trails
73
+
74
+ ```typescript
75
+ // Example with proper transaction handling
76
+ async function transferFunds(fromId: string, toId: string, amount: number) {
77
+ const transaction = await db.transaction();
78
+ try {
79
+ await accountService.debit(fromId, amount, { transaction });
80
+ await accountService.credit(toId, amount, { transaction });
81
+ await transaction.commit();
82
+ } catch (error) {
83
+ await transaction.rollback();
84
+ throw error;
85
+ }
86
+ }
87
+ ```
88
+
89
+ ## Security Best Practices
90
+
91
+ ### Input Validation and Sanitization
92
+
93
+ - **Schema Validation:** Use libraries like Joi, Yup, or Zod for input validation
94
+ - **SQL Injection Prevention:** Use parameterized queries or ORM
95
+ - **XSS Prevention:** Sanitize user inputs and use Content Security Policy
96
+ - **CORS Configuration:** Configure CORS appropriately for your use case
97
+
98
+ ### Authentication and Authorization
99
+
100
+ - **JWT Implementation:** Implement secure JWT token handling
101
+ - **Password Security:** Use bcrypt for password hashing
102
+ - **Rate Limiting:** Implement rate limiting for login attempts
103
+ - **Session Management:** Secure session handling and cleanup
104
+
105
+ ```typescript
106
+ // Example secure password handling
107
+ import bcrypt from 'bcrypt';
108
+
109
+ async function hashPassword(password: string): Promise<string> {
110
+ const saltRounds = 12;
111
+ return bcrypt.hash(password, saltRounds);
112
+ }
113
+
114
+ async function verifyPassword(
115
+ password: string,
116
+ hash: string
117
+ ): Promise<boolean> {
118
+ return bcrypt.compare(password, hash);
119
+ }
120
+ ```
121
+
122
+ ## Performance Optimization
123
+
124
+ ### Caching Strategies
125
+
126
+ - **Redis Integration:** Use Redis for session storage and caching
127
+ - **HTTP Caching:** Implement proper HTTP caching headers
128
+ - **Database Caching:** Cache frequently accessed database queries
129
+ - **CDN Integration:** Use CDNs for static assets
130
+
131
+ ### Memory Management
132
+
133
+ - **Memory Leak Prevention:** Monitor and prevent memory leaks
134
+ - **Garbage Collection:** Understand V8 garbage collection
135
+ - **Stream Processing:** Use streams for large data processing
136
+ - **Worker Threads:** Utilize worker threads for CPU-intensive tasks
137
+
138
+ ## Error Handling and Logging
139
+
140
+ ### Comprehensive Error Handling
141
+
142
+ - **Global Error Handler:** Implement application-wide error handling
143
+ - **Custom Error Classes:** Create specific error types for different scenarios
144
+ - **Error Reporting:** Integrate with error tracking services (Sentry, etc.)
145
+ - **Graceful Degradation:** Handle service failures gracefully
146
+
147
+ ```typescript
148
+ // Example custom error classes
149
+ class ValidationError extends Error {
150
+ constructor(
151
+ message: string,
152
+ public field: string
153
+ ) {
154
+ super(message);
155
+ this.name = 'ValidationError';
156
+ }
157
+ }
158
+
159
+ class DatabaseError extends Error {
160
+ constructor(
161
+ message: string,
162
+ public query?: string
163
+ ) {
164
+ super(message);
165
+ this.name = 'DatabaseError';
166
+ }
167
+ }
168
+ ```
169
+
170
+ ### Structured Logging
171
+
172
+ - **Log Levels:** Use appropriate log levels (error, warn, info, debug)
173
+ - **Structured Format:** Use JSON logging for machine readability
174
+ - **Request Correlation:** Implement request ID correlation
175
+ - **Performance Logging:** Log response times and performance metrics
176
+
177
+ ## Environment and Configuration
178
+
179
+ ### Environment Management
180
+
181
+ - **Environment Variables:** Use .env files for configuration
182
+ - **Configuration Validation:** Validate configuration at startup
183
+ - **Secrets Management:** Secure handling of API keys and secrets
184
+ - **Multi-Environment Support:** Support dev/staging/production configs
185
+
186
+ ### Deployment Considerations
187
+
188
+ - **Health Checks:** Implement health check endpoints
189
+ - **Graceful Shutdown:** Handle SIGTERM and SIGINT signals
190
+ - **Process Monitoring:** Use PM2 or similar for process management
191
+ - **Container Optimization:** Optimize Docker images for Node.js
192
+
193
+ ```typescript
194
+ // Example graceful shutdown
195
+ process.on('SIGTERM', async () => {
196
+ console.log('SIGTERM received, shutting down gracefully');
197
+ await server.close();
198
+ await database.disconnect();
199
+ process.exit(0);
200
+ });
201
+ ```
202
+
203
+ ## Testing Strategies
204
+
205
+ ### API Testing
206
+
207
+ - **Integration Tests:** Test complete request/response cycles
208
+ - **Contract Testing:** Verify API contracts and schemas
209
+ - **Load Testing:** Test performance under load
210
+ - **Security Testing:** Test for common vulnerabilities
211
+
212
+ ### Mocking and Stubbing
213
+
214
+ - **Database Mocking:** Mock database calls in unit tests
215
+ - **External Service Mocking:** Mock third-party API calls
216
+ - **Time Mocking:** Mock dates and times for consistent testing
217
+ - **Environment Mocking:** Mock environment variables
218
+
219
+ ## Package Management
220
+
221
+ ### Dependency Management
222
+
223
+ - **Lock Files:** Always commit package-lock.json
224
+ - **Security Audits:** Regular npm audit and vulnerability checks
225
+ - **Version Pinning:** Pin critical dependencies to specific versions
226
+ - **Dev Dependencies:** Separate development and production dependencies
227
+
228
+ ### Performance Dependencies
229
+
230
+ - **Bundle Analysis:** Analyze bundle size and dependencies
231
+ - **Tree Shaking:** Ensure unused code is eliminated
232
+ - **Critical Path:** Optimize critical path dependencies
233
+ - **Lazy Loading:** Implement lazy loading where appropriate
234
+
235
+ ## Monitoring and Observability
236
+
237
+ ### Application Monitoring
238
+
239
+ - **Metrics Collection:** Collect application and business metrics
240
+ - **Performance Monitoring:** Monitor response times and throughput
241
+ - **Error Tracking:** Track and alert on errors
242
+ - **Custom Dashboards:** Create dashboards for key metrics
243
+
244
+ ### Debugging Tools
245
+
246
+ - **Node.js Debugger:** Use built-in debugging tools
247
+ - **Memory Profiling:** Profile memory usage and leaks
248
+ - **CPU Profiling:** Identify performance bottlenecks
249
+ - **Distributed Tracing:** Implement distributed tracing for microservices
@@ -0,0 +1,234 @@
1
+ ---
2
+ description: 'Node.js backend documentation standards and API documentation guidelines'
3
+ applyTo: '**/*.md'
4
+ ---
5
+
6
+ # Node.js Backend Documentation Guidelines
7
+
8
+ ## API Documentation Standards
9
+
10
+ ### OpenAPI/Swagger Documentation
11
+
12
+ - **Schema Definition:** Define complete API schemas using OpenAPI 3.0+
13
+ - **Interactive Documentation:** Provide interactive API documentation
14
+ - **Code Examples:** Include request/response examples in multiple languages
15
+ - **Authentication Documentation:** Document all authentication methods
16
+ - **Error Response Documentation:** Document all possible error responses
17
+
18
+ ```yaml
19
+ # Example OpenAPI schema
20
+ paths:
21
+ /api/v1/users:
22
+ get:
23
+ summary: Get all users
24
+ parameters:
25
+ - name: page
26
+ in: query
27
+ schema:
28
+ type: integer
29
+ default: 1
30
+ responses:
31
+ '200':
32
+ description: Successful response
33
+ content:
34
+ application/json:
35
+ schema:
36
+ type: object
37
+ properties:
38
+ data:
39
+ type: array
40
+ items:
41
+ $ref: '#/components/schemas/User'
42
+ ```
43
+
44
+ ### Endpoint Documentation
45
+
46
+ - **Purpose Description:** Clearly describe what each endpoint does
47
+ - **Request Parameters:** Document all query parameters, path parameters, and request body
48
+ - **Response Format:** Document response structure and data types
49
+ - **Status Codes:** List all possible HTTP status codes and their meanings
50
+ - **Rate Limiting:** Document rate limiting rules and headers
51
+
52
+ ### Authentication Documentation
53
+
54
+ - **Token Format:** Document JWT structure and claims
55
+ - **Authorization Flow:** Describe OAuth or other auth flows
56
+ - **Scope Documentation:** Document API scopes and permissions
57
+ - **Token Refresh:** Document token refresh procedures
58
+ - **Security Headers:** Document required security headers
59
+
60
+ ## Database Documentation
61
+
62
+ ### Schema Documentation
63
+
64
+ - **Entity Relationship Diagrams:** Visual representation of database schema
65
+ - **Table Descriptions:** Purpose and usage of each table
66
+ - **Column Documentation:** Data types, constraints, and relationships
67
+ - **Index Documentation:** Performance-critical indexes
68
+ - **Migration History:** Document major schema changes
69
+
70
+ ### Data Flow Documentation
71
+
72
+ - **CRUD Operations:** Document create, read, update, delete patterns
73
+ - **Transaction Boundaries:** Document transaction scopes
74
+ - **Data Validation Rules:** Business rules and constraints
75
+ - **Audit Trail:** Document audit and logging mechanisms
76
+ - **Backup and Recovery:** Document backup strategies
77
+
78
+ ## Environment and Deployment Documentation
79
+
80
+ ### Configuration Documentation
81
+
82
+ - **Environment Variables:** Complete list with descriptions and examples
83
+ - **Configuration Files:** Document all configuration files and their purpose
84
+ - **Secrets Management:** Document how secrets are handled
85
+ - **Feature Flags:** Document feature flag configurations
86
+ - **Third-Party Services:** Document external service dependencies
87
+
88
+ ```markdown
89
+ ## Environment Variables
90
+
91
+ | Variable | Description | Example | Required |
92
+ | ------------ | -------------------------- | ----------------------------------- | -------- |
93
+ | DATABASE_URL | Database connection string | postgresql://user:pass@localhost/db | Yes |
94
+ | JWT_SECRET | Secret key for JWT tokens | your-secret-key | Yes |
95
+ | REDIS_URL | Redis connection string | redis://localhost:6379 | No |
96
+ ```
97
+
98
+ ### Deployment Documentation
99
+
100
+ - **Build Process:** Document build and compilation steps
101
+ - **Docker Configuration:** Document container setup and requirements
102
+ - **Health Checks:** Document health check endpoints and criteria
103
+ - **Scaling Considerations:** Document horizontal and vertical scaling
104
+ - **Monitoring Setup:** Document monitoring and alerting configuration
105
+
106
+ ## Error Handling Documentation
107
+
108
+ ### Error Response Format
109
+
110
+ - **Consistent Structure:** Standardize error response format
111
+ - **Error Codes:** Document custom error codes and meanings
112
+ - **Localization:** Document multi-language error message support
113
+ - **Debug Information:** Document debug info inclusion in development
114
+ - **Error Recovery:** Document error recovery strategies
115
+
116
+ ```typescript
117
+ // Example error response format
118
+ interface ErrorResponse {
119
+ success: false;
120
+ error: {
121
+ code: string;
122
+ message: string;
123
+ details?: any;
124
+ timestamp: string;
125
+ requestId: string;
126
+ };
127
+ }
128
+ ```
129
+
130
+ ### Troubleshooting Guides
131
+
132
+ - **Common Issues:** Document frequently encountered problems
133
+ - **Debug Steps:** Step-by-step debugging procedures
134
+ - **Log Analysis:** How to interpret logs and error messages
135
+ - **Performance Issues:** Common performance problems and solutions
136
+ - **Service Dependencies:** Troubleshooting external service issues
137
+
138
+ ## Performance Documentation
139
+
140
+ ### Performance Benchmarks
141
+
142
+ - **Response Time Targets:** Document expected response times
143
+ - **Throughput Metrics:** Document expected requests per second
144
+ - **Resource Usage:** Document memory and CPU usage patterns
145
+ - **Database Performance:** Document query performance expectations
146
+ - **Caching Strategies:** Document caching implementations and TTLs
147
+
148
+ ### Optimization Guidelines
149
+
150
+ - **Profiling Tools:** Document profiling and monitoring tools
151
+ - **Bottleneck Identification:** Common performance bottlenecks
152
+ - **Optimization Techniques:** Proven optimization strategies
153
+ - **Load Testing:** Document load testing procedures
154
+ - **Capacity Planning:** Guidelines for scaling decisions
155
+
156
+ ## Security Documentation
157
+
158
+ ### Security Architecture
159
+
160
+ - **Threat Model:** Document potential security threats
161
+ - **Security Controls:** Document implemented security measures
162
+ - **Vulnerability Management:** Document security update procedures
163
+ - **Penetration Testing:** Document security testing procedures
164
+ - **Compliance Requirements:** Document regulatory compliance needs
165
+
166
+ ### Security Configuration
167
+
168
+ - **HTTPS Configuration:** SSL/TLS setup and best practices
169
+ - **CORS Configuration:** Cross-origin resource sharing setup
170
+ - **Security Headers:** Required security headers and their purposes
171
+ - **Input Validation:** Document validation rules and sanitization
172
+ - **Rate Limiting:** Document rate limiting implementation
173
+
174
+ ## Development Workflow Documentation
175
+
176
+ ### Code Organization
177
+
178
+ - **Project Structure:** Document folder and file organization
179
+ - **Module Dependencies:** Document internal module relationships
180
+ - **Design Patterns:** Document architectural patterns used
181
+ - **Code Style:** Document coding standards and conventions
182
+ - **Git Workflow:** Document branching and commit strategies
183
+
184
+ ### Development Setup
185
+
186
+ - **Prerequisites:** Required tools and versions
187
+ - **Installation Steps:** Step-by-step setup instructions
188
+ - **Database Setup:** Local database configuration
189
+ - **Environment Setup:** Development environment configuration
190
+ - **IDE Configuration:** Recommended IDE settings and extensions
191
+
192
+ ### Testing Documentation
193
+
194
+ - **Test Structure:** Document test organization and naming
195
+ - **Test Data:** Document test fixtures and data setup
196
+ - **Mocking Strategies:** Document mocking patterns
197
+ - **Coverage Requirements:** Document test coverage targets
198
+ - **CI/CD Integration:** Document automated testing in pipelines
199
+
200
+ ## Monitoring and Observability Documentation
201
+
202
+ ### Metrics Documentation
203
+
204
+ - **Business Metrics:** Key business indicators to track
205
+ - **Technical Metrics:** System performance metrics
206
+ - **Custom Metrics:** Application-specific metrics
207
+ - **Alert Thresholds:** When to alert on metric values
208
+ - **Dashboard Configuration:** Key dashboards and their purposes
209
+
210
+ ### Logging Documentation
211
+
212
+ - **Log Levels:** When to use each log level
213
+ - **Log Format:** Structured logging format and fields
214
+ - **Log Correlation:** Request tracking and correlation
215
+ - **Log Retention:** Log storage and retention policies
216
+ - **Log Analysis:** Common log analysis patterns
217
+
218
+ ## Runbook Documentation
219
+
220
+ ### Operational Procedures
221
+
222
+ - **Deployment Procedures:** Step-by-step deployment process
223
+ - **Rollback Procedures:** How to rollback failed deployments
224
+ - **Backup Procedures:** Database and file backup processes
225
+ - **Disaster Recovery:** Recovery procedures for major incidents
226
+ - **Maintenance Windows:** Planned maintenance procedures
227
+
228
+ ### Incident Response
229
+
230
+ - **On-Call Procedures:** Who to contact during incidents
231
+ - **Escalation Matrix:** When and how to escalate issues
232
+ - **Communication Templates:** Incident communication templates
233
+ - **Post-Incident Reviews:** How to conduct post-mortems
234
+ - **Knowledge Base:** Common issues and their solutions