This page covers the commands that are useful after the basic file analysis,
package analysis, and blast-radius workflows in the README.
Analyze a local project:
pkgrank files .Analyze a remote repo:
pkgrank files tokio-rs/tokio
pkgrank files https://github.com/fastapi/fastapi
pkgrank files gl:inkscape/inkscape
pkgrank files cb:forgejo/forgejo
pkgrank files sh:~sircmpwn/aerc
pkgrank files bb:pypy/pypyUseful options:
pkgrank files . --git
pkgrank files . --focus src/main.rs
pkgrank files . --directory
pkgrank files . --include-tests
pkgrank files . --cache
pkgrank files . --fail-on-violation
pkgrank files . --affected src/parser.rs
git diff --name-only | pkgrank files . --affected -When output is piped, files writes one JSON object. With --affected,
.changed lists the inputs and .affected lists their transitive dependents,
excluding the inputs themselves. An empty result has .affected_count == 0
and .affected == []. With --focus, .focus contains the matching file
rows with their imports and imported_by paths. Both options work together.
For example:
pkgrank files . --affected src/parser.rs | jq -r '.affected[]'A test in .affected has an import path to a changed file. Whether its
assertions catch a bug is a separate question. In durability, changing
src/recordlog.rs flagged all 38 existing integration test files. Their tests
passed with the bug present. Four new regression cases failed on that revision
and passed with the torn-tail fix.
Rows include structural role, PageRank, consumer PageRank, betweenness, instability, blast radius, cycle membership, external dependencies, and optional git churn fields.
Rank packages in a dependency graph:
pkgrank
pkgrank path/to/npm-project
pkgrank --ecosystem js path/to/project
pkgrank --ecosystem python path/to/project
pkgrank --ecosystem go path/to/project
pkgrank --metric consumers-pagerank -n 10
pkgrank --format json --json-limit 200The graph edge A -> B means package A depends on package B.
- PageRank on the depends-on graph surfaces shared dependencies.
- Consumer PageRank on the reversed graph surfaces top-level consumers.
Show packages that transitively depend on a package:
pkgrank blast-radius my_crate
pkgrank blast-radius serde --workspace-only=false
pkgrank blast-radius express path/to/npm-project
pkgrank blast-radius serde --workspace-only=false -n 20When the graph contains multiple versions of a package, pass its exact
name@version. If multiple Cargo sources supply the same name and version,
use a full package ID from the ambiguity message.
For an npm workspace chain app -> bridge -> leaf, querying the blast radius
of leaf lists bridge at depth 1 and app at depth 2. The lockfile's link
to a workspace and the target containing its dependencies represent one package.
The graph covers installed packages and workspaces and omits the lockfile’s
empty-key root project entry. See the npm package-lock specification.
For Go, pass the module directory or its go.mod. Both use go mod graph in
the module directory. You can also save that command’s output and analyze it
later with --ecosystem go:
go mod graph > module-graph.txt
pkgrank blast-radius example.org/leaf module-graph.txt --ecosystem goFor app -> bridge -> leaf, the output for leaf contains bridge at depth 1
and app at depth 2. These are module requirements. See the
Go module graph reference.
Output is sorted by BFS depth, then by PageRank within each depth.
For Cargo projects, combine cargo outdated with centrality:
pkgrank upgrade-priority -n 15
pkgrank upgrade-priority --format json | jq '.rows[:5]'Live queries require cargo-outdated. The default graph includes external packages.
Each row matches the installed name and version. Reports for the same installed version and target share one row. reported_via
retains each member, dependency path, and its compatible and latest versions.
target_version uses the compatible update when the latest graph removes the
package. Rows with no upgrade version are omitted. graph_match distinguishes matched, outside_graph, and
ambiguous (multiple sources for that version). Unmatched rows sort last.
Use --dev or --build to include those dependency kinds. For optional
dependencies, --features pipeline,storage selects the same features for both
Cargo metadata and the upgrade report.
To compare graph configurations against a fixed set of available updates, pass
--outdated-report updates.json from cargo outdated --format json. This
ranks only the observations in that file. Cargo still resolves the selected
graph. For example:
pkgrank upgrade-priority . --outdated-report updates.json --features pipelinepkgrank files can check layer rules from .pkgrank.toml:
[layers]
domain = ["src/domain/**", "src/models/**"]
infra = ["src/infra/**", "src/db/**"]
api = ["src/api/**", "src/routes/**"]
[[deny]]
from = "domain"
to = "infra"
[[allow]]
from = "domain"
to = ["domain"][[deny]] forbids specific imports. [[allow]] makes the listed targets the
only allowed imports for a layer. Same-layer imports are allowed.
Run:
pkgrank files . --fail-on-violationpkgrank files stores snapshots to SQLite by default. To make that explicit:
pkgrank files . --store trueQuery stored snapshots with:
pkgrank query hotspots
pkgrank query deps
pkgrank query projects
pkgrank query "files lib.rs"
pkgrank query compare
pkgrank query driftThese commands use Cargo metadata and are intended for multi-repo or multi-crate analysis:
| Command | What it writes |
|---|---|
sweep-local |
Per-repo artifacts for a directory of repos |
view |
HTML and JSON snapshot from local metadata and optional crates.io crawl |
triage |
Artifact-backed triage bundle |
cratesio |
Bounded crates.io dependency crawl |
The view and triage commands use a TLC score:
- blast radius:
10 * ln(transitive_dependents + 1) - centrality:
1000 * pagerank - boundary complexity: number of third-party dependencies
TLC is a triage signal, not a quality metric.
pkgrank modules shells out to cargo modules dependencies and ranks Rust
modules, types, traits, and functions by coupling:
cargo install cargo-modules
pkgrank modules -p my_crate --lib -n 25
pkgrank modules-sweep -p crate_a -p crate_b --libRun the MCP stdio server:
pkgrank mcp-stdioToolset selection:
- default: slim tool surface
PKGRANK_MCP_TOOLSET=full: module graph, file analysis, and ecosystem toolsPKGRANK_MCP_TOOLSET=debug: internal artifact-inspection tools
From a source checkout, run the MCP example to start real servers and call their tools over stdio. It checks the slim, full, and debug toolsets and exits after validating their responses.
cargo run --locked --example mcp_smoke