CLI • GitHub Action • MCP • Agent Skill

Inspect Angular Bundles.
Enforce Zero-Bloat Budgets.

Analyze Angular esbuild stats.json through a fast CLI, GitHub Actions, a native MCP server, or an installable Agent Skill—then trace dependencies, measure optimizations, and enforce bundle budgets.

⚡ NATIVE ANALYSIS
Fast native analysis with zero runtime dependencies; reported timings exclude Angular builds and external Nx subprocesses.
🎯 ROOT-CAUSE TRACING
Trace exact file-by-file import chains pulling oversized dependencies into entry points.
🛡️ AUTOMATED CI GATING
Enforce max initial JS, total bundle sizes, and delta thresholds directly in GitHub PRs.
🤖 AI AGENTS & MCP
Native Model Context Protocol server over stdio for Claude Code, Antigravity, and Cursor.

Use BundleRadar with AI coding agents

⚡

MCP Server

Four typed tools let an agent inspect bundles, trace import paths, measure deltas, and enforce budgets through structured calls.

🤖

Agent Skill

An installable optimization workflow guides an agent from baseline and diagnosis through source edits, rebuilds, tests, and measured verification.

The Problem

Why Angular Bundles Grow Out of Control

Modern Angular applications use esbuild for blazing fast build times, but bundle size regressions remain a major source of slow Time-to-Interactive (TTI) and First Contentful Paint (FCP).

1

Accidental Entry Point Leaks

Importing a single utility function from a non-tree-shakeable CommonJS library (like lodash or moment) pulls megabytes directly into main.js.

2

Duplicate Nested Dependencies

Conflicting transitive versions of packages like tslib or rxjs get bundled simultaneously without developer awareness, bloating chunk payloads.

3

Zero CI Visibility & Gating

Pull requests merge unnoticed size spikes because standard CI logs bury massive JSON outputs instead of surfacing clear byte deltas and failing budgets.

Quick Setup

Installation

Install the self-contained binary with zero runtime dependencies directly to /usr/local/bin (or specify --bin-dir ~/.local/bin).

$ curl -fsSL https://raw.githubusercontent.com/sonuKumar03/bundleradar/master/install.sh | sh
# Install binary + AI Agent Skill:
$ curl -fsSL https://raw.githubusercontent.com/sonuKumar03/bundleradar/master/install.sh | sh -s -- --with-skill

Quickstart

Generate Angular stats during your build and run bundleradar in two simple steps:

Step 1: Build Angular with stats-json
ng build --stats-json
This produces dist/<project-name>/stats.json.
Step 2: Inspect Bundle Breakdown
bundleradar scan dist/my-app/stats.json
Command Reference

Core Commands to Inspect, Benchmark & Control Bundles

Each command outputs clean, structured ANSI tables and trees designed for both human terminal inspection and automated CI pipelines.

1

bundleradar scan <stats.json> [--entry <source-or-glob>] [--why <pkg>]

Breakdown

Inspects initial entry points, lazy route chunks, and calculates total NPM package contributions sorted by byte weight. Use --entry / -e (e.g. source path src/main.ts or emitted chunk glob main-*.js) to scope analysis to a specific entrypoint, or --why <pkg> to trace package import roots.

💡 Entrypoint Scoping & TotalJS Invariant: --entry / -e scopes initial versus lazy reachability, package attribution, and root traces strictly to the selected entrypoint. The overall TotalJS metric consistently reflects the whole browser build across all chunks.

$ bundleradar scan dist/apps/portal/stats.json
⚡ BUNDLERADAR BUNDLE SCAN
-------------------------------------------------------------
Entrypoint "main":
Initial JavaScript: 3.08 MB [~946.81 KB gzip]
Async / Lazy Chunks: 87.13 KB (18 chunks)
TOP CONTRIBUTING NPM PACKAGES
-------------------------------------------------------------
1. exceljs 923.69 KB [~277.11 KB gzip] (1 modules)
2. moment-timezone 723.39 KB [~217.02 KB gzip] (3 modules)
3. pdfjs-dist 324.85 KB [~97.45 KB gzip] (1 modules)
4. three 295.20 KB [~88.56 KB gzip] (2 modules)
5. chart.js 192.18 KB [~57.65 KB gzip] (2 modules)
# Scoped to entrypoint:
$ bundleradar scan dist/apps/portal/stats.json --entry src/main.ts
2

bundleradar diff <stats.json> --against <baseline-or-git-ref>

PR Delta & Attribution

Compares the current build against a baseline file or Git ref (e.g. origin/master), automatically building the baseline in an isolated worktree. Traces the shortest BFS import chain directly to regressing packages with emitted chunk attribution.

$ bundleradar diff dist/apps/portal/stats.json --against origin/master
⚡ BUNDLERADAR COMPARISON & DIFF
-------------------------------------------------------------
Initial JS: 2.79 MB → 3.08 MB (+295.73 KB)
Lazy JS: 87.13 KB → 87.13 KB (0 B)
Total JS: 2.88 MB → 3.17 MB (+295.73 KB)
CHANGED PACKAGES
-------------------------------------------------------------
➕ three +295.20 KB (main-PJ5NP3ZD.js)
• Import path: apps/portal/src/main.ts → apps/portal/src/app/app.component.ts → node_modules/three/build/three.module.js
🔄 @angular/router +244 B (main-PJ5NP3ZD.js)
🔄 lodash +11 B (main-PJ5NP3ZD.js)
Micro-drift: 70.31 KB across sub-threshold updates
3

bundleradar gate <stats.json> [--entry <entry>] [flags]

CI Gate

Enforces strict size budgets and regression limits in pull request pipelines. Returns exit code 0 on pass, or exit code 1 with budget violation details to block oversized pull requests. Budgets can be scoped to specific entrypoints via --entry / -e (e.g. src/main.ts or main-*.js).

$ bundleradar gate dist/apps/portal/stats.json --entry src/main.ts --max-initial=300KB
✓ BUDGET GATE PASSED: Initial JS is 248.50 KB (budget: 300.00 KB)
$ bundleradar gate dist/apps/portal/stats.json --max-initial=200KB
✗ BUDGET GATE FAILED: Initial JS is 248.50 KB (budget: 200.00 KB, exceeded by +48.50 KB)
Process exited with status code 1. Pipeline failed.
4

bundleradar workspace [list|scan] [--root <dir>] [--app <name=stats>]

Nx Monorepo

Discovers and scans builds across an Nx monorepo workspace to compare multi-app sizes, shared library costs, duplicate dependencies, and artifact freshness.

$ bundleradar workspace scan
WORKSPACE APPLICATION SUMMARY
-------------------------------------------------------------
• admin-dashboard: Initial 1.25 MB | Lazy 450 KB | Total 1.70 MB ✓ fresh
• portal: Initial 2.08 MB | Lazy 86 KB | Total 2.16 MB ✓ fresh
SHARED NX LIBRARIES & DUPLICATES
-------------------------------------------------------------
1. @nx-workspace/reports 412.50 KB (used in admin-dashboard, portal)
2. @nx-workspace/charting 195.20 KB (used in portal)
• Cross-App Repeat: exceljs repeated across 2 app deployments (1.85 MB total)
5

bundleradar mcp

Model Context Protocol

Starts a native Model Context Protocol (MCP) server over standard I/O for AI coding assistants (Claude Code, Antigravity, Cursor) to inspect bundles, trace dependency chains, and enforce budgets directly inside agent tool loops.

# Register with Claude Code CLI (stdio protocol):
$ claude mcp add bundleradar -- bundleradar mcp
# Stdio server starts quietly and exchanges JSON-RPC 2.0 messages with client:
{"jsonrpc":"2.0","method":"tools/list"} → 4 tools available
✓ Tools: bundle_scan, bundle_diff, bundle_gate, workspace_summary

Configuration (.bundleradar.yml)

Persist project-wide size budgets and optimization rules in your repository root:

# .bundleradar.yml
budgets:
  initial_js_max: 250kb
  total_max: 1.5mb

rules:
  disallow_packages:
    - moment
    - lodash

GitHub Actions Integration

Drop bundleradar directly into your GitHub Actions workflow to post automated PR comments with delta summaries and fail oversized changes. Use the entry input to scope analysis and budget enforcement to a specific entrypoint (e.g. src/main.ts or main-*.js):

name: Bundle Size Budget Check
on: [pull_request]

jobs:
  bundleradar:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      
      - run: npm ci
      - run: npx ng build --stats-json
      
      - name: Run bundleradar CI
        uses: sonuKumar03/bundleradar@v2.0.0
        with:
          stats: dist/my-app/stats.json
          entry: src/main.ts
          max-initial: '250kb'
          post-comment: true
Agentic Architecture

AI Agents & Model Context Protocol (MCP)

Give your coding agent a measured bundle optimization loop: baseline → diagnose → trace → edit → rebuild/test → measure → gate. The Agent Skill supplies the reasoning workflow, MCP is the preferred structured interface when available, and CLI JSON is the universal fallback.

Available MCP Tools (bundleradar mcp)
bundle_scan Inspection

Analyze bundle sizes (initial JS, async JS, total assets) and top contributing npm packages with optional filters and entrypoint scoping.

bundle_diff Delta & Attribution

Compare current build against a baseline file or git ref, calculating size deltas with BFS import chain regression attribution and micro-drift grouping.

bundle_gate CI Budget Gate

Validate bundle sizes, regressions, and architecture rules against policy budgets in CI (max initial, max total, max delta, forbidden packages).

workspace_summary Monorepo

Discover and summarize all application targets across an Nx or multi-package monorepo workspace, tracking cross-app shared packages.

Quick Client Setup
Claude Code CLI Terminal Command
claude mcp add bundleradar -- bundleradar mcp

Runs instantly without modifying config files directly.

Claude Desktop & Cursor mcp.json
{
  "mcpServers": {
    "bundleradar": {
      "command": "bundleradar",
      "args": ["mcp"]
    }
  }
}
🤖

Companion Agent Skill Definition (SKILL.md)

Install the self-contained binary and complete skill tree for generic agents, Claude Code, and Codex. The binary and Angular esbuild stats.json are prerequisites; use --skill-dir <path> for a custom skill location. The installed Skill uses MCP when available and CLI JSON otherwise.

Prompt: “Reduce the initial JavaScript bundle by at least 50 KB without changing application behavior. Establish a baseline first, identify the highest-confidence optimization, trace its import path, make the change, rebuild, run tests, and report the measured delta.”

curl -fsSL https://raw.githubusercontent.com/sonuKumar03/bundleradar/master/install.sh | sh -s -- --with-skill
View Full Agent Docs →