DEV Community

Cover image for I Built a Code Archaeology Engine for AI — Here's Why Claude and Cursor Keep Forgetting Your Architecture
EliotShift
EliotShift

Posted on

I Built a Code Archaeology Engine for AI — Here's Why Claude and Cursor Keep Forgetting Your Architecture

I Built a Code Archaeology Engine for AI — Here's Why Claude and Cursor Keep Forgetting Your Architecture

TL;DR: AI coding assistants have zero architectural memory.

LORE MCP Server Cover Every session starts from scratch. I built LORE — an open-source MCP server with 13 analyzers that gives your AI deep understanding of your codebase structure. Works with Claude Desktop, Cursor, and Windsurf.


The Problem: AI Has Amnesia

Every time you start a new AI coding session, the same ritual happens.

You explain: "We use PostgreSQL because..."

Then: "Auth uses JWT with 24h expiry..."

And: "Our API follows REST with /api/v1/..."

The AI nods, understands, writes some code. Session ends.

Next session? Complete amnesia. You repeat everything. Again. And again.

After the 50th time, I stopped explaining and started building.


What I Built: LORE MCP Server

LORE (Layout-Oriented Reverse Engineering) is a code archaeology engine that reads your TypeScript/JavaScript codebase and extracts deep architectural intelligence — automatically.

No manual documentation. No prompts to paste. No CLAUDE.md files to maintain.

npx lore-mcp init
Enter fullscreen mode Exit fullscreen mode

That's the setup. One command. LORE scans your entire project, runs 13 parallel analyzers, and feeds structured results to your AI assistant through the Model Context Protocol.


What Does LORE Actually Analyze?

LORE isn't a simple dependency checker. It runs 13 deep analyzers in parallel:

# Analyzer What It Finds
1 AST Parser Full TypeScript/TSX structure via ts-morph
2 Dependency Graph Every import, export, re-export in your project
3 Circular Dependencies Import cycles ranked by severity
4 Dependency Direction Layer violations (controller importing DB code)
5 Shannon Entropy Complexity scoring per file
6 Hotspot Analysis Files that change too often (git churn)
7 Import Impact Downstream blast radius of every import
8 Type Safety Scorer any usage, explicit types, strictness grades
9 Hidden Coupling Implicit dependencies through shared types
10 AI Recommendations Prioritized fix suggestions (P0–P3)
11 Tooling Config ESLint, Prettier, tsconfig validation
12 Breaking Changes High-risk deprecation patterns
13 Gap Analysis Missing error handling, testing gaps

Here's what lore status looks like on a real project:

$ lore status

  LORE MCP Server v0.1.6
  ────────────────────────────────────

  Architecture Analysis Complete

  ├─ Overall Score:      87/100
  ├─ Type Safety:        92/100
  ├─ Tooling Config:     78/100
  └─ Architecture:       91/100

  Circular Dependencies: 3 found (2 critical)
  Hotspot Modules:       5 detected
  Hidden Coupling:       8 links
  AI Recommendations:    12 suggestions

  Analysis complete — 0 errors, 0 crashes
Enter fullscreen mode Exit fullscreen mode

LORE Status Terminal

Real output from lore status on Express.js project


How It Works: 3 Steps

Step 1: Scan Your Codebase

LORE recursively walks your project tree, parsing every .ts and .tsx file. It reads your AST, maps imports/exports, tracks types, and understands your configuration files.

Step 2: Run 13 Analyzers in Parallel

All 13 analyzers fire simultaneously through a plugin pipeline:

  • Coupling matrices are computed
  • Dependency graphs are mapped
  • Hotspot scoring runs against your git history
  • Type safety is evaluated across every file
  • Circular dependencies are detected and ranked

Step 3: Feed Results to Your AI

Via MCP, Claude Desktop, Cursor, or Windsurf queries LORE on-demand. Your AI now reasons about real structural data — not guesses.

Ask Claude:

  • "What are the hidden coupling risks in my codebase?"
  • "Which modules are the biggest hotspots?"
  • "Show me all circular dependencies and their severity."
  • "What are the P0 recommendations?"

LORE runs the analysis and returns structured data. Claude interprets it and gives you actionable answers.


MCP Integration (60-Second Setup)

Add LORE to your MCP client configuration:

Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "lore": {
      "command": "npx",
      "args": ["-y", "lore-mcp"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Cursor — Add to your MCP settings:

{
  "mcpServers": {
    "lore": {
      "command": "npx",
      "args": ["-y", "lore-mcp"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Restart your AI tool. That's it. Your AI now has architectural memory.


Dependency Graph

LORE generates dependency graphs showing module relationships


Battle-Tested on Real Projects

LORE isn't a toy. I tested it on 16 major open-source TypeScript projects:

Project Files Analyzed Result
Express 42 100% Pass
Next.js 68 100% Pass
NestJS 38 100% Pass
Fastify 55 100% Pass
Prisma 45 100% Pass
Zod 35 100% Pass
TypeORM 60 100% Pass
React 73 100% Pass

16 projects. 100% pass rate. Zero crashes.


Cross-Platform: Runs Everywhere

LORE is built on Node.js with zero native dependencies. If Node.js runs on your system, LORE runs too.

  • macOS (Intel + Apple Silicon M1/M2/M3/M4)
  • All Linux distros (Ubuntu, Debian, Kali, Fedora, Arch, CentOS, Alpine)
  • Windows 10/11
  • CI/CD pipelines (GitHub Actions, GitLab CI, Jenkins)

Only requirement: Node.js 18+. No Docker, no VM, no Rosetta.


The Tech Stack

  • Language: TypeScript 5.5+
  • AST Parsing: ts-morph 21
  • Protocol: Model Context Protocol (MCP) SDK 1.0
  • Transport: Stdio (Claude Desktop / IDE compatible)
  • Validation: Zod schemas
  • Output: ANSI terminal, Markdown, SARIF

CLI Commands

lore [path]            # Analyze project (default: cwd)
lore init              # Extract architectural decisions
lore status            # View decisions by category
lore diff              # Diff against saved baseline
lore doctor            # Environment + tooling check
lore doctor --fix      # Auto-fix project setup
lore watch             # Watch + re-analyze on change
lore mcp inspect       # Inspect MCP server setup
lore mcp config        # Claude Desktop config snippet
lore version           # Show version
Enter fullscreen mode Exit fullscreen mode

Open Source & Local-First

LORE is 100% open source under MIT license. No data leaves your machine. No cloud. No API keys. No telemetry.

Everything runs locally. Your code never gets sent anywhere.


What's Next

  • [ ] LORE INTEGRITY — verify decisions are actually implemented
  • [ ] VS Code Extension
  • [ ] LORE NETWORK — share anonymous architectural patterns
  • [ ] Plugin API — write your own analyzers

Try It Now

# No install needed
npx lore-mcp init

# Or install globally
npm install -g lore-mcp
lore status
Enter fullscreen mode Exit fullscreen mode

GitHub: github.com/EliotShift/lore-mcp
npm: npmjs.com/package/lore-mcp
Docs: eliotshift.github.io/lore-mcp


Built with care from Morocco.

If you found this useful, give LORE a star on GitHub. It helps more than you think.

Top comments (2)

Collapse
 
globalchatapp profile image
Global Chat

The amnesia framing is right, but there is a layer below it I keep hitting. Even with LORE feeding architectural context, different agents working on the same project (Claude Code, Cursor, a background CI agent) each build their own model from scratch. They do not share LORE's output or write back when one of them notices something new. Are you treating LORE as a read-only index, or could it become the write path too, where agents post findings back so the next session starts from an updated graph instead of re-scanning?

Collapse
 
eliotshift profile image
EliotShift • Edited

This is exactly the right question. LORE today is read-only —
but you're describing LORE NETWORK, which is the next major
milestone. The plan is:

  1. .lore/ directory as persistent knowledge graph (JSON)
  2. Every agent session writes findings back after analysis
  3. Next session starts from updated graph, not re-scan
  4. Multi-agent: Claude Code, Cursor, CI all read/write same graph

You're not the only one hitting this wall. It's the biggest gap
in AI-native development right now. LORE NETWORK is designed
to solve exactly this. Stay tuned it's coming in v0.2