# analyze-bundle

Convert Next.js bundle analyzer data to NDJSON and explore it

Skill by Vercel. Category: Web and browsers.

## Install

Project (for this project only):

```sh
npx skills add vercel-labs/dev3000 --skill analyze-bundle
```

Works with: Claude Code, Codex CLI, Cursor, Antigravity, Copilot CLI, opencode.

Global (for every project on this machine):

```sh
npx skills add vercel-labs/dev3000 --skill analyze-bundle -g
```

Works with: Claude Code, Codex CLI, Cursor, Antigravity, Copilot CLI, opencode.

## Tags

- Runs on your computer: It runs as a program on your machine, with your access.
- Runs shell commands: Its steps run shell commands in your terminal.

## Security audits

- Gen Agent Trust Hub: Pass
- Socket: Pass
- Snyk: Pass
- ZeroLeaks: Pass

Installs: 196. Installs counted by skills.sh. [Open on skills.sh](https://www.skills.sh/vercel-labs/dev3000/analyze-bundle)

## Source

[Open the source](https://github.com/vercel-labs/dev3000/tree/HEAD/.agents/skills/analyze-bundle). Checked 2026-10-24. This summary may contain AI-generated text, so it can be wrong. Check the source before you rely on it.

## SKILL.md

````markdown
---
name: analyze-bundle
description: Convert Next.js bundle analyzer data to NDJSON and explore it
allowed-tools: Bash(node *) Bash(head:*) Bash(tail:*) Bash(grep:*) Bash(jq:*) Read
---

# analyze-to-ndjson

Converts Next.js bundle analyzer binary `.data` files into grep/jq-friendly NDJSON.

## Analyze artifacts

This workflow pre-generates analyzer artifacts in:

- `.next/diagnostics/analyze/ndjson/routes.ndjson`
- `.next/diagnostics/analyze/ndjson/sources.ndjson`
- `.next/diagnostics/analyze/ndjson/output_files.ndjson`
- `.next/diagnostics/analyze/ndjson/module_edges.ndjson`
- `.next/diagnostics/analyze/ndjson/modules.ndjson`

Focus on reading these files and using their evidence to prioritize changes.

## Output files

| File | What's in it |
|---|---|
| `modules.ndjson` | Global module registry (`id`, `ident`, `path`) |
| `module_edges.ndjson` | Module dependency graph (`from`, `to`, `kind`: sync/async) |
| `sources.ndjson` | Per-route source tree with sizes and environment flags |
| `chunk_parts.ndjson` | Granular size data: one line per (source, output_file) pair |
| `output_files.ndjson` | Per-route output files with aggregated sizes |
| `routes.ndjson` | Route-level summaries |

## Browsing the output

### Route overview

```bash
jq -s 'sort_by(-.total_compressed_size)' .next/diagnostics/analyze/ndjson/routes.ndjson
```

### Find large sources

```bash
jq -s '
  group_by(.full_path)
  | map(max_by(.compressed_size))
  | sort_by(-.compressed_size)
  | .[0:10]
  | .[] | {full_path, compressed_size, size, route}
' .next/diagnostics/analyze/ndjson/sources.ndjson
```

### Client-side JS

```bash
grep '"client":true' .next/diagnostics/analyze/ndjson/sources.ndjson \
  | grep '"js":true' \
  | jq -s 'sort_by(-.compressed_size) | .[0:10] | .[] | {full_path, compressed_size}'
```

### Module dependencies

```bash
grep '"from":42,' .next/diagnostics/analyze/ndjson/module_edges.ndjson | jq .to
grep '"to":42,' .next/diagnostics/analyze/ndjson/module_edges.ndjson | jq .from
grep 'react-dom' .next/diagnostics/analyze/ndjson/modules.ndjson | jq '{id, path}'
```

### Output files for a route

```bash
grep '"route":"/"' .next/diagnostics/analyze/ndjson/output_files.ndjson \
  | jq -s 'sort_by(-.total_compressed_size) | .[0:10] | .[] | {filename, total_compressed_size, num_parts}'
```

### Directory tree for a route

```bash
grep '"route":"/"' .next/diagnostics/analyze/ndjson/sources.ndjson \
  | jq 'select(.parent_id == null)'
```
````

- Previous: [d3k](https://syn4pse.dev/terminal/d3k.md)
- Next: [deepsec](https://syn4pse.dev/terminal/deepsec.md)
- [Terminal](https://syn4pse.dev/terminal.md)
- [Suggest a change](mailto:terminal@syn4pse.dev?subject=Terminal%20suggestion)
