ns-optimize-function

Optimizes a user-selected Node.js function through baseline benchmarking and validated rewrites.

6|7|Updated Jun 4, 2026
One-click install
npx skills add https://github.com/nodesource/nsolid-plugin --skill ns-optimize-function-nodesource
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ns-optimize-function
Source: https://github.com/nodesource/nsolid-plugin/tree/main/skills/ns-optimize-function
Command: npx skills add https://github.com/nodesource/nsolid-plugin --skill ns-optimize-function-nodesource

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Optimizing JavaScript functions without measurement often wastes effort on cold paths or produces unverified speedups. This Skill enforces a disciplined workflow: analyze the function's real usage, benchmark the baseline, propose a behavior-preserving rewrite, and validate the improvement with A/B benchmarks. ## Core Features & Use Cases - Impact Analysis: Reads the target function, its references, call sites, and tests to assess algorithmic complexity, blast radius, and whether optimization is actually worthwhile. - Baseline Benchmarking: Delegates to the ns-benchmark-run skill to measure the current implementation using real inputs derived from call sites and tests. - Validated Rewrites: Proposes a single behavior-preserving optimization, requires user approval, then hands off to ns-validate-optimization for A/B comparison with up to 3 retry attempts. - Use Case: A developer notices a slow request handler in their Node.js API. They point at the function, and the Skill confirms it is a hot path, benchmarks it, rewrites the dominant allocation cost, and verifies a measurable throughput improvement. ## Quick Start Optimize this Node.js function to make it faster and validate the improvement with a benchmark.

Frequently Asked Questions about ns-optimize-function

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize a slow Node.js function?▼

Point to the function in your workspace or paste its code. The Skill analyzes its call sites and complexity, benchmarks the current implementation, proposes a behavior-preserving rewrite for your approval, and validates the speedup with an A/B benchmark comparison.

How does benchmark validation work for code optimization?▼

The Skill first records a baseline ops/sec measurement of the original function, then delegates to ns-validate-optimization, which runs an A/B comparison between original and optimized code, retrying up to 3 times until the improvement clears the effectiveness threshold.

Can I use this for live N|Solid production diagnostics?▼

No. This Skill requires local workspace source code and is not for live N|Solid diagnostics alone. It works on functions you can point to in your codebase, using call sites and tests to derive realistic benchmark inputs.

When should I not optimize a function?▼

Skip optimization when the function sits on a cold path such as startup or config loading, where gains are negligible. The Skill explicitly assesses optimization worthiness during impact analysis and stops rather than optimizing code that is not worth changing.

What happens if the optimization does not improve performance?▼

If validation exhausts 3 attempts without clearing the effectiveness threshold, the Skill reports the best measured attempt and states plainly that the target was not met. It never claims success for an optimization that failed validation.