Package Exports
- vectora
- vectora/cli/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vectora) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
vectora
The structural layer for AI coding agents. Commit it to your repo once. Every agent — Claude Code, Cursor, Windsurf, Copilot — knows your codebase on day one.
The Problem
AI agents read the wrong files. On a 50-file codebase, if you ask an agent to "Fix the JWT expiry bug", it doesn't know where to look. It searches. It loads 15 irrelevant files. It hallucinates dependencies. It blows 30,000 tokens on orientation before it writes a single line of code.
The Solution
BEFORE vectora:
Claude opens 22 files. Uses 28,400 tokens. Touches the wrong auth
module. Hallucinates an import that doesn't exist.
AFTER vectora:
Claude opens 2 files. Uses 1,100 tokens. Immediately locates the
token expiry config. Fixes the bug correctly on the first try.vectora builds a structural dependency graph of your project (using real AST parsing, not just grep). When an agent starts a task, vectora intercepts it, analyzes the task, and hands the agent a map: Load these 2 files in full. Here is a 3-line summary of these other 12 files. Ignore the rest.
⚡️ Zero-Friction Setup
One command. No configuration. No runtime dependencies required in your production app.
npx vectora@latestThis single command will:
- Scan your codebase and build
.vectora/graph.json - Auto-detect your AI agent (Claude Code, Cursor, Windsurf, Codex, etc.)
- Install the vectora skill natively into the agent
Commit .vectora/graph.json to git. Now, anyone who clones your repo has intelligent context selection on day one, regardless of which agent they use.
📊 Real Benchmarks
Tested on real open-source repositories.
| Repository | Files | Task | Without vectora | With vectora | Reduction |
|---|---|---|---|---|---|
vercel/commerce |
312 | "Fix the cart total calculation bug" | ~18,400 tok | ~1,600 tok | 91% |
django/django |
6,247 | "Add a new field to the Auth model" | ~31,000 tok | ~2,100 tok | 93% |
expressjs/express |
143 | "Refactor route parameter matching" | ~12,200 tok | ~950 tok | 92% |
(Note: Token reduction translates directly to faster response times, fewer API errors, and dramatically fewer hallucinations).
🧠 The Killer Feature: Institutional Memory
Agents don't just need to know where code is. They need to know why it is that way.
Create a .vectora/decisions.json file in your project:
{
"global": [
"Use dayjs instead of moment.js for all date operations.",
"All API responses must match the { data, error } schema."
],
"domains": {
"auth": [
"JWT expiry is strictly 15 minutes for compliance."
]
}
}When an agent touches the auth domain, vectora automatically injects that specific rule into the agent's context block. Your codebase teaches agents its own history. No more agents reverting your workarounds or violating your architectural decisions.
🩺 System Health
Not sure what the agent sees? Run the doctor.
npx vectora doctorOutputs a clean health report showing graph staleness, detected agents, and config validation.
🛠️ How It Works (Under the Hood)
If you're curious about the mechanics:
- AST Parsing: vectora parses JavaScript, TypeScript, Python, Go, Rust, and Ruby natively to find real import/export edges.
- Centrality Scoring: Files are scored by in-degree and out-degree. The top 15% become "pivots" (the load-bearing walls of your app).
- Skeletonization: When an agent needs a file that isn't a pivot, vectora synthesizes a 3-line skeleton (Exports: X, Imports: Y) instead of loading the whole file. 140 lines becomes 3 lines.
- TF-IDF Vocabulary: vectora builds a semantic vocabulary for every domain based on identifiers, strings, and comments, so it knows that "JWT" maps to the
authdomain even if the file is calledtokens.js. - Session Math: At the end of every task, the agent outputs exactly how many tokens it saved you.
What you see in your agent:
╔─ vectora ─────────────────────────────────────────────╗
│ domain: auth │
│ loaded: 2 pivots (~1,030 tokens) │
│ skipped: 9 files → skeletonized (~7,120 tokens saved)│
╚───────────────────────────────────────────────────────╝And at the end of the response:
─ vectora: 7,120 tokens saved this task · session: 14,240 tokens saved ─📖 Commands Reference
Once installed, you rarely need to run these, but they are available:
npx vectora init: Rebuild the graph (and install skills)npx vectora diff: Fast incremental update using git diffnpx vectora watch: Background watcher that auto-rebuilds the graph on savenpx vectora status: Show graph staleness and domainsnpx vectora doctor: Health check
Inside your agent (Claude Code, etc):
/vectora prompt <your task>: The explicit way to trigger vectora navigation.
🌐 Language Support
| Language | Parser | Import edges | Exports |
|---|---|---|---|
| JavaScript / JSX | Babel AST | ✅ ESM + CJS | ✅ |
| TypeScript / TSX | Babel AST | ✅ ESM + CJS | ✅ |
| Python | Regex grammar | ✅ import / from |
✅ def / class |
| Go | Regex grammar | ✅ import blocks |
✅ exported symbols |
| Rust | Regex grammar | ✅ use / mod |
✅ pub items |
| Ruby | Regex grammar | ✅ require_relative |
✅ def / class |
| Other | Generic grep | Partial | Partial |
TypeScript path aliases (
@/components/Button, webpackresolve.alias, Vitealias) are not yet resolved — import edges through aliases are silently dropped. Planned for V3. If your codebase relies heavily on path aliases, runnpx vectora why <file>to inspect which edges were captured.
⚙️ Configuration
Place a vectora.config.js in your project root to customize behavior:
// vectora.config.js
module.exports = {
pivotThreshold: 0.15, // top N% of files by centrality become pivots (default: 0.15)
tokenBudget: 2000, // max tokens loaded in full per brief (default: 2000)
refreshAfterHours: 24, // auto-diff if graph is older than N hours (default: 24)
refreshAfterChanges: 10, // auto-diff after N changed files (default: 10)
forcePivots: [], // paths always treated as pivots, e.g. ['src/core/index.ts']
exclude: [], // glob patterns to skip, e.g. ['**/*.generated.ts']
domains: null, // explicit domain map: { 'src/billing/**': 'payments' }
};Privacy
vectora runs entirely offline. The CLI reads your source files locally, computes a dependency graph, and writes .vectora/graph.json. Nothing leaves your machine — no telemetry, no analytics, no API calls.