# Add Dependabot to an Elixir Library

Yes. An agent writes a Dependabot config for an Elixir library's Hex packages and GitHub Actions, checks the first bumps pass its CI matrix and opens a PR.

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

## What the agent does

The agent reads the dependency shape before it writes any configuration, because for a library it is the whole question. In an Elixir library like elixir-plug/plug, `mix.exs` declares four dependencies with deliberately wide requirements: `mime` at `~> 1.0 or ~> 2.0`, `telemetry` at `~> 0.4.3 or ~> 1.0`, `plug_crypto` at a requirement that changes with the `PLUG_CRYPTO_2_0` environment variable, and `ex_doc` only in the `:docs` environment. `mix.lock` pins nine packages, those four plus `ex_doc`'s chain of `earmark_parser`, `makeup`, `makeup_elixir`, `makeup_erlang` and `nimble_parsec`. `.github/workflows/ci.yml` runs on every pull request and push to `main` with a two-row matrix, Elixir 1.15 on OTP 24 with `PLUG_CRYPTO_2_0` set to `false` and Elixir 1.19 on OTP 28 with it `true`, and on the newer row adds `mix deps.get --check-locked`, `mix format --check-formatted` and `mix deps.unlock --check-unused`. It uses `actions/checkout@v6` and `erlef/setup-beam@v1`. There is no `.github/dependabot.yml`.

Those wide requirements are the point: a library's users resolve against them, so a bot that tightens `~> 1.0 or ~> 2.0` to `~> 2.1` in `mix.exs` would break downstream builds for nothing. The agent writes `.github/dependabot.yml` with the `mix` ecosystem at the root directory, a weekly schedule, and `versioning-strategy: lockfile-only`, so Dependabot moves `mix.lock` and never edits `mix.exs`. It groups `ex_doc` and its five rendering packages into one pull request under a `docs` group, since they only matter when documentation builds and tend to move together, and leaves `mime`, `telemetry` and `plug_crypto` as one pull request each so a runtime change gets its own review. A second entry covers `github-actions`, so `checkout` and `setup-beam` get a pull request when a new major tag appears.

Then it checks what the first bumps would do, because the matrix has a trap. The lock pins one `plug_crypto`, but the `PLUG_CRYPTO_2_0=false` row changes the requirement in `mix.exs`, so the agent installs both Erlang and Elixir pairs from the matrix, runs `mix deps.get` and `mix test` under each setting against a lock bumped the way Dependabot would bump it, and confirms `mix deps.get --check-locked` still passes on the lint row. It also confirms the `docs` group resolves, since `ex_doc` is fetched only with `MIX_ENV=docs`. Any surprise, such as a lock the two rows cannot share, goes into the pull request as a note rather than a silent `ignore` rule.

Last it adds `open-pull-requests-limit` so the first week does not open nine pull requests at once, labels the bot's pull requests `dependencies`, and writes a short note in `CONTRIBUTING` terms in the pull request description: Dependabot's pull requests run the same CI as everyone's, with a read-only token, which this workflow needs nothing beyond.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add Dependabot to this Elixir library. Read mix.exs, mix.lock and .github/workflows/ci.yml first, and note how wide the dependency requirements are and what the CI matrix varies. Write .github/dependabot.yml with a mix entry at the root on a weekly schedule using lockfile-only versioning so mix.exs is never rewritten, a group for ex_doc and its rendering packages, a pull request limit, a dependencies label, and a github-actions entry for the workflow's actions. Install the oldest and newest Erlang and Elixir pairs from the matrix, bump mix.lock the way Dependabot would, and run mix deps.get, mix test and the lint row's checks under both settings of the matrix's environment variable; report anything the two rows cannot share. Open a pull request with the config and what each check returned.",
  "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

A pull request that adds one file, `.github/dependabot.yml`, and a description that explains each choice against the library's own files: why `lockfile-only`, which packages form the `docs` group, and what `mix deps.get`, `mix test`, `--check-locked` and `--check-unused` returned under both matrix rows with a bumped lock. If the two rows resolved different versions of a package, the description says which and what the first Dependabot pull request will show.

A reviewer checks that the strategy keeps `mix.exs` untouched, that the group holds only documentation packages, and that the weekly day and limit suit how often they want to review bot pull requests. Once merged, Dependabot opens its first pull requests on the next scheduled day, each checked by the same CI matrix.

## Run it on every terminal hand-off

A maintainer who has just handled a security release by hand starts this from the terminal with this body and the repository in `resources`, and goes back to the changelog. The run reads the real requirements and the real matrix, so the config respects the library's published ranges instead of tightening them.

Send a `request_id`, a UUID, with the body so a retried start returns the run it already began. When the turn ends, `GET /o/{org}/sessions/{id}` names the pull request, and a follow-up to the same session can ask for an `ignore` rule on a package the team pins on purpose, or for the schedule to move to a different day.

## Why run it on Rush?

The config is twenty lines; the work is knowing whether those lines will open pull requests the matrix can pass, and that means two Erlang and Elixir pairs, both settings of the matrix's variable and a bumped lock. The agent runs all of that in its own sandbox and keeps every command and its output in the run's record, so the pull request says what the first bot pull request will look like rather than guessing.

The same run fits any Hex package or Phoenix application: an application with a tight lock where `versioning-strategy` should move `mix.exs` too, an umbrella with several `mix.exs` files that each need a directory entry, a library with a Rust NIF that needs the Cargo ecosystem beside `mix`. Each gets a config derived from its own files and a check against its own CI.

## Frequently asked questions

### Why lockfile-only?

A library publishes its `mix.exs` requirements to Hex, and downstream projects resolve against them. If Dependabot tightened `~> 1.0 or ~> 2.0` every time a package released, users would be forced onto new versions for no reason. Moving only `mix.lock` keeps CI testing against current versions while the published ranges stay wide.

### What about the environment variable in the CI matrix?

The `PLUG_CRYPTO_2_0=false` row changes the `plug_crypto` requirement, so a lock bumped to a 2.x release and a row that requires 1.x have to be checked together. The run installs both pairs and runs the checks under both settings, and the pull request reports whether a single lock satisfies them.

### Will Dependabot's pull requests run the test matrix?

Yes. `ci.yml` runs on every `pull_request` event and needs no secrets, so a Dependabot pull request gets the same two rows. Its `GITHUB_TOKEN` is read-only, which this workflow never needs to be otherwise.

### Can I group everything into one weekly pull request?

A group with a wildcard pattern does that. The config keeps runtime dependencies separate so a `telemetry` or `mime` bump is reviewed on its own, and groups only the documentation chain. Changing that is one edit to the `groups` section.

## More Elixir jobs

- [Add Dialyzer to an Elixir App from a Linear Issue](https://getrush.ai/run/add-dialyzer/elixir/)
- [Add mix audit Dependency Scanning to an Elixir Project](https://getrush.ai/run/add-mix-audit/elixir/)
- [Add Property-Based Tests to an Elixir Library](https://getrush.ai/run/add-property-tests/elixir/)

## The same job on other stacks

- [Set Up Dependabot for a Flutter App's Pub, Gradle and Actions Dependencies](https://getrush.ai/run/add-dependabot/flutter/)
- [Add Dependabot to a Go CLI Repository](https://getrush.ai/run/add-dependabot/go-cli/)
- [Add Dependabot to a Gradle Project](https://getrush.ai/run/add-dependabot/gradle/)

## 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/)
