DEV Community

Cover image for $0.60 per session, just on orientation. Here is what my AI agent was doing before writing any code.
GDS K S
GDS K S

Posted on

$0.60 per session, just on orientation. Here is what my AI agent was doing before writing any code.

GitHub: github.com/glincker/stacklit | npm: npx stacklit init


I have been counting.

Every time I open Claude Code on a repo, it reads 8 to 12 files before doing anything useful. read_file src/auth/service.ts. read_file src/db/connection.ts. One after another. Just orientation. Figuring out what goes where.

On a medium repo, that costs about 400,000 tokens. The agent burns through its context window before writing a single line.

Second session? Same files. Same cost. There is no memory. No map. No way for one agent's exploration to benefit the next.

The file nobody made yet

.gitignore tells git what to skip. package.json tells npm what to install. But nothing tells AI agents how your code is organized.

So I made it.

npx stacklit init
Enter fullscreen mode Exit fullscreen mode

cover

One command scans your codebase and generates stacklit.json:

{
  "modules": {
    "src/auth": {
      "purpose": "Authentication and session management",
      "files": 8,
      "lines": 1200,
      "exports": ["AuthProvider", "useSession()", "loginAction()"],
      "depends_on": ["src/db", "src/config"],
      "activity": "high"
    }
  },
  "hints": {
    "add_feature": "Create handler in src/api/, add route in src/index.ts",
    "test_command": "npm test"
  }
}
Enter fullscreen mode Exit fullscreen mode

Commit it. Now every agent that touches your repo already knows the structure.

Real numbers, not marketing

I ran Stacklit on four popular open source projects and counted the tokens:

Project Language Lines of code Stacklit index tokens
Express.js JavaScript 21,346 3,765
FastAPI Python 108,075 4,142
Gin Go 23,829 3,361
Axum Rust 43,997 14,371

FastAPI. 108,000 lines of Python. The entire project structure fits in 4,142 tokens. That is less than what an agent burns reading one large file.

What you actually get

Three files from one command:

stacklit.json -- The index. Modules, dependencies, exports, type definitions, git activity, framework detection, hints. Committed to git. Any agent reads it.

DEPENDENCIES.md -- A Mermaid dependency diagram. Renders directly on GitHub. Click the file in your repo and see the graph.

Stacklit OG

stacklit.html -- An interactive visual map. Four views: graph, tree, table, flow. Opens in a browser, works without a server. Gitignored because you regenerate it locally.

11 languages via tree-sitter

Stacklit does not use regex to guess at your code. It uses tree-sitter, the same parser that powers syntax highlighting in VS Code, Neovim, and GitHub. Full AST parsing.

Language What it extracts
Go imports, exports with signatures, struct fields, interface methods
TypeScript/JS imports (ESM, CJS, dynamic), classes, interfaces, type aliases
Python imports, classes with methods, type hints, decorators
Rust use/mod/crate, pub items with generics, trait methods
Java imports, public classes, method signatures with types
C# using directives, public types, method signatures
Ruby require, classes, modules, method definitions
PHP namespace use, classes, traits, public methods
Kotlin imports, classes, objects, functions
Swift imports, structs, classes, protocols
C/C++ includes, functions, structs, typedefs

Plus generic fallback for anything else (line count and language detection).

It also has an MCP server

stacklit serve
Enter fullscreen mode Exit fullscreen mode

Seven tools. get_overview, get_module, find_module, list_modules, get_dependencies, get_hot_files, get_hints.

Add three lines to your Claude Desktop or Cursor config:

{
  "mcpServers": {
    "stacklit": {
      "command": "stacklit",
      "args": ["serve"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Now your agent calls get_overview() once instead of reading a dozen files to build context.

How it compares

Stacklit Repomix Aider repo-map Codebase Memory MCP
Output size ~4k tokens 500k+ tokens Ephemeral SQLite DB
Committed to repo Yes Too large No No
Dependency graph Yes No Yes Yes
Visual output HTML (4 views) No No No
MCP server Yes No No Yes
Runtime needed No No Yes Yes

Install

npx stacklit init          # npm
go install github.com/glincker/stacklit/cmd/stacklit@latest  # go
Enter fullscreen mode Exit fullscreen mode

Single binary. Zero dependencies. Runs in under 100ms on most repos.

The whole thing is MIT licensed and open source.

GitHub: github.com/glincker/stacklit

If this is useful, a star helps other developers find it.


Top comments (0)