See the structure of a code change before you commit it.
Clarity builds dependency impact graphs from source code. It shows how files, modules, tests, and documentation connect so developers and coding agents can reason about design changes with evidence instead of intuition.
Use it when you want to know:
Clarity works at file granularity. It recovers coupling shape, not runtime behavior or full API contracts.
Install with npm:
npm install -g @legacycodehq/clarity
Or on macOS/Linux with Homebrew:
brew install LegacyCodeHQ/tap/clarity
Keep a live graph open while you code:
clarity watch
Show the structural impact of your uncommitted work:
clarity show
Find what depends on a file before changing it:
clarity show path/to/file.go --reach up
Review the structural footprint of a branch:
clarity show -c main...HEAD
Every graph answers four questions.
| Question | Meaning | Examples |
|---|---|---|
| Which snapshot? | working tree, commit, or range | clarity show, -c HEAD, -c main...HEAD |
| What anchor? | changed files, paths, modules, whole tree, paths between files | src/auth, --module auth, --all, --between a,b |
| What lens? | how much context or abstraction to apply | --reach up, --reach down, --depth 2, --collapse |
| What rendering? | how to output the graph | DOT, Mermaid, browser URL, live UI |
This makes Clarity useful for both quick local checks and repeatable agent workflows.
clarity show
Shows the dependency graph around your uncommitted work.
Use it to check:
clarity show -c HEAD
clarity show -c main...HEAD
Use commit and range snapshots to review structural impact after the fact. This is useful for pull requests, regression windows, release reviews, and agent-generated changes.
clarity show path/to/file.go --reach up
clarity show path/to/file.go --reach both --depth 2
Use upstream reach to answer "who imports this?" before changing a file. Use bounded reach to estimate blast radius.
clarity show src/auth
clarity show src/auth --reach both
clarity show --all --collapse
Use scoped graphs to explore unfamiliar code. Collapse configured modules when the file-level graph is too noisy.
clarity show --between ui/login.ts,server/session.go
Shows the dependency paths connecting two files. Use this when you need to explain why two areas are coupled or decide where to cut a dependency.
clarity modules
clarity show --module auth --reach both
clarity show --all --collapse
Declare modules in .clarity/modules.json, inspect a module in context, or
collapse modules into architecture-level nodes.
clarity cycles src
clarity cycles src --url
Lists circular dependencies within a scope and can produce focused visualizations for each cycle.
clarity watch
clarity watch src/auth --reach both
Runs a local live graph that updates as files change. Use it during refactors or large agent edits to keep structural feedback visible.
clarity setup
Adds repository instructions so coding agents can use Clarity as part of their normal loop.
Good agent patterns:
--reach upclarity show -f mermaid after editsclarity show -u for a shareable review artifactclarity show -f dot
clarity show -f mermaid
clarity show -u
DOT is the default. Mermaid works well in docs, IDEs, and agent UIs. -u
creates a browser-friendly visualization URL.
Clarity supports dependency extraction for:
Support quality varies by language. Run:
clarity languages
to see the current maturity and extension list.
clarity cycles
clarity workspace
cycles reports circular file dependencies.
workspace builds Go module and Rust crate relationship graphs.
These surfaces are useful, but their output may change.
Clarity is not a replacement for tests, type checks, linters, or code review.
It does not provide:
It is a structural verification tool: it shows coupling, impact, boundaries, cycles, and change shape.
This project is licensed under the GNU Affero General Public License v3.0.
Copyright (c) 2026-present, Legacy Code Headquarters (OPC) Private Limited. All rights reserved.
$ claude mcp add clarity-cli \
-- python -m otcore.mcp_server <graph>