claudex-setup 1.4.0 → 1.6.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.
- package/package.json +1 -1
- package/src/setup.js +91 -4
- package/src/techniques.js +2 -0
package/package.json
CHANGED
package/src/setup.js
CHANGED
|
@@ -95,6 +95,17 @@ function detectDependencies(ctx) {
|
|
|
95
95
|
guidelines.push('- Use Playwright for E2E tests. Keep tests in tests/ or e2e/');
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// Testing tools
|
|
99
|
+
if (allDeps['msw']) {
|
|
100
|
+
guidelines.push('- Use MSW (Mock Service Worker) for API mocking in tests. Define handlers in __mocks__/');
|
|
101
|
+
}
|
|
102
|
+
if (allDeps['@testing-library/react']) {
|
|
103
|
+
guidelines.push('- Use Testing Library for component tests. Prefer userEvent over fireEvent, query by role/label');
|
|
104
|
+
}
|
|
105
|
+
if (allDeps['@vitest/coverage-v8'] || allDeps['@vitest/coverage-istanbul']) {
|
|
106
|
+
guidelines.push('- Coverage configured. Maintain coverage thresholds. Check reports before merging');
|
|
107
|
+
}
|
|
108
|
+
|
|
98
109
|
// tRPC
|
|
99
110
|
if (allDeps['@trpc/server'] || allDeps['@trpc/client']) {
|
|
100
111
|
guidelines.push('- Use tRPC for type-safe API calls. Define routers in server, use client hooks in components');
|
|
@@ -197,6 +208,39 @@ function detectDependencies(ctx) {
|
|
|
197
208
|
guidelines.push('- AWS CDK available. Define stacks in lib/, constructs as separate classes');
|
|
198
209
|
}
|
|
199
210
|
|
|
211
|
+
// Security middleware
|
|
212
|
+
if (allDeps['express-rate-limit']) {
|
|
213
|
+
guidelines.push('- Rate limiting configured. Apply to auth endpoints. Set appropriate windowMs and max values');
|
|
214
|
+
}
|
|
215
|
+
if (allDeps['hpp']) {
|
|
216
|
+
guidelines.push('- HPP (HTTP Parameter Pollution) protection enabled');
|
|
217
|
+
}
|
|
218
|
+
if (allDeps['csurf']) {
|
|
219
|
+
guidelines.push('- CSRF protection enabled. Ensure tokens are included in all state-changing requests');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// AWS Lambda
|
|
223
|
+
if (allDeps['@aws-sdk/client-lambda'] || allDeps['@aws-cdk/aws-lambda'] || allDeps['aws-cdk-lib']) {
|
|
224
|
+
guidelines.push('- Lambda handlers: keep cold start fast, use layers for deps, set appropriate memory/timeout');
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Deprecated dependency warnings
|
|
228
|
+
if (allDeps['moment']) {
|
|
229
|
+
guidelines.push('- ⚠️ moment.js is deprecated and heavy (330KB). Migrate to date-fns or dayjs');
|
|
230
|
+
}
|
|
231
|
+
if (allDeps['request']) {
|
|
232
|
+
guidelines.push('- ⚠️ request is deprecated. Use fetch (native) or axios instead');
|
|
233
|
+
}
|
|
234
|
+
if (allDeps['lodash'] && !allDeps['lodash-es']) {
|
|
235
|
+
guidelines.push('- Consider replacing lodash with native JS methods or lodash-es for tree-shaking');
|
|
236
|
+
}
|
|
237
|
+
if (allDeps['node-sass']) {
|
|
238
|
+
guidelines.push('- ⚠️ node-sass is deprecated. Migrate to sass (dart-sass)');
|
|
239
|
+
}
|
|
240
|
+
if (allDeps['tslint']) {
|
|
241
|
+
guidelines.push('- ⚠️ TSLint is deprecated. Migrate to ESLint with @typescript-eslint');
|
|
242
|
+
}
|
|
243
|
+
|
|
200
244
|
return guidelines;
|
|
201
245
|
}
|
|
202
246
|
|
|
@@ -371,7 +415,14 @@ function getFrameworkInstructions(stacks) {
|
|
|
371
415
|
- Prefer Server Components by default; add 'use client' only when needed
|
|
372
416
|
- Use next/image for images, next/link for navigation
|
|
373
417
|
- API routes go in app/api/ (App Router) or pages/api/ (Pages Router)
|
|
374
|
-
- Use loading.tsx, error.tsx, and not-found.tsx for route-level UX
|
|
418
|
+
- Use loading.tsx, error.tsx, and not-found.tsx for route-level UX
|
|
419
|
+
|
|
420
|
+
### Next.js App Router
|
|
421
|
+
- Default to Server Components. Add 'use client' only when needed (hooks, events, browser APIs)
|
|
422
|
+
- Use Server Actions for mutations. Validate with Zod, call revalidatePath after writes
|
|
423
|
+
- Route handlers in app/api/ export named functions: GET, POST, PUT, DELETE
|
|
424
|
+
- Use loading.tsx, error.tsx, not-found.tsx for route-level UI states
|
|
425
|
+
- Middleware in middleware.ts for auth checks, redirects, headers`);
|
|
375
426
|
} else if (stackKeys.includes('react')) {
|
|
376
427
|
sections.push(`### React
|
|
377
428
|
- Use functional components with hooks exclusively
|
|
@@ -444,7 +495,26 @@ function getFrameworkInstructions(stacks) {
|
|
|
444
495
|
- Handle all errors explicitly — never ignore err returns
|
|
445
496
|
- Use context.Context for cancellation and timeouts
|
|
446
497
|
- Prefer table-driven tests
|
|
447
|
-
- Run \`go vet\` and \`golangci-lint\` before committing
|
|
498
|
+
- Run \`go vet\` and \`golangci-lint\` before committing
|
|
499
|
+
- If using gRPC: define .proto files in proto/ or pkg/proto, generate with protoc
|
|
500
|
+
- If Makefile exists: use make targets for build/test/lint
|
|
501
|
+
- Organize: cmd/ for entry points, internal/ for private packages, pkg/ for public`);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
if (stackKeys.includes('cpp')) {
|
|
505
|
+
sections.push(`### C++
|
|
506
|
+
- Follow project coding standards (check .clang-format if present)
|
|
507
|
+
- Use smart pointers (unique_ptr, shared_ptr) over raw pointers
|
|
508
|
+
- Run clang-tidy for static analysis
|
|
509
|
+
- Prefer const references for function parameters
|
|
510
|
+
- Use CMake targets, not raw compiler flags`);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (stackKeys.includes('bazel')) {
|
|
514
|
+
sections.push(`### Bazel
|
|
515
|
+
- Define BUILD files per package. Keep targets focused
|
|
516
|
+
- Use visibility carefully — prefer package-private
|
|
517
|
+
- Run buildifier for formatting`);
|
|
448
518
|
}
|
|
449
519
|
|
|
450
520
|
if (stackKeys.includes('terraform')) {
|
|
@@ -453,7 +523,10 @@ function getFrameworkInstructions(stacks) {
|
|
|
453
523
|
- Always run \`terraform plan\` before \`terraform apply\`
|
|
454
524
|
- Store state remotely (S3 + DynamoDB, or Terraform Cloud)
|
|
455
525
|
- Use variables.tf for all configurable values
|
|
456
|
-
- Tag all resources consistently
|
|
526
|
+
- Tag all resources consistently
|
|
527
|
+
- If using Helm: define charts in charts/ or helm/, use values.yaml for config
|
|
528
|
+
- Lock providers: always commit .terraform.lock.hcl
|
|
529
|
+
- Use terraform fmt before committing`);
|
|
457
530
|
}
|
|
458
531
|
|
|
459
532
|
const hasJS = stackKeys.some(k => ['react', 'vue', 'angular', 'nextjs', 'node', 'svelte'].includes(k));
|
|
@@ -523,10 +596,24 @@ npm run lint # or: npx eslint .`;
|
|
|
523
596
|
|
|
524
597
|
// --- Framework-specific instructions ---
|
|
525
598
|
const frameworkInstructions = getFrameworkInstructions(stacks);
|
|
526
|
-
|
|
599
|
+
let stackSection = frameworkInstructions
|
|
527
600
|
? `\n## Stack-Specific Guidelines\n\n${frameworkInstructions}\n`
|
|
528
601
|
: '';
|
|
529
602
|
|
|
603
|
+
// Check for security-focused project
|
|
604
|
+
const pkg2 = ctx.jsonFile('package.json') || {};
|
|
605
|
+
const allDeps2 = { ...(pkg2.dependencies || {}), ...(pkg2.devDependencies || {}) };
|
|
606
|
+
const hasSecurityDeps = allDeps2['helmet'] || allDeps2['jsonwebtoken'] || allDeps2['bcrypt'] || allDeps2['passport'];
|
|
607
|
+
if (hasSecurityDeps) {
|
|
608
|
+
stackSection += '\n### Security Best Practices\n';
|
|
609
|
+
stackSection += '- Follow OWASP Top 10 — run /security-review regularly\n';
|
|
610
|
+
stackSection += '- Never log sensitive data (passwords, tokens, PII)\n';
|
|
611
|
+
stackSection += '- Use parameterized queries — never string concatenation for SQL\n';
|
|
612
|
+
stackSection += '- Set security headers via Helmet. Review CSP policy for your frontend\n';
|
|
613
|
+
stackSection += '- Rate limit all authentication endpoints\n';
|
|
614
|
+
stackSection += '- Validate and sanitize all user input at API boundaries\n';
|
|
615
|
+
}
|
|
616
|
+
|
|
530
617
|
// --- TypeScript-specific additions ---
|
|
531
618
|
let tsSection = '';
|
|
532
619
|
if (hasTS) {
|
package/src/techniques.js
CHANGED
|
@@ -955,6 +955,8 @@ const STACKS = {
|
|
|
955
955
|
swift: { files: ['Package.swift'], content: {}, label: 'Swift' },
|
|
956
956
|
terraform: { files: ['main.tf', 'terraform'], content: {}, label: 'Terraform' },
|
|
957
957
|
kubernetes: { files: ['k8s', 'kubernetes', 'helm'], content: {}, label: 'Kubernetes' },
|
|
958
|
+
cpp: { files: ['CMakeLists.txt', 'Makefile', '.clang-format'], content: {}, label: 'C++' },
|
|
959
|
+
bazel: { files: ['BUILD', 'WORKSPACE', 'BUILD.bazel', 'WORKSPACE.bazel'], content: {}, label: 'Bazel' },
|
|
958
960
|
};
|
|
959
961
|
|
|
960
962
|
module.exports = { TECHNIQUES, STACKS };
|