Bom slimmer

From cdxgen/cdxgen · View interactive version

Bom slimmer is an AI agent skill from the GitHub repository cdxgen/cdxgen. Reviews a codebase's direct dependencies and designs lightweight, low-risk, zero-dependency custom replacements using cdxgen SBOM evidence, occurrence/callstack usage data, and license and supply-chain risk evaluation. Use when asked to shrink node_modules, reduce dependency bloat or copyleft exposu

How to use this skill

Skill file

Skill: BOM Slimmer

This skill guides a local LLM through analyzing a project's direct dependencies, identifying high-overhead packages, and designing low-risk, zero-dependency custom replacements.


1. Using cdxgen SBOM as the Authoritative Data Source

A CycloneDX SBOM generated by cdxgen (bom.json) provides a complete, normalized, and machine-readable inventory of all direct and transitive dependencies. Use it as your primary source of truth:

  1. Locate Direct Dependencies:

Look under bom.metadata.component (the parent package) and trace its relationships in the dependencies array.

  1. Trace Dependency Trees:

Find the dependencies block at the root of the SBOM. Each entry maps a package ref to its direct dependency dependsOn refs:

```json

{

"ref": "pkg:npm/foo@1.0.0",

"dependsOn": ["pkg:npm/bar@2.0.0", "pkg:npm/baz@1.5.0"]

}

```

  1. Calculate Transitive Footprint:

For any candidate direct dependency, traverse the dependsOn graph in the SBOM to identify how many total sub-packages will be completely purged from node_modules if that direct dependency is removed.

  1. Inspect Metadata:

Filter out type: "development" components or dev-only scopes if you are optimizing production boot time and install footprint.


2. Advanced Analysis Data Points

Note 1: Utilizing Occurrence and Callstack Evidence

When cdxgen is run under --profile research (or during deep Evinse executions), it populates components with schema-valid occurrences and callstacks under evidence:

Note 2: Incorporating License, Author, and Publisher Data

Use the following additional SBOM metadata to guide the business and legal aspects of the replacement:


3. Step-by-Step Analysis Workflow

Step 1: Mapping the Surface Area

Step 2: Code Search & Usage Audit

Step 3: Assessing Replacement Viability

Evaluate candidates against these key replacement archetypes:

Step 4: Drafting Custom Replacements

For viable candidates, design a zero-dependency JS/TS snippet. Follow these requirements:

  1. Compatibility: Ensure the new implementation supports the exact same input/output formats and signatures as the replaced library APIs.
  2. Standards: Avoid complex regexes that could cause backtracking vulnerabilities (e.g. ReDoS). Prefer simple string splitting, slice operations, and standard built-ins.
  3. Cross-Platform: Support Node.js, Bun, and Deno by using global/web-standard APIs (globalThis) where possible.

4. Risk Assessment Guide

Assign a risk category to each proposed replacement:

| Risk Category | Criteria | Example |

| :-------------- | :------------------------------------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------- |

| Low Risk | Standard built-in exists; utility does basic string formatting/math; isolated to a single non-critical utility. | Replacing uuid with crypto.randomUUID() or yoctocolors with ANSI codes. |

| Medium Risk | Requires writing custom parsing logic for standard formats; used in core execution paths; handles external network calls. | Replacing cheerio with regex/slicing for HTML page scraping. |

| High Risk | Parser/validation logic for complex, specification-heavy formats; deeply integrated across numerous modules. | Replacing yaml, @babel/parser, or ajv schema validator. |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.