@nerviq/cli 1.11.0 → 1.12.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 (49) hide show
  1. package/README.md +97 -19
  2. package/bin/cli.js +618 -182
  3. package/package.json +2 -2
  4. package/src/activity.js +49 -9
  5. package/src/adoption-advisor.js +299 -0
  6. package/src/aider/techniques.js +16 -11
  7. package/src/analyze.js +128 -0
  8. package/src/anti-patterns.js +13 -0
  9. package/src/audit.js +97 -22
  10. package/src/behavioral-drift.js +801 -0
  11. package/src/continuous-ops.js +681 -0
  12. package/src/cost-tracking.js +61 -0
  13. package/src/cursor/techniques.js +17 -12
  14. package/src/deep-review.js +83 -0
  15. package/src/diff-only.js +280 -0
  16. package/src/doctor.js +118 -55
  17. package/src/governance.js +59 -43
  18. package/src/hook-validation.js +342 -0
  19. package/src/index.js +5 -0
  20. package/src/integrations.js +42 -5
  21. package/src/mcp-validation.js +337 -0
  22. package/src/opencode/techniques.js +12 -7
  23. package/src/operating-profile.js +574 -0
  24. package/src/org.js +97 -13
  25. package/src/plans.js +192 -8
  26. package/src/platform-change-manifest.js +86 -0
  27. package/src/policy-layers.js +210 -0
  28. package/src/profiles.js +4 -1
  29. package/src/prompt-injection.js +74 -0
  30. package/src/repo-archetype.js +386 -0
  31. package/src/setup.js +34 -0
  32. package/src/source-urls.js +132 -132
  33. package/src/supplemental-checks.js +13 -12
  34. package/src/techniques/api.js +407 -0
  35. package/src/techniques/automation.js +316 -0
  36. package/src/techniques/compliance.js +257 -0
  37. package/src/techniques/hygiene.js +294 -0
  38. package/src/techniques/instructions.js +243 -0
  39. package/src/techniques/observability.js +226 -0
  40. package/src/techniques/optimization.js +142 -0
  41. package/src/techniques/quality.js +317 -0
  42. package/src/techniques/security.js +237 -0
  43. package/src/techniques/shared.js +443 -0
  44. package/src/techniques/stacks.js +2294 -0
  45. package/src/techniques/tools.js +106 -0
  46. package/src/techniques/workflow.js +413 -0
  47. package/src/techniques.js +78 -5607
  48. package/src/watch.js +18 -0
  49. package/src/windsurf/techniques.js +17 -12
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Observability technique fragments.
3
+ * Generated mechanically from the legacy techniques.js monolith during HR-09.
4
+ */
5
+
6
+ const {
7
+ hasFrontendSignals,
8
+ hasProjectFile,
9
+ readProjectFiles,
10
+ isFlutterProject,
11
+ isSwiftProject,
12
+ isKotlinProject,
13
+ } = require('./shared');
14
+
15
+ module.exports = {
16
+ otelConfigured: {
17
+ id: 130001,
18
+ name: 'OpenTelemetry SDK configured',
19
+ check: (ctx) => {
20
+ const pkg = ctx.fileContent('package.json') || '';
21
+ const req = readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
22
+ const goMod = ctx.fileContent('go.mod') || '';
23
+ const cargo = ctx.fileContent('Cargo.toml') || '';
24
+ const deps = [pkg, req, goMod, cargo].join('\n');
25
+ return /opentelemetry|@opentelemetry\/sdk|otel/i.test(deps) ||
26
+ ctx.files.some(f => /otel.*config|opentelemetry.*config/i.test(f));
27
+ },
28
+ impact: 'high',
29
+ category: 'observability',
30
+ fix: 'Add OpenTelemetry SDK to your project for unified traces, metrics, and logs collection.',
31
+ },
32
+
33
+ prometheusMetrics: {
34
+ id: 130002,
35
+ name: 'Prometheus metrics configured',
36
+ check: (ctx) => {
37
+ const pkg = ctx.fileContent('package.json') || '';
38
+ const req = readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
39
+ const goMod = ctx.fileContent('go.mod') || '';
40
+ const cargo = ctx.fileContent('Cargo.toml') || '';
41
+ const deps = [pkg, req, goMod, cargo].join('\n');
42
+ if (/prom-client|prometheus_client|prometheus\/client_golang|prometheus/i.test(deps)) return true;
43
+ const code = readProjectFiles(ctx, /\.(js|ts|py|go|rs|java)$/i);
44
+ return /\/metrics\b/.test(code);
45
+ },
46
+ impact: 'high',
47
+ category: 'observability',
48
+ fix: 'Add a Prometheus client library and expose a /metrics endpoint for monitoring.',
49
+ },
50
+
51
+ structuredLogging: {
52
+ id: 130003,
53
+ name: 'Structured logging library',
54
+ check: (ctx) => {
55
+ const pkg = ctx.fileContent('package.json') || '';
56
+ const req = readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
57
+ const goMod = ctx.fileContent('go.mod') || '';
58
+ const cargo = ctx.fileContent('Cargo.toml') || '';
59
+ const deps = [pkg, req, goMod, cargo].join('\n');
60
+ return /winston|pino|bunyan|structlog|python-json-logger|slog|log\/slog|tracing|tracing-subscriber|logback|log4j/i.test(deps);
61
+ },
62
+ impact: 'high',
63
+ category: 'observability',
64
+ fix: 'Use a structured logging library (winston, pino, structlog, slog, tracing) for machine-readable logs.',
65
+ },
66
+
67
+ distributedTracing: {
68
+ id: 130004,
69
+ name: 'Distributed tracing configured',
70
+ check: (ctx) => {
71
+ const pkg = ctx.fileContent('package.json') || '';
72
+ const req = readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
73
+ const goMod = ctx.fileContent('go.mod') || '';
74
+ const cargo = ctx.fileContent('Cargo.toml') || '';
75
+ const deps = [pkg, req, goMod, cargo].join('\n');
76
+ if (/jaeger|zipkin|opentelemetry-api|@opentelemetry\/api|dd-trace|datadog-apm/i.test(deps)) return true;
77
+ return ctx.files.some(f => /jaeger|zipkin|tracing.*config/i.test(f));
78
+ },
79
+ impact: 'high',
80
+ category: 'observability',
81
+ fix: 'Add a distributed tracing library (Jaeger, Zipkin, OpenTelemetry) for cross-service request tracking.',
82
+ },
83
+
84
+ healthEndpoint: {
85
+ id: 130005,
86
+ name: 'Health check endpoint',
87
+ check: (ctx) => {
88
+ const code = readProjectFiles(ctx, /\.(js|ts|py|go|rs|java|rb)$/i);
89
+ const configs = readProjectFiles(ctx, /\.(ya?ml|json|toml)$/i);
90
+ return /['"\/]health[z]?['"]\s*[,):]|\/health[z]?\b|healthCheck|health_check|livenessProbe|readinessProbe/i.test(code + configs);
91
+ },
92
+ impact: 'high',
93
+ category: 'observability',
94
+ fix: 'Add a /health or /healthz endpoint for load balancer and orchestrator health checks.',
95
+ },
96
+
97
+ alertingConfigured: {
98
+ id: 130006,
99
+ name: 'Alerting system configured',
100
+ check: (ctx) => {
101
+ const pkg = ctx.fileContent('package.json') || '';
102
+ const deps = [pkg, readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i)].join('\n');
103
+ const configs = readProjectFiles(ctx, /\.(ya?ml|json|toml)$/i);
104
+ return /alertmanager|pagerduty|opsgenie|victorops|alert.*rule/i.test(deps + configs) ||
105
+ ctx.files.some(f => /alert.*rule|alertmanager/i.test(f));
106
+ },
107
+ impact: 'medium',
108
+ category: 'observability',
109
+ fix: 'Configure alerting (Alertmanager, PagerDuty, OpsGenie) to get notified of production issues.',
110
+ },
111
+
112
+ dashboardDefined: {
113
+ id: 130007,
114
+ name: 'Monitoring dashboard defined',
115
+ check: (ctx) => {
116
+ const pkg = ctx.fileContent('package.json') || '';
117
+ return ctx.files.some(f => /grafana\/.*\.json|\.dashboard\.json/i.test(f)) ||
118
+ /grafana|@grafana/i.test(pkg) ||
119
+ hasProjectFile(ctx, /grafana/i);
120
+ },
121
+ impact: 'medium',
122
+ category: 'observability',
123
+ fix: 'Add Grafana dashboard JSON files or configure dashboard-as-code for production monitoring.',
124
+ },
125
+
126
+ logAggregation: {
127
+ id: 130008,
128
+ name: 'Log aggregation configured',
129
+ check: (ctx) => {
130
+ const pkg = ctx.fileContent('package.json') || '';
131
+ const req = readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
132
+ const configs = readProjectFiles(ctx, /\.(ya?ml|json|toml)$/i);
133
+ const all = [pkg, req, configs].join('\n');
134
+ return /elasticsearch|elastic\.co|logstash|kibana|loki|grafana-loki|cloudwatch.*log|datadog|fluentd|fluent-bit|filebeat/i.test(all);
135
+ },
136
+ impact: 'medium',
137
+ category: 'observability',
138
+ fix: 'Configure log aggregation (ELK, Loki, CloudWatch, Datadog) for centralized log analysis.',
139
+ },
140
+
141
+ errorTrackingService: {
142
+ id: 130031,
143
+ name: 'Error tracking service configured',
144
+ check: (ctx) => {
145
+ const pkg = ctx.fileContent('package.json') || '';
146
+ const req = readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
147
+ const goMod = ctx.fileContent('go.mod') || '';
148
+ const cargo = ctx.fileContent('Cargo.toml') || '';
149
+ const deps = [pkg, req, goMod, cargo].join('\n');
150
+ return /@sentry\/|sentry-sdk|sentry_sdk|bugsnag|rollbar|datadog.*apm|dd-trace|getsentry/i.test(deps);
151
+ },
152
+ impact: 'high',
153
+ category: 'error-tracking',
154
+ fix: 'Add an error tracking service (Sentry, Bugsnag, Rollbar, Datadog APM) to catch production errors.',
155
+ },
156
+
157
+ errorBoundaries: {
158
+ id: 130032,
159
+ name: 'Error boundaries in frontend',
160
+ check: (ctx) => {
161
+ if (!hasFrontendSignals(ctx)) return null;
162
+ const components = readProjectFiles(ctx, /\.(jsx|tsx|vue|svelte|js|ts)$/i);
163
+ if (!components) return null;
164
+ return /ErrorBoundary|errorHandler|onErrorCaptured|componentDidCatch|getDerivedStateFromError|error\.vue|_error\.(jsx|tsx|js|ts)/i.test(components);
165
+ },
166
+ impact: 'high',
167
+ category: 'error-tracking',
168
+ fix: 'Add error boundaries (React ErrorBoundary, Vue errorHandler) to gracefully handle frontend errors.',
169
+ },
170
+
171
+ unhandledRejection: {
172
+ id: 130033,
173
+ name: 'Unhandled rejection/exception handler',
174
+ check: (ctx) => {
175
+ const code = readProjectFiles(ctx, /\.(js|ts|py|go|rs)$/i);
176
+ return /unhandledRejection|uncaughtException|sys\.excepthook|recover\(\)|panic.*handler|set_hook.*panic/i.test(code);
177
+ },
178
+ impact: 'high',
179
+ category: 'error-tracking',
180
+ fix: 'Add handlers for unhandledRejection and uncaughtException to prevent silent failures.',
181
+ },
182
+
183
+ errorReporting: {
184
+ id: 130034,
185
+ name: 'Error notification/reporting pattern',
186
+ check: (ctx) => {
187
+ const code = readProjectFiles(ctx, /\.(js|ts|py|go|rs|java|rb)$/i);
188
+ return /error.*webhook|error.*slack|error.*notify|alert.*error|captureException|captureMessage|notify.*error/i.test(code);
189
+ },
190
+ impact: 'medium',
191
+ category: 'error-tracking',
192
+ fix: 'Add error reporting patterns (webhook, Slack alerts, Sentry capture) to get notified of failures.',
193
+ },
194
+
195
+ errorBudgetSlo: {
196
+ id: 130035,
197
+ name: 'SLO/SLA or error budget defined',
198
+ check: (ctx) => {
199
+ const docs = readProjectFiles(ctx, /\.(md|txt|rst|ya?ml|json|toml)$/i);
200
+ return /\bslo\b|\bsla\b|error.budget|service.level|uptime.*target|availability.*target/i.test(docs);
201
+ },
202
+ impact: 'medium',
203
+ category: 'error-tracking',
204
+ fix: 'Define SLOs, SLAs, or error budgets in your docs to set clear reliability targets.',
205
+ },
206
+
207
+ crashReporting: {
208
+ id: 130036,
209
+ name: 'Crash reporting for mobile',
210
+ check: (ctx) => {
211
+ const hasMobile = isFlutterProject(ctx) || isSwiftProject(ctx) || isKotlinProject(ctx) ||
212
+ /react-native|expo/i.test(ctx.fileContent('package.json') || '');
213
+ if (!hasMobile) return null;
214
+ const deps = [
215
+ ctx.fileContent('package.json') || '',
216
+ ctx.fileContent('pubspec.yaml') || '',
217
+ ctx.fileContent('Podfile') || '',
218
+ readProjectFiles(ctx, /(^|\/)build\.gradle(\.kts)?$/i),
219
+ ].join('\n');
220
+ return /crashlytics|sentry.*native|@sentry\/react-native|bugsnag.*react-native|firebase.*crash/i.test(deps);
221
+ },
222
+ impact: 'high',
223
+ category: 'error-tracking',
224
+ fix: 'Add crash reporting (Crashlytics, Sentry Native) to track mobile app crashes in production.',
225
+ },
226
+ };
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Optimization technique fragments.
3
+ * Generated mechanically from the legacy techniques.js monolith during HR-09.
4
+ */
5
+
6
+ const {
7
+ hasFrontendSignals,
8
+ hasProjectFile,
9
+ readProjectFiles,
10
+ getWorkflowContent,
11
+ } = require('./shared');
12
+
13
+ module.exports = {
14
+ compactionAwareness: {
15
+ id: 568,
16
+ name: 'CLAUDE.md mentions /compact or compaction',
17
+ check: (ctx) => {
18
+ const md = ctx.claudeMdContent() || '';
19
+ return /\/compact|compaction|context.*(limit|manage|budget)/i.test(md);
20
+ },
21
+ impact: 'medium',
22
+ rating: 4,
23
+ category: 'performance',
24
+ fix: 'Add compaction guidance to CLAUDE.md (e.g. "Run /compact when context is heavy").',
25
+ template: null
26
+ },
27
+
28
+ contextManagement: {
29
+ id: 45,
30
+ name: 'Context management awareness',
31
+ check: (ctx) => {
32
+ const md = ctx.claudeMdContent() || '';
33
+ return /context.*(manage|window|limit|budget|token)/i.test(md);
34
+ },
35
+ impact: 'medium',
36
+ rating: 4,
37
+ category: 'performance',
38
+ fix: 'Add context management tips to CLAUDE.md to help Claude stay within token limits.',
39
+ template: null
40
+ },
41
+
42
+ effortLevelConfigured: {
43
+ id: 2016,
44
+ name: 'Effort level or thinking configuration',
45
+ check: (ctx) => {
46
+ const md = ctx.claudeMdContent() || '';
47
+ const shared = ctx.jsonFile('.claude/settings.json') || {};
48
+ const local = ctx.jsonFile('.claude/settings.local.json') || {};
49
+ return /effort|thinking/i.test(md) || shared.effortLevel || local.effortLevel ||
50
+ shared.alwaysThinkingEnabled !== undefined || local.alwaysThinkingEnabled !== undefined;
51
+ },
52
+ impact: 'low', rating: 3, category: 'performance',
53
+ fix: 'Configure effortLevel or mention thinking strategy in CLAUDE.md for task-appropriate reasoning depth.',
54
+ template: null
55
+ },
56
+
57
+ lighthouseCI: {
58
+ id: 130171,
59
+ name: 'Lighthouse CI configured',
60
+ check: (ctx) => {
61
+ if (!hasFrontendSignals(ctx)) return null;
62
+ return hasProjectFile(ctx, /(^|\/)\.?lighthouserc\.(js|json|ya?ml)$/i) ||
63
+ /lighthouse/i.test(getWorkflowContent(ctx));
64
+ },
65
+ impact: 'medium',
66
+ category: 'performance-budget',
67
+ fix: 'Add Lighthouse CI (lighthouserc.js) to enforce performance budgets in your CI pipeline.',
68
+ confidence: 0.7,
69
+ },
70
+
71
+ bundleSizeLimit: {
72
+ id: 130172,
73
+ name: 'Bundle size check configured',
74
+ check: (ctx) => {
75
+ if (!hasFrontendSignals(ctx)) return null;
76
+ const pkg = ctx.fileContent('package.json') || '';
77
+ return /size-limit|bundlewatch|@next\/bundle-analyzer|webpack-bundle-analyzer/i.test(pkg);
78
+ },
79
+ impact: 'medium',
80
+ category: 'performance-budget',
81
+ fix: 'Add bundle size checks (size-limit, bundlewatch, @next/bundle-analyzer) to prevent bundle bloat.',
82
+ confidence: 0.7,
83
+ },
84
+
85
+ webVitals: {
86
+ id: 130173,
87
+ name: 'Core Web Vitals tracking configured',
88
+ check: (ctx) => {
89
+ if (!hasFrontendSignals(ctx)) return null;
90
+ const pkg = ctx.fileContent('package.json') || '';
91
+ const src = readProjectFiles(ctx, /\.(jsx?|tsx?)$/i, 20);
92
+ return /web-vitals|next\/web-vitals|@vercel\/speed-insights/i.test(pkg + src);
93
+ },
94
+ impact: 'medium',
95
+ category: 'performance-budget',
96
+ fix: 'Add Core Web Vitals tracking (web-vitals, next/web-vitals) for real user performance monitoring.',
97
+ confidence: 0.7,
98
+ },
99
+
100
+ performanceRegression: {
101
+ id: 130174,
102
+ name: 'Performance regression testing in CI',
103
+ check: (ctx) => {
104
+ if (!hasFrontendSignals(ctx)) return null;
105
+ const ci = getWorkflowContent(ctx);
106
+ const pkg = ctx.fileContent('package.json') || '';
107
+ return /benchmark|bench|perf.*test|lighthouse.*assert/i.test(ci + pkg);
108
+ },
109
+ impact: 'low',
110
+ category: 'performance-budget',
111
+ fix: 'Add performance regression testing in CI (benchmark, lighthouse assert) to catch regressions early.',
112
+ confidence: 0.7,
113
+ },
114
+
115
+ imageOptimization: {
116
+ id: 130175,
117
+ name: 'Image optimization configured',
118
+ check: (ctx) => {
119
+ if (!hasFrontendSignals(ctx)) return null;
120
+ const pkg = ctx.fileContent('package.json') || '';
121
+ return /sharp|imagemin|next\/image|responsive-loader|@squoosh/i.test(pkg);
122
+ },
123
+ impact: 'low',
124
+ category: 'performance-budget',
125
+ fix: 'Add image optimization (sharp, imagemin, next/image) to reduce page weight and improve loading.',
126
+ confidence: 0.7,
127
+ },
128
+
129
+ lazyLoading: {
130
+ id: 130176,
131
+ name: 'Code splitting and lazy loading',
132
+ check: (ctx) => {
133
+ if (!hasFrontendSignals(ctx)) return null;
134
+ const src = readProjectFiles(ctx, /\.(jsx?|tsx?)$/i, 30);
135
+ return /React\.lazy|import\s*\(|loadable|dynamic\s*\(\s*\(\)\s*=>/i.test(src);
136
+ },
137
+ impact: 'low',
138
+ category: 'performance-budget',
139
+ fix: 'Use code splitting and lazy loading (React.lazy, dynamic import, loadable) to reduce initial bundle size.',
140
+ confidence: 0.7,
141
+ },
142
+ };
@@ -0,0 +1,317 @@
1
+ /**
2
+ * Quality technique fragments.
3
+ * Generated mechanically from the legacy techniques.js monolith during HR-09.
4
+ */
5
+
6
+ const {
7
+ getClaudeInstructionBundle,
8
+ hasDocumentedVerificationGuidance,
9
+ hasDocumentedTestCommand,
10
+ hasDocumentedLintCommand,
11
+ hasDocumentedBuildCommand,
12
+ hasFrontendSignals,
13
+ } = require('./shared');
14
+
15
+ module.exports = {
16
+ verificationLoop: {
17
+ id: 93,
18
+ name: 'Claude instruction surfaces include verification criteria',
19
+ check: (ctx) => {
20
+ const docs = getClaudeInstructionBundle(ctx);
21
+ return hasDocumentedVerificationGuidance(docs);
22
+ },
23
+ impact: 'critical',
24
+ rating: 5,
25
+ category: 'quality',
26
+ fix: 'Add canonical test/lint/build commands to your Claude instruction surfaces (CLAUDE.md, imported docs, or .claude/commands) so Claude can verify its own work.',
27
+ template: null
28
+ },
29
+
30
+ testCommand: {
31
+ id: 93001,
32
+ name: 'Claude instruction surfaces include a test command',
33
+ check: (ctx) => {
34
+ return hasDocumentedTestCommand(getClaudeInstructionBundle(ctx));
35
+ },
36
+ impact: 'high',
37
+ rating: 5,
38
+ category: 'quality',
39
+ fix: 'Add an explicit test command to your Claude instruction surfaces (for example "Run `npm test` before committing").',
40
+ template: null
41
+ },
42
+
43
+ lintCommand: {
44
+ id: 93002,
45
+ name: 'Claude instruction surfaces include a lint command',
46
+ check: (ctx) => {
47
+ return hasDocumentedLintCommand(getClaudeInstructionBundle(ctx));
48
+ },
49
+ impact: 'high',
50
+ rating: 4,
51
+ category: 'quality',
52
+ fix: 'Add a lint command to your Claude instruction surfaces so Claude can check style and static quality automatically.',
53
+ template: null
54
+ },
55
+
56
+ buildCommand: {
57
+ id: 93003,
58
+ name: 'Claude instruction surfaces include a build command',
59
+ check: (ctx) => {
60
+ return hasDocumentedBuildCommand(getClaudeInstructionBundle(ctx));
61
+ },
62
+ impact: 'medium',
63
+ rating: 4,
64
+ category: 'quality',
65
+ fix: 'Add a build command to your Claude instruction surfaces so Claude can verify compilation before committing.',
66
+ template: null
67
+ },
68
+
69
+ frontendDesignSkill: {
70
+ id: 1025,
71
+ name: 'Frontend design skill for anti-AI-slop',
72
+ check: (ctx) => {
73
+ if (!hasFrontendSignals(ctx)) return null;
74
+ const md = ctx.claudeMdContent() || '';
75
+ return md.includes('frontend_aesthetics') || md.includes('anti-AI-slop') || md.includes('frontend-design');
76
+ },
77
+ impact: 'medium',
78
+ rating: 5,
79
+ category: 'design',
80
+ fix: 'Install the official frontend-design skill for better UI output quality.',
81
+ template: null
82
+ },
83
+
84
+ tailwindMention: {
85
+ id: 102501,
86
+ name: 'Tailwind CSS configured',
87
+ check: (ctx) => {
88
+ if (!hasFrontendSignals(ctx)) return null;
89
+ const pkg = ctx.fileContent('package.json') || '';
90
+ return pkg.includes('tailwind') ||
91
+ ctx.files.some(f => /tailwind\.config/.test(f));
92
+ },
93
+ impact: 'low',
94
+ rating: 3,
95
+ category: 'design',
96
+ fix: 'Consider adding Tailwind CSS for rapid, consistent UI styling with Claude.',
97
+ template: null
98
+ },
99
+
100
+ claudeMdFreshness: {
101
+ id: 2001,
102
+ name: 'CLAUDE.md mentions current Claude features',
103
+ check: (ctx) => {
104
+ const md = ctx.claudeMdContent() || '';
105
+ if (md.length < 50) return false; // too short to evaluate
106
+ // Check for awareness of features from 2025+
107
+ const modernFeatures = ['hook', 'skill', 'agent', 'subagent', 'mcp', 'compact', '/clear', 'extended thinking', 'tool_use', 'worktree'];
108
+ const found = modernFeatures.filter(f => md.toLowerCase().includes(f));
109
+ return found.length >= 2; // knows at least 2 modern features
110
+ },
111
+ impact: 'medium',
112
+ rating: 4,
113
+ category: 'quality-deep',
114
+ fix: 'Your CLAUDE.md may be outdated. Modern Claude Code supports hooks, skills, agents, MCP, worktrees, and extended thinking. Mention the ones you use.',
115
+ template: null
116
+ },
117
+
118
+ claudeMdNoContradictions: {
119
+ id: 2003,
120
+ name: 'CLAUDE.md has no obvious contradictions',
121
+ check: (ctx) => {
122
+ const md = ctx.claudeMdContent();
123
+ if (!md || md.length < 50) return false; // no CLAUDE.md or too short = not passing
124
+ // Check for common contradictions
125
+ // Check for contradictions on the SAME topic (same line or adjacent sentence)
126
+ const lines = md.split('\n');
127
+ let hasContradiction = false;
128
+ for (const line of lines) {
129
+ if (/\balways\b.*\bnever\b|\bnever\b.*\balways\b/i.test(line)) {
130
+ hasContradiction = true;
131
+ break;
132
+ }
133
+ }
134
+ const hasBothStyles = /\buse tabs\b/i.test(md) && /\buse spaces\b/i.test(md);
135
+ return !hasContradiction && !hasBothStyles;
136
+ },
137
+ impact: 'high',
138
+ rating: 4,
139
+ category: 'quality-deep',
140
+ fix: 'CLAUDE.md may contain contradictory instructions. Review for conflicting rules (e.g., "always X" and "never X" about the same topic).',
141
+ template: null
142
+ },
143
+
144
+ hooksAreSpecific: {
145
+ id: 2004,
146
+ name: 'Hooks use specific matchers (not catch-all)',
147
+ check: (ctx) => {
148
+ const settings = ctx.jsonFile('.claude/settings.local.json') || ctx.jsonFile('.claude/settings.json');
149
+ if (!settings || !settings.hooks) return null; // no hooks = not applicable
150
+ const hookStr = JSON.stringify(settings.hooks);
151
+ // Check that hooks have matchers, not just catch-all
152
+ return hookStr.includes('matcher');
153
+ },
154
+ impact: 'medium',
155
+ rating: 3,
156
+ category: 'quality-deep',
157
+ fix: 'Hooks without matchers run on every tool call. Use matchers like "Write|Edit" or "Bash" to target specific tools.',
158
+ template: null
159
+ },
160
+
161
+ commandsUseArguments: {
162
+ id: 2006,
163
+ name: 'Commands use $ARGUMENTS for flexibility',
164
+ check: (ctx) => {
165
+ if (!ctx.hasDir('.claude/commands')) return null; // not applicable
166
+ const files = ctx.dirFiles('.claude/commands');
167
+ if (files.length === 0) return null;
168
+ // Check if at least one command uses $ARGUMENTS
169
+ for (const f of files) {
170
+ const content = ctx.fileContent(`.claude/commands/${f}`) || '';
171
+ if (content.includes('$ARGUMENTS') || content.includes('$arguments')) return true;
172
+ }
173
+ return false;
174
+ },
175
+ impact: 'medium',
176
+ rating: 3,
177
+ category: 'quality-deep',
178
+ fix: 'Commands without $ARGUMENTS are static. Use $ARGUMENTS to make them flexible: "Fix the issue: $ARGUMENTS"',
179
+ template: null
180
+ },
181
+
182
+ agentsHaveMaxTurns: {
183
+ id: 2007,
184
+ name: 'Subagents have max-turns limit',
185
+ check: (ctx) => {
186
+ if (!ctx.hasDir('.claude/agents')) return null;
187
+ const files = ctx.dirFiles('.claude/agents');
188
+ if (files.length === 0) return null;
189
+ for (const f of files) {
190
+ const content = ctx.fileContent(`.claude/agents/${f}`) || '';
191
+ // Current frontmatter uses kebab-case: max-turns (also accept legacy maxTurns)
192
+ if (!content.includes('max-turns') && !content.includes('maxTurns')) return false;
193
+ }
194
+ return true;
195
+ },
196
+ impact: 'medium',
197
+ rating: 3,
198
+ category: 'quality-deep',
199
+ fix: 'Subagents without max-turns can run indefinitely. Add "max-turns: 50" to subagent YAML frontmatter.',
200
+ template: null
201
+ },
202
+
203
+ securityReviewInWorkflow: {
204
+ id: 2008,
205
+ name: '/security-review command or workflow',
206
+ check: (ctx) => {
207
+ const hasCommand = ctx.hasDir('.claude/commands') &&
208
+ (ctx.dirFiles('.claude/commands') || []).some(f => f.includes('security') || f.includes('review'));
209
+ const md = ctx.claudeMdContent() || '';
210
+ const hasExplicitRef = /\/security-review|security review command|security workflow/i.test(md);
211
+ return hasCommand || hasExplicitRef;
212
+ },
213
+ impact: 'medium',
214
+ rating: 4,
215
+ category: 'quality-deep',
216
+ fix: 'Claude Code has built-in /security-review (OWASP Top 10). Add it to your workflow or create a /security command.',
217
+ template: null
218
+ },
219
+
220
+ testCoverage: {
221
+ id: 2010,
222
+ name: 'Test coverage or strategy mentioned',
223
+ check: (ctx) => {
224
+ const md = ctx.claudeMdContent() || '';
225
+ return /coverage|test.*strateg|e2e|integration test|unit test/i.test(md);
226
+ },
227
+ impact: 'medium', rating: 3, category: 'quality',
228
+ fix: 'Mention your testing strategy in CLAUDE.md (unit, integration, E2E, coverage targets).',
229
+ template: null
230
+ },
231
+
232
+ typeCheckingConfigured: {
233
+ id: 2031,
234
+ name: 'Type checking configured (TypeScript or similar)',
235
+ check: (ctx) => {
236
+ return !!(ctx.fileContent('tsconfig.json') || ctx.fileContent('jsconfig.json') ||
237
+ ctx.fileContent('pyrightconfig.json') || ctx.fileContent('mypy.ini'));
238
+ },
239
+ impact: 'medium', rating: 3, category: 'quality',
240
+ fix: 'Add type checking configuration. Type-safe code produces fewer Claude errors.',
241
+ template: null
242
+ },
243
+
244
+ noDeprecatedPatterns: {
245
+ id: 2009,
246
+ name: 'No deprecated patterns detected',
247
+ check: (ctx) => {
248
+ const md = ctx.claudeMdContent();
249
+ if (!md) return false;
250
+ // Only flag truly deprecated patterns, not valid aliases
251
+ const deprecatedPatterns = [
252
+ /\bhuman_prompt\b/i, /\bassistant_prompt\b/i, // old completions API format (not Messages API)
253
+ /\buse model claude-3-opus\b/i, // explicit recommendation to use old name as --model
254
+ /\buse model claude-3-sonnet\b/i,
255
+ ];
256
+ return !deprecatedPatterns.some(p => p.test(md));
257
+ },
258
+ impact: 'medium',
259
+ rating: 3,
260
+ category: 'quality-deep',
261
+ fix: 'CLAUDE.md references deprecated API patterns (human_prompt/assistant_prompt). Update to current Messages API conventions.',
262
+ template: null
263
+ },
264
+
265
+ claudeMdQuality: {
266
+ id: 102502,
267
+ name: 'CLAUDE.md has substantive content',
268
+ check: (ctx) => {
269
+ const md = ctx.claudeMdContent();
270
+ if (!md) return null;
271
+ const lines = md.split('\n').filter(l => l.trim());
272
+ const sections = (md.match(/^##\s/gm) || []).length;
273
+ const hasCommand = /\b(npm|yarn|pnpm|pytest|go |make |ruff |cargo |dotnet )\b/i.test(md);
274
+ return lines.length >= 15 && sections >= 2 && hasCommand;
275
+ },
276
+ impact: 'medium',
277
+ rating: 4,
278
+ category: 'quality-deep',
279
+ fix: 'CLAUDE.md exists but lacks substance. Add at least 2 sections (## headings) and include your test/build/lint commands.',
280
+ template: null
281
+ },
282
+
283
+ consistencyPassAtK: {
284
+ id: 110005,
285
+ name: 'Consistency/pass@k evaluation mentioned',
286
+ check: (ctx) => {
287
+ const md = ctx.claudeMdContent() || '';
288
+ const configPaths = [
289
+ 'package.json',
290
+ 'jest.config.js',
291
+ 'jest.config.cjs',
292
+ 'jest.config.mjs',
293
+ 'vitest.config.js',
294
+ 'vitest.config.ts',
295
+ 'playwright.config.js',
296
+ 'playwright.config.ts',
297
+ 'pytest.ini',
298
+ 'pyproject.toml',
299
+ 'tox.ini',
300
+ '.github/workflows/ci.yml',
301
+ '.github/workflows/ci.yaml',
302
+ '.github/workflows/test.yml',
303
+ '.github/workflows/test.yaml',
304
+ ];
305
+ const configContent = configPaths
306
+ .map(file => ctx.fileContent(file) || '')
307
+ .filter(Boolean)
308
+ .join('\n');
309
+
310
+ return /pass@k|consistency|multiple runs?|reproducib/i.test(`${md}\n${configContent}`);
311
+ },
312
+ impact: 'low', rating: 3, category: 'quality',
313
+ fix: 'Mention pass@k or consistency testing in CLAUDE.md or test configuration so repeated-run quality evaluation is explicit.',
314
+ template: null,
315
+ confidence: 0.7,
316
+ },
317
+ };