Skip to content

Commit c6dc2cb

Browse files
authored
docs(readme): make CLI the primary interface (#30)
## Summary - reposition README as CLI-first instead of MCP-first - move MCP setup under an explicit secondary integration section - add CLI-centric quick start and command-oriented usage guidance ## Why The project now presents CLI as the primary interface and MCP as optional, aligning repository messaging with intended usage. ## Testing - docs-only change
1 parent d47fd27 commit c6dc2cb

File tree

1 file changed

+87
-69
lines changed

1 file changed

+87
-69
lines changed

README.md

Lines changed: 87 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# codebase-intelligence
44

5-
**Codebase analysis engine for TypeScript projects.**
5+
**CLI-first codebase analysis for TypeScript projects.**
66

7-
Parse your codebase, build a dependency graph, compute architectural metrics, and query it all via MCP for LLM-assisted code understanding.
7+
Parse your codebase, build a dependency graph, compute architectural metrics, and query everything from your terminal/CI. MCP support is included as an optional secondary interface.
88

99
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
1010
[![Node](https://img.shields.io/badge/Node-%3E%3D18-brightgreen)](https://nodejs.org)
@@ -16,83 +16,116 @@ Parse your codebase, build a dependency graph, compute architectural metrics, an
1616

1717
## Quick Start
1818

19-
### Claude Code (one-liner)
19+
### CLI (recommended)
2020

2121
```bash
22-
claude mcp add -s user -t stdio codebase-intelligence -- npx -y codebase-intelligence@latest .
22+
npx codebase-intelligence overview ./src
2323
```
2424

25-
Done. Available in all projects. Verify with `/mcp` inside Claude Code.
25+
Common workflows:
26+
27+
```bash
28+
npx codebase-intelligence hotspots ./src --metric complexity --limit 10
29+
npx codebase-intelligence impact ./src parseCodebase
30+
npx codebase-intelligence dead-exports ./src --limit 20
31+
npx codebase-intelligence changes ./src --json
32+
```
2633

27-
To scope to a single project instead:
34+
### MCP (optional)
2835

2936
```bash
30-
claude mcp add -s project -t stdio codebase-intelligence -- npx -y codebase-intelligence@latest ./src
37+
claude mcp add -s user -t stdio codebase-intelligence -- npx -y codebase-intelligence@latest .
3138
```
3239

3340
## Table of Contents
3441

3542
- [Features](#features)
3643
- [Installation](#installation)
37-
- [Usage](#usage)
38-
- [MCP Integration](#mcp-integration)
44+
- [CLI Usage](#cli-usage)
45+
- [MCP Integration (Secondary)](#mcp-integration-secondary)
3946
- [Metrics](#metrics)
4047
- [Architecture](#architecture)
4148
- [Requirements](#requirements)
4249
- [Limitations](#limitations)
50+
- [Release](#release)
4351
- [Contributing](#contributing)
4452
- [License](#license)
4553

4654
## Features
4755

48-
- **15 MCP tools** — codebase overview, file context, hotspots, module structure, force analysis, dead exports, symbol context, search, impact analysis, rename planning, process tracing, community detection, and more
49-
- **2 MCP prompts** — detect_impact, generate_map
50-
- **3 MCP resources** — clusters, processes, setup guide
56+
- **15 CLI commands** for architecture analysis, dependency impact, dead code detection, and search
57+
- **Machine-readable JSON output** (`--json`) for automation and CI pipelines
58+
- **Auto-cached index** in `.code-visualizer/` for fast repeat queries
5159
- **11 architectural metrics** — PageRank, betweenness, coupling, cohesion, tension, churn, complexity, blast radius, dead exports, test coverage, escape velocity
52-
- **Symbol-level analysis**call graph with callers/callees, symbol PageRank, per-symbol impact analysis
53-
- **BM25 search**find files and symbols by keyword with ranked results
54-
- **Process tracing** — detect entry points and trace execution flows through the call graph
55-
- **Community detection** — Louvain algorithm discovers natural file groupings beyond directory structure
56-
- **Graph persistence**cache parsed graphs to `.code-visualizer/` for instant startup
60+
- **Symbol-level analysis** — callers/callees, symbol importance, impact blast radius
61+
- **BM25 search**ranked keyword search across files and symbols
62+
- **Process tracing** — detect entry points and execution flows through the call graph
63+
- **Community detection** — Louvain clustering for natural file groupings
64+
- **MCP parity (secondary)**same analysis available as 15 MCP tools, 2 prompts, and 3 resources
5765

5866
## Installation
5967

60-
Run directly with npx (no install needed):
68+
Run directly with npx (no install):
6169

6270
```bash
63-
npx codebase-intelligence ./src
71+
npx codebase-intelligence overview ./src
6472
```
6573

6674
Or install globally:
6775

6876
```bash
6977
npm install -g codebase-intelligence
70-
codebase-intelligence ./src
78+
codebase-intelligence overview ./src
7179
```
7280

73-
## Usage
81+
## CLI Usage
7482

7583
```bash
76-
npx codebase-intelligence ./src
77-
# => Parsed 142 files, 387 functions, 612 dependencies
78-
# => MCP stdio server started
84+
codebase-intelligence <command> <path> [options]
7985
```
8086

81-
### Options
87+
### Commands
88+
89+
| Command | What it does |
90+
|---|---|
91+
| `overview` | High-level codebase snapshot |
92+
| `hotspots` | Rank files by metric (coupling, churn, complexity, blast radius, coverage, etc.) |
93+
| `file` | Full context for one file |
94+
| `search` | BM25 keyword search |
95+
| `changes` | Git diff analysis with risk metrics |
96+
| `dependents` | File-level blast radius |
97+
| `modules` | Module architecture + cross-dependencies |
98+
| `forces` | Cohesion/tension/escape-velocity analysis |
99+
| `dead-exports` | Unused export detection |
100+
| `groups` | Top-level directory groups + aggregate metrics |
101+
| `symbol` | Callers/callees and symbol metrics |
102+
| `impact` | Symbol-level blast radius |
103+
| `rename` | Reference discovery for rename planning |
104+
| `processes` | Entry-point execution flow tracing |
105+
| `clusters` | Community-detected file clusters |
106+
107+
### Useful flags
108+
109+
| Flag | Description |
110+
|---|---|
111+
| `--json` | Stable JSON output |
112+
| `--force` | Rebuild index even if cache is valid |
113+
| `--limit <n>` | Limit results on supported commands |
114+
| `--metric <m>` | Select ranking metric for `hotspots` |
115+
116+
For full command details, see [docs/cli-reference.md](docs/cli-reference.md).
117+
118+
## MCP Integration (Secondary)
119+
120+
Running without a subcommand starts the MCP stdio server (backward compatible):
82121

83-
| Flag | Description | Default |
84-
|------|-------------|---------|
85-
| `<path>` | Path to TypeScript codebase | required |
86-
| `--index` | Persist graph index to `.code-visualizer/` | off |
87-
| `--force` | Re-index even if HEAD unchanged | off |
88-
| `--status` | Print index status and exit | - |
89-
| `--clean` | Remove `.code-visualizer/` index and exit | - |
90-
91-
## MCP Integration
122+
```bash
123+
npx codebase-intelligence ./src
124+
```
92125

93126
### Claude Code (manual)
94127

95-
Add to `.mcp.json` in your project root:
128+
Add to `.mcp.json`:
96129

97130
```json
98131
{
@@ -122,25 +155,7 @@ Add to `.cursor/mcp.json` or `.vscode/mcp.json`:
122155
}
123156
```
124157

125-
### MCP Tools
126-
127-
| Tool | What it does |
128-
|------|--------------|
129-
| `codebase_overview` | High-level architecture: modules, entry points, key metrics |
130-
| `file_context` | Everything about one file: exports, imports, dependents, metrics |
131-
| `get_dependents` | File-level blast radius: what breaks if you change this file |
132-
| `find_hotspots` | Ranked files by any metric (coupling, churn, complexity, etc.) |
133-
| `get_module_structure` | Module map with cross-deps, cohesion, circular deps |
134-
| `analyze_forces` | Module health: tension files, bridges, extraction candidates |
135-
| `find_dead_exports` | Unused exports that can be safely removed |
136-
| `get_groups` | Top-level directory groups with aggregate metrics |
137-
| `symbol_context` | Callers, callees, importance metrics for any function or class |
138-
| `search` | Find files and symbols by keyword with ranked results |
139-
| `detect_changes` | Git diff with risk metrics per changed file |
140-
| `impact_analysis` | Symbol-level blast radius with depth-grouped risk labels |
141-
| `rename_symbol` | Find all references to a symbol (read-only, for rename planning) |
142-
| `get_processes` | Trace execution flows from entry points through the call graph |
143-
| `get_clusters` | Community-detected clusters of related files |
158+
For MCP tool details, see [docs/mcp-tools.md](docs/mcp-tools.md).
144159

145160
## Metrics
146161

@@ -160,21 +175,24 @@ Add to `.cursor/mcp.json` or `.vscode/mcp.json`:
160175

161176
## Architecture
162177

163-
```
164-
codebase-intelligence <path>
178+
```text
179+
codebase-intelligence <command> <path>
165180
|
166181
v
167-
+---------+ +---------+ +----------+ +---------+
168-
| Parser | --> | Graph | --> | Analyzer | --> | MCP |
169-
| TS AST | | grapho- | | metrics | | stdio |
170-
| | | logy | | | | |
171-
+---------+ +---------+ +----------+ +---------+
182+
+---------+ +---------+ +----------+
183+
| Parser | --> | Graph | --> | Analyzer |
184+
| TS AST | | grapho- | | metrics |
185+
| | | logy | | |
186+
+---------+ +---------+ +----------+
187+
|
188+
+--> CLI output (default)
189+
+--> MCP stdio (optional mode)
172190
```
173191

174-
1. **Parser** — extracts files, functions, and imports via the TypeScript Compiler API. Resolves path aliases, respects `.gitignore`, detects test associations.
175-
2. **Graph** — builds nodes and edges with [graphology](https://graphology.github.io/). Detects circular deps via iterative DFS.
176-
3. **Analyzer** — computes all 11 metrics plus group-level aggregations.
177-
4. **MCP**exposes 15 tools, 2 prompts, and 3 resources via stdio for LLM agents.
192+
1. **Parser** — extracts files, functions, and imports via TypeScript Compiler API.
193+
2. **Graph** — builds dependency/call graphs with [graphology](https://graphology.github.io/).
194+
3. **Analyzer** — computes file/module/symbol metrics.
195+
4. **Interfaces**CLI is primary; MCP is available for agent integrations.
178196

179197
## Requirements
180198

@@ -183,9 +201,9 @@ codebase-intelligence <path>
183201

184202
## Limitations
185203

186-
- TypeScript only (no JS CommonJS, Python, Go, etc.)
187-
- Static analysis only (no runtime/dynamic imports)
188-
- Call graph confidence varies: type-resolved calls are reliable, text-inferred calls are best-effort
204+
- TypeScript-focused analysis
205+
- Static analysis only (no runtime tracing)
206+
- Call graph confidence varies by symbol resolution quality
189207

190208
## Release
191209

@@ -208,7 +226,7 @@ Publishing is automated and **only happens on `v*` tags**.
208226
3. Tag: `git tag vX.Y.Z`
209227
4. Push: `git push origin main --tags`
210228

211-
The `v*` tag triggers the `CI` workflow's **publish** job, which runs `npm publish --access public --provenance`.
229+
The `v*` tag triggers the `CI` workflow publish job (`npm publish --access public --provenance`).
212230

213231
## Contributing
214232

0 commit comments

Comments
 (0)