# Add a Minimum Supported Rust Version Check to a Rust CLI

Yes. An agent finds the oldest toolchain that builds your CLI, declares it as rust-version in Cargo.toml, adds a CI job that verifies it, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-msrv-check/rust-cli/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the repository into its own cloud sandbox and reads what the project already says about toolchains, which is usually nothing. In a tool like bootandy/dust, `Cargo.toml` declares `edition = "2024"` for the `du-dust` package but no `rust-version`, so the only floor is the one the edition implies. `.github/workflows/CICD.yml` has a `style` job on `dtolnay/rust-toolchain@stable` running `cargo fmt --all -- --check` and `cargo clippy --locked -- -D warnings`, and a `build` job with sixteen targets that installs `dtolnay/rust-toolchain@master` with a per-target toolchain variable, builds with `--locked --release` through `cross` where needed, runs `cargo test --locked` where the host can execute the binary, and publishes archives on tags. Nothing in it checks that an older compiler still works, and `README.md` tells users to `cargo install du-dust` without saying which Rust they need. `Cargo.lock` holds 125 packages, including `clap` 4 with `derive`, `sysinfo` 0.39, `rayon`, `regex`, `chrono` and `ctrlc`, each with its own floor.

It installs `cargo-msrv` in the sandbox and runs `cargo msrv find`, which bisects released toolchains, installing each through `rustup`, until it finds the oldest one where `cargo check` succeeds with the lockfile as committed. The edition gives the search a lower bound, since edition 2024 needs a toolchain that supports it, so the bisection is short. The result is written to `Cargo.toml` as `rust-version`, and the agent runs `cargo msrv verify` once more against that exact value to confirm the write matches the finding, then `cargo build --locked` and `cargo test --locked` on that toolchain, because a crate can type-check on an old compiler and still fail to link or to pass its own tests there.

Then it adds an `msrv` job to `CICD.yml` beside `style`: checkout, read the floor from the manifest with `cargo metadata --no-deps --format-version 1` and `jq '.packages[0].rust_version'` so the workflow never repeats the number, install that toolchain with `dtolnay/rust-toolchain@master`, and run `cargo check --locked --all-targets`. Reading the version from the manifest rather than hard-coding it means a future bump is a one-line change in `Cargo.toml` and the job follows. The `--locked` flag is kept on purpose: the floor is a statement about this lockfile, and the job must fail, not silently resolve newer dependencies, when someone bumps a dependency whose own `rust-version` is higher.

Finally it adds one line under the `From source` or `cargo install` section of `README.md` stating the minimum Rust version and that it is checked in CI, and notes in the pull request that with `rust-version` set, Cargo's MSRV-aware resolver, the default for edition 2024, will prefer dependency versions compatible with the floor on the next `cargo update`, which is the practical payoff of declaring it.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Establish and enforce a minimum supported Rust version for this CLI. Read Cargo.toml, Cargo.lock and the GitHub Actions workflows first. Install cargo-msrv in the sandbox, run cargo msrv find against the committed lockfile to get the oldest toolchain that builds the crate, write it as rust-version in Cargo.toml, then verify it with cargo msrv verify and run cargo build and cargo test with --locked on that toolchain. Add an msrv job to the CI workflow that reads rust-version from cargo metadata, installs that toolchain and runs cargo check --locked --all-targets. Add a line to the README stating the minimum version. Open a pull request that explains how the floor was found and what happens when a dependency raises its own rust-version.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request touching three files: `Cargo.toml` gains `rust-version`, the CI workflow gains an `msrv` job, and `README.md` gains one sentence. The description explains which toolchains `cargo msrv find` tried and where the bisection landed, and pastes the `cargo msrv verify`, `cargo build --locked` and `cargo test --locked` output from that toolchain so the number is backed by a build, not a guess.

The run's record keeps every `rustup` install and every `cargo` invocation with its output, so a reviewer can see that the test suite, including the integration tests under `tests/`, passed on the floor toolchain and not only on stable.

Before merging, a reviewer decides whether the found floor is the one to promise, since a maintainer may prefer a rounder or slightly newer version than the mechanical minimum, and checks that the new job runs on pull requests as well as on pushes so a dependency bump that raises the floor is caught before it lands.

## Run it on every pull request that changes Cargo.lock

In the console, an automation in the Project that has the repository, with a `github` trigger on `pull_request.opened`, starts one run per pull request with the event after the prompt. The prompt asks the run to finish at once unless `Cargo.lock` or `Cargo.toml` changed, and otherwise to install the declared `rust-version` toolchain, run `cargo msrv verify` and `cargo check --locked --all-targets`, and leave a review comment naming the dependency that raised the floor when the check fails, with the version that still fits.

The CI job catches the same failure, but it reports a compiler error, not a cause. The run's comment says which crate in the lockfile moved and what its new `rust-version` is, which is the piece of information the author needs to choose between pinning the dependency back and bumping the floor.

## Why run it on Rush?

Finding a real minimum means installing several toolchains and building the crate on each, which is slow and messy on a laptop and is exactly the kind of work that gets replaced by copying whatever number a similar project uses. The agent's sandbox is a fresh machine where `rustup` can install six toolchains without polluting anything, and every build it ran is in the record, so the number in the pull request is the number that was tested.

Enforcing it is cheap once it exists, and the job the agent writes reads the floor from the manifest, so the same request works unchanged across every Rust repository in an organisation, each run finding its own crate's floor in its own sandbox and opening its own pull request.

## Frequently asked questions

### Why not just set rust-version to the current stable?

Because that promises nothing to users on older toolchains and still breaks silently when a dependency moves past it. The found floor is the version your users can actually build with today, and the CI job keeps that true. A maintainer can still round it up in review; the pull request shows what the mechanical minimum was.

### What does --locked have to do with the floor?

The minimum version depends on the exact dependency versions in `Cargo.lock`. Without `--locked`, an old toolchain's Cargo could resolve different versions and pass or fail for unrelated reasons. With it, the check tests the lockfile you ship, and a dependency bump that raises a floor fails the job instead of being resolved around.

### How long does cargo msrv find take?

It depends on how many toolchains the bisection tries, each a download plus a `cargo check`. The run's record shows the exact list for your crate. The CI job that enforces the result installs one toolchain and runs one `cargo check`, so the ongoing cost is a single extra job.

### What happens when a dependency raises its own rust-version?

The `msrv` job fails on the pull request that bumps it, because `--locked` refuses to resolve around the newer crate. The author then either keeps the older dependency version or raises `rust-version` in the same pull request, and the README line follows. Nothing changes for users until that choice is merged.

### Does edition 2024 already fix a floor?

It sets a lower bound, since only toolchains that know the edition can build the crate, but the real floor is usually higher because of dependencies and language features the code uses. Declaring `rust-version` turns the implicit bound into an explicit one that Cargo's resolver and `clippy::incompatible_msrv` can act on.

## More Rust CLI jobs

- [Add a Nix Flake to a Rust CLI](https://getrush.ai/run/add-nix-flake/rust-cli/)
- [Add Shell Completions to a Rust CLI](https://getrush.ai/run/add-shell-completion/rust-cli/)
- [Add Snapshot Tests for the Shell Scripts a Rust CLI Generates](https://getrush.ai/run/add-snapshot-tests/rust-cli/)

## The same job on other stacks

- [Add an MSRV Check to a Tokio Project](https://getrush.ai/run/add-msrv-check/tokio/)

## More jobs like this: Hand off a long task

- [Serve Storybook Stories From the App's MSW Handlers](https://getrush.ai/run/add-msw-to-storybook/msw/)
- [Convert a Compose Project's Dockerfiles to Multi-stage Builds](https://getrush.ai/run/add-multi-stage-builds/docker-compose/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
