claudex-setup 1.2.0 → 1.4.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/bin/cli.js +6 -0
- package/package.json +1 -1
- package/src/audit.js +12 -1
- package/src/setup.js +130 -12
- package/src/techniques.js +2 -0
package/bin/cli.js
CHANGED
|
@@ -49,6 +49,12 @@ async function main() {
|
|
|
49
49
|
dir: process.cwd()
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
if (!require('fs').existsSync(options.dir)) {
|
|
53
|
+
console.error(`\n Error: Directory not found: ${options.dir}`);
|
|
54
|
+
console.error(' Run claudex-setup from inside your project directory.\n');
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
52
58
|
try {
|
|
53
59
|
if (command === 'badge') {
|
|
54
60
|
const { getBadgeMarkdown } = require('../src/badge');
|
package/package.json
CHANGED
package/src/audit.js
CHANGED
|
@@ -97,7 +97,18 @@ async function audit(options) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
if (options.json) {
|
|
100
|
-
|
|
100
|
+
const { version } = require('../package.json');
|
|
101
|
+
console.log(JSON.stringify({
|
|
102
|
+
version,
|
|
103
|
+
timestamp: new Date().toISOString(),
|
|
104
|
+
score,
|
|
105
|
+
stacks,
|
|
106
|
+
passed: passed.length,
|
|
107
|
+
failed: failed.length,
|
|
108
|
+
skipped: skipped.length,
|
|
109
|
+
checkCount: applicable.length,
|
|
110
|
+
results
|
|
111
|
+
}, null, 2));
|
|
101
112
|
return { score, passed: passed.length, failed: failed.length, stacks, results };
|
|
102
113
|
}
|
|
103
114
|
|
package/src/setup.js
CHANGED
|
@@ -29,8 +29,7 @@ function detectScripts(ctx) {
|
|
|
29
29
|
// Helper: detect key dependencies and generate guidelines
|
|
30
30
|
// ============================================================
|
|
31
31
|
function detectDependencies(ctx) {
|
|
32
|
-
const pkg = ctx.jsonFile('package.json');
|
|
33
|
-
if (!pkg) return [];
|
|
32
|
+
const pkg = ctx.jsonFile('package.json') || {};
|
|
34
33
|
const allDeps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
|
|
35
34
|
const guidelines = [];
|
|
36
35
|
|
|
@@ -96,10 +95,47 @@ function detectDependencies(ctx) {
|
|
|
96
95
|
guidelines.push('- Use Playwright for E2E tests. Keep tests in tests/ or e2e/');
|
|
97
96
|
}
|
|
98
97
|
|
|
98
|
+
// tRPC
|
|
99
|
+
if (allDeps['@trpc/server'] || allDeps['@trpc/client']) {
|
|
100
|
+
guidelines.push('- Use tRPC for type-safe API calls. Define routers in server, use client hooks in components');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Stripe
|
|
104
|
+
if (allDeps['stripe']) {
|
|
105
|
+
guidelines.push('- Use Stripe SDK for payments. Always verify webhooks with stripe.webhooks.constructEvent()');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Resend
|
|
109
|
+
if (allDeps['resend']) {
|
|
110
|
+
guidelines.push('- Use Resend for transactional email. Define templates as React components');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Express security
|
|
114
|
+
if (allDeps['helmet']) {
|
|
115
|
+
guidelines.push('- Helmet is configured — ensure all middleware is applied before routes');
|
|
116
|
+
}
|
|
117
|
+
if (allDeps['jsonwebtoken']) {
|
|
118
|
+
guidelines.push('- Use JWT for authentication. Always verify tokens with the correct secret/algorithm');
|
|
119
|
+
}
|
|
120
|
+
if (allDeps['bcrypt']) {
|
|
121
|
+
guidelines.push('- Use bcrypt for password hashing. Never store plaintext passwords');
|
|
122
|
+
}
|
|
123
|
+
if (allDeps['cors']) {
|
|
124
|
+
guidelines.push('- CORS is configured — restrict origins to known domains in production');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Monorepo
|
|
128
|
+
if (allDeps['turbo'] || allDeps['turborepo']) {
|
|
129
|
+
guidelines.push('- Turborepo monorepo — use `turbo run` for all tasks. Respect package boundaries');
|
|
130
|
+
}
|
|
131
|
+
if (allDeps['nx']) {
|
|
132
|
+
guidelines.push('- Nx monorepo — use `nx affected` for incremental builds and tests');
|
|
133
|
+
}
|
|
134
|
+
|
|
99
135
|
// Python
|
|
100
136
|
const reqTxt = ctx.fileContent('requirements.txt') || '';
|
|
101
137
|
if (reqTxt.includes('sqlalchemy')) {
|
|
102
|
-
guidelines.push('- Use SQLAlchemy for
|
|
138
|
+
guidelines.push('- Use SQLAlchemy for database operations. Define models in models/');
|
|
103
139
|
}
|
|
104
140
|
if (reqTxt.includes('pydantic')) {
|
|
105
141
|
guidelines.push('- Use Pydantic for data validation and serialization');
|
|
@@ -107,6 +143,59 @@ function detectDependencies(ctx) {
|
|
|
107
143
|
if (reqTxt.includes('pytest')) {
|
|
108
144
|
guidelines.push('- Use pytest for testing. Run with `python -m pytest`');
|
|
109
145
|
}
|
|
146
|
+
if (reqTxt.includes('alembic')) {
|
|
147
|
+
guidelines.push('- Use Alembic for database migrations. Run `alembic upgrade head` after model changes');
|
|
148
|
+
}
|
|
149
|
+
if (reqTxt.includes('celery')) {
|
|
150
|
+
guidelines.push('- Use Celery for background tasks. Define tasks in tasks/ or services/');
|
|
151
|
+
}
|
|
152
|
+
if (reqTxt.includes('redis')) {
|
|
153
|
+
guidelines.push('- Redis is available for caching and task queues');
|
|
154
|
+
}
|
|
155
|
+
if (reqTxt.includes('langchain')) {
|
|
156
|
+
guidelines.push('- Use LangChain for chain/agent orchestration. Define chains in chains/ directory');
|
|
157
|
+
}
|
|
158
|
+
if (reqTxt.includes('openai')) {
|
|
159
|
+
guidelines.push('- OpenAI SDK available. Use structured outputs where possible');
|
|
160
|
+
}
|
|
161
|
+
if (reqTxt.includes('anthropic')) {
|
|
162
|
+
guidelines.push('- Anthropic SDK available. Prefer Claude for complex reasoning tasks');
|
|
163
|
+
}
|
|
164
|
+
if (reqTxt.includes('chromadb')) {
|
|
165
|
+
guidelines.push('- Use ChromaDB for local vector storage. Persist collections to disk');
|
|
166
|
+
}
|
|
167
|
+
if (reqTxt.includes('pinecone')) {
|
|
168
|
+
guidelines.push('- Use Pinecone for production vector search. Define index schemas upfront');
|
|
169
|
+
}
|
|
170
|
+
if (reqTxt.includes('mlflow')) {
|
|
171
|
+
guidelines.push('- Use MLflow for experiment tracking. Log all model parameters and metrics');
|
|
172
|
+
}
|
|
173
|
+
if (reqTxt.includes('wandb')) {
|
|
174
|
+
guidelines.push('- Use Weights & Biases for experiment tracking and visualization');
|
|
175
|
+
}
|
|
176
|
+
if (reqTxt.includes('transformers')) {
|
|
177
|
+
guidelines.push('- HuggingFace Transformers available. Use AutoModel/AutoTokenizer for loading');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// JS AI/ML/Cloud deps
|
|
181
|
+
if (allDeps['@anthropic-ai/sdk']) {
|
|
182
|
+
guidelines.push('- Anthropic SDK configured. Use Messages API with structured tool_use for agents');
|
|
183
|
+
}
|
|
184
|
+
if (allDeps['openai']) {
|
|
185
|
+
guidelines.push('- OpenAI SDK available. Use structured outputs and function calling');
|
|
186
|
+
}
|
|
187
|
+
if (allDeps['@modelcontextprotocol/sdk']) {
|
|
188
|
+
guidelines.push('- MCP SDK available. Build MCP servers with stdio transport');
|
|
189
|
+
}
|
|
190
|
+
if (allDeps['langchain'] || allDeps['@langchain/core']) {
|
|
191
|
+
guidelines.push('- LangChain available. Use LCEL for chain composition');
|
|
192
|
+
}
|
|
193
|
+
if (allDeps['@aws-sdk/client-s3'] || allDeps['@aws-sdk/client-dynamodb']) {
|
|
194
|
+
guidelines.push('- AWS SDK v3 configured. Use modular imports, not aws-sdk v2');
|
|
195
|
+
}
|
|
196
|
+
if (allDeps['@aws-cdk/aws-lambda'] || allDeps['aws-cdk-lib']) {
|
|
197
|
+
guidelines.push('- AWS CDK available. Define stacks in lib/, constructs as separate classes');
|
|
198
|
+
}
|
|
110
199
|
|
|
111
200
|
return guidelines;
|
|
112
201
|
}
|
|
@@ -342,18 +431,29 @@ function getFrameworkInstructions(stacks) {
|
|
|
342
431
|
|
|
343
432
|
if (stackKeys.includes('rust')) {
|
|
344
433
|
sections.push(`### Rust
|
|
345
|
-
-
|
|
346
|
-
-
|
|
347
|
-
-
|
|
348
|
-
-
|
|
434
|
+
- Use Result<T, E> for error handling, avoid unwrap() in production code
|
|
435
|
+
- Prefer &str over String for function parameters
|
|
436
|
+
- Use clippy: \`cargo clippy -- -D warnings\`
|
|
437
|
+
- Structure: src/lib.rs for library, src/main.rs for binary`);
|
|
349
438
|
}
|
|
350
439
|
|
|
351
440
|
if (stackKeys.includes('go')) {
|
|
352
441
|
sections.push(`### Go
|
|
353
|
-
- Follow standard project layout
|
|
354
|
-
-
|
|
355
|
-
-
|
|
356
|
-
-
|
|
442
|
+
- Follow standard Go project layout (cmd/, internal/, pkg/)
|
|
443
|
+
- Use interfaces for dependency injection and testability
|
|
444
|
+
- Handle all errors explicitly — never ignore err returns
|
|
445
|
+
- Use context.Context for cancellation and timeouts
|
|
446
|
+
- Prefer table-driven tests
|
|
447
|
+
- Run \`go vet\` and \`golangci-lint\` before committing`);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
if (stackKeys.includes('terraform')) {
|
|
451
|
+
sections.push(`### Terraform
|
|
452
|
+
- Use modules for reusable infrastructure components
|
|
453
|
+
- Always run \`terraform plan\` before \`terraform apply\`
|
|
454
|
+
- Store state remotely (S3 + DynamoDB, or Terraform Cloud)
|
|
455
|
+
- Use variables.tf for all configurable values
|
|
456
|
+
- Tag all resources consistently`);
|
|
357
457
|
}
|
|
358
458
|
|
|
359
459
|
const hasJS = stackKeys.some(k => ['react', 'vue', 'angular', 'nextjs', 'node', 'svelte'].includes(k));
|
|
@@ -507,6 +607,12 @@ Before completing any task, confirm:
|
|
|
507
607
|
${verificationSteps.join('\n')}
|
|
508
608
|
</verification>
|
|
509
609
|
|
|
610
|
+
## Context Management
|
|
611
|
+
- Use /compact when context gets large (above 50% capacity)
|
|
612
|
+
- Prefer focused sessions — one task per conversation
|
|
613
|
+
- If a session gets too long, start fresh with /clear
|
|
614
|
+
- Use subagents for research tasks to keep main context clean
|
|
615
|
+
|
|
510
616
|
## Workflow
|
|
511
617
|
- Verify changes with tests before committing
|
|
512
618
|
- Use descriptive commit messages (why, not what)
|
|
@@ -726,8 +832,10 @@ Fix the GitHub issue: $ARGUMENTS
|
|
|
726
832
|
const rules = {};
|
|
727
833
|
const hasTS = stacks.some(s => s.key === 'typescript');
|
|
728
834
|
const hasPython = stacks.some(s => s.key === 'python');
|
|
835
|
+
const hasFrontend = stacks.some(s => ['react', 'vue', 'angular', 'svelte', 'nextjs'].includes(s.key));
|
|
836
|
+
const hasBackend = stacks.some(s => ['go', 'python', 'django', 'fastapi', 'rust', 'java'].includes(s.key));
|
|
729
837
|
|
|
730
|
-
if (
|
|
838
|
+
if (hasFrontend || (hasTS && !hasBackend)) {
|
|
731
839
|
rules['frontend.md'] = `When editing JavaScript/TypeScript files (*.ts, *.tsx, *.js, *.jsx, *.vue):
|
|
732
840
|
- Use functional components with hooks (React/Vue 3)
|
|
733
841
|
- Add TypeScript interfaces for all props and function params
|
|
@@ -735,6 +843,16 @@ Fix the GitHub issue: $ARGUMENTS
|
|
|
735
843
|
- Use named exports over default exports
|
|
736
844
|
- Handle errors explicitly — no empty catch blocks
|
|
737
845
|
- Keep component files under 200 lines; extract sub-components
|
|
846
|
+
`;
|
|
847
|
+
}
|
|
848
|
+
if (hasBackend) {
|
|
849
|
+
rules['backend.md'] = `When editing backend code:
|
|
850
|
+
- Handle all errors explicitly — never swallow exceptions silently
|
|
851
|
+
- Validate all external input at API boundaries
|
|
852
|
+
- Use dependency injection for testability
|
|
853
|
+
- Keep route handlers thin — delegate to service/business logic layers
|
|
854
|
+
- Log errors with sufficient context for debugging
|
|
855
|
+
- Never hardcode secrets or credentials
|
|
738
856
|
`;
|
|
739
857
|
}
|
|
740
858
|
if (hasPython) {
|
package/src/techniques.js
CHANGED
|
@@ -953,6 +953,8 @@ const STACKS = {
|
|
|
953
953
|
java: { files: ['pom.xml'], content: {}, label: 'Java' },
|
|
954
954
|
kotlin: { files: ['build.gradle.kts'], content: {}, label: 'Kotlin' },
|
|
955
955
|
swift: { files: ['Package.swift'], content: {}, label: 'Swift' },
|
|
956
|
+
terraform: { files: ['main.tf', 'terraform'], content: {}, label: 'Terraform' },
|
|
957
|
+
kubernetes: { files: ['k8s', 'kubernetes', 'helm'], content: {}, label: 'Kubernetes' },
|
|
956
958
|
};
|
|
957
959
|
|
|
958
960
|
module.exports = { TECHNIQUES, STACKS };
|