SQL on one side.
Markdown on the other.
Lattice is a bidirectional sync engine between a database (SQLite or Postgres) and the rendered context files your agents actually read. Your schema, your render logic, your file format.
Install
The library, the CLI, or a self-updating one-liner. Node 18+. Just want the app? Get the desktop install →
Library
npm install latticesqlCLI + local GUI
npm install -g latticesql
lattice gui # opens the GUI at http://localhost:4317One-liner (macOS / Linux) — brings its own Node if you need it
curl -fsSL https://latticedesktop.com/install.sh | shQuick Start
Define a table. Render a context file. Watch it stay in sync.
import { Lattice } from 'latticesql';
const db = new Lattice('./state.db');
db.define('projects', {
columns: {
id: 'TEXT PRIMARY KEY',
name: 'TEXT NOT NULL',
status: 'TEXT',
owner: 'TEXT',
},
render: 'default-table',
outputFile: 'PROJECTS.md',
});
await db.init();
await db.render('./context');
// → context/PROJECTS.md, ready for any agent to readPrimitives
define()Declare tables with typed columns. Lattice manages schema migrations.
render specsBuilt-in (table/list/detail/json) or your own function. Token-budgeted, cache-friendly.
defineWriteback()Watch a file, parse agent output back into rows. Bidirectional sync, your parser, your validation.
entity contextsOne directory per row with custom templates. Per-entity scope, no monolithic context dumps.
reward trackingScore rows on use; auto-prune below thresholds. Agents converge on what works.
adaptersSQLite via better-sqlite3 (sync, local) or Postgres via pg (async, shared). Same API.
Writeback — Agents as Data Producers
Render specs go SQL → markdown. Writeback pipelines go markdown → SQL. Agent output lands as rows you can query.
db.defineWriteback('agent-notes', {
watchFile: 'context/NOTES.md',
parse(content) {
// Your parser. Returns rows to upsert.
return parseMarkdownNotes(content);
},
persist(rows) {
return db.upsert('notes', rows);
},
});
await db.watch('./context');
// → Agent writes to NOTES.md. Lattice parses + persists to SQL.SQLite Adapter
Synchronous. Local. Fast.
Backed by better-sqlite3. Sub-ms lookups. WAL mode. Ideal for per-developer or per-agent state.
Postgres Adapter
Async. Shared. Production-ready.
Backed by pg. Same Lattice API. Auto-detected from a postgres:// connection string. Use for team-shared state.
Read the Full API.
Schemas, render specs, writeback, entity contexts, reward tracking, adapters — everything in one reference.