All jobs

Add Credo to an Elixir App from a Linear Issue

Yes. An agent adds Credo to your Elixir project, writes a .credo.exs that passes on today's code, adds mix credo --strict to the existing CI job 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 reads the project's shape and its CI before adding a tool. In an app like hexpm/hexpm, mix.exs asks for Elixir ~> 1.20, lists a long deps() with Phoenix, Ecto, Oban, Broadway and the lumis_wasm_* highlighter crates, and defines aliases for setup, ecto.setup, assets.deploy and a test alias that creates and migrates the database first. There is no credo, dialyxir or sobelow in the list. .formatter.exs already enforces style with Phoenix.LiveView.HTMLFormatter over lib, test, config and priv/*/seeds.exs, and .github/workflows/main.yml has a format job on ubuntu-24.04 with OTP 29.1 and Elixir 1.20.4 that restores deps and _build from a cache keyed on mix.lock, runs mix compile --warnings-as-errors, mix format --check-formatted and mix ecto.setup against a Postgres 18 service; test-hexpm runs mix test, and test-hex runs the Hex client's suite against three of its branches. .github/dependabot.yml groups weekly mix and github-actions updates. lib/ holds 485 .ex files across hexpm, hexpm_web and mix/tasks, and test/ 281 test files.

The agent adds {:credo, "~> 1.7", only: [:dev, :test], runtime: false} to deps(), runs mix deps.get so mix.lock records it, and generates .credo.exs with mix credo gen.config. Then it runs mix credo --strict over the real code and reads the result. A project of this size produces findings in several checks, and the agent sorts them the same way a maintainer would: fix the ones that are mechanical and local, such as an alias order or a missing @moduledoc false on a private module, in a handful of files; leave the design-level ones such as nesting depth or module length as configured exceptions, by setting the check to false or raising its threshold in .credo.exs with a one-line comment above each; and never change behaviour to satisfy a lint. The goal of the first pull request is a configuration that is honest about the codebase and passes, with a list of the checks turned down and why, not a sweep through 485 files.

In CI it adds one step, mix credo --strict, to the existing format job after mix format --check-formatted. That job already compiles the project in the dev environment with the dependency cache, which is what Credo needs, and it needs no database, so no new job and no new service. The cache key hashes mix.lock, which changes with the new dependency, so the first run after merge rebuilds the cache once and main writes it back. The agent also checks that mix compile --warnings-as-errors still passes, since a @moduledoc or alias change can surface a warning.

Before opening the pull request it runs mix format --check-formatted, mix compile --warnings-as-errors, mix credo --strict and mix test in the sandbox against a Postgres it starts the way the workflow's service does, and pastes the Credo summary line and the test result into the description, with the table of checks it configured down.

Start it with one API call

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

{
  "agent": "claude",
  "input": "Add Credo to this Elixir project and open a pull request. Read mix.exs, mix.lock, .formatter.exs, .github/workflows/main.yml, .github/dependabot.yml and the layout of lib/ and test/ first. Add credo as a dev and test dependency with runtime: false, run mix deps.get so mix.lock is updated, and generate .credo.exs with mix credo gen.config. Run mix credo --strict and triage the findings: fix mechanical, local ones such as alias ordering or a missing @moduledoc false in the files they occur in; for design-level checks such as nesting depth, module or function length and cyclomatic complexity, configure the check down or off in .credo.exs with a one-line comment above each explaining why; never change runtime behaviour to satisfy a check. Add a single step, mix credo --strict, to the existing format job in main.yml after the format check, since that job already compiles in dev with the dependency cache and Credo needs no database. Start a Postgres like the workflow's service, then run mix format --check-formatted, mix compile --warnings-as-errors, mix credo --strict and mix test, and put the Credo summary, the list of configured-down checks with reasons, and the test result in the pull request description. Change nothing else.",
  "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 that adds credo to mix.exs and mix.lock, a new .credo.exs with commented adjustments, one new step in the format job of .github/workflows/main.yml, and small edits in the files where Credo found something mechanical to fix. The description quotes the final mix credo --strict summary, lists each check the agent configured down with the reason written beside it in the config, and shows mix test passing after the changes.

The format, test-hexpm and test-hex jobs run on the pull request, so the new Credo step reports as part of the existing format check rather than as a new one, and the dependency cache is rebuilt once because mix.lock changed. Dependabot's weekly mix group picks up future Credo releases with everything else.

A reviewer reads .credo.exs and decides, check by check, whether to keep the configured-down ones or to open follow-up issues for them, and glances at the handful of mechanical edits. If they would rather Credo not fail CI at first, they drop --strict or add || true in one place.

Run it on every Linear issue labelled agent

In the console, an automation with a linear trigger on linear.issue.labeled and the label agent starts one run per labelled issue, with the issue as its context, in the Project that has the repository. Changes made by an app integration never fire it, so the agent's own comments on the issue do not start new runs. An issue titled Add Credo and make it pass with this prompt in its description is the whole input.

From your own server, the same run is one POST /o/{org}/sessions per issue: the repository in resources, plus the issue's https://linear.app/<workspace>/issue/<ID> URL there too, read through your Linear connection into the prompt. A webhook on the API key posts run.completed or run.failed when the turn finishes, with the session_url to read the pull request link.

The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.

Why run it on Rush?

Adding a linter to a large codebase is a reading job, not a typing job. The first mix credo --strict on hundreds of modules says a lot, and someone has to decide which findings are worth a code change, which are a configuration decision, and which are noise, and then write the reasons down where the next person will find them. The agent does that in its own sandbox with the dependencies compiled, the real findings in front of it and mix test available after every edit, and the whole sequence stays in the run's record.

It also fits the tool into the CI the project already has instead of bolting on another job. One step in the format job reuses the compiled dev build and the mix.lock cache, needs no database, and means the maintainers get Credo for the cost of the time the step itself takes, with no new secrets, services or required checks to manage.

Frequently asked questions

Will it rewrite hundreds of files to make Credo happy?

No. The prompt limits code edits to mechanical, local fixes such as alias order or a missing @moduledoc false. Design-level findings like nesting depth or function length are configured in .credo.exs with a comment, so the first pull request is a passing baseline the team can tighten later rather than a sweep through 485 files.

Why not a separate CI job for Credo?

The existing format job already compiles the project in dev with the dependency cache, which is exactly what mix credo needs, and Credo does not touch the database. A new job would recompile everything and add a second Postgres service for nothing. One step after mix format --check-formatted is enough.

Does Credo replace the formatter?

No. mix format --check-formatted with the LiveView HTML formatter plugin keeps running as it does today. Credo checks things the formatter does not, such as consistency, readability and refactoring opportunities, and the two are complementary.

Does it also add Dialyzer or Sobelow?

Not in this pull request. Both are reasonable next steps and the description names them, but each has its own first-run cost, Dialyzer in particular needs a PLT cache in CI, so they belong in their own changes with their own reasoning.

More Elixir jobs

More jobs like this: Turn a Linear label into a PR

Keep reading