reversa-optimize

Optimizes code performance with measured before-and-after benchmarks while preserving output equivalence.

1.5k|405|Updated Apr 26, 2026
One-click install
npx skills add https://github.com/sandeco/reversa --skill reversa-optimize
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: reversa-optimize
Source: https://github.com/sandeco/reversa/tree/main/agents/reversa-optimize
Command: npx skills add https://github.com/sandeco/reversa --skill reversa-optimize

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Legacy code often contains performance bottlenecks that are risky to change because there is no proof the optimized version behaves identically. This Skill reduces execution time, memory, and resource consumption only when the gain is measured and output equivalence is proven, rejecting premature optimization.

Core Features & Use Cases

  • Evidence-Based Optimization: Identifies bottlenecks through declared asymptotic complexity and real benchmarks rather than intuition, recording baseline measurements before any change.
  • Output Equivalence Proof: Requires a safety net of tests (including characterization tests when coverage is missing) and proves the optimized code produces identical output for the same inputs, including edge cases.
  • Gated Transformations: Every code change passes through an approval gate with a diff, generates a self-contained plan.html, and persists transformation records with diffs and before/after evidence.
  • Use Case: A legacy report generator takes 40 seconds per run. The agent measures the baseline, proposes an algorithmic improvement, proves equivalent output on edge cases, applies the change after gate approval, and confirms the measured gain.

Quick Start

Ask the agent to run /reversa-optimize on a slow function or module so it measures the bottleneck, proposes an optimization, and applies it only after your approval.

Frequently Asked Questions about reversa-optimize

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

FAQPage Schema
How do I safely optimize legacy code performance with an AI agent?

Run /reversa-optimize on the target code. The agent measures a baseline, proposes the optimization with estimated gain, shows a diff for approval, then applies it only after proving output equivalence and confirming the measured improvement.

What is the difference between reversa-optimize and reversa-simplify?

reversa-optimize targets resource costs such as time, memory, and asymptotic complexity with measured gains. reversa-simplify targets clarity of logic. If the real goal is reducing logical complexity rather than resource cost, the agent redirects to /reversa-simplify.

Can I optimize code that has no test coverage?

Yes, but the agent first requires a safety net. It offers green characterization tests that fix the current output before optimizing, and if the safety net is refused, it downgrades the opportunity and records the absence of proof.

What happens if the optimization shows no measured gain?

The change is reverted using the recorded diff. The agent only considers work an optimization when the post-change measurement improves; regressions or flat results are rolled back automatically.

Does reversa-optimize work without a runnable benchmark environment?

Yes. When the harness cannot execute the project, the agent falls back to declared asymptotic complexity for time and space, and explicitly states that no runtime benchmark was performed.