home / skills / zhanghandong / rust-skills / rust-deps-visualizer

rust-deps-visualizer skill

/skills/rust-deps-visualizer

This skill visualizes Rust project dependencies as ASCII art, helping you quickly understand structure, depth, and feature-driven relationships.

npx playbooks add skill zhanghandong/rust-skills --skill rust-deps-visualizer

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.7 KB
---
name: rust-deps-visualizer
description: "Visualize Rust project dependencies as ASCII art. Triggers on: /deps-viz, dependency graph, show dependencies, visualize deps, 依赖图, 依赖可视化, 显示依赖"
argument-hint: "[--depth N] [--features]"
allowed-tools: ["Bash", "Read", "Glob"]
---

# Rust Dependencies Visualizer

Generate ASCII art visualizations of your Rust project's dependency tree.

## Usage

```
/rust-deps-visualizer [--depth N] [--features]
```

**Options:**
- `--depth N`: Limit tree depth (default: 3)
- `--features`: Show feature flags

## Output Format

### Simple Tree (Default)

```
my-project v0.1.0
├── tokio v1.49.0
│   ├── pin-project-lite v0.2.x
│   └── bytes v1.x
├── serde v1.0.x
│   └── serde_derive v1.0.x
└── anyhow v1.x
```

### Feature-Aware Tree

```
my-project v0.1.0
├── tokio v1.49.0 [rt, rt-multi-thread, macros, fs, io-util]
│   ├── pin-project-lite v0.2.x
│   └── bytes v1.x
├── serde v1.0.x [derive]
│   └── serde_derive v1.0.x (proc-macro)
└── anyhow v1.x [std]
```

## Implementation

**Step 1:** Parse Cargo.toml for direct dependencies

```bash
cargo metadata --format-version=1 --no-deps 2>/dev/null
```

**Step 2:** Get full dependency tree

```bash
cargo tree --depth=${DEPTH:-3} ${FEATURES:+--features} 2>/dev/null
```

**Step 3:** Format as ASCII art tree

Use these box-drawing characters:
- `├──` for middle items
- `└──` for last items
- `│   ` for continuation lines

## Visual Enhancements

### Dependency Categories

```
my-project v0.1.0
│
├─[Runtime]─────────────────────
│ ├── tokio v1.49.0
│ └── async-trait v0.1.x
│
├─[Serialization]───────────────
│ ├── serde v1.0.x
│ └── serde_json v1.x
│
└─[Development]─────────────────
  ├── criterion v0.5.x
  └── proptest v1.x
```

### Size Visualization (Optional)

```
my-project v0.1.0
├── tokio v1.49.0        ████████████ 2.1 MB
├── serde v1.0.x         ███████ 1.2 MB
├── regex v1.x           █████ 890 KB
└── anyhow v1.x          ██ 120 KB
                         ─────────────────
                         Total: 4.3 MB
```

## Workflow

1. Check for Cargo.toml in current directory
2. Run `cargo tree` with specified options
3. Parse output and generate ASCII visualization
4. Optionally categorize by purpose (runtime, dev, build)

## Related Skills

| When | See |
|------|-----|
| Crate selection advice | m11-ecosystem |
| Workspace management | m11-ecosystem |
| Feature flag decisions | m11-ecosystem |

Overview

This skill generates ASCII-art visualizations of a Rust project's dependency graph from local Cargo metadata. It runs cargo tree (and optionally inspects feature flags) to produce readable, navigable trees, category sections, and optional size bars. The output helps developers quickly understand dependency depth, features, and categories without leaving the terminal.

How this skill works

The skill checks for Cargo.toml in the current directory, runs cargo metadata and cargo tree to collect dependency information, and parses that output into an ASCII tree. Options allow limiting depth and showing feature flags; the formatter applies box-drawing characters and can group dependencies by purpose or annotate sizes when available.

When to use it

  • Quickly inspect a project's dependency tree in the terminal
  • Audit feature flags and transitive crates before a release
  • Identify deep or unexpected transitive dependencies
  • Visualize dev vs runtime vs build dependencies
  • Estimate dependency footprint when size data is available

Best practices

  • Run from the crate root where Cargo.toml is present
  • Limit --depth to 2–4 for large dependency graphs to avoid noise
  • Use --features when you need feature-aware dependency visibility
  • Combine visual output with cargo tree filters (e.g., --all-features) for targeted inspection
  • Use categories (runtime/dev/build) to focus reviews and PR discussions

Example use cases

  • Run /rust-deps-visualizer --depth 3 to produce a concise project tree before a dependency audit
  • Enable feature-aware view to confirm which optional features pull in heavy transitive crates
  • Group dependencies into Runtime, Serialization, and Development to present in a code review
  • Generate size-annotated output to find the largest crates affecting binary size

FAQ

What if cargo tree is not installed?

Install it via cargo install cargo-tree or use a recent Rust toolchain that includes cargo-tree; the skill relies on cargo tree output.

How do I show feature flags?

Invoke the skill with the --features flag; it will include feature lists next to crates when available.