optimize

A code-performance tool that measures where a program is slow, recommends focused changes, and applies them while checking that the code still works.

In plain words
What is it for?
Use it to investigate slow page loads, responses, memory use, or large bundles, then optimize the relevant code using tests written before the changes.
Why use it?
It replaces guesswork with measurements and prevents speed improvements from breaking existing behavior. It also confirms whether the changes actually helped.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/mountainunicorn/add/optimize
Any agent
npx skills add MountainUnicorn/add --skill optimize
Clone the repo
git clone --depth 1 https://github.com/MountainUnicorn/add

Made for: Claude Code, Codex.

Per session 17 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,628 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00017 $0.03628
Opus 5 $0.00009 $0.01814
Sonnet 5 $0.00003 $0.00726
Haiku 4.5 $0.00002 $0.00363

Measured yesterday against content hash 97e49bdb7f84, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

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 yesterday.

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.

core/skills/optimize/SKILL.md · 510 lines

How it starts

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

ADD Optimize Skill v{{VERSION}}

Identify and fix performance bottlenecks. This skill profiles code to find slow operations, suggests optimizations, and implements them with test-driven discipline.

Overview

The Optimize skill improves application performance while maintaining correctness. It:

  • Profiles code to identify bottlenecks
  • Quantifies performance issues
  • Suggests targeted optimizations
  • Implements with TDD (tests before optimization)
  • Verifies improvements with measurements
  • Documents optimizations for future maintainers

Performance optimization follows TDD discipline: write tests that capture performance expectations before implementing optimizations.

Pre-Flight Checks

  1. Verify implementation exists

    • Identify implementation files (src/, app/, etc.)
    • Verify code is in GREEN state (all tests passing)
    • Halt if tests not passing (optimize only stable code)
  2. Load configuration

    • Read .add/config.json
    • Extract performance targets:
      • perf.pageLoadTime (e.g., < 2 seconds)
      • perf.responseTime (e.g., < 100ms)
      • perf.memoryLimit (e.g., < 50MB)
      • perf.bundleSize (e.g., < 500KB)
  3. Determine scope

    • Use --scope flag to target: backend, frontend, or full
    • Default: full system
    • Scope guides which profiling tools to use
  4. Check for profiling data

    • If --profile-first: profile before optimization
    • Otherwise, use existing profile if available
    • Or ask user for baseline metrics
  5. Identify profiling tools

    • Backend: py-spy, perf, go pprof, node --prof, etc.
    • Frontend: Chrome DevTools, Lighthouse, WebPageTest
    • Database: EXPLAIN ANALYZE, pg_stat_statements, etc.
  6. Check for session handoff — per the Session-Handoff Preflight in ${CLAUDE_PLUGIN_ROOT}/references/skill-epilogue.md

Execution Steps

Step 1: Baseline Profiling (if --profile-first)

Establish baseline measurements:

For Backend (Python):

# Profile with py-spy
py-spy record -o profile.svg -- python -m pytest tests/

# Or use cProfile
python -m cProfile -s cumulative app.py > profile.txt

# Database queries
EXPLAIN ANALYZE SELECT ...

Read the full file on GitHub · 510 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. yesterday First seen · 510 lines · 17 tokens per session scan A 97e49bdb7f84

Subscribe to this mod's changes

optimize is a skill published in the GitHub repository MountainUnicorn/add (11 stars, last pushed 1mo ago), licensed MIT. It adds 17 tokens to every session and 3,628 once invoked, about $0.0001 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-30.