measure-before-optimize

measure-before-optimize is a skill for Claude Code from karsten-s-nielsen/mad-scientist-skills. It costs 89 tokens per session (2,103 once invoked), scanned A, original, MIT.

A measurement step used before changing performance-sensitive code. It records how fast a function is now, including its typical and slower-case timings, so the result can be compared after the change.

In plain words
What is it for?
Use it before changing functions covered by benchmarks, performance records, documented hot paths, large-scale data work, or memory-limited Spark operations.
Why use it?
It prevents an attempted speed improvement from making the code slower without anyone noticing.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions CLAUDE.md.

Part of the mad-scientist-skills plugin — 10 skills, 4 commands shipped together

Good fit Use it before changing functions covered by benchmarks, performance records, documented hot paths, large-scale data work, or memory-limited Spark operations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/karsten-s-nielsen/mad-scientist-skills/measure-before-optimize
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add karsten-s-nielsen/mad-scientist-skills --skill measure-before-optimize
Clone the repo
git clone --depth 1 https://github.com/karsten-s-nielsen/mad-scientist-skills

Made for: Claude Code.

Or install mad-scientist-skills, the plugin that ships this one along with the rest of its 10 skills, 4 commands.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for measure-before-optimize

README.md
[![agentmods](https://agentmods.dev/badge/skills/karsten-s-nielsen/mad-scientist-skills/measure-before-optimize/github.svg)](https://agentmods.dev/skills/karsten-s-nielsen/mad-scientist-skills/measure-before-optimize)
Your own site
<a href="https://agentmods.dev/skills/karsten-s-nielsen/mad-scientist-skills/measure-before-optimize"><img src="https://agentmods.dev/badge/skills/karsten-s-nielsen/mad-scientist-skills/measure-before-optimize/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for measure-before-optimize

Your own site · 80×15
<a href="https://agentmods.dev/skills/karsten-s-nielsen/mad-scientist-skills/measure-before-optimize"><img src="https://agentmods.dev/badge/skills/karsten-s-nielsen/mad-scientist-skills/measure-before-optimize.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 89 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,103 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00089 $0.02103
Opus 5 $0.00044 $0.01052
Sonnet 5 $0.00018 $0.00421
Haiku 4.5 $0.00009 $0.00210

Measured 12d ago against content hash b6261ac16b77, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

measure-before-optimize scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/mad-scientist-skills/skills/measure-before-optimize/SKILL.md · 178 lines

How it starts

The opening of the file, as written. The whole thing — 178 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Measure Before Optimize

A pre-change measurement discipline that captures a performance baseline, gates the change on a regression threshold, and reports the delta. Designed as a peer to optimization-audit: this skill is pre-change, that one is retrospective.

When to use this skill

  • Before modifying a function that has a pytest-benchmark test.
  • Before modifying a function listed in the project's performance baselines file (commonly docs/performance-baselines.md or docs/benchmarks.md).
  • Before modifying a function flagged as a hot path in CLAUDE.md, CONTRIBUTING.md, or a performance-related document.
  • When the user says "optimize X", "speed up Y", "this function is slow", or similar performance-intent phrases.
  • When a task touches tracking-scale data, Spark UDFs with strict memory budgets, or any code in a documented hot loop.

What this skill is NOT for

  • Retrospective performance audits — use optimization-audit instead.
  • First-time benchmark creation — if no benchmark exists for the function being modified, warn the user and offer to add one, but do not block. This skill gates CHANGES to measured functions, not the creation of new ones.
  • Micro-benchmarks of framework internals that you do not own.
  • Production profiling — this skill runs local micro-benchmarks only, not production traces.

Workflow

Phase 1: Identify the measurement surface

Read the project's baselines file (default: docs/performance-baselines.md). Extract the table of benchmarked functions. If the file is a JSON baselines file, parse it directly. If neither exists, grep for @pytest.mark.benchmark or benchmark( invocations in tests/ and src/tests/.

Build a set of "measured functions" — functions with known benchmarks. Cross-reference with the function being modified.

  • If the function is in the measurement surface: proceed to Phase 2.
  • If the function is NOT in the measurement surface: warn the user:

    "The function <name> is not currently benchmarked. I can add a pytest-benchmark test before modifying it, or you can proceed without a baseline. Which?"

  • Do not block — the user may have a good reason to proceed without a baseline.

Read the full file on GitHub · 178 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 178 lines · 89 tokens per session scan A b6261ac16b77

Subscribe to this mod's changes

measure-before-optimize is a skill published in the GitHub repository karsten-s-nielsen/mad-scientist-skills (3 stars, last pushed 13d ago), licensed MIT. It adds 89 tokens to every session and 2,103 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

concept

This skill should be used when the user asks to "create a concept spec", "retrofit a module", "check spec drift", "run drift detection", "design a new module", "wyx concept", or wants to generate, update, or drift-check CONCEPT.md files. Supports retrofit, greenfield, drift detection, and discovery modes.

jlifyio/wyx · 73 tokens

map

This skill should be used when the user asks to "generate architecture map", "visualize spec relationships", "create ARCHITECTURE.md", "show concept dependencies", "wyx map", or wants a Mermaid graph with dependency matrix and data flow paths derived from all wyx specs.

jlifyio/wyx · 60 tokens

audit

This skill should be used when the user asks to "audit spec coverage", "find uncovered modules", "scan for missing specs", "check wyx coverage", "get spec TODO list", "wyx audit", "wyx", or wants a prioritized list of wyx skill commands for uncovered modules. Scans for coverage gaps, pipeline/sync candidates, and…

jlifyio/wyx · 81 tokens

sync

This skill should be used when the user asks to "document sync patterns", "map sync handlers", "create SYNCS.md", "review sync coordination", "wyx sync", or wants to understand how concepts communicate through orchestrated workflows. Produces SYNCS.md coordination maps.

jlifyio/wyx · 58 tokens

pipeline

This skill should be used when the user asks to "create a pipeline spec", "document data transformations", "document data flow", "specify pipeline invariants", "wyx pipeline", or wants to design, retrofit, or discover data pipelines with quality invariants and boundary ownership. Produces PIPELINE.md specs.

jlifyio/wyx · 66 tokens

refactor

Automated iterative code refactoring with swarm-orchestrated specialist agents including deep codebase discovery, confidence-scored code review, and security analysis. Use this skill when the user wants to improve existing code quality, clean up messy code, restructure, simplify, reduce tech debt, or perform…

zircote-plugins/refactor · 112 tokens