# Add Dependabot to a Cobra CLI

Yes. An agent reads your Cobra CLI's go.mod, workflows, Makefile and Dockerfile, writes a grouped .github/dependabot.yml, runs lint and tests, and opens a PR.

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

## What the agent does

The agent reads the module and the release machinery before it writes anything, because a Go CLI's dependencies are not all in `go.mod`. In a Cobra CLI laid out like stern/stern, `go.mod` declares `go 1.27.2` and requires `github.com/spf13/cobra`, `github.com/spf13/pflag`, `github.com/spf13/cast`, four `k8s.io` modules (`api`, `apimachinery`, `cli-runtime`, `client-go`) at the same version, `k8s.io/klog/v2`, `golang.org/x/sync`, `golang.org/x/time`, `github.com/fatih/color` and `github.com/AlecAivazis/survey/v2`. The `k8s.io` modules move in lockstep, so a Dependabot configuration that updates them one at a time produces four pull requests that each fail to build until the others merge.

The tooling is the other half. `Makefile` installs `goreleaser`, `golangci-lint`, `validate-krew-manifest` and `yq` with `go install` into `hack/tools/bin` at versions held in `GORELEASER_VERSION`, `GOLANGCI_LINT_VERSION`, `VALIDATE_KREW_MAIFEST_VERSION` and `YQ_VERSION`; Dependabot reads manifests, not Makefile variables, so those four pins stay manual and the agent says so in the pull request. `.github/workflows/ci.yaml` checks that `go mod tidy` leaves `go.sum` unchanged, runs `make verify-readme`, `make test` (which runs `golangci-lint run` before `go test -v ./...`), `make build`, `make dist` and `make validate-krew-manifest`; `release.yaml` logs in to `ghcr.io` with `docker/login-action` and runs `make release` plus `rajatjindal/krew-release-bot`. Both use `actions/checkout` and `actions/setup-go` by major tag. `Dockerfile` is four lines on `gcr.io/distroless/static-debian13` with no tag, and `.goreleaser.yaml` publishes the image, a Krew manifest and a WinGet manifest. There is no `.github/dependabot.yml` and no Renovate file.

With that read, the agent writes `.github/dependabot.yml`. A `gomod` entry on `/` runs weekly with a `kubernetes` group for `k8s.io/*`, a `golang-x` group for `golang.org/x/*` and a `spf13` group for `github.com/spf13/*`, so the modules that are released together arrive together. A `github-actions` entry on `/` covers both workflows. For the Dockerfile the agent explains rather than configures: Dependabot updates the tag in a `FROM` line, and this `FROM` has none, so a `docker` entry would have nothing to bump until the image is pinned to a tag or digest, which it offers as a follow-up. It validates the file against the `dependabot-2.0` JSON schema from SchemaStore, since a misspelled key is ignored rather than rejected.

Then it proves the baseline: `go mod tidy` followed by `git diff --exit-code go.sum`, as CI does, then `make test`, which installs `golangci-lint` at the Makefile's pin and runs the `errcheck`, `govet`, `ineffassign`, `staticcheck` and `unused` linters from `.golangci.yml` before the tests, then `make build`. The output goes into the pull request so the first Dependabot pull request is judged against a known-green tree.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add Dependabot to this Cobra CLI. Read go.mod, go.sum, Makefile, .golangci.yml, .goreleaser.yaml, Dockerfile and every workflow under .github/workflows first. Write .github/dependabot.yml with a weekly gomod entry on / that groups the k8s.io modules, the golang.org/x modules and the github.com/spf13 modules, and a github-actions entry for the workflows. Decide whether a docker entry can update the Dockerfile base image as written, and if not, say why in the pull request instead of adding one. List the tool versions pinned in the Makefile that Dependabot will not track. Validate the file against the dependabot-2.0 JSON schema. Run go mod tidy with a go.sum diff check, make test and make build, and open a pull request with the file, the schema check and the output. Do not upgrade any module yourself.",
  "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

The pull request adds one file, `.github/dependabot.yml`. Its description lists the three groups and the modules each matches, explains why the Dockerfile's untagged `FROM` line gets no `docker` entry, names the four tool pins in `Makefile` that stay manual, and pastes the schema check, the `go.sum` diff check, the `golangci-lint` and `go test` output from `make test`, and the `make build` result.

The `CI` workflow runs on the pull request unchanged: the tidy check, README check, lint, tests, build, snapshot dist and Krew manifest validation all run on a tree where only a file under `.github` changed. After the merge, Dependabot's first weekly run opens one pull request per group plus one per action that has a newer major tag.

Before merging, a reviewer decides whether weekly is the right cadence for a project that cuts releases from tags, whether the `k8s.io` group should also carry `k8s.io/klog/v2` and `k8s.io/utils`, and whether to pin the distroless image to a digest now so the `docker` entry can follow.

## Run it on every Go repository without an update bot

An organisation with many Go CLIs starts one run per repository from its own server: one `POST /o/{org}/sessions` each with the repository in `resources` and a `request_id` that is a UUID v5 of the repository's full name, so a retried call returns the run already started. Each run reads its own `go.mod`, so a CLI with a `replace` directive gets that module left out of the groups and named in the description, a multi-module repository gets one `gomod` entry per directory with a `go.mod`, and a repository that already has `dependabot.yml` gets a comment on what it lacks and no pull request.

A team that wants the file to stay complete runs this prompt monthly from an automation with a `schedule` trigger, in the Project that holds the repository. When a new workflow or a second `go.mod` has appeared since the last run, that run opens a pull request adding the missing entry; otherwise it ends with no pull request and says so. An automation has its own `max_runs_per_hour` cap, separate from any API key.

## Why run it on Rush?

The hard part of Dependabot for a Go CLI is not the YAML, it is knowing which modules must move together, which references a bot can and cannot bump, and which versions live outside any manifest. The agent reads `go.mod`, the workflows, the Makefile and the Dockerfile in its own sandbox and writes the groups and the caveats from what it found, rather than from a template that treats every module as independent.

The schema check, the tidy check, `golangci-lint`, `go test` and `make build` all run in the sandbox and stay with the run, and the pull request quotes them. A platform team can run this across every Go repository it owns at once, and each pull request arrives with its own proof.

## Frequently asked questions

### Why group the k8s.io modules?

Because `k8s.io/api`, `k8s.io/apimachinery`, `k8s.io/cli-runtime` and `k8s.io/client-go` are released together at the same version and depend on each other at that version. Updated one at a time, the first pull request fails to build until the others land. A `kubernetes` group with the pattern `k8s.io/*` makes them one pull request.

### Can Dependabot update the goreleaser and golangci-lint versions?

No. They are Makefile variables installed with `go install`, not entries in a manifest Dependabot reads. The pull request lists them, `GORELEASER_VERSION`, `GOLANGCI_LINT_VERSION`, `VALIDATE_KREW_MAIFEST_VERSION` and `YQ_VERSION`, so the team knows they stay manual, and the agent can move them into a `tools` module in a later run if asked.

### Why is there no docker entry?

Because `Dockerfile` starts `FROM gcr.io/distroless/static-debian13` with no tag, and Dependabot's `docker` ecosystem updates the tag on a `FROM` line. With nothing to compare, an entry would be inert. Once the image is pinned to a tag or a digest, adding the entry is a three-line change.

### Does the run touch the release workflow?

No. The `github-actions` entry lets Dependabot propose updates to `docker/login-action`, `rajatjindal/krew-release-bot` and the checkout and setup-go actions in both workflows, but the agent changes neither workflow and never pushes a tag, so nothing is released.

## More Cobra jobs

- [Add a --dry-run Flag to a Cobra CLI](https://getrush.ai/run/add-dry-run-flag/cobra/)
- [Add GoReleaser to a Cobra CLI](https://getrush.ai/run/add-goreleaser/cobra/)
- [Add govulncheck to a Cobra CLI's CI](https://getrush.ai/run/add-govulncheck-to-ci/cobra/)

## The same job on other stacks

- [Set Up Dependabot for a Dagster Workspace with uv](https://getrush.ai/run/add-dependabot/dagster/)
- [Add Dependabot to a Docker Compose Repository](https://getrush.ai/run/add-dependabot/docker-compose/)
- [Add Dependabot to an Echo App](https://getrush.ai/run/add-dependabot/echo/)

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