Build a specification

To represent you, an AI agent has to understand you.

Base Layer is an open-source pipeline that turns your writing into a specification for AI agents. It uses your chats, essays, notes and transcripts to write plain-text claims about how you reason, communicate and decide. An agent reads the specification before acting for you.

Each claim cites the facts behind it. Each fact quotes your own words. You can check any claim and correct it.

To see a finished specification before you spend anything, read the Zitkala-Sa example.

Install

Base Layer needs Python 3.10 or later and git. It reads your model API key from the ANTHROPIC_API_KEY environment variable (get a key). Set the key in your shell profile or a secrets manager. Do not type it into a command.

pip install git+https://github.com/agulaya24/BaseLayer.git

Base Layer is pre-1.0 (version 0.5.0) and is not on PyPI. The baselayer name on PyPI belongs to another project.

Run it on your own writing, or on writing by someone who has agreed to it.

The cited build

The cited build is the process we use to make specifications. It extracts facts from the person's own words. Each fact quotes the passage it came from. The build then groups the facts and writes claims that cite them. It checks every citation and quote before writing the files an agent reads.

A specification has three layers. ANCHORS describe the certainties the person reasons from. CORE describes how they communicate. PREDICTIONS describe how they are likely to respond in a given kind of situation.

The cited build takes eight commands in a fresh data root, the directory that holds the database. The commands are init, import, extract --turn-contract, distill and assemble for each layer, author-from-package, verify-spec and consolidate. The build also needs a file listing the names the person goes by.

distill and author-from-package print a cost estimate before they start. Neither will run unless you set a spend ceiling at or above its estimate.

consolidate writes two files, served.txt and index.json. You put them in an agent's system prompt by hand. Base Layer cannot yet serve them to an agent automatically.

The full command sequence is in PIPELINE.md section 14, along with the batch setup used for the measured builds.

A quicker start in Claude Code

baselayer run is the older, quicker pipeline. It takes one command and serves its result to Claude Code over MCP (Model Context Protocol). It makes far fewer checks than the cited build. The second line below requires Claude Code.

baselayer run chatgpt-export.zip     # or claude-export.json, a folder of journals, notes.md
claude mcp add --scope user --transport stdio base-layer -- baselayer-mcp

On the first run, baselayer run asks for consent and for the writer's name and pronouns. --accept-data-processing answers the consent prompt. The pipeline estimates the extraction cost and asks before spending. The estimate covers extraction only and has been too low, so treat it as a floor.

The result is three markdown files in data/identity_layers/ inside the data root. The data root defaults to ~/.baselayer. The second line registers the MCP server, which serves those files to new Claude Code sessions in any folder.

To build a specification for someone else, use a fresh data root so their facts do not mix with yours. The README quick start shows how.

Cost

The table shows API spend for one specification by corpus size. Figures marked derived use recorded token usage from cited builds made in September and October 2026, with extraction repriced for Claude Haiku 5.5. Figures marked projected scale those builds' costs per fact.

The cited build column uses the batch setup. Extraction and distill run through Anthropic's Message Batches API at half price, as in every measured build. Running the eight commands as written, at full rate, costs roughly 1.7 to 1.9 times as much.

corpus facts cited build, batch setup baselayer run
about 50,000 words of essays or posts about 1,000 $5 to $7, projected $1 to $2, projected
about 150,000 words of posts and talk transcripts about 3,000 about $17, projected $3 to $4, projected
about 300,000 words of long essays about 5,000 about $28, derived about $6, projected
a chat history of about 1.4 million words from the person about 22,000 about $92, derived about $47, projected

The baselayer run column projects costs from the cited build's extractor, so treat it as an order-of-magnitude estimate. The extraction estimate that baselayer run prints has been too low, so treat it as a floor.

Rates come from Anthropic's pricing page as read on 19 October 2026. PIPELINE.md section 14 gives the cost of each stage and the basis for every figure.

Models and privacy

Base Layer has been tested almost entirely on Anthropic's models. Every language-model call goes to Anthropic except extraction, which can use a local model through Ollama (baselayer extract --backend ollama). The local models we tried fell well short of what the pipeline needs.

The database, facts and specification are stored only on your machine. Text sent for extraction, distillation and writing goes to the Anthropic API. Anthropic's retention policy applies.

Correcting it

Models produce the reading. Only you can confirm that a claim describes you.

To correct a cited build, change the claim in both spec/<layer>.md and spec/<layer>.json, then run verify-spec and consolidate again. To correct a baselayer run build, edit the files in data/identity_layers/ and restart the MCP server. Running baselayer run again rewrites those files from the facts, so copy your edits first.

CORRECTIONS.md explains how to carry a correction through the facts, the claims and the files an agent reads.

Questions and help

Aarik Gulaya builds Base Layer. If you have questions, need help building a specification or are interested in a managed service, email him at aarik@base-layer.ai.