|
| 1 | +--- |
| 2 | +title: "Flags Reference" |
| 3 | +description: "Complete reference for all Codeflash CLI flags and options" |
| 4 | +icon: "list" |
| 5 | +sidebarTitle: "Flags Reference" |
| 6 | +keywords: ["flags", "options", "arguments", "command line"] |
| 7 | +--- |
| 8 | + |
| 9 | +# Flags Reference |
| 10 | + |
| 11 | +Complete reference for all Codeflash CLI flags and command-line options. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Main Command Flags |
| 16 | + |
| 17 | +| Flag | Type | Description | |
| 18 | +|------|------|-------------| |
| 19 | +| `--file` | `PATH` | Optimize only this file | |
| 20 | +| `--function` | `NAME` | Optimize only this function (requires `--file`) | |
| 21 | +| `--all` | `[PATH]` | Optimize all functions. Optional path to start from | |
| 22 | +| `--replay-test` | `PATH` | Path to replay test file(s) | |
| 23 | +| `--benchmark` | flag | Enable benchmark mode | |
| 24 | +| `--no-pr` | flag | Don't create PR, update locally | |
| 25 | +| `--no-gen-tests` | flag | Don't generate tests | |
| 26 | +| `--no-draft` | flag | Skip draft PRs | |
| 27 | +| `--worktree` | flag | Use git worktree | |
| 28 | +| `--staging-review` | flag | Upload to staging | |
| 29 | +| `--verbose` / `-v` | flag | Verbose debug output | |
| 30 | +| `--verify-setup` | flag | Run setup verification | |
| 31 | +| `--version` | flag | Show version | |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## Configuration Override Flags |
| 36 | + |
| 37 | +Override settings from `pyproject.toml` via command line. |
| 38 | + |
| 39 | +| Flag | Type | Description | |
| 40 | +|------|------|-------------| |
| 41 | +| `--config-file` | `PATH` | Path to pyproject.toml | |
| 42 | +| `--module-root` | `PATH` | Python module root directory | |
| 43 | +| `--tests-root` | `PATH` | Tests directory | |
| 44 | +| `--benchmarks-root` | `PATH` | Benchmarks directory | |
| 45 | + |
| 46 | +<Accordion title="Complete Examples"> |
| 47 | +<Tabs> |
| 48 | + <Tab title="Linux/macOS"> |
| 49 | + ```bash |
| 50 | + # Override config file location |
| 51 | + codeflash --file src/app.py --function main --config-file configs/pyproject.toml --no-pr |
| 52 | + |
| 53 | + # Override module root |
| 54 | + codeflash --file src/app.py --function main --module-root src --no-pr |
| 55 | + |
| 56 | + # Override tests root |
| 57 | + codeflash --file src/app.py --function main --tests-root tests/unit --no-pr |
| 58 | + |
| 59 | + # Combine multiple overrides |
| 60 | + codeflash --file src/app.py --function main \ |
| 61 | + --module-root src \ |
| 62 | + --tests-root tests \ |
| 63 | + --no-pr |
| 64 | + ``` |
| 65 | + </Tab> |
| 66 | + <Tab title="Windows"> |
| 67 | + ```powershell |
| 68 | + # Override config file location |
| 69 | + codeflash --file src\app.py --function main --config-file configs\pyproject.toml --no-pr |
| 70 | +
|
| 71 | + # Override module root |
| 72 | + codeflash --file src\app.py --function main --module-root src --no-pr |
| 73 | +
|
| 74 | + # Override tests root |
| 75 | + codeflash --file src\app.py --function main --tests-root tests\unit --no-pr |
| 76 | + ``` |
| 77 | + </Tab> |
| 78 | +</Tabs> |
| 79 | +</Accordion> |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## Optimize Subcommand Flags |
| 84 | + |
| 85 | +Flags specific to the `codeflash optimize` command. |
| 86 | + |
| 87 | +| Flag | Type | Description | |
| 88 | +|------|------|-------------| |
| 89 | +| `--output` | `PATH` | Trace file output path (default: `codeflash.trace`) | |
| 90 | +| `--timeout` | `INT` | Maximum trace time in seconds | |
| 91 | +| `--max-function-count` | `INT` | Max times to trace a function (default: 100) | |
| 92 | +| `--config-file-path` | `PATH` | Path to pyproject.toml | |
| 93 | +| `--trace-only` | flag | Only trace, don't optimize | |
| 94 | + |
| 95 | +<Info> |
| 96 | + The `--output` flag specifies where to save the trace file. If not specified, it defaults to `codeflash.trace` in the current directory. |
| 97 | +</Info> |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## Behavior Flags |
| 102 | + |
| 103 | +Control how Codeflash behaves during optimization. |
| 104 | + |
| 105 | +| Flag | Description | |
| 106 | +|------|-------------| |
| 107 | +| `--no-pr` | Run locally without creating a pull request | |
| 108 | +| `--no-gen-tests` | Use only existing tests, skip test generation | |
| 109 | +| `--no-draft` | Skip optimization for draft PRs (CI mode) | |
| 110 | +| `--worktree` | Use git worktree for isolated optimization | |
| 111 | +| `--staging-review` | Upload optimizations to staging for review | |
| 112 | +| `--verbose` / `-v` | Enable verbose debug logging | |
| 113 | + |
| 114 | +<Accordion title="Complete Examples"> |
| 115 | +```bash |
| 116 | +# Local optimization only |
| 117 | +codeflash --file src/app.py --function main --no-pr |
| 118 | + |
| 119 | +# Use only existing tests |
| 120 | +codeflash --file src/app.py --function main --no-gen-tests --no-pr |
| 121 | + |
| 122 | +# Enable verbose logging |
| 123 | +codeflash --file src/app.py --function main --verbose --no-pr |
| 124 | + |
| 125 | +# Use worktree for isolation |
| 126 | +codeflash --file src/app.py --function main --worktree --no-pr |
| 127 | + |
| 128 | +# Upload to staging |
| 129 | +codeflash --all --staging-review --no-pr |
| 130 | +``` |
| 131 | +</Accordion> |
| 132 | + |
| 133 | +--- |
| 134 | + |
| 135 | +## Flag Combinations |
| 136 | + |
| 137 | +Common flag combinations for different use cases: |
| 138 | + |
| 139 | +### Local Development |
| 140 | + |
| 141 | +```bash |
| 142 | +# Optimize locally with verbose output |
| 143 | +codeflash --file src/app.py --function main --no-pr --verbose |
| 144 | +``` |
| 145 | + |
| 146 | +### CI/CD Pipeline |
| 147 | + |
| 148 | +```bash |
| 149 | +# Skip draft PRs and use existing tests only |
| 150 | +codeflash --all --no-draft --no-gen-tests |
| 151 | +``` |
| 152 | + |
| 153 | +### Debugging |
| 154 | + |
| 155 | +```bash |
| 156 | +# Trace only with custom output and timeout |
| 157 | +codeflash optimize app.py --trace-only --output debug.trace --timeout 60 |
| 158 | +``` |
| 159 | + |
| 160 | +### Custom Configuration |
| 161 | + |
| 162 | +```bash |
| 163 | +# Override multiple config settings |
| 164 | +codeflash --file src/app.py --function main \ |
| 165 | + --module-root src \ |
| 166 | + --tests-root tests/unit \ |
| 167 | + --benchmarks-root tests/benchmarks \ |
| 168 | + --no-pr |
| 169 | +``` |
| 170 | + |
| 171 | +--- |
| 172 | + |
| 173 | +## Next Steps |
| 174 | + |
| 175 | +<CardGroup cols={2}> |
| 176 | + <Card |
| 177 | + title="Optimization Commands" |
| 178 | + icon="bullseye" |
| 179 | + href="/cli-reference/optimization" |
| 180 | + > |
| 181 | + Learn how to use optimization commands |
| 182 | + </Card> |
| 183 | + <Card |
| 184 | + title="Troubleshooting" |
| 185 | + icon="wrench" |
| 186 | + href="/cli-reference/troubleshooting" |
| 187 | + > |
| 188 | + Fix common issues |
| 189 | + </Card> |
| 190 | +</CardGroup> |
| 191 | + |
0 commit comments