What the agent does
The github.com/golang/mock repository is archived on GitHub and the project continues at go.uber.org/mock, with the same gomock package name and the same mockgen tool. The agent begins by finding both halves of the dependency: the tests that import gomock, and the generated files that import it too. In a tool like dineshba/tf-summarize, go.mod requires github.com/golang/mock v1.6.0, one test, writer/separate_tree_test.go, builds a controller with gomock.NewController(t), and one generated file, testdata/mocks/mock_io_writer.go, mocks io.Writer. Its header reads Source: io (interfaces: Writer).
That header is all that remains of how the file was made. The repository has no go:generate directive and the Makefile has no mockgen target, so the agent reconstructs the command from it: the package io, the interface Writer, the output path and the package name mocks. It first proves the cheap route works, replacing the import path in both files and running go get go.uber.org/mock@latest, and then runs the tests.
It does not stop at the passing import swap, because a hand-edited generated file drifts from what the tool now writes. It runs go run go.uber.org/mock/mockgen@latest -destination testdata/mocks/mock_io_writer.go -package mocks io Writer and diffs the result against the edited file. The new generator adds a comment block recording the command, an isgomock struct{} field on the mock type, the real parameter name p in place of arg0, and any in place of interface{}. The method set is unchanged, so mockWriter.EXPECT().Write(gomock.Any()).Return(0, nil).Times(1) in the test compiles as written.
The agent then reads what else moved. go get raised github.com/stretchr/testify from v1.7.0 to v1.9.0 as a side effect, which belongs in the description and not hidden in go.sum. After go mod tidy, golang/mock no longer appears in either module file. It runs go test ./... -count=1, the command behind the Makefile's test target, and the lint target, and adds a //go:generate line beside the mock so the next person does not have to rebuild the command from a header.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Move this Go module from github.com/golang/mock to go.uber.org/mock. Find every file that imports github.com/golang/mock/gomock, and separate hand-written tests from files generated by mockgen (they start with a Code generated by MockGen comment). Find how each mock was generated: go:generate directives, Makefile targets, scripts, or the Source line in the file header. Run the tests first and record the result. Replace the import path, run go get go.uber.org/mock@latest, then regenerate every mock with go run go.uber.org/mock/mockgen@latest using the same source, destination and package as before; do not hand-edit generated files. Show the diff of each regenerated file and say whether any method signature changed. Add a go:generate directive for any mock that had none. Run go mod tidy and list every other module version that changed as a side effect. Run go vet, the test command from the Makefile or CI workflow, and the linter if the repository has one. Confirm golang/mock is gone from go.mod and go.sum. Open a pull request with the commands, their output and the side-effect version changes.",
"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
A pull request that edits the one test file, replaces the generated mock, and updates go.mod and go.sum. The description lists the mockgen command recovered from the header, the diff of the regenerated file reduced to its four kinds of change, the testify bump that came along, and the test output before and after.
A reviewer checks two things. The first is that the regenerated mock still has the methods the tests call, which the diff shows directly. The second is the side effect: a testing library moved two minor versions because the new module requires it, and the description points at the go.mod line so nobody finds it later by surprise. The defer ctrl.Finish() line in the test is left in place; it is harmless, and removing it is a style choice the agent mentions without making.
Run it on every Linear issue labelled dependencies
Connect Linear in the console under Settings → Connections, then add an automation on the Project with a linear trigger on linear.issue.labeled, the label of your choice in labels, and the prompt above. When someone in your Rush org labels an issue, a run starts in the Project's repository and the issue is appended after the prompt as event text. The saved prompt is the only instruction; the issue arrives as third-party data.
The automation's max_runs_per_hour cap applies when a batch of issues is labelled at once: events past it wait as queued runs and start when the hour has room.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
Regenerating mocks means running a code generator that compiles against your packages, then compiling and running the tests against its output. That needs a full toolchain and network access to fetch the tool, and it should not depend on whichever mockgen version happens to be on a developer's laptop. The sandbox starts clean, so the version in the pull request is the one the command names.
The run also keeps what a quick local change loses: the exact generator command, the diff it produced and the list of versions go get moved. Those are in the transcript and the description, which turns a reviewer's question about a changed generated file into something they can read.
Frequently asked questions
Can I just change the import path and keep my generated mocks?
It compiles and the tests pass in this repository, because the runtime package kept its API. The generated file then no longer matches what the current mockgen writes, so the next regeneration produces an unrelated-looking diff. Regenerating in the same pull request keeps the two changes together.
What does the new mockgen change in a generated file?
For this io.Writer mock: a comment recording the generating command, an isgomock struct{} field, the interface's own parameter names instead of arg0, and any instead of interface{}. No method was added or removed.
Do I still need ctrl.Finish()?
Not when the controller is created with gomock.NewController(t) and a *testing.T, since the controller registers its own cleanup. Existing defer ctrl.Finish() lines keep working, so the agent leaves them unless you ask for the cleanup.
Will other dependencies change?
They can. Here go get go.uber.org/mock@latest selects v0.6.0 and raises testify from v1.7.0 to v1.9.0 to satisfy it. The agent reports every such change by reading the go.mod diff.