Agent skill

Analyzing Backend Bundle

by TriliumNext in TriliumNext/Trilium

A skill your agent uses when analyzing the server/desktop backend bundle — "what does the server load at startup?", "is <dependency lazy on the backend?", "why is <package in the startup set?", "how…

AGPL-3.0Auto-check passedKnowledge Management

Install Analyzing Backend Bundle

skills CLI
$ npx skills add TriliumNext/Trilium --skill analyzing-backend-bundle -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install TriliumNext/Trilium analyzing-backend-bundle --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/TriliumNext/Trilium.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/analyzing-backend-bundle .claude/skills/analyzing-backend-bundle && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
analyzing-backend-bundle
GitHub stars
38k
Token cost
~2.6k tokens
SKILL.md length
1,131 words
Files
7
Skills in repo
22
Repo updated
First seen
Licence
AGPL-3.0

At a glance

A skill your agent uses when analyzing the server/desktop backend bundle — "what does the server load at startup?", "is <dependency lazy on the backend?", "why is <package in the startup set?", "how…

  • Analyzing the server/desktop backend bundle — what does the server load at startup?
  • SKILL.md covers Tools, Getting the metafile, Interpreting the results and Fix patterns, by constraint, plus 2 more sections
  • Runs JavaScript scripts from its folder; calls node and pnpm
  • Is <dependency lazy on the backend?

What it does

Analyzing Backend Bundle is an agent skill from TriliumNext/Trilium. Use when analyzing the server/desktop backend bundle — "what does the server load at startup?", "is <dependency lazy on the backend?", "why is <package in the startup set?", "how big is the eager set?", chunk analysis after adding a dynamic-import seam, backend memory profiling (RSS, retained script source, heap), or any before/after comparison for backend lazy-loading. Records what a bundle actually loads at boot, joins it with the esbuild metafile, and explains why each package is eager. Don't write a new…

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files.

It sits in Knowledge Management, covering Web performance. The repository describes itself as: Build your personal knowledge base with Trilium Notes. The licence is AGPL-3.0.

When your agent uses it

  • Analyzing the server/desktop backend bundle — what does the server load at startup?
  • Is <dependency lazy on the backend?
  • Why is <package in the startup set?
  • How big is the eager set?

Example prompts

  • “what does the server load at startup?”
  • “is <dependency lazy on the backend?”
  • “why is <package in the startup set?”
  • “/analyzing-backend-bundle”

Requirements

  • Node.js

What it can do on your machine

Read from SKILL.md and the folder at commit cac2b4f. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (JavaScript), which the agent can run.

    Shell commands in SKILL.md call:

    • node
    • pnpm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pnpm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Analyzing Backend Bundle loads about 2.6k tokens when it runs. Until then it costs about 159 tokens; SKILL.md has 1,131 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~159
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from TriliumNext/Trilium at commit cac2b4f, republished under its AGPL-3.0 licence (© TriliumNext). 1,131 words, ~2,597 tokens.

Download SKILL.mdSave it as .claude/skills/analyzing-backend-bundle/SKILL.md (or your agent's skills folder). This skill also uses 6 other files; get the full folder from GitHub.
name
analyzing-backend-bundle
description
Use when analyzing the server/desktop backend bundle — "what does the server load at startup?", "is <dependency> lazy on the backend?", "why is <package> in the startup set?", "how big is the eager set?", chunk analysis after adding a dynamic-import seam, backend memory profiling (RSS, retained script source, heap), or any before/after comparison for backend lazy-loading. Records what a bundle actually loads at boot, joins it with the esbuild metafile, and explains why each package is eager. Don't write a new throwaway module-hook logger, metafile joiner, or heap-snapshot parser — all already live here.

Analyzing the backend bundle

The backend bundles (apps/server/dist, apps/desktop/dist) are esbuild ESM output with code splitting: an entry plus chunks/, where a chunk loads only when a dynamic import() first needs it. Every megabyte the process loads at startup costs three ways, permanently:

  • Retained source (~1 MB heap per loaded MB): V8 keeps each loaded script's source string for the life of the script. Double that for a chunk containing any character above U+00FF — esbuild escapes strings (charset: "ascii") but emits regex literals verbatim, and one raw Arabic digit stores the whole chunk two-byte.
  • Parser high-water (~5 B native per loaded byte, cold start): V8's parse of the loaded code peaks in malloc'd memory that glibc keeps as dirty pages after it is freed. NODE_COMPILE_CACHE roughly halves it on warm starts.
  • Bytecode and metadata in the JS heap.

Reference points (2026-08, Node 22, real 146 MB DB, same source built both ways; the full table is in PR #11111): the monolithic 14.8 MB CJS bundle cost 207 MB RSS / 64 MB heap post-GC and 1 177 ms to first HTTP response; the split ESM build loaded 7.65 MB at startup and cost 120 MB / 42 MB and 895 ms, with the V8 parser's native peak down from 78 MB to 21 MB. ESM without seams matched CJS on every metric — splitting only pays through dynamic-import boundaries. So the question that matters is never "how big is the bundle" but "how much of it loads at startup" — and the tools here answer it with runtime evidence, not static guessing.

Tools

All in this folder, zero dependencies. record and profile-bundle boot the real server, so they need the usual environment (adapt paths; use a scratch copy of a real document.db for realistic becca numbers, or an empty dir for setup-mode):

bash
ENV="TRILIUM_ENV=production TRILIUM_DATA_DIR=<scratch>/data TRILIUM_PORT=8123 \
     TRILIUM_RESOURCE_DIR=$PWD/apps/server/dist"

# 1. Record which dist/ files the server loads at startup (ground truth):
env $ENV node .claude/skills/analyzing-backend-bundle/analyze-bundle.mjs record \
    --bundle apps/server/dist/main.mjs --out /tmp/loaded.txt --port 8123

# 2. Join with the metafile: eager vs lazy totals, per package, biggest eager chunks:
node .claude/skills/analyzing-backend-bundle/analyze-bundle.mjs startup \
    --meta <meta.json> --loaded /tmp/loaded.txt

# 3. Explain WHY a package is eager (shortest static import chain from the entry;
#    --from <input> traces from a module that is itself dynamically imported):
node .claude/skills/analyzing-backend-bundle/analyze-bundle.mjs why \
    --meta <meta.json> iconv-lite undici
node .claude/skills/analyzing-backend-bundle/analyze-bundle.mjs why \
    --meta <meta.json> --from apps/server/src/www.ts highlight.js

# 4. Whole-bundle composition, no boot needed:
node .claude/skills/analyzing-backend-bundle/analyze-bundle.mjs packages --meta <meta.json>

# 5. After adding any lazy seam — catches the CJS interop break described below:
node .claude/skills/analyzing-backend-bundle/check-dynamic-imports.mjs apps/server/dist

# Memory numbers (RSS/heap post-GC; add --snapshot for a heap snapshot):
env $ENV node --expose-gc .claude/skills/analyzing-backend-bundle/profile-bundle.cjs \
    apps/server/dist/main.mjs --port 8123 --snapshot /tmp/s.heapsnapshot

# Startup speed (spawn -> first HTTP response, median of N runs):
env $ENV node .claude/skills/analyzing-backend-bundle/bench-startup.mjs \
    apps/server/dist/main.mjs 5

# What the heap actually retains (proves which chunk sources are resident):
node --max-old-space-size=8192 .claude/skills/analyzing-backend-bundle/heap-strings.mjs \
    /tmp/s.heapsnapshot

The desktop bundle embeds the same server code, so server recordings generalize to it; record/profile-bundle cannot boot apps/desktop/dist/main.mjs under plain node (it imports electron), but packages and why work on its metafile directly.

Getting the metafile

buildBackend() writes dist/meta.json, and the last call in the app's build script wins — after pnpm server:build it describes image_worker.cjs, not main. To get the main bundle's metafile, temporarily leave only the main.ts buildBackend call in apps/server/scripts/build.ts, run the build, and save dist/meta.json elsewhere before restoring. (Making buildBackend write per-entry metafiles is the real fix if this grates.)

Interpreting the results

  • Eagerness is decided only by the recording. The metafile marks every dynamic-import target chunk with entryPoint (240 of 286 outputs in the first analysis), so any static reasoning that consults entryPoint, or assumes "chunk = lazy", overcounts. Conversely the static-reachability closure undercounts: a dynamic import executed during boot loads its chunk anyway.
  • "NOT statically reachable" + present in the startup set has two causes, and they call for opposite fixes. Either a dynamic import runs during startup — the seam exists and boot-time code defeats it, so defer that call (example: the /mcp route registering the MCP SDK at boot instead of on first request) — or the package is reached by an ordinary static chain from a module that is itself dynamically imported at boot, such as apps/server/src/www.ts. why --from apps/server/src/www.ts <pkg> shows the second kind; the fix there is a seam somewhere along the chain it prints.
  • why takes a package name, not a substring. A bare needle matches at node_modules/<name>/ or a whole path segment, because plain substring matching silently confuses a package with any file whose name merely ends the same way — "highlight.js" also appears in postcss's terminal-highlight.js, which reads as a plausible but entirely fictitious dependency edge.
  • Chunks load as units. A package can be "lazy" in source but ride in a chunk shared with eager code; startup's biggest-chunks table shows each chunk's dominant input so this is visible.
  • A why chain through an absurd path is a stubbing opportunity — e.g. highlight.js reached via sanitize-html → postcss/lib/terminal-highlight (postcss's terminal error pretty-printer). An esbuild alias to a stub kills such an edge at build level.
Show full SKILL.md (473 more words)Show less

Fix patterns, by constraint

SituationFix
Used only inside an async functionMove the import into it: const { x } = await import("pkg") (the pattern in pdf_processor.ts, office_processor.ts, claude_agent.ts)
Loaded at boot by a dynamic importKeep the registration eager, import the payload in the request handler on first use
Consumed synchronously (script API, sucrase transpile)Per-call import is impossible — preload conditionally at startup behind the feature's flag (backend scripting is off by default)
Pulled by a dep's edge that never runs meaningfullyesbuild alias/stub for that one file

After any fix: re-run record + startup and compare the eager total, run check-dynamic-imports.mjs (see below), and check no chunk in the new startup set carries characters above U+00FF (grep -lP '[^\x00-\xFF]' over the loaded chunks; heap-strings.mjs shows a ~2x source string when one slips through).

The CommonJS interop trap — verify every new seam

const { x } = await import("some-cjs-package") is silently broken in the split ESM build. esbuild cannot know a CommonJS module's named exports, so it emits the chunk with a single default export; destructuring names off the namespace yields undefined, and the first call fails with something like "l is not a constructor". Unit tests do not catch it, because a vi.mock("some-cjs-package", …) supplies whatever names the test asks for.

Write the seam through the interop instead, and give the test mock a matching default (the real module has one — that is the shape Node's own CJS interop produces):

ts
const mod = await import("undici");
const { Agent, fetch } = mod.default ?? mod;   // works in ESM chunks, CJS output, and Node

Seams whose target is own source or a real ESM package (unpdf, the agent SDK, the MCP SDK, core's own modules) are unaffected — they have genuine named exports. Only CJS packages bite. check-dynamic-imports.mjs compares, for every dynamic import in the built bundle, the names the consumer destructures against the names the target chunk exports; run it on a clean build after adding a seam, and confirm the seam works for real (import the emitted chunk in a scratch script and call into it) rather than trusting the unit tests.

Gotchas

  • NODE_V8_COVERAGE does not capture the loaded-script list here (the dump held only node internals) — the module hook (loghook.cjs, preloaded by record) is the reliable tool.
  • The server handles SIGTERM without exiting (DB close), so anything that boots it must escalate to SIGKILL — record does; a hand-rolled runner that waits on exit after SIGTERM hangs and leaks an orphaned server.
  • __dirname in ESM output is defined by the buildBackend banner and resolves to the bundle root even inside chunks/ — bundled code locates preload.cjs, image_worker.cjs and assets relative to the entry. Don't "simplify" the banner; which chunk a module lands in must not change what __dirname means.
  • Heap snapshots for a ~55 MB heap parse fine with --max-old-space-size=8192; write them only when needed (--snapshot), they're ~70-90 MB on disk.

Related skills: measure-startup-requests (the client-side counterpart), profiling-client-performance (renderer-side cost), developing-electron-desktop (desktop launch specifics when verifying a change in the real app).

© TriliumNext, AGPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 6 other files in .claude/skills/analyzing-backend-bundle of TriliumNext/Trilium.

  • SKILL.md
  • analyze-bundle.mjs
  • bench-startup.mjs
  • check-dynamic-imports.mjs
  • heap-strings.mjs
  • loghook.cjs
  • profile-bundle.cjs

Open the folder on GitHubat commit cac2b4f

Compare with similar skills

Analyzing Backend Bundle next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Analyzing Backend Bundle compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Analyzing Backend Bundle this skillTriliumNext/Trilium38k—~2.6kAutomated safety check: PassAGPL-3.0
Remembercommercetools/ui-kit154—~2kAutomated safety check: NotesMIT
Gitnexus ExplorerTommy-yw/RunbookHermes5463 repos~1.8kAutomated safety check: PassMIT
Learning Visualization Skillmingchen666/Reviva237—~1.1kAutomated safety check: PassNone
Network Protocol Vizmingchen666/Reviva237—~1.1kAutomated safety check: PassNone
Data Structure Visualizationmingchen666/Reviva237—~1.1kAutomated safety check: PassNone

Similar skills

  • Remember

    commercetools/ui-kit

    Persist guidelines, conventions, and architectural decisions into the repository's knowledge base.

    154 GitHub stars~2k tokensUpdated 5 days ago
    Knowledge ManagementAuto-check: notes
  • Gitnexus Explorer

    Tommy-yw/RunbookHermes

    Index a codebase with GitNexus and serve an interactive knowledge graph via web UI + Cloudflare tunnel.

    546 GitHub starsUsed in 3 repos~1.8k tokens
    Knowledge ManagementAuto-check passed
  • Generate single-file HTML visual explanations for learning and review.

    237 GitHub stars~1.1k tokensUpdated 16 days ago
    Knowledge ManagementAuto-check passed
  • Network Protocol Viz

    mingchen666/Reviva

    Generate single-file HTML animations that teach network protocols and packet flow.

    237 GitHub stars~1.1k tokensUpdated 16 days ago
    Knowledge ManagementAuto-check passed
  • A skill your agent uses whenever the user wants visual learning for data structures, algorithms, trees, graphs, sorting, searching, hashing, recursion, complexity analysis, 408 data structure…

    237 GitHub stars~1.1k tokensUpdated 16 days ago
    Knowledge ManagementAuto-check passed
  • React Doctor

    makeplane/plane

    Scans React code for lint, accessibility, bundle size and architecture issues, reports a health score and checks that changes do not lower it.

    61k GitHub starsUsed in 12 repos~657 tokens
    Frontend & DesignAuto-check passed

More from TriliumNext/Trilium

All 22 skills in this repo
  • Cutting A Release

    TriliumNext/Trilium

    A skill your agent uses when cutting, preparing, or debugging a Trilium release — bumping the monorepo version, tagging, or diagnosing a failed "Release" workflow run.

    38k GitHub stars~3.2k tokensUpdated today
    Auto-check passed
  • Developing Electron Desktop

    TriliumNext/Trilium

    A skill your agent uses when working on the Trilium Electron desktop app (apps/desktop) — adding or changing an electronApi method / IPC channel, touching preload.ts, main.ts, services/window.ts or…

    38k GitHub stars~5.7k tokensUpdated today
    Auto-check passed
  • Evolving The Data Model

    TriliumNext/Trilium

    A skill your agent uses when adding a DB migration or a new column/field to a Becca entity in Trilium ("add a migration", "new column on notes/attributes", "ALTER TABLE", "add a field to…

    38k GitHub stars~2.1k tokensUpdated today
    Auto-check passed
  • Adding Internal API Route

    TriliumNext/Trilium

    A skill your agent uses when adding, moving, or wiring an internal REST endpoint in Trilium (a new /api/ route) — choosing between a core-shared handler (packages/trilium-core/src/routes/index.ts…

    38k GitHub stars~3.3k tokensUpdated today
    Auto-check passed
  • Adding LLM MCP Tools

    TriliumNext/Trilium

    A skill your agent uses when adding, changing, or reviewing an LLM/MCP tool in Trilium (the defineTools definitions under packages/trilium-core/src/services/llm/tools/ —…

    38k GitHub stars~2.5k tokensUpdated today
    Auto-check passed
  • Ckeditor5 Plugin Development

    TriliumNext/Trilium

    Write, extend, and review CKEditor 5 plugins in the Trilium (TriliumNext Notes) monorepo — the rich-text-note editor under packages/ckeditor5, whose plugins live in src/plugins/.

    38k GitHub stars~4.8k tokensUpdated today
    Auto-check passed

Questions about Analyzing Backend Bundle

What does Analyzing Backend Bundle do?

A skill your agent uses when analyzing the server/desktop backend bundle — "what does the server load at startup?", "is <dependency lazy on the backend?", "why is <package in the startup set?", "how…. Analyzing Backend Bundle is an agent skill from TriliumNext/Trilium.", chunk analysis after adding a dynamic-import seam, backend memory profiling (RSS, retained script source, heap), or any before/after comparison for backend lazy-loading.

When should I use Analyzing Backend Bundle?

Analyzing Backend Bundle fits situations like: analyzing the server/desktop backend bundle — what does the server load at startup?; is <dependency lazy on the backend?; why is <package in the startup set?; how big is the eager set?.

How do I install Analyzing Backend Bundle in Claude Code?

Run `npx skills add TriliumNext/Trilium --skill analyzing-backend-bundle -a claude-code`. Or copy the skill folder (.claude/skills/analyzing-backend-bundle in TriliumNext/Trilium) into .claude/skills/analyzing-backend-bundle in your project. Claude Code loads it when a task matches its description.

How do I install Analyzing Backend Bundle in Codex?

Run `npx skills add TriliumNext/Trilium --skill analyzing-backend-bundle -a codex`. Or copy the skill folder (.claude/skills/analyzing-backend-bundle in TriliumNext/Trilium) into .agents/skills/analyzing-backend-bundle in your project. Codex loads it when a task matches its description.

Can I use Analyzing Backend Bundle in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add TriliumNext/Trilium --skill analyzing-backend-bundle -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/analyzing-backend-bundle, .gemini/skills/analyzing-backend-bundle, .github/skills/analyzing-backend-bundle and .opencode/skills/analyzing-backend-bundle in your project.

What does Analyzing Backend Bundle need to run?

Going by SKILL.md and its folder, Analyzing Backend Bundle needs JavaScript for the scripts in its folder and the command-line tools its instructions call (node and pnpm). Our summary lists: Node.js.

Does Analyzing Backend Bundle access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Analyzing Backend Bundle safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Analyzing Backend Bundle use?

Analyzing Backend Bundle is published under the AGPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Analyzing Backend Bundle use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Analyzing Backend Bundle?

Skills that share tags, products or a category with Analyzing Backend Bundle: Remember (commercetools/ui-kit, 154 stars), Gitnexus Explorer (Tommy-yw/RunbookHermes, 546 stars), Learning Visualization Skill (mingchen666/Reviva, 237 stars) and Network Protocol Viz (mingchen666/Reviva, 237 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Analyzing Backend Bundle?

TriliumNext (a GitHub organization) maintains it in TriliumNext/Trilium, which has 38,248 GitHub stars. The repository holds 22 skills in this directory. The repository was last updated on October 8, 2026.

Source: TriliumNext/Trilium on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.