โPart of my program is too slow and I don't know where to start.โ
Agents can profile, try optimizations and benchmark them in a loop. Watch for cheating: an agent may 'win' by skipping work or changing the benchmark.
Fix it yourself in 3 steps
Write a benchmark and a correctness test so 'faster' and 'still right' are both measured.
Ask the agent to profile first and list the top hotspots before changing anything.
Let it try one change at a time; check the diff to make sure tests and benchmark weren't edited.
Copy this prompt
Make [function/module] faster without changing its results. First run the benchmark and profiler and report the top 3 hotspots. Then try one optimization at a time, rerunning the correctness tests and benchmark after each. Never edit the tests or benchmark. Stop after 5 attempts and summarize what helped.
Type your details in the boxes above the message, then tap Copy & open. Leave a box empty if you're not sure.
Yes. A coding agent like Claude Code can profile your code, try optimizations and benchmark them in a loop. Give it a benchmark and a correctness test so 'faster' and 'still right' are both measured.
Can AI cheat when optimizing code?
Yes, sometimes it 'wins' by skipping work or changing the benchmark. Check the diff to make sure the tests and benchmark weren't edited, and that results are still correct.
Where should AI start when speeding up code?
Ask it to profile first and list the top hotspots before changing anything. Then let it try one change at a time so you know what actually helped.
Anthropic's coding agent for your terminal, IDE and desktop: it reads the whole repo, runs commands and tests, edits files in place, and keeps a plan visible while it works โ strongest when you want Claude driving the change set instead of pasting snippets by hand.
A VS Code-style code editor built around AI: chat with your codebase, accept multi-line edits and hand bigger tasks to background agents. The comfortable choice if you live in an editor.
OpenAI's coding agent that runs in the CLI and in the cloud: you hand it a well-scoped task, it edits the repo, runs checks, and comes back with a pull request you review before merge โ best when the change is clear and you want a discrete handoff.