/nsolid-plugin:ns-validate-optimizationfrom N|Solid Plugin
Validates Node.js optimizations with controlled A/B benchmarks, providing ops/sec comparison and statistical significance. Use after ns-optimize-function or diagnostics produce a candidate fix.
Ships in N|Solid Plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill is usually called after ns-cpu-spike-analysis, which sets a workspace context flag indicating whether the code is available locally.
If the workspace context flag says the code is available:
If the workspace context flag says the code is NOT available:
ns-cpu-spike-analysis flow.If the optimized implementation has a different entry point or wrapper shape, account for that separately, but keep the benchmark contract aligned with the original usage unless the user explicitly says the contract changed.
functionData for Original and OptimizedEvery benchmark call requires a functionData object. You will build two of them — one for the original, one for the optimized — using the exact same args and argSetupCode in both.
type — code structure type"function" — function declaration or expression"class" — class-based implementation"snippet" — multiple functions, classes, or code elements together"anonymous_function" — anonymous functioncode — the JavaScript source stringmodule.exportsexplanationentryPoint — the name of the function or method to callargs — arguments for benchmarkingFollow these steps:
argsargSetupCodeargsargs MUST be identical between the original and optimized runs — otherwise the comparison is invalidargSetupCode MUST be identical between the original and optimized runs — otherwise the comparison is invalidargSetupCode — mock definitions for complex dependenciesbenchmarkConfig — benchmark engine configuration (shared by both runs)repeatSuite: 15 (number of suite runs — higher values improve statistical accuracy but take longer)minSamples: 10 (minimum samples required per run)minTime: 0.05 (minimum time per sample in seconds)maxTime: 0.5 (maximum time per sample in seconds)Before calling any benchmark tools, present both functionData objects and the proposed benchmarkConfig to the user for review.
Your confirmation message must include:
argsargSetupCode if presentbenchmarkConfig values (repeatSuite, minSamples, minTime, maxTime) with a brief explanation of eachIf relevant tests were found, mention which test file(s), fixtures, or helper builders influenced the proposed input shape.
After presenting, explicitly offer to:
benchmarkConfig (e.g. increase repeatSuite for more statistical accuracy, or decrease it for faster runs)For example, if repeatSuite is set to 15 but the function is very fast, suggest increasing it. If the function is slow, suggest decreasing it to get results faster.
Do NOT call run_benchmark, get_benchmark_result, compare_benchmarks, or any result-saving step until the user explicitly confirms both the arguments and the configuration.
For complex external dependencies, add the dependency as an explicit parameter to BOTH original and optimized signatures, mock it in argSetupCode, and pass the parameter name (not the value) in args. Example (HTTP req/res):
// Original: function exampleFn(req, res) { arrExample.push(JSON.parse(resp)); res.end(); }
// Transformed: function exampleFn(req, res, arrExample) { arrExample.push(JSON.parse(resp)); res.end(); }
args: ["req", "res", "arrExample"]
argSetupCode:
const req = { url: '/test' };
const res = { writeHead: function() {}, write: function() {}, end: function() {} };
const arrExample = [];
For more patterns (DB, FS, event emitters, async/await, class instantiation), see reference/benchmark-inputs.md in the ns-benchmark-run skill directory.
Call run_benchmark with:
functionData: { type, code, explanation, entryPoint, args, argSetupCode? } for the originalisOptimized: falsebenchmarkConfig only if the run_benchmark schema exposes that parameter (or functionData.benchmarkConfig). If not, record the desired config and state that tool defaults were used.Note the returned jobId as originalJobId.
Run the wait script (use the absolute path of the directory where you read this SKILL.md):
node "<skill-dir>/wait.cjs" 20
Call get_benchmark_result with originalJobId. If not yet "completed", run node "<skill-dir>/wait.cjs" 5 and poll again. Poll up to 12 times; if still not completed, report the originalJobId and incomplete status rather than looping indefinitely.
Extract the full result object from the response. It contains:
result.name — the benchmark nameresult.plugins — any plugins that ran (e.g., V8NeverOptimizePlugin)result.opsSec — average operations per secondresult.opsSecPerRun — per-run ops/sec valuesresult.iterations — total iterations executedresult.histogram — timing distribution with samples, min, max, and sampleDataresult.benchmarkConfig — the configuration used (repeatSuite, minSamples, minTime, maxTime)Keep the full result JSON available to present to the user.
You must try the optimized implementation up to 3 total attempts if the benchmark does not clear the effectiveness threshold on the first try.
For each optimized attempt:
functionData: { type, code, explanation, entryPoint, args, argSetupCode? }args, argSetupCode, and benchmarkConfig as the originalrun_benchmark with isOptimized: truebenchmarkConfig only if the schema exposes it; if passed, it must be identical to the original run.jobId as optimizedJobIdnode "<skill-dir>/wait.cjs" 20
Call get_benchmark_result with optimizedJobId. If not yet "completed", run node "<skill-dir>/wait.cjs" 5 and poll again. Poll up to 12 times; if still not completed, report the optimizedJobId and incomplete status rather than looping indefinitely.
Extract the full result object from the response, with the same fields as the original run (name, plugins, opsSec, opsSecPerRun, iterations, histogram, benchmarkConfig).
Keep the full result JSON available to present to the user.
Call compare_benchmarks passing both originalJobId and optimizedJobId.
Analyze:
verdict: "optimization_effective" requires both isSignificant === true AND improvementPercent > 25pValue: must be < 0.05 to be statistically significantimprovementPercent: the percentage speed improvementIf the comparison is not optimization_effective:
optimization_effectiveIf none of the 3 optimized attempts reaches the threshold:
Build a markdown report with these sections:
## Summary## Request## Results## Tool Execution LogThe ## Results section must include the benchmark verdict, improvement percentage, p-value, statistical significance, and the best optimized attempt if multiple retries were required.
For ## Tool Execution Log, include the raw input/output pairs for each run_benchmark call and the matching get_benchmark_result polls for that same jobId, preserving chronological order across the original run and every optimized attempt.
Present the comparison results in a markdown table showing original vs. optimized side by side. Include all relevant metrics so the user can see the full performance picture at a glance.
The table must include:
Example table format:
| Metric | Original | Optimized |
|---|---|---|
| Function | <entryPoint> | <entryPoint> |
| ops/sec | ||
| Improvement % | — | +% |
| p-value | — | |
| Verdict | — | optimization_effective/not_effective |
| Iterations | ||
| Runs | 15 | 15 |
| Histogram min/max | ms / ms | ms / ms |
| Config | repeatSuite=15, minSamples=10, minTime=0.05s, maxTime=0.5s | repeatSuite=15, minSamples=10, minTime=0.05s, maxTime=0.5s |
| Variance | High/Low (x) | High/Low (x) |
| Benchmark ID | <id> | <id> |
When either side shows high variance (wide min/max spread), append a diagnostic line: note likely causes (V8 JIT tier transitions, GC pauses on allocating functions, system load/CPU throttling, input sensitivity) and recommend increasing repeatSuite/minSamples or inspecting per-run ops/sec for outliers.
As a recommended next step, advise the user to validate the optimization under representative load and capture fresh CPU profiles afterward. That follow-up helps confirm whether the function-level benchmark improvement produces a meaningful impact on end-to-end application performance.
.md) under .nsolid/assets/ — for example .nsolid/assets/benchmark-<entryPoint>.md. Report the saved path alongside the final verdict.After reporting the verdict, end the response with a single HTML comment containing the data the host extension needs to offer an "Apply optimization" action. Use the raw optimized source (unescaped newlines are fine inside a JSON string if you properly escape them), the final verdict flags, and any hot-function reference the extension provided in the prior CPU analysis.
<!-- nsolid-ide-optimized: {"code":"<optimized source>","entryPoint":"<entryPoint>","improvementPct":<number>,"pValue":<number>,"isSignificant":<bool>,"verdictEffective":<bool>} -->
Only emit the marker when a valid A/B comparison completed. If the benchmark failed, timed out, or the original/optimized code was unavailable, omit the marker entirely — the host extension will not offer the apply action.
args, argSetupCode, and benchmarkConfig MUST be identical for both runs — otherwise the A/B comparison is statistically invalid.wait.cjs, do not rely on estimating time.compare_benchmarks returns "optimization_effective".What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub nodesource/nsolid-plugin --plugin nsolid-plugin18 skills in this plugin
/ns-advanced-memory-leak-hunterPerforms an advanced N|Solid memory leak hunt comparing baseline vs peak heap evidence to isolate retained constructors, closures, and retainer paths. Use when the user reports recurring/staircase memory growth, elusive leaks, retained objects, closures holding references, or a standard heap sample/snapshot analysis was inconclusive. Prefer supplied baseline/peak assets; capture new samples only when needed./ns-analyze-assetAnalyzes an existing N|Solid diagnostic asset by asset ID or local asset path using asset-summary. Use when the user asks to inspect, review, summarize, or interpret an already-captured CPU profile, heap profile, heap sample, or heap snapshot, including assets just produced by ns-generate-asset. Do not use to capture new profiles/snapshots./ns-analyze-eventInvestigates an existing N|Solid event payload and correlates relevant MCP evidence. Use when the user provides or references an event such as process-blocked, new-vulnerability-found, agent-exit, uncaught exception, stack trace, span data. Routes follow-up to CPU, memory, vulnerability, or tracing workflows when needed./ns-analyze-tracingAnalyzes N|Solid/OpenTelemetry tracing evidence for request latency, HTTP errors, and service dependencies. Use when the user asks about slow endpoints, API timeouts, distributed traces/spans, N+1 queries, await chains, microservice latency, cascading failures, or trace IDs. Query N|Solid only when no trace data was provided. Builds the span waterfall with `tracing-detail` when the console offers it./ns-analyze-vulnerabilitiesAnalyzes live runtime vulnerabilities loaded by connected N|Solid Node.js processes. Use when the user wants to know which CVEs are actually present in running apps, active exploitable/live vulnerabilities, zero-day exposure, supply-chain risk in production, or production package risk. For static npm-audit-style project dependency scans, use ns-audit-dependencies instead./ns-audit-dependenciesAudits a local Node.js project dependency tree with NCM vulnerability data. Use when the user asks for an npm audit-style security review, package CVEs, direct/transitive vulnerability report, dependency risk assessment, or remediation plan before upgrading. For vulnerabilities actually loaded in running N|Solid processes, use ns-analyze-vulnerabilities instead.2 plugins ship this exact skill · first indexed Jul 15, 2026
Other plugins' skills for the same job