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:
- What does this change touch?
- Who depends on this file?
- Why are these two areas connected?
- Did this refactor cross a boundary?
- Did we introduce a cycle?
- What does this branch look like structurally?
Clarity works at file granularity. It recovers coupling shape, not runtime behavior or full API contracts.
Install with npm:
npm install -g @legacycodehq/clarityOr on macOS/Linux with Homebrew:
brew install LegacyCodeHQ/tap/clarityKeep a live graph open while you code:
clarity watchShow the structural impact of your uncommitted work:
clarity showFind what depends on a file before changing it:
clarity show path/to/file.go --reach upReview the structural footprint of a branch:
clarity show -c main...HEADEvery 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 showShows the dependency graph around your uncommitted work.
Use it to check:
- whether the change stayed inside the intended area
- which neighboring files are affected
- whether tests are connected to the changed code
- whether new coupling appeared
clarity show -c HEAD
clarity show -c main...HEADUse 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 2Use 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 --collapseUse 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.goShows 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 --collapseDeclare modules in .clarity/modules.json, inspect a module in context, or
collapse modules into architecture-level nodes.
clarity cycles src
clarity cycles src --urlLists circular dependencies within a scope and can produce focused visualizations for each cycle.
clarity watch
clarity watch src/auth --reach bothRuns a local live graph that updates as files change. Use it during refactors or large agent edits to keep structural feedback visible.
clarity setupAdds repository instructions so coding agents can use Clarity as part of their normal loop.
Good agent patterns:
- inspect dependents before refactoring with
--reach up - run
clarity show -f mermaidafter edits - generate
clarity show -ufor a shareable review artifact - use the graph to catch unexpected coupling before commit
clarity show -f dot
clarity show -f mermaid
clarity show -uDOT is the default. Mermaid works well in docs, IDEs, and agent UIs. -u
creates a browser-friendly visualization URL.
Clarity supports dependency extraction for:
- C, C++, C#
- Dart
- Go
- Java, Kotlin, Scala
- JavaScript, TypeScript, Svelte
- Markdown
- Python, Ruby
- Rust
- Swift
- Zig
Support quality varies by language. Run:
clarity languagesto see the current maturity and extension list.
clarity cycles
clarity workspacecycles 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:
- full symbol-level call graphs
- runtime behavior analysis
- API contract verification
- semantic correctness guarantees
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.