precomputed-optional-parameter

Community

Avoid redundant expensive recomputation

Authorusepowershell
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Public APIs that compute expensive data and then delegate to internal helpers can accidentally cause duplicate heavy work when the helper recomputes the same data. This pattern prevents wasted CPU and startup cost by letting callers supply pre-computed results while preserving backward compatibility for existing internal callers.

Core Features & Use Cases

  • Optional parameter pattern: inner helpers accept an optional precomputed argument that defaults to null.
  • Guarded computation: helpers use null-coalescing to compute only when the value is not provided.
  • Type visibility guidance: promote sealed helper types to internal if they must appear in the public signature.
  • Primary use case: expensive PowerShell runspace creation and session introspection where double initialization is costly.
  • Responsibility model: the public API layer is responsible for computing and passing the precomputed data when available.

Quick Start

Compute the expensive data in the public method and pass it as the optional parameter to the inner helper to avoid duplicate work.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: precomputed-optional-parameter
Download link: https://github.com/usepowershell/PoshMcp/archive/main.zip#precomputed-optional-parameter

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.