Skip to main content

Codeflash CLI Reference

Complete command-line reference for all Codeflash commands, flags, and options with practical examples you can run directly in your terminal.
Prerequisites - Ensure Codeflash is installed in your Python environment and you have a configured pyproject.toml in your project.

Quick Start

# Activate virtual environment (if using one)
source .venv/bin/activate

# Verify installation
codeflash --version

Common Workflows

1. First-Time Setup

1

Install Codeflash

pip install codeflash
2

Initialize Project

codeflash init
3

Verify Setup

codeflash --verify-setup
4

Run First Optimization

codeflash --file src/main.py --function my_function --no-pr

2. Optimize a Workflow

1

Trace Your Script

codeflash optimize my_script.py --arg1 value1
2

Review Optimizations

Check the generated PR or local changes for optimization suggestions.

3. CI/CD Integration

1

Set Up GitHub Actions

codeflash init-actions
2

Merge the Workflow PR

Review and merge the generated GitHub Actions workflow.
3

Automatic Optimization

Codeflash will now optimize code in every PR automatically!

Help & Version

# Display version
codeflash --version

# Main help
codeflash --help

# Subcommand help
codeflash optimize --help
codeflash init --help

Documentation Structure

This CLI reference is organized into the following sections:

Next Steps