What the agent does
The agent reads how the project already lints before it adds a tool. In a CLI like ajeetdsouza/zoxide, Cargo.toml is a single package, edition = "2024", rust-version = "1.88.0", license = "MIT", with a dozen runtime dependencies such as clap, askama, bincode and time, a build script that generates shell completions through clap_complete and its Fig and Nushell variants, and a lockfile of 128 packages. There is no deny.toml and no cargo audit anywhere. Lint runs through a justfile: just lint on Unix enters nix-shell --pure from shell.nix and runs cargo-fmt --check, cargo clippy --all-features --all-targets -- -Dwarnings, cargo msrv verify, cargo udeps, mandoc, markdownlint, nixfmt, shellcheck, shfmt and yamlfmt; on Windows it runs only fmt and clippy. .github/workflows/ci.yml installs Nix with cachix/install-nix-action, installs just with taiki-e/install-action and runs just lint test on ubuntu-latest.
It then generates a deny.toml and makes it pass on this graph. cargo deny init writes the template; the agent trims it to the four checks and fills in what the lockfile needs: an [licenses] allow list built from cargo deny list, which on this tree is MIT, Apache-2.0 and the handful of permissive licences crates like unicode-ident carry, so that a new copyleft dependency fails the check; [advisories] against the RustSec database with no ignores, so the first run reports the real state; [bans] with multiple-versions = "warn", because the lockfile already resolves four crates at two versions each (getrandom, hashbrown, heck and wit-bindgen), duplicates the project should see but not block on; and [sources] limited to crates.io, since Cargo.toml has no git dependencies. Each line the template would leave as a question is answered in a comment that names the crate it is there for.
Wiring follows the repository's own shape. cargo-deny goes into shell.nix beside pkgs.cargo-msrv and pkgs.cargo-nextest, so the Nix shell that CI and contributors use carries it, and one line cargo deny check joins the Unix lint entry in the justfile and the Windows one, since cargo-deny runs there too. No new job is added to ci.yml, because just lint is already the lint step on every push and pull request. The agent checks .github/dependabot.yml, which only watches github-actions, and notes in the pull request that cargo-deny's advisory check is what will catch a vulnerable crate in the absence of a Cargo ecosystem entry there.
The proof is the check's own output. The agent runs cargo deny check inside the Nix shell as just lint would, shows the four summaries, and if the advisory database names a crate in the current lockfile, it leaves that finding in the output and, if the fix is a compatible bump, opens the pull request with Cargo.lock updated and the advisory id in the description rather than adding an ignore. It also runs cargo deny check licenses once with a deliberately empty allow list to show that the configuration is what makes the check pass, not an accident of defaults.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add cargo-deny to this Rust CLI. Read Cargo.toml, Cargo.lock, the justfile, shell.nix, rustfmt.toml, .github/workflows/ci.yml and .github/dependabot.yml first. Write a deny.toml with a licenses allow list derived from cargo deny list for the current lockfile, advisories with no ignores, bans with multiple-versions set to warn, and sources limited to crates.io, and comment every non-default line with the crate it is for. Add cargo-deny to the Nix shell and a cargo deny check line to both lint entries in the justfile, without adding a new CI job. Run cargo deny check and include its output in the pull request; if an advisory names a crate, update the lockfile when a compatible version fixes it instead of ignoring it. Open a pull request.",
"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 on its own branch with a new deny.toml at the root, one package added to shell.nix, one line in each lint entry of the justfile, and nothing in .github/workflows/ci.yml, because the existing just lint test step now runs the check. If an advisory named a crate with a compatible fix, Cargo.lock carries that bump as its own commit, so a reviewer can see the lockfile change apart from the configuration.
The description quotes the four cargo deny check summaries, the licence set the allow list was built from, and the duplicate-version warnings the bans check reports, so a reviewer sees what the tool will say on the next pull request. The full output is in the transcript at GET /o/{org}/sessions/{id}/messages beside the command that produced it.
Before merging, a reviewer decides whether multiple-versions should be deny rather than warn, whether any licence in the allow list should not be there, and whether to add a Cargo ecosystem to Dependabot so advisories arrive as pull requests too. A follow-up message to the same session can tighten the bans section or add a [graph] target list for the platforms the release workflow builds.
Run it on every Rust repository you maintain
A maintainer with several Rust CLIs starts one run per repository with one POST /o/{org}/sessions each, the repository in resources and this prompt as input. Each run reads its own lockfile and lint setup, so a repository that lints through a Makefile or a plain workflow step gets the check added there instead of in a justfile, and each opens its own pull request.
A key may have at most max_concurrent runs in progress at once, four by default, yet a loop over more crates than that can send every request straight away: the extra runs come back 202 with status: "queued" and start, oldest first, as earlier audits end. Send a request_id, one UUID per repository, so a retried call returns the run it already started.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A deny.toml that passes is easy; one that passes because it is right is not. The licence list has to come from the real lockfile, the bans section has to fit a tree that already carries four crates at two versions, and the tool has to run where the project's other linters already run, inside a Nix shell here, or contributors will never see it. The agent reads the lint flow and the lockfile, generates the configuration from them and runs the check in a sandbox of its own, with the output kept.
The pull request carries the check's summaries and the reasoning behind each allow-list entry, so the review is a read of one TOML file and three one-line edits. Several repositories can be handled at once, each in its own sandbox, each with its own pull request.
Frequently asked questions
Is cargo-deny the same as cargo-audit?
It includes the advisory check cargo-audit does and adds three more: licences, duplicate or banned crates, and allowed sources. On a project with no audit step at all, one tool covers all four, and the configuration file is what makes the licence and ban checks say something useful about this tree.
Why does it go into shell.nix and the justfile rather than a new workflow job?
Because that is where this repository's linters live. just lint already runs fmt, clippy, msrv, udeps and six other checks inside the Nix shell, and CI runs just lint test. Adding the tool there means contributors run it locally the same way CI does, with no second place to maintain.
What if the advisory check fails on the current lockfile?
Then the pull request shows it. If a compatible version fixes the advisory, the agent updates Cargo.lock in a separate commit and names the advisory id; if only a breaking upgrade would fix it, the finding stays in the output and the description says so, rather than hiding it behind an ignore entry.
Will the licence allow list break the next dependency bump?
Only if the new crate carries a licence outside the list, which is the point. The list is built from the licences already in the tree and commented per entry, so when a bump fails the check, the reviewer sees exactly which licence arrived and decides whether to add it.
More Rust CLI jobs
The same job on other stacks
- Add cargo-deny to a Rust Library Workspace (Rust library)
- Add cargo-deny to a Tokio Project (Tokio)
- Add cargo-deny to a Rust Workspace (Rust)