What the agent does
The agent reads how CI is already built before adding to it. In a repository shaped like casey/just, .github/workflows/ci.yaml has four jobs: lint (clippy, cargo fmt --check, a bin/forbid script that greps for dbg! and todo, and shellcheck on www/install.sh), msrv (cargo check on the 1.89.0 toolchain that rust-version in Cargo.toml names), pages (builds the book with a pinned mdbook and mdbook-linkcheck) and test (cargo test --all on Ubuntu, macOS and Windows). Every uses: is pinned to an exact version, actions/checkout@v6.1.0, Swatinem/rust-cache@v2.9.2, actions-rust-lang/setup-rust-toolchain@v1.17.0, and .github/workflows/actions.lock records each one's commit, generated by gh actions-lock. RUSTFLAGS: --deny warnings is set for the whole workflow. There is no cargo audit, no cargo deny, no deny.toml and no Dependabot or Renovate config, and Cargo.lock resolves 155 packages.
The agent adds an audit job to ci.yaml rather than a new workflow, so it shares the file's on: block (pull requests and pushes to master), its concurrency group and its defaults. The job checks out the code with the same pinned actions/checkout, installs cargo-audit as a prebuilt binary rather than cargo install, which would compile it on every run, and runs cargo audit against Cargo.lock. If the install step is a third-party action, the agent runs gh actions-lock so actions.lock gains the new entry, because the lockfile is marked machine-generated and the repository's convention is that every uses: has a lock entry. It also adds an audit entry in the [group: 'check'] section of the justfile, next to outdated and unused, so just audit runs the same check locally, and lists it in the ci entry beside test, build-book and forbid.
Then it runs cargo audit in the sandbox against the real lockfile. Whatever the advisory database says that day decides the next step: a vulnerability in a dependency that has a fixed release gets bumped in Cargo.lock with cargo update --package <crate> and cargo test --all re-run; a yanked or unmaintained warning gets either a bump or an entry in .cargo/audit.toml under [advisories] ignore with a comment that says why and when to revisit. The agent decides whether the job should run with --deny warnings, which fails on unmaintained crates too, or only on vulnerabilities, and explains the choice in the pull request; the default it proposes is to fail on vulnerabilities and report warnings.
The audit job is also given a schedule trigger in its own small workflow if the maintainers want advisories caught between pull requests, since a new RUSTSEC entry changes nothing in the repository and would otherwise go unnoticed until the next push. The pull request pastes the cargo audit output from the sandbox and the cargo test --all result after any bump.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add a cargo-audit check to this Rust CLI's CI and open a pull request. Read Cargo.toml, Cargo.lock, the justfile, .github/workflows/ci.yaml and .github/workflows/actions.lock first and match their conventions exactly: add an audit job to ci.yaml that uses the same pinned actions/checkout, installs cargo-audit as a prebuilt binary rather than cargo install, and runs cargo audit against Cargo.lock. If you add any new action, pin it to an exact version and update actions.lock with gh actions-lock, since that file is machine-generated and every action in this repository is locked. Add a `just audit` entry in the justfile's check group and include it in the ci entry. Run cargo audit in the sandbox: for any vulnerability with a fixed release, bump that crate in Cargo.lock with cargo update --package and re-run cargo test --all; for yanked or unmaintained warnings, either bump or add an ignore entry in .cargo/audit.toml with a comment saying why. Propose failing the job on vulnerabilities only, and explain in the pull request how to make warnings fail too. Paste the full cargo audit output and the test result in the pull request description, and change nothing else.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- 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.
- 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.
- 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 that edits .github/workflows/ci.yaml to add the audit job, updates .github/workflows/actions.lock if a new action was introduced, adds an audit entry to the justfile, and, depending on what the advisory database reported, bumps one or more crates in Cargo.lock or adds .cargo/audit.toml with commented ignores. The description quotes the cargo audit output as the sandbox saw it and the cargo test --all result that followed any bump.
The new job runs on the pull request itself, so the first audit result appears as a check next to lint, msrv, pages and test before merge. A reviewer reads the ignore entries, if any, and decides whether --deny warnings should be on from day one or after the unmaintained crates have been dealt with, and whether to add the job to the branch protection rules.
Run it on every Monday morning
Once the job is merged, CI catches advisories on every push, but a new RUSTSEC entry arrives between pushes. Make this an automation in the Project with a schedule trigger, cron 0 9 * * 1 in your timezone, and a prompt that runs cargo audit, bumps any crate with a fixed release, runs cargo test --all and opens one pull request on its own branch; a week with a clean audit opens nothing. A run whose tests fail after the bump ends needs_review with the failing output rather than opening a broken pull request. An automation has its own max_runs_per_hour cap, separate from any API key.
From your own tooling, the same work is one POST /o/{org}/sessions with this body and the repository in resources; the key's webhook_url posts run.completed with the session_url when the turn ends.
The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.
Why run it on Rush?
The hard part of adding an audit is not the YAML, it is the first run: the database says something about a crate three levels down in Cargo.lock, and someone has to find out whether a fixed release exists, whether the bump compiles under RUSTFLAGS: --deny warnings, and whether the tests still pass on all three operating systems. The agent does the bump and the test run in its own sandbox, with the audit output in front of it, and keeps every command and result in the run's record.
It also respects a repository that is strict about its actions. Pinning the new action to an exact version and regenerating actions.lock is the kind of convention a quick contribution forgets and a maintainer then has to request. The agent reads the lockfile's header, sees who generates it, and follows the rule, so the pull request is about the audit and not about process.
Frequently asked questions
Why cargo-audit rather than cargo-deny?
The question here is advisories, and cargo audit checks exactly that against the RustSec database with one command and one optional config file. cargo-deny also checks licenses, duplicate versions and sources, which is a bigger policy decision for the maintainers. The agent names that option in the pull request and leaves it as a separate change.
Will it install cargo-audit from source on every CI run?
No. cargo install cargo-audit compiles it and would add minutes to every run, so the job installs a prebuilt binary. If that is done through an action, the action is pinned to an exact version and recorded in actions.lock, the same way Swatinem/rust-cache@v2.9.2 already is.
What happens when there is no fix for an advisory?
The agent adds the advisory id to .cargo/audit.toml under [advisories] ignore with a comment naming the crate, why it cannot be bumped and what to watch for. The job then passes, and the ignore is visible in the diff rather than hidden in a CI flag.
Does it fail the build on unmaintained crates?
Not by default. cargo audit reports unmaintained and yanked as warnings, and the proposed job fails on vulnerabilities only. The pull request explains that adding --deny warnings makes those fail as well, so the maintainers can turn that on once the warnings it would raise today have been handled.
More Rust CLI jobs
The same job on other stacks
More jobs like this: Upgrade dependencies weekly
- Add cargo-deny to a Rust Workspace (Rust)
- Add cargo-deny to a Rust Library Workspace (Rust library)