Complete AI Training
Sign inGet my AI kit

Your job's AI kit

Get your AI kit

Tell us who you are and what you do. We show you your kit right away and email you the link: skills, prompts, AI agents, MCP servers and courses for your job.

500+ jobs ready, and we make a kit for any other job. No payment needed to look.

Share

AI agent for frontend developers

Bundle Size Budget Agent

Every pull request stays within the size budget, or the extra cost is explained and accepted

Bundle Size Budget Agent: what goes in, what the agent does and what you get

What it does

A new date library adds 70 KB, and three months later the page loads half a second slower. On each pull request, this agent builds the bundle and compares its size with the budget for each entry point. If the size grows beyond the allowance, it traces the increase to the dependency or import that caused it, using the build's size breakdown. It then tries cheaper options: a lighter library, importing only the part needed or loading the code later on demand. After each try it rebuilds to confirm the savings and checks that the tests still pass. It writes the results as a comment on the pull request. The developer approves the change. Edge case: a growth that comes from a needed feature is reported with the cost so the team can raise the budget on purpose.

How it works

Follow the arrows from top to bottom. The orange dashed arrow is the loop: when a check fails, the agent goes back and tries again.

Start and resultWhat it doesA check on its own workWaits for your OKGoes back and retries
Yes, continueYes, continueApprovedNoNo 1 STARTS WHEN Pull request opened or updated 2 USES A TOOL Build the bundle and read the size breakdown 3 DOES Compare each entry point with the budget 4 CHECKS THE RESULT Is every entry point within its budget? If not: trace the growth to the dependency or importresponsible. Back to step 2. 5 DOES Try a lighter alternative, a partial import or lazyloading 6 USES A TOOL Rebuild and run the tests 7 CHECKS THE RESULT Is the size now within budget and do the tests pass? If not: try the next option or report the change as overbudget. Back to step 5. 8 DOES Write the results as a pull request comment 9 YOU APPROVE Developer approves the change or raises the budget 10 RESULT Pull request comment and suggested patch
Read the steps as a list
  1. Pull request opened or updated
  2. Build the bundle and read the size breakdown
  3. Compare each entry point with the budget
  4. Is every entry point within its budget?If not: trace the growth to the dependency or import responsible. Back to step 2.
  5. Try a lighter alternative, a partial import or lazy loading
  6. Rebuild and run the tests
  7. Is the size now within budget and do the tests pass?If not: try the next option or report the change as over budget. Back to step 5.
  8. Write the results as a pull request comment
  9. Developer approves the change or raises the budgetThe agent waits here for your OK.
  10. Pull request comment and suggested patch

How it decides

A change fails when it grows an entry point beyond its budget. Fixes are chosen by size saved with the least code change.

  • Fail when an entry point grows more than 5 KB over its budget
  • Prefer lazy loading for code used on less than 20 percent of visits
  • Report the cost of any new dependency over 10 KB
  • Suggest raising the budget only with the feature owner's approval

Make it yours

Every agent is a starting point. You choose these settings for your own situation.

  • Budget per entry point
  • Tolerance over budget (default 5 KB)
  • Alternatives allowed (lighter libraries, lazy loading)
  • Where comments are posted

What keeps you in control

It always asks you first

  • Merging the suggested patch
  • Any change to the budget

Hard limits

  • Never merges code
  • Never changes the budget without approval

It stops when

  • Done: budget met or increase accepted by the developer
  • Stop: the build fails for reasons unrelated to size

Set it up

We guide you through the set-up, step by step

Members get the full set-up guide for this agent. No technical skills needed: you copy, paste and upload.

10 minto set it up in your AI
5 AIsChatGPT, Claude, Copilot, Gemini, Grok
  • One set of instructions to paste into your AI, with the clicks for ChatGPT, Claude, Microsoft 365 Copilot, Gemini and Grok
  • The agent then walks you through connecting your own data, one source at a time
  • A downloadable copy with the flow chart, the rules and the full guide
Get access to this agent

An example run

What happensA pull request added a charting library and grew the main bundle from 182 KB to 267 KB against a 200 KB budget. The agent traced 78 KB to the library. It tried a lighter charting package, which saved 51 KB but failed 2 tests. It then lazy loaded the chart page, which brought the main bundle to 189 KB with passing tests. The developer approved.

More agents for frontend developers