All blog posts

Codeflash Plugin for Claude Code

Saurabh Misra
April 8, 2026

With more AI generated code now, the focus is on implementing features and fixing bugs. Coding agents are great for these tasks, but we asked the question - what is the performance of the code that is generated? Our results were shocking. In a pull request  with 47,000 lines of code changes, we profiled with Codeflash and found ~120 optimizations. This reveals the extent of the slow code that we are all shipping. So we asked the question: is there a way to prevent this while still shipping code quickly? To solve this problem, we created the CodeFlash Claude Code plugin.

Introducing Codeflash Plugin for Claude Code

Our Claude Code plugin monitors the new code you’re writing in the background as an expert performance engineer, and when your new code is ready to commit, it tries to apply rigorous optimization approaches by searching for the best way to speed up your code, while still thoroughly verifying for correctness. All this happens within 3 minutes.

The result - All your new code is always optimal. Codeflash can convert those pesky $O(n^2)$ loops into $O(n)$ lookups, or change the dataflow to simplify the problem, or cache when appropriate. This way, your application runs super efficiently at scale, with low latencies and low compute costs.

Getting Started

In your Claude Code Session, add the Codeflash marketplace

/plugin marketplace add codeflash-ai/codeflash-cc-plugin

Install the Codeflash Plugin

/plugin install codeflash

Setup Codeflash for your project

/codeflash:setup

It's a one-time command which discovers your project layout and config and sets up your authentication for Codeflash.

Running Codeflash optimizations

Our philosophy is “Continuous Optimization”. We want all your code to be optimal, without slowing you down. That's why we run Codeflash in the background while you continue your work with Claude Code. Codeflash starts optimizations whenever a new commit is created during a claude session, and gives the control back to the user. It doesn’t matter if commit was created by the user manually or by Claude code itself.

You can also explicitly ask Claude to "make this run faster" or use the "/optimize" command provided by our plugin like "/optimize --file myfile.py" or "/optimize --file myfile.py --function myfunc".

Codeflash spawns a new subagent that runs in a background shell, trying to find the optimization for your code. If it finds a real optimization it can prove then it asks claude to review it and presents the optimization to you - with the concise speedup numbers and correctness proof.

How it works under the hood

Claude code triggers the Codeflash plugin as a stop hook that fires whenever new code is committed since the session's start. Actual flow:

  1. Claude/Human commits code that touches Python, Java, JavaScript/TypeScript files.
  2. Hook detects the commit and identifies changes.
  3. Codeflash analyzes the functions present in those changes for performance characteristics, your actual test suite and generates tests for more verification.
  4. It benchmarks multiple optimization candidates against the original code in a separate worktree.
  5. If the optimization is faster and all tests pass, it creates a suggestion.

No setup per function. No benchmark files to maintain. No profiler sessions to schedule. The plugin discovers your project structure, finds your tests, and handles the rest. No side-effects in your repository as it operates in a separate git worktree which gets deleted once it completes.

Optimality as a guarantee

It is eye-opening when we realize the amount of slow code that is being shipped daily. Once you witness Codeflash in action, and notice all the slow code being written - it’s hard to go back to the old way. There are several optimizations patterns Codeflash has found that are merged in production and reduced latency and cost on cloud.

We hope you find as much value out of Codeflash as we and our early users are getting.

Codeflash is closer to what would happen if you had a performance engineer on your team who reviewed every commit, profiled every changed function, benchmarked every alternative, and only spoke up when they had a verified improvement with numbers to back it up. You can check out the plugin here!

Table of contents
This is some text inside of a div block.

Stay in the Loop!

Join our newsletter and stay updated with the latest in performance optimization automation.

Thank you! We received your submission!
Oops! Something went wrong.
Share article
hillsidehillside
Before equalization
After equalization

Stay in the Loop!

Join our newsletter and stay updated with fresh insights and exclusive content.

Thank you! We received your submission!
Oops! Something went wrong.