All jobs

Add Dependabot to a Go CLI Repository

Yes. An agent adds a Dependabot configuration for Go modules, GitHub Actions and the Dockerfile base image, fixes the Go version CI pins, and opens a PR.

Run this on RushOpens 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 everything that names a dependency. In a Go CLI like rakyll/hey, go.mod declares go 1.24.0 with one direct requirement, golang.org/x/net, and golang.org/x/text as indirect, so go.sum is four lines long. .github/workflows/go.yml uses actions/checkout@v4 and actions/setup-go@v4 with go-version: '1.21', three minor versions behind the module file, and runs go build -v ./... and go test -v ./.... The Dockerfile starts FROM golang:1.15 as build and installs the tool with go get before a scratch final stage, the Makefile cross-compiles three binaries and uploads them with gsutil, and .travis.yml still asks for Go 1.13 on a service the repository no longer uses. There is no .github/dependabot.yml.

It writes one configuration that covers all three ecosystems it found. .github/dependabot.yml gets a gomod entry on the repository root with a weekly schedule, a github-actions entry for the two actions in go.yml, and a docker entry for the golang base image in the Dockerfile, each with an open-pull-requests-limit so a quiet repository is not flooded. The gomod entry groups the golang.org/x/* modules into one pull request, because they move together and x/text only exists here as a dependency of x/net. Every entry carries a label and a commit message prefix so the maintainer can tell the three streams apart in the pull request list.

Two related fixes go in the same pull request because Dependabot's pull requests would otherwise run on the wrong toolchain. go.yml is changed to go-version-file: go.mod, so CI tests each bump on the version the module declares instead of downloading a newer toolchain at run time, and actions/setup-go@v4 and actions/checkout@v4 are left for Dependabot's first actions pull request to bump rather than bumped by hand. .travis.yml is deleted, with the reason in the description. The Dockerfile's golang:1.15 line is not edited by hand either: the docker entry will propose the current tag, and the description notes that the go get line inside it predates module mode and will need the maintainer's attention when that pull request arrives.

Before opening anything it checks what it can. It runs go build ./... and go test ./... in its sandbox on the version go.mod names to record a passing baseline, runs actionlint on the changed workflow, and validates the new YAML against the keys Dependabot's documentation defines, since GitHub only reports a malformed configuration after it is merged. Those outputs go into the pull request.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add Dependabot to this Go CLI repository. Read go.mod, go.sum, the Dockerfile, the Makefile, .travis.yml and every file under .github/ first, and list every ecosystem that has dependencies to update. Write .github/dependabot.yml with a weekly gomod entry that groups the golang.org/x modules, a github-actions entry, and a docker entry for the Dockerfile base image, each with a pull request limit, a label and a commit message prefix. Change the workflow to read the Go version from go.mod so Dependabot's pull requests are tested on the declared version, remove the unused Travis configuration, and do not bump any dependency or action by hand. In your sandbox run go build ./... and go test ./... on the version go.mod declares, run actionlint on the workflow, and open a pull request that lists the files changed, each Dependabot entry and why it exists, and the command output.",
  "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 adding .github/dependabot.yml, editing .github/workflows/go.yml and deleting .travis.yml. The description lists the three entries and what each watches, explains the x/ group, and says what will happen the first Monday after merge: one pull request for the module group, one or two for the actions, and one proposing a current golang image for the Dockerfile.

The run's record holds the go build and go test output on the module's own Go version and the actionlint result, so a reviewer can see the workflow change is valid and the baseline passes before any bump lands.

Before merging, a reviewer confirms Dependabot is allowed on the repository in its settings, decides whether weekly is the right cadence for a tool that ships rarely, and plans for the Dockerfile pull request, which will surface the pre-module go get line that needs rewriting by a person.

Run it on every Monday morning

A team that wants the configuration to stay complete runs this prompt weekly from an automation with a schedule trigger set to Monday morning in its timezone, in the Project that holds the repository. Each run reads the repository as it is that week: when .github/dependabot.yml already covers every ecosystem present, the run ends with no pull request and says so; when a new Dockerfile, a second module or a new workflow directory has appeared since, it opens a pull request that adds the missing entry.

Each run has its own sandbox and its own pull request, and an automation run has its own max_runs_per_hour cap. The run's result says which entries it found and which it added, so a reader of the Project's run list knows without opening the pull request.

The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.

Why run it on Rush?

A Dependabot file is short, and the mistakes are in what it misses: a Dockerfile nobody remembers, actions pinned three majors back, a CI job that tests every bump on the wrong Go version. The agent reads the whole repository for dependency sources before writing the file, and fixes the toolchain mismatch in the same pull request, so the first Dependabot pull request after merge is tested the way the maintainer expects.

The sandbox runs the build and tests on the exact Go version the module declares and keeps the record. The same request runs against every Go repository an organisation owns, each in its own sandbox with its own go.mod and workflows read first, so every repository gets a configuration that matches what it contains rather than a copied template.

Frequently asked questions

Why group the golang.org/x modules?

They are released together and x/text is only present because x/net needs it, so separate pull requests would land in lockstep anyway. One grouped pull request bumps both and runs CI once.

Why not bump the actions and the Go image in this pull request?

So the first Dependabot pull requests prove the configuration works end to end, and so each bump gets its own CI run. The Docker base image jump from golang:1.15 also exposes an old go get line in the Dockerfile that a person should rewrite, which is a bad thing to bury in a configuration change.

Why change the workflow's Go version?

go.mod declares Go 1.24.0 and the workflow pins 1.21. Go fetches the newer toolchain at run time, so CI passes, but every Dependabot pull request would be tested on a toolchain download rather than the declared version. Reading the version from go.mod removes that gap and makes future Go bumps a one-file change.

What if the repository is a template that many tools copy?

The configuration file lists only what this repository contains. A repository with no Dockerfile would get no docker entry, and the weekly automation in the section above adds one the week a Dockerfile appears.

More Go CLI jobs

The same job on other stacks

Keep reading