skillfed

codeflash

Client for codeflash.ai - automatic code performance optimization, powered by AI

codeflash v0.20.6 191.9K downloads/30d#9,872 on PyPI
License unclear Active released

What it is and what it does

Codeflash is a command-line client for an AI-powered code optimization service. It analyzes your Python code, generates multiple optimization candidates using LLMs, tests them for correctness, benchmarks them for performance, and opens pull requests with the best improvements. You configure it once with `codeflash init` (which asks for an API key and optional GitHub app setup), then run `codeflash --all` to optimize an entire codebase, `codeflash optimize myscript.py` for a single file, or set up GitHub Actions to optimize all future pull requests automatically.

The tool depends on a large set of runtime libraries for code analysis (libcst, jedi), testing (pytest and variants), profiling (line-profiler, memray), and communication with the Codeflash service (requests, posthog, sentry-sdk). It's designed for teams shipping Python code—AI agents, computer vision, PyTorch, numerical, and backend workloads—where performance matters and code review is already part of the workflow.

Use it for:

  • Optimize an entire existing Python codebase in one pass to find and merge performance improvements across all modules.
  • Automatically optimize new code in pull requests via GitHub Actions before it ships, ensuring performance without manual profiling.
  • Profile and optimize a single Python script or workflow end-to-end without manual benchmarking or code review.
  • Integrate performance optimization into CI/CD so that performance regressions are caught and fixed before merge.
  • Explore multiple optimization strategies for hot code paths and let the tool rank them by actual benchmark results.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Codeflash is a CLI tool that uses LLMs to automatically generate, test, and benchmark Python code optimizations, then opens pull requests with the best performance improvements found.

Yes, with conditions. Install if you have an active Codeflash.ai account and API key, want LLM-assisted performance optimization integrated into your workflow, and are willing to review and merge AI-generated pull requests. The tool is actively maintained, has low install friction, and carries no known vulnerabilities. The main friction is the unclear license metadata—verify the BSL-1.1 terms apply to your use case before relying on it in production. The 38 runtime dependencies are substantial but necessary for the feature set.

Install

codeflash on PyPI

pip

pip install codeflash

uv

uv add codeflash

poetry

poetry add codeflash

Installing codeflash

Before you install

Low install friction with a pure-Python wheel. Requires 38 runtime dependencies including testing frameworks (pytest, pytest-asyncio, pytest-memray), profiling tools (line-profiler, memray), and LLM/analysis libraries (jedi, libcst, crosshair-tool). Active maintenance with latest release 76 days ago.

License in practice

License treatment is unclear—no SPDX identifier or raw license text is available in the package metadata, though the description mentions BSL-1.1. Verify the actual license terms before committing to production use.

Quickstart

pip install codeflash
codeflash init
codeflash --all

Requires Python >=3.9. Codeflash init requires an API key from codeflash.ai and optionally a GitHub app installation to open pull requests.

Verify before relying

  • Whether the BSL-1.1 license mentioned in the description is the actual license or if the unclear metadata reflects a different licensing model.
  • Whether the 38 runtime dependencies are all required at install time or if some are optional for specific features.
  • Performance and cost implications of running LLM-based optimization on large codebases.

Package facts

License not declared (unclear)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 38 — attrs, click, codeflash-benchmark, coverage, crosshair-tool, dill, filelock, gitpython, humanize, inquirer, isort, jedi, junitparser, libcst, line-profiler, lxml, memray, parameterized, platformdirs, posthog, pydantic, pygls, pytest-asyncio, pytest-memray, pytest-timeout, pytest, requests, rich, sentry-sdk, tomlkit
Maintenance actively maintained — 76 days since the last release
First released
Downloads 191,944/month — #9,872 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: codeflash-0.20.6-py3-none-any.whl

Keywords: LLM, ai, code, codeflash, machine learning, optimization, performance

Tags

python code performance optimizationautomatic code optimization with aillm-powered performance tuningpython performance profiling and optimizationcode optimization pull requestsai code optimizerpython benchmarking and optimization
performance-optimizationai-assistedcode-analysis

More Quality Assurance packages