What the agent does
The agent reads the build before it limits anything. In an app laid out like solidjs/solid-realworld, package.json depends on solid-js ^1.3.3 and marked ^0.8.0, builds with rollup 2.52.3, @rollup/plugin-babel 5.2.0 and babel-preset-solid, minifies with rollup-plugin-terser only when production is set, and has three scripts: start (serve public and rollup -w -c), build (rollup -c --environment production) and a placeholder test that runs the shell's test builtin. rollup.config.js takes src/index.js as the single input, writes ES modules into public/, clears public/* except index.html on each build, and sets preserveEntrySignatures: false. src/App.js imports Home, Article, Profile and Editor directly and lazy-loads Settings and Auth, while each page's index.js, such as src/pages/Home/index.js, lazy-loads its own component, so the production build is public/index.js plus one chunk per lazy import. .gitignore excludes public/* except index.html, package-lock.json is at lockfile version 2, and .github/workflows/gh-pages.yml runs on pushes to main and on pull requests with setup-node at 14, npm install, npm run build, and a Pages deploy that only runs on main. Nothing measures what the build produced.
The tool is size-limit with the @size-limit/file plugin, which measures files that already exist rather than bundling them again, the right choice for an app whose bundler is Rollup. The agent installs both as dev dependencies, which updates package-lock.json, and adds a size-limit section to package.json with two entries: public/index.js, the entry chunk every visitor downloads, and public/*.js, the entry plus every lazy chunk. Each entry gets a limit the agent sets from what it measures in its own sandbox after npm run build, with a small margin, and the pull request lists the measured sizes and the limits beside them so the reviewer can see the headroom. The plugin reports Brotli sizes by default; gzip: true is the one-word switch if the hosting compresses with gzip, and the pull request says which the GitHub Pages deploy serves.
A size script runs size-limit, and the placeholder test script becomes npm run build && size-limit, so npm test does what the name says. In gh-pages.yml the agent adds npm run size after npm run build in the existing job, so a pull request that pushes a chunk past its limit fails the check before anything deploys. Current size-limit releases need a newer Node than the 14 the workflow pins, so the agent moves setup-node to 20, runs the Rollup build on it in the sandbox to confirm nothing in the 2.x toolchain objects, and notes the version change in the pull request as its own line. It does not switch npm install to npm ci, which would be a separate change, but mentions it.
The check is the command. The agent runs npm run build and npm run size and keeps the table size-limit prints; then, in the sandbox only, it lowers one limit below the measured size, runs again, and keeps the non-zero exit and the message so the pull request shows what a failure looks like. It also adds a short README section: what the two entries mean, how to raise a limit on purpose when a feature justifies it, and that size-limit --why needs a bundler plugin the app does not use, so the way to find what grew is to diff the chunk list.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add a bundle size check to this SolidJS and Rollup app. Read package.json, package-lock.json, rollup.config.js, src/index.js, src/App.js, src/pages/Home/index.js, public/index.html, .gitignore, readme.md and .github/workflows/gh-pages.yml first. Run npm install and npm run build and record the size of public/index.js and of every chunk in public/. Install size-limit and @size-limit/file as dev dependencies and add a size-limit section to package.json with two entries, public/index.js and public/*.js, each with a limit slightly above the size you measured; list the measured sizes and limits in the pull request. Add a size script and make the test script run the build then size-limit. In gh-pages.yml add npm run size after the build step and move setup-node to a Node version size-limit supports, confirming the build still passes on it. Add a README section on the two entries and how to raise a limit. Run npm run build and npm run size, show one deliberate failure in the sandbox without committing it, and open a pull request that quotes both outputs.",
"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
The pull request changes package.json (two dev dependencies, the size-limit section, the size and test scripts), package-lock.json, .github/workflows/gh-pages.yml (the size step and the Node version) and readme.md (the new section). No source file under src/ changes and the Rollup configuration is untouched. Its description quotes the size-limit table for the passing run, the measured size next to each limit, and the failing run's output from the sandbox so the reviewer knows what the check prints when it trips.
A reviewer checks that the limits leave enough room for ordinary work without leaving so much that the check never fires, which is a judgement the measured numbers make possible; that the glob public/*.js does not include a file the build copies rather than produces; and that the Node version bump did not change the build output, which the agent confirms by comparing chunk sizes before and after. They may prefer the pull request comment that andresz1/size-limit-action posts over a plain failing step, and the README names it as the next step.
Visitors see the same site. The check only runs in CI and on npm test, and the Pages deploy still publishes public/ from main.
Run it on every pull request
Once the limits are in package.json, every pull request runs the size step in the existing workflow, so no automation is needed for the check itself. An automation on the Project with a github trigger on workflow_run.failure starts a read-only run when that step fails; it reads the failing output, diffs the chunk list against main, and posts a comment naming the import that grew the bundle, which is the part a contributor usually has to hunt for.
For an organisation with several front-end repositories, a handler on the reader's own server sends this body once per repository to POST /o/{org}/sessions, naming the repository in resources and a request_id that is a UUID v5 of the repository name, so a retried call returns the run it already started. Each run measures that app's own build and sets limits from its own numbers rather than from a shared figure.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A size limit is only as good as the number it starts from, and that number has to come from a real build of this app, not from a guess. The agent runs the production build in its own sandbox, reads the chunk sizes off the output, sets limits from them, and keeps the passing and failing tables with the pull request, so the reviewer sees the measurement rather than a threshold someone typed.
Front-end teams own many small apps with the same bundler and different outputs. One run per repository gives each its own limits, measured from its own build, in a pull request that touches only the files the check needs.
Frequently asked questions
Why the file plugin instead of a bundler preset?
Because Rollup already produced the files. @size-limit/file measures public/index.js and the chunks as they are, compressed the way a server would send them. A bundler preset would build the app a second time with a different bundler and measure something the site never ships.
Where do the limits come from?
From the sizes the agent measures after npm run build in its sandbox, plus a margin, listed in the pull request beside each limit. Nothing is invented; a reviewer who wants more or less headroom edits the number in package.json.
Brotli or gzip?
size-limit reports Brotli by default. If the host compresses with gzip only, gzip: true on each entry switches the measurement. The pull request says which one the deploy target serves so the number matches what visitors download.
Will the CI Node version change affect the build?
The agent confirms it does not by building on the new version and comparing chunk sizes. Rollup 2.x and the Babel plugins run on Node 20; the only reason for the bump is that size-limit requires a newer Node than 14.
How do I find out what grew when the check fails?
Compare the chunk list and sizes against main; the entry that moved is usually one import. size-limit --why needs a bundler plugin this app does not use, so the README points at the diff instead, and the workflow_run.failure automation above does that diff for you.
More SolidJS jobs
The same job on other stacks
- Add a Bundle Size Check to a TypeScript Library from a Linear Issue (TypeScript library)
- Add a Bundle Size Check to a Vite React App (Vite + React)
- Add a Bundle Size Check to a Lit Component (Lit)