A knowledge graph for your codebase, written in markdown.
AGENTS.md doesn't scale. A single flat file can describe a small project, but as a codebase grows, maintaining one monolithic document becomes impractical. Key design decisions get buried, business logic goes undocumented, and agents hallucinate context they should be able to look up.
Compress the knowledge about your program domain into a graph — a set of interconnected markdown files that live in a lat.md/ directory at the root of your project. Sections link to each other with [[wiki links]], markdown files link into the codebase ([[src/auth.ts#validateToken]]), source files link back with // @lat: [[section-id]] comments, and lat check ensures nothing drifts out of sync.
-
Faster coding for agents — instead of grepping through your codebase, agents search the knowledge graph to discover key design decisions, constraints, and domain context fast and consistently.
-
Faster workflow for humans — your agents maintain lat files for you. When you review a diff, start with the semantic changes in
lat.md/to understand what changed and why. Reviewing code becomes the secondary task. -
Knowledge retention — the context and reasoning behind your prompts is usually lost after a session ends. With lat, agents capture that knowledge into the graph as they work, so future sessions start with full context instead of rediscovering it from scratch.
-
Test specs with enforcement — test cases can be described as sections in
lat.md/and marked withrequire-code-mention: true. Each spec then must be referenced by a// @lat:comment in test code.lat checkflags any spec without a backlink, so you can review and maintain test coverage from the knowledge graph.
The lat CLI gives agents and humans a system to navigate and maintain the graph:
lat init— sets up popular coding agents with hooks and instructions to keep lat updated and correctlat check— enforces referential consistency; agents call it automatically before finishing worklat searchandlat section— agents use these to understand your prompts and navigate the graph instead of endlessgrepcalls
lat is a workflow that comes with tools — build pre-commit hooks and GitHub bots, run CI tasks that improve the knowledge graph in the background.
npm install -g lat.mdThen run lat init in the repo you want to use lat in.
For validation and navigation without UI, search, or embedding downloads:
npm install -g @lat.md/core
lat-core checklat-core also provides locate, section, refs, expand, external, and paths. Both packages can be installed together; they expose different executable names.
After the first Action release, the prebuilt checker is available from this same repository:
permissions:
contents: read
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: vercel-labs/lat.md@action-v1
with:
working-directory: .
profile: 'false'The Action includes its checker and parser assets. No Node setup, npm install, project build, or embedding credentials are needed. Validation errors fail the job. Use an immutable action-vX.Y.Z tag or commit SHA to pin a release.
Maintainers build and test the artifact with pnpm build:action and pnpm test:action. The Publish check action workflow tests the artifact across Linux, Windows, and macOS before publishing dedicated Action tags. Source branches lack the generated runtime; invoke a released Action tag.
Run lat init to scaffold a lat.md/ directory, then write markdown files describing your architecture, business logic, test specs — whatever matters. Link between sections using [[file#Section#Subsection]] syntax. Link to source code symbols with [[src/auth.ts#validateToken]]. Annotate source code with // @lat: [[section-id]] (or # @lat: [[section-id]] in Python and PHP) comments to tie implementation back to concepts.
my-project/
├── lat.md/
│ ├── architecture.md # system design, key decisions
│ ├── auth.md # authentication & authorization logic
│ └── tests.md # test specs (require-code-mention: true)
├── src/
│ ├── auth.ts # // @lat: [[auth#OAuth Flow]]
│ └── server.ts # // @lat: [[architecture#Request Pipeline]]
└── ...
lat init # scaffold a lat.md/ directory
lat check # run full graph and documentation validation
lat locate "OAuth Flow" # find sections by name (exact, fuzzy)
lat section "auth#OAuth Flow" # show a section with its links and refs
lat refs "auth#OAuth Flow" # find what references a section
lat search "how do we auth?" # semantic search via embeddings
lat expand "fix [[OAuth Flow]]" # expand [[refs]] in a prompt for agents
lat mcp # start MCP server for editor integrationSemantic search (lat search) works offline by default — no API key required. It uses a bundled local embedding model (all-MiniLM-L6-v2, compiled to WebAssembly; no native binaries, no network).
To use higher-quality hosted embeddings instead, provide an OpenAI (sk-...) or Vercel AI Gateway (vck_...) API key, resolved in order:
LAT_LLM_KEYenv var — direct valueLAT_LLM_KEY_FILEenv var — path to a file containing the keyLAT_LLM_KEY_HELPERenv var — shell command that prints the key (10s timeout)- Config file — power users can set
llm_keymanually. Runlat paths --configto print its location. Runlat pathsto see cache and other storage paths with their purposes.
Switch backends any time with lat reindex (--local to force the offline model, --remote to use your key).
Development requires Node.js 22, pnpm, and Rust installed through rustup. The pnpm setup installs the matching WASM target and build tools project-locally. See the development process for complete setup and contribution guidance.
pnpm install
pnpm buildall
pnpm test