Dependency graph

ctx dep¶
Generate a dependency graph from source code.
Auto-detects the project ecosystem from manifest files and outputs a dependency graph in Mermaid, table, or JSON format.
Supported ecosystems:
| Ecosystem | Manifest | Method |
|---|---|---|
| Go | go.mod |
go list -json ./... |
| Node.js | package.json |
Parse package.json (workspace-aware) |
| Python | requirements.txt or pyproject.toml |
Parse manifest directly |
| Rust | Cargo.toml |
cargo metadata |
Detection order: Go, Node.js, Python, Rust. First match wins.
Flags:
| Flag | Description | Default |
|---|---|---|
--format |
Output format: mermaid, table, json |
mermaid |
--external |
Include external/third-party dependencies | false |
--type |
Force ecosystem: go, node, python, rust |
auto-detect |
Examples:
# Auto-detect and show internal deps as Mermaid
ctx dep
# Include external dependencies
ctx dep --external
# Force Node.js detection (useful when multiple manifests exist)
ctx dep --type node
# Machine-readable output
ctx dep --format json
# Table format
ctx dep --format table
Ecosystem notes:
- Go: Uses
go list -json ./.... Requiresgoin PATH. - Node.js: Parses
package.jsondirectly (no npm/yarn needed). For monorepos with workspaces, shows workspace-to-workspace deps (internal) or all deps per workspace (external). - Python: Parses
requirements.txtorpyproject.tomldirectly (no pip needed). Shows declared dependencies; does not trace imports. With--external, includes dev dependencies frompyproject.toml. - Rust: Requires
cargoin PATH. Usescargo metadatafor accurate dependency resolution.