Improve the cost that matters
Optimize the actual workload, not the appearance of an algorithm. Establish the relevant behavior, input sizes, and costly path, then choose the simplest change that earns its complexity.
For analysis requests, inspect and report without editing implementation. For explicit optimization requests, make necessary in-scope edits and verification without a separate ritual. If the symptom's cause is unknown, establish it first; no companion diagnosis or design skill is required.
Find and validate opportunities
Use existing profiles, measurements, tests, and code evidence. For a broad scan, the bundled scanner can supply leads; it is optional when the hotspot is already known. Resolve the script relative to this skill's location and run python3 <script> <target> --format json or --format markdown. Scanner warnings and a clean scan are not proof of performance or correctness.
Prioritize hot paths and meaningful input sizes. Distinguish algorithmic scaling from constant factors and remote I/O. If a transformation needs care, consult the optimization notes; do not apply every pattern.
Preserve observable ordering, equality, duplicate handling, mutation/identity, errors, access filters, and public interfaces as relevant. Batching and caching need valid semantics, not just fewer calls. If a public contract must change, explain the smallest required decision rather than silently expanding the optimization.
Choose focused behavior checks and a repeatable measurement where a performance claim needs one. Add tests that protect real behavior; do not block ordinary implementation just because the existing suite is sparse. Resolve consequential ambiguity before choosing new behavior.
Finish with evidence
Run required checks and affected regression coverage. Compare like-for-like inputs and environments; label asymptotic reasoning and expected improvements separately from measured gains. If verification fails, report what remains and do not claim completion.
Present supported hotspots or the implemented improvement, relevant locations, evidence, and tradeoffs. Reporting prompts are optional when a larger report benefits from structure, not mandatory fields.
Preserve dirty and concurrent changes; coordinate ownership before overlapping edits. No automatic commits, tracker mutations, publication, or broad refactors. Save reports only when requested, using the requested path or repository convention, otherwise a descriptive path under docs/.