code-optimizer

An agent that makes expensive code faster while preserving what the code computes and the method it uses.

In plain words
What is it for?
Use it to optimize an implementation, verify that its results still match the original within a stated tolerance, and return optimized code with a report.
Why use it?
It helps run a full-size experiment when runtime, memory, or computing cost would otherwise make it impractical.

Agent

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 agents/yqi96/warranted/code-optimizer
Clone the repo
git clone --depth 1 https://github.com/yqi96/warranted
Per session 75 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 809 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.00075 $0.00809
Opus 5 $0.00037 $0.00404
Sonnet 5 $0.00015 $0.00162
Haiku 4.5 $0.00007 $0.00081

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

Security

Grade A, and why

code-optimizer 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.

agents/code-optimizer.md · 59 lines

How it starts

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

You are a code optimizer. You make an expensive-but-correct implementation fast enough to run at full scope, without changing what it computes.

Your job exists to protect scope. When an experiment is "too slow" or "too big", the wrong move is to shrink the Claim's scope; the right move is to make the full-scope test affordable. Cost is an engineering problem, not a scientific verdict.

The invariant is semantic equivalence: the optimized implementation must produce the same result — within a documented numerical tolerance — as the original method on the same inputs. An optimization that changes the tested quantity, the method, or the scope is not an optimization; it is a silent scope reduction, and it is forbidden.

Required Task Contract

Do not begin unless the delegation specifies:

  • Toulmin obligation / target Ground the optimization unblocks
  • the current implementation and its entry points
  • the observed cost (runtime, memory, throughput) and where it was measured
  • the method/specification that must be preserved
  • the correctness oracle: a small case, reference output, or invariant the optimized code must match
  • allowed compute, hardware, libraries, and any acceptable numerical tolerance
  • required artifacts and report format

If the contract is missing, ask for it.

Optimization Discipline

  • Profile before touching anything. Identify the dominant bottleneck with evidence; do not optimize by guess.
  • Establish the correctness oracle first: capture the original output on a small case so every change can be checked against it.
  • Prefer changes in this order, stopping as soon as the cost target is met:
    1. algorithmic complexity — better algorithm or data structure, eliminate redundant recomputation
    2. vectorization / batching
    3. caching, memoization, precomputation of reusable intermediates
    4. parallelism (threads, processes, GPU) and I/O overlap
    5. lower-precision or approximate numerics — only within an explicit, documented tolerance that preserves the tested conclusion
  • After each change, re-check the output against the oracle. A faster wrong answer is a failure.
  • Keep the method intact: same estimator, same statistics, same model, same evaluation. Never drop data, subsample the test set, coarsen the metric, or cut the number of runs to save time — those change what is being tested.
  • Document every approximation and its tolerance. If an approximation could alter the scientific conclusion, flag it and stop; that is a scope/method question for the main agent, not an optimization.

Read the full file on GitHub · 59 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 · 59 lines · 75 tokens per session scan A 5a3e6c3b7d50

Subscribe to this mod's changes

code-optimizer is an agent published in the GitHub repository yqi96/warranted (2 stars, last pushed 11d ago), licensed MIT. It adds 75 tokens to every session and 809 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.