DevLens logo # DevLens OSS **See how a codebase fits together. Give your AI agent the same map.** DevLens turns a local repository into a searchable code graph. Trace a request from its route to the code that handles it, see what depends on a function before changing it, or ask your coding agent to find the relevant files and explain the flow. [![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](LICENSE) [![npm: @devlensio/cli](https://img.shields.io/npm/v/@devlensio/cli?logo=npm&color=cb3837)](https://www.npmjs.com/package/@devlensio/cli) [![Built with Bun](https://img.shields.io/badge/Built%20with-Bun-f9f1e1?logo=bun)](https://bun.sh) [Quick start](#quick-start) · [Web UI & Code View](#see-it-the-web-ui) · [AI agents & MCP](#use-it-with-your-ai-agent-mcp) · [CLI](#cli) · [Benchmarks](#benchmarks)
| Use | What it helps you do | | :-- | :-- | | [**Web UI & Code View**](#see-it-the-web-ui) | Get your bearings in an unfamiliar repo, then follow a call into the source without losing your place. | | [**MCP for AI agents**](#use-it-with-your-ai-agent-mcp) | Give Claude Code, Cursor, Codex, or Hermes a way to look up symbols, trace a feature, and check the impact of a change before editing. | | [**CLI**](#cli) | Get an architecture brief in your terminal, compare analyzed commits during a review, or pipe JSON into a script. | [![Watch the DevLens walkthrough](assets/demo-thumbnail.png)](https://www.youtube.com/watch?v=oHQT35Lv6_k) ## See it: the Web UI DevLens architecture graph with labeled central nodes, filters, and a node sidebar *Start with the architecture. Search for a route, component, or function and zoom in on the code that matters to your task.* ### Trace a feature before you change it 1. **Find the entry point.** Search for a route or handler. Filter by node or relationship type if the graph is busy. 2. **Follow the calls.** The **Flow** tab shows resolved calls and, where supported, hooks and rendered children in source order. This is static analysis, not a runtime trace. 3. **Read the code side by side.** In **Code View**, click a call badge to open the callee beside its caller. Each card shows syntax-highlighted source with its file path and line numbers. To read just one node, use the panel's **Code** tab. 4. **Check the blast radius.** Find upstream dependents before refactoring, or use **K-hop** to see what the symbol depends on. When reviewing a PR, compare two analyzed commits to see what changed in the graph.
More screenshots: Flow, Code View, filters, and blast radius
Node panel and Flow tab Hover card over the graph
The node panel and Flow tab show what a symbol does and which calls appear in its source. Hover without committing: score, hooks, local state, a collapsed summary, and the two ways in. The graph, toolbar and filters stay where they are.
A code card with technical, business and security summaries expanded Filter control centre
Inside a code card: technical, business and security are independent sections, technical open by default. Security carries its severity (HIGH here). Filter by node type, edge type, score, rendering boundary and entry-point reach, with live counts from your graph.
Code view with three cards Six code cards connected by call arrows
Two callees open beside their caller — the common case while reading. Click a badge to add a card, Auto-arrange to lay them out. The same view at six cards: a call tree on one canvas, arrows showing direction, Back closing them one at a time.
Blast radius — what depends on this node
Blast radius at two hops shows upstream dependents. K-hop follows downstream dependencies.
### Run the Web UI Use Bun 1.2+ and Node.js 20.9+ for the source checkout. The Web UI is not bundled with the npm CLI. ```bash git clone https://github.com/devlensio/devlensOSS.git cd devlensOSS bun install bun start ``` Open **http://localhost:3000** (or the URL printed by `bun start`) and analyze a local checkout. If you've already analyzed it with the CLI, open it directly: the UI and CLI use the same graph store under `~/.devlens/`. ## Quick start Install the CLI to explore from your terminal or connect an agent. If you only want the browser, [run the Web UI](#run-the-web-ui) instead. ```bash npm install -g @devlensio/cli cd /path/to/your/repo devlens analyze . devlens overview ``` `analyze` builds the graph and its search index. **You don't need an API key to build or query the graph.** See the [CLI install guide](src/cli/README.md#install) for standalone binaries and language runtime requirements. ## Use it with your AI agent (MCP) DevLens includes a **Model Context Protocol (MCP) server** in the CLI. It gives your agent access to the same graph you explore in the Web UI. Instead of starting an architecture question with a broad file search, the agent can ask DevLens for relevant symbols, call relationships, file references, and short snippets in a token-budgeted response. It can then open the source it needs to verify the answer. **Try asking your agent:** > Use DevLens to trace checkout from its entry point. Show the main calls and cite the files and lines I should read. > Before editing `createOrder`, use DevLens to find its callers and tell me what might be affected. Don't change any files yet. > Use DevLens to give me an onboarding tour. Pick three entry points and explain why each one matters. ### Connect an MCP client Run `devlens analyze .` in your repo first. Launch the agent in that checkout when possible. If its MCP server runs from another folder, give the agent the absolute repo path so it can pass `repoPath` to `resolve_context`. The client starts `devlens mcp` for you over stdio; the Web UI does not need to be running. **Claude Code** (run from the repo): ```bash claude mcp add devlens -- devlens mcp ```
Cursor, Claude Desktop, Codex, Hermes, and other clients **Cursor** (`.cursor/mcp.json`) or **Claude Desktop** (its MCP config): ```json { "mcpServers": { "devlens": { "command": "devlens", "args": ["mcp"] } } } ``` If a desktop client cannot find `devlens`, use the full path to the executable. For Claude Desktop on Windows, see the [Windows example](docs/mcp-reference.md#quick-start). **Codex** (`~/.codex/config.toml`): ```toml [mcp_servers.devlens] command = "devlens" args = ["mcp"] ``` **Hermes** (`~/.hermes/config.yaml`): ```yaml mcp_servers: devlens: command: devlens args: [mcp] ``` **Other clients:** use the stdio command `devlens mcp`. For Streamable HTTP, run `devlens mcp http -p 7000` from your repo and point the client at `http://localhost:7000/mcp`. Don't expose this endpoint publicly: its tools can return source snippets.
### What the agent can query | Tool | When to use it | | :-- | :-- | | `resolve_context` | Start with a question about the repo. Get ranked symbols, call flow, and file and line references within a token budget. | | `find_symbols` | Find symbols by name, path, or keywords. | | `get_node` | Inspect a symbol's callers, callees, available summaries, and optional source. | | `blast_radius` | Check upstream dependents or downstream dependencies, or compare two analyzed commits. | | `repo` | List analyzed repos, analyze a folder, or check graph freshness and health. | [Full MCP reference and example responses](docs/mcp-reference.md) ## CLI Run these inside an analyzed checkout. Use `--json` on query commands to pipe results into a script or CI job. ```bash devlens architecture # Get a brief on modules, routes, and flows devlens find-nodes -t ROUTE # Find entry points devlens get-context "checkout flow" # Get a context packet without an MCP client devlens check-freshness # Check whether the graph matches HEAD ``` | I want to… | Use | | :-- | :-- | | Inspect a symbol or read its source | `devlens get-node ` or `devlens node-code ` | | Check the impact before editing | `devlens blast-radius ` for dependents; `devlens khop ` for dependencies | | Review a change once both commits are analyzed | `devlens diff ` or `devlens review-pr ` | | Find circular dependencies | `devlens cycles` | [Full CLI reference](src/cli/README.md) ## Optional AI summaries The graph, Code View, and MCP queries work without a DevLens model provider. Configure one if you want technical, business, and security summaries alongside the source. ```bash devlens init devlens summarize . # Add summaries to an existing graph # Or run devlens analyze . --summarize when analyzing a repo ``` In the Web UI, open **Config**, choose **OpenAI-compatible** or **Anthropic**, enter the provider name, base URL, API key, and model, then click **Save** and **Set active**. Both setup paths use `~/.devlens/config.json`. A hosted model provider or agent can receive code or snippets used in its requests. ## What DevLens understands DevLens uses language-specific parsers to link symbols, routes, calls, imports, and framework relationships such as navigation and data access. Coverage varies by language and framework. | Language | Frameworks / stacks the graph understands | What gets parsed | | :-- | :-- | :-- | | **TypeScript / JavaScript** | React, Next.js (app and pages router), Express/Hono/Fastify, React Router, TanStack Router, any Node | components, hooks, state stores, classes, methods, functions, routes | | **Python** | FastAPI, Flask, Django (+DRF), SQLAlchemy / Django ORM, Celery, Pydantic | classes, methods, functions, routes, data models | | **Java** | Spring Boot (controllers, JPA, Spring Data repositories) | classes, methods, interfaces, enums, routes | | **Go** | net/http, Gin, Echo, chi, Fiber, GORM, database/sql | structs, interfaces, methods, functions, routes | | **Rust** | axum, actix-web, rocket, utoipa, Diesel | structs, enums, traits, impl blocks, methods, functions, routes |
Graph legend: node and edge types **Node types** (the legend colour and the node's shape both follow this): | Type | What it is | | :-- | :-- | | `ROUTE` | An HTTP route or page — a real node, so you can start from a URL and walk inward. | | `COMPONENT` | A React (or equivalent) component. | | `HOOK` | A React hook: shared stateful logic. | | `STATE_STORE` | A store, context or atom — where state actually lives. | | `STORY` | A Storybook story. | | `FUNCTION` | A free function. | | `METHOD` | A method on a class, struct or trait impl. | | `UTILITY` | A helper module whose exports are used everywhere. | | `TEST` | A test file or case. | | `CLASS` | A class. | | `INTERFACE` | An interface, protocol or abstract base class. | | `STRUCT` | A struct or record type. | | `TRAIT` | A Rust trait. | | `IMPL_BLOCK` | A Rust `impl` block. | | `ENUM` | An enum. | | `MODULE` | A module or namespace. | | `PACKAGE` | An external package. | | `FILE` | A source file, used for the file-level view and for languages without finer nodes. | | `THIRD_PARTY` | A resolved method on a third-party dependency. | | `GHOST` | A placeholder for a call or import the parser could not resolve to real code — visible on purpose, so gaps are not silent. | **Edge types** (the arrows, and the verbs in the panels): | Edge | Means | | :-- | :-- | | `CALLS` | This node invokes the target inside its own body. | | `USES` | References the target without calling it — a type, constant or import. | | `IMPORTS` | Imports the target's module. | | `PROP_PASS` | Passes the target down as a prop, slot or child component. | | `HANDLES` | Registers the target as an event or callback handler. | | `EMITS` | Emits an event the target listens for. | | `LISTENS` | Subscribes to an event the target emits. | | `READS_FROM` | Reads state or data owned by the target. | | `WRITES_TO` | Mutates state or data owned by the target. | | `NAVIGATES_TO` | Navigation target — a URL this node routes to. | | `NEXTJS_API_CALL` | Calls a Next.js API route over HTTP. | | `TESTS` | A test that exercises the target. | | `EXTENDS` | Inherits from the target class. | | `IMPLEMENTS` | Implements the target interface, trait or ABC. | | `GUARDS` | Middleware or guard protecting the target. | | `WRAPPED_BY` | Wrapped by the target (higher-order component or decorator). | | `THROWS` | Throws or raises the target's error type. | | `EXPORTS` | Re-exports the target from this module. |
## Benchmarks In a benchmark with 133 questions on one TypeScript repo, DevLens returned smaller context packets than Graphify and codegraph and had the lowest per-call latency in the table. The retrieval and agent-loop scores measure different things. | | **DevLens V3 (5 tools)** | **Graphify** | codegraph | semble | bm25 | | :-- | :-- | :-- | :-- | :-- | :-- | | Correctness (agent loop, same run) | **0.643** | 0.619 | 0.667 | 0.714 | 0.667 | | F1 (agent loop, same run) | **0.529** | 0.526 | 0.604 | 0.636 | 0.581 | | Correctness (retrieval layer) | **0.694** | 0.662 | 0.674 | 0.652 | 0.664 | | Response packet | **2,230 tokens** | 15,020 tokens | 6,339 tokens | 736 tokens | 721 tokens | | Latency per call | **67 ms** | 2,469 ms | 2,736 ms | 508 ms | 108 ms | [Full results and methodology](docs/PUBLIC-BENCHMARKS.md) ## Project links - [Web UI development](frontend/README.md) · [CLI source](src/cli/) · [MCP source](src/mcp/) - [Analysis engine package](https://www.npmjs.com/package/devlensio) · [MCP search index and packet format](docs/mcp-reference.md) - [DevLens Cloud waitlist](https://devlens.io) - [License: AGPL-3.0](LICENSE)