All jobs

Add an ESLint Check to GitHub Actions for a Next.js App

Yes. An agent adds a workflow that runs your existing ESLint config on every pull request, makes the current code pass it first and opens a pull request.

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 sandbox and reads how linting works today before writing a workflow. In shadcn-ui/taxonomy there is no .github/workflows directory at all. The lint script is next lint, with ESLint 8 and eslint-config-next 13.0.0 while the app itself is on next 13.3.2-canary.13. .eslintrc.json extends next/core-web-vitals, prettier and plugin:tailwindcss/recommended, sets tailwindcss/classnames-order to error with cn as a callee, turns off react/jsx-key and @next/next/no-html-link-for-pages, and parses .ts and .tsx files with @typescript-eslint/parser. The only check that runs anywhere is the Husky pre-commit hook, and it runs npx pretty-quick --staged, which is Prettier, not ESLint.

Next it pins the toolchain the workflow must reproduce. pnpm-lock.yaml is lockfileVersion: '6.0', which pnpm 8 writes, and package.json has no packageManager field, so pnpm/action-setup needs version: 8 spelled out. .nvmrc says v16.18.0, so actions/setup-node reads node-version-file: .nvmrc instead of a hard-coded version. postinstall runs prisma generate, which needs the schema in prisma/ but no database, so pnpm install --frozen-lockfile works in CI with no secrets.

Then it runs the check the way CI will, before CI exists. It installs with the frozen lockfile and runs pnpm lint on the untouched branch. If that reports errors, a workflow added on top would fail on its first pull request, so the agent applies next lint --fix for what ESLint can fix by itself, mostly classnames-order, in a commit of its own, and lists whatever is left with file and line instead of disabling rules. It also notes what next lint does not cover: by default it lints app, pages, components, lib and src, so hooks/, config/, types/, middleware.ts and env.mjs are not linted today. Adding --dir flags would widen the check, so the agent reports it and leaves the scope as it is unless input asks.

The workflow it writes, .github/workflows/lint.yml, runs on pull_request and on pushes to main, checks out, sets up pnpm 8 and Node from .nvmrc with the pnpm store cached, installs with --frozen-lockfile and runs pnpm lint. It cancels an older run of the same branch with a concurrency group and grants contents: read only. Before pushing, the agent runs the same steps in the sandbox from a clean node_modules to show they pass.

Start it with one API call

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

{
  "agent": "claude",
  "input": "Add a GitHub Actions workflow that runs ESLint on every pull request and on pushes to main. Read package.json, .eslintrc.json, prettier.config.js, .nvmrc, pnpm-lock.yaml and .husky/ first. Use the pnpm version the lockfile format implies and the Node version in .nvmrc, cache the pnpm store, install with --frozen-lockfile and run pnpm lint. Give the workflow contents: read permissions and a concurrency group per branch. Before adding it, run pnpm lint on the untouched branch; if it fails, fix what next lint --fix can fix in a separate commit and list every remaining error with file and line in the pull request instead of disabling rules. Report which directories next lint does not cover but do not widen its scope. Do not change .eslintrc.json or upgrade any package. Run the workflow's steps in the sandbox from a clean install to show they pass. Open a pull request.",
  "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 with one new file, .github/workflows/lint.yml, and, only if the baseline had fixable errors, a separate commit with the next lint --fix changes. Keeping the fixes in their own commit lets a reviewer read the workflow and the code changes apart. The description shows the baseline pnpm lint output, what was fixed automatically, anything left with file and line, and the list of directories next lint does not reach.

The pull request is also the workflow's first run: its checks show the new lint job installing with pnpm 8 on Node 16.18.0 and running next lint on GitHub's runner. The session transcript keeps the same steps from the sandbox, from the frozen install to the final passing lint.

Before merging, a reviewer checks that the workflow does not need any secret, that the autofix commit only reorders Tailwind classes or makes other changes ESLint marks as safe, and decides whether the uncovered directories should be linted in a follow-up.

Run it on every repository with no CI

Where one repository has no CI, others in the same organisation often have none either, such as starters that grew into products. A script on your own server can list them and send one POST /o/{org}/sessions per repository with that repository in resources, each in its own sandbox with its own install. The prompt reads the repository's own lint script and lockfile, so the same input works for a repository on npm or Yarn.

Set a webhook_url on the key and Rush posts run.completed or run.failed as each run finishes, with a session_url that returns the pull request link. A run that found more errors than it could fix still ends with a pull request listing them, so nothing is lost by starting many at once.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

The step people skip when adding lint to CI is running it first on the code as it stands, from a clean install with the lockfile frozen, so the first pull request after the workflow lands is not the one that turns red. In a Rush sandbox the agent does exactly that install, with prisma generate running in postinstall on a machine that has no database and no .env, which is also what the GitHub runner will have.

The transcript is the evidence that the workflow is right before it ever runs on GitHub: the pnpm and Node versions it picked and why, the baseline errors, the autofix and the final clean run, each with its output.

Frequently asked questions

Will it change our ESLint rules to make CI pass?

No. The prompt forbids editing .eslintrc.json. Errors ESLint can fix are fixed in a separate commit; the rest are listed with file and line for you to decide on.

Why pnpm 8 and not the newest pnpm?

The lockfile says lockfileVersion: '6.0', the format pnpm 8 reads and writes, and there is no packageManager field to say otherwise. A newer pnpm could rewrite the lockfile or refuse --frozen-lockfile, so the workflow matches what the repository already uses.

Should Prettier run in the same workflow?

It can. The Husky hook runs Prettier only on staged files, so CI is the place to check the whole tree. Ask in a follow-up and the agent adds prettier --check . as a second step, after checking that it passes on the current code.

next lint is deprecated in newer Next.js. Does that matter here?

Not for this repository, which is on Next 13 where next lint is the documented way in. On a newer Next.js the agent runs the ESLint CLI with your config instead, and says so in the pull request.

More ESLint jobs

The same job on other stacks

Keep reading