This guide takes you from zero to your first pruneguard results in under five
minutes. No Rust toolchain, no compilation -- just npm install and go.
- Node.js >= 18
- A JS/TS project (single package or monorepo)
npm install pruneguardThe pruneguard package automatically installs the correct native binary for
your platform. Supported: macOS (ARM64, x64), Linux (x64/ARM64, glibc and
musl), Windows (x64, ARM64).
The bare pruneguard command is all you need. No config file required. It
runs a review of your current branch, classifying findings as blocking
(high-confidence errors/warnings) or advisory. This is the primary
command for CI and agent workflows:
npx pruneguardBy default this detects your base branch automatically. To be explicit:
npx pruneguard --changed-since origin/mainExit code 0 means safe to merge. Exit code 1 means blocking findings exist.
Example output:
BLOCKING:
error [high] unused-export packages/core/src/old.ts#deprecatedFn
Not imported by any reachable module.
ADVISORY:
warn [medium] unused-file packages/legacy/src/widget.ts
No incoming imports from any entrypoint.
Trust: fullScope=true, unresolvedPressure=0.01, baseline=applied
1 blocking, 1 advisory, 342 files, 14ms
For JSON output (recommended for CI and agents):
npx pruneguard --format jsonRun a full-repo scan from your project root to see everything:
npx pruneguard scanpruneguard builds a complete module graph of your repository and reports unused files, unused exports, unused dependencies, cycles, and boundary violations. The text output shows each finding with its severity, confidence level, and evidence.
Example output:
error [high] unused-export packages/core/src/old.ts#deprecatedFn
Not imported by any reachable module.
warn [medium] unused-file packages/legacy/src/widget.ts
No incoming imports from any entrypoint.
2 findings (1 error, 1 warning), 342 files, 12ms
Most repos work without a config file. If you need custom rules, ownership,
or framework overrides, run pruneguard init to generate a minimal config:
npx pruneguard initThis creates a pruneguard.json with just the schema reference:
{
"$schema": "./node_modules/pruneguard/configuration_schema.json"
}See config.md for the full configuration reference.
Show only findings in a specific area of the repo:
npx pruneguard --focus "packages/core/**" scanThe full graph is still built and analyzed; --focus only filters the
reported findings.
Only show errors:
npx pruneguard --severity error scanOnly report findings related to files changed since a base branch:
npx pruneguard --changed-since origin/mainThe bare pruneguard command is built for CI and agent workflows. It
classifies findings as blocking (high-confidence errors/warnings) or
advisory, and exits 0 when there are no blockers:
npx pruneguardExit code 0 = safe to merge. Exit code 1 = blocking findings exist.
Before removing files from your repo, verify they are safe to delete:
npx pruneguard safe-delete src/legacy/old-widget.ts src/utils/deprecated.tspruneguard classifies each target as safe, needs-review, or blocked, with reasons and a recommended deletion order.
Generate a structured remediation plan for specific findings or files:
npx pruneguard fix-plan src/legacy/old-widget.tsThe plan includes specific actions, steps, risk levels, and verification instructions.
Every command supports --format json for machine-readable output:
npx pruneguard --format json
npx pruneguard --format json scan
npx pruneguard --format json safe-delete src/old.tsBefore editing shared code, check what would be affected:
npx pruneguard impact src/utils/helpers.tsGet a proof chain for why something is unused or violating a boundary:
npx pruneguard explain src/old.ts#deprecatedFnAll CLI commands are available as typed JS functions:
import { scan, review, safeDelete, fixPlan } from "pruneguard";
const report = await scan();
console.log(report.summary.totalFindings);See js-api.md for the full API reference.
Add pruneguard to your CI pipeline with the GitHub Action or raw CLI commands. See ci-integration.md for complete examples.
If you already use knip or dependency-cruiser, pruneguard can convert your existing config:
npx pruneguard migrate knip
npx pruneguard migrate depcruiseSee migration.md for details.
- Configuration reference -- all config options
- CI integration -- GitHub Actions, baseline workflows
- JS API reference -- programmatic usage
- Agent usage -- AI agent workflows and decision logic
- Competitive positioning -- vs knip, vs dependency-cruiser
- Recipes -- copy-paste automation examples