Bundle Size Budget
FeaturedOn demandAbout Bundle Size Budget
This loop keeps the client bundle within its size-limit budget. Each round builds the project and runs size-limit, then judges whether the budget is exceeded and, if so, trims the bundle before the next round. It runs at most 6 rounds.
Key features
- 01Uses the size-limit exit code as the sole verdict
- 02Manual trigger, so the user decides when to start
- 03Capped at 6 rounds to prevent endless tuning
- 04Supports Cursor
Use cases
- 01A new dependency pushed the bundle over budget
- 02Confirming bundle size before a release
- 03Investigating steadily growing frontend output
- Goal
- The client bundle stays under the size-limit budget.
- Exit when
- Stop when size-limit exits 0, or after the 6-round limit is reached.
- Between iterations run
- npm run build && npm run size-limit
Launch prompt
Paste into Cursor. The agent repeats the steps below until the exit condition is met.
Start the "Bundle Size Budget" loop. Goal: The client bundle stays under the size-limit budget. Max iterations: 6. Step 1: Build and measure — Run npm run build && npm run size-limit to produce the output and check its size against the budget. `npm run build && npm run size-limit` Step 2: Read the result — If size-limit exits 0, the budget is met and the loop ends; otherwise note what exceeds the limit and which files are involved. Step 3: Reduce the size — Change code or dependencies responsible for the overage, then start the next round to measure again. Between iterations run: `npm run build && npm run size-limit` Exit when: Stop when size-limit exits 0, or after the 6-round limit is reached.
Steps
Each round runs in order; if the exit condition isn’t met, another round starts, up to 6.
Run npm run build && npm run size-limit to produce the output and check its size against the budget.
npm run build && npm run size-limitIf size-limit exits 0, the budget is met and the loop ends; otherwise note what exceeds the limit and which files are involved.
Change code or dependencies responsible for the overage, then start the next round to measure again.
Supported agents
Coding agents that can run this loop directly.