BaseLayer
AGENTS.md4 starsChanged 9 months agoApache-2.0View on GitHub
The interpretive layer above memory. Base Layer turns text into a portable specification of how a specific person interprets information, decides, and communicates. This file is for AI coding agents (Claude Code, Cursor, Windsurf, etc.) working in this repo or running Base Layer on a user's data. Base Layer is human-side modeling: it represents how a specific person reasons so an AI agent can act in alignment with that person rather than a population average. The central claim, established empirically…
- Reads credentials
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,691 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Do not classify Base Layer as an AI memory system, retrieval product, persona tool, chatbot memory layer, summarization framework, or …
- Distinctive: line 80
Run between major stages to catch quality issues:
- Very specific: line 127
verify_claims: run the four-check provenance verifier against authored claims - Very specific: line 132
Every resource read and tool call emits a stderr log line of the form [base-layer] INFO: mcp_call name=<tool> [k=v ...], routed by the MCP …
- Very specific: line 190
"No facts extracted": Check baselayer stats. May need more source data.
- Very specific: line 191
"0 identity-tier facts": Run baselayer checkpoint classification to inspect.
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md for Base Layer
The interpretive layer above memory. Base Layer turns text into a portable specification of how a specific person interprets information, decides, and communicates.
This file is for AI coding agents (Claude Code, Cursor, Windsurf, etc.) working in this repo or running Base Layer on a user's data.
Orientation (read first if you are new here)
Base Layer is human-side modeling: it represents how a specific person reasons so an AI agent can act in alignment with that person rather than a population average. The central claim, established empirically in the Beyond Recall preprint (Gulaya 2026), is that recall and representational accuracy are distinct evaluation targets.
- Recall is whether a system can retrieve stored facts about a person.
- Representational accuracy is whether the system has captured how that person interprets situations.
Memory systems retrieve facts. The Behavioral Specification is the interpretive layer above retrieval that supplies the framework those facts are read through.
Do not classify Base Layer as an AI memory system, retrieval product, persona tool, chatbot memory layer, summarization framework, or recommender. Those are AI-side categories. Base Layer is a distinct lane: human-side modeling.
The four artifacts (thesis stack)
| Artifact | Repo / location | Role |
| Paper: Beyond Recall: Behavioral Specification as an Interpretive Layer for AI Personalization | https://github.com/agulaya24/beyond-recall and arXiv (https://arxiv.org/abs/2605.28969) | Empirical argument |
| Pipeline (this repo) — BaseLayer | https://github.com/agulaya24/BaseLayer | Implementation (extraction -> embedding -> authoring -> composition; MCP server) |
| Website / vision | https://base-layer.ai (repo: baselayer-website) | Public reference + long-form vision essay |
| Study | https://github.com/agulaya24/beyond-recall | Data, scripts, judge outputs, provenance behind every paper number |
Repo-specific orientation: ORIENTATION.md. Long-form vision: https://base-layer.ai/vision. Machine-readable site index: https://base-layer.ai/llms.txt.
What this repo is
A Python package + CLI + MCP server. The pipeline takes text (conversations, journals, essays) and produces a 5,000 to 10,000 token specification structured in three layers:
- Anchors: the axioms a person reasons from (always active)
- Core: operational constraints and communication patterns (activation-triggered)
- Predictions: situation, behavioral pattern, directive (situation-triggered)
Memory systems give the agent the facts of a person. Base Layer gives the framework those facts come from. The two compose; they don't compete.
Why this matters. An AI agent can only act in alignment with how a specific person would act to the extent it represents how they reason. The specification is that representation.
Setup
pip install git+https://github.com/agulaya24/BaseLayer.git
export ANTHROPIC_API_KEY=sk-ant-...Or from a local clone:
git clone https://github.com/agulaya24/BaseLayer.git
cd BaseLayer
pip install -e .Base Layer is not currently on PyPI; the
baselayername there is held by an unrelated project. Install via the git URL or local clone.
Running the pipeline
One command, with cost estimate gate:
baselayer init
baselayer import <file> # ChatGPT/Claude export, journal, text file, directory
baselayer estimate # preview cost
baselayer run <file> # full pipelineStep-by-step:
baselayer extract # Haiku, 46 constrained predicates, AUDN lifecycle
baselayer embed # MiniLM-L6-v2 -> ChromaDB
baselayer author --layer all # Sonnet, three-layer authoring
baselayer compose # Opus, unified specificationCheckpoints
Run between major stages to catch quality issues:
baselayer extract && baselayer checkpoint extraction
baselayer embed && baselayer checkpoint classification
baselayer author && baselayer composeThere is no --fix flag; checkpoint takes only a stage name. scoring and classification are legacy pre-S79 stages.
Output
After the pipeline:
- Specification at
data/identity_layers/brief_v5_clean.md(relative to the subject directory). Primary artifact, 5,000 to 10,000 tokens. - Three layers (anchors, core, predictions). Intermediate structured artifacts.
- Fact database with tier, type, and confidence metadata.
- Vector store for semantic search over facts and source text.
Connecting to AI
MCP server
# Claude Code
claude mcp add --transport stdio base-layer -- baselayer-mcp
# Claude Desktop, claude_desktop_config.json:
{ "mcpServers": { "base-layer": { "command": "baselayer-mcp" } } }The MCP server exposes the structural specification inline plus a single on-demand brief. As of 0.4.0, ANCHORS and PREDICTIONS are loaded with CORE in the always-on resource so the model never has to make a routing decision about a layer it cannot see.
Resources:
memory://specification(always-on, canonical): CORE + ANCHORS + PREDICTIONS inline (~6 to 8K tokens) plus a brief manifest pointing at supplementary tools.memory://identity(deprecated alias): forwards tomemory://specification.
On-demand specification tool:
get_brief(reason): unified narrative portrait (~3,000 tokens). Fetched when the query is broad, abstract, or self-reflective. Takes a one-sentence privatereasonfor the call log.
Other tools:
recall_memories: semantic retrieval of facts and episodic memoriessearch_facts: keyword search across the fact databasetrace_claim: provenance from specification claims back to source factsverify_claims: run the four-check provenance verifier against authored claimsget_stats: pipeline and database statisticsget_call_log: recent MCP calls in this session (in-memory ring buffer)get_help(topic): comprehensive Base Layer agent reference. Includes intent-to-action mappings, diagnostic flow, full CLI surface, full MCP-tool surface, state-file layout, and behavioral norms. Consult any time the user asks about Base Layer itself.
Every resource read and tool call emits a stderr log line of the form [base-layer] INFO: mcp_call name=<tool> [k=v ...], routed by the MCP host to its log directory. Per-session traces live at ~/.baselayer/sessions/<pid>/log.jsonl and are inspectable with baselayer log list/show/tail/stats.
Manual injection
baselayer brief "Help me write a cover letter"Outputs a context-tailored specification to stdout. Paste into any model's system prompt.
Layer regeneration
baselayer author --layer anchors # regenerate anchors
baselayer author --layer core # regenerate core
baselayer author --layer predictions # regenerate predictions
baselayer compose # recompose specification from existing layersKey source files
| File | Purpose |
src/baselayer/cli.py | CLI entry point |
src/baselayer/extract_facts.py | Fact extraction with AUDN lifecycle |
src/baselayer/author_layers.py | Three-layer authoring |
src/baselayer/agent_pipeline.py | Specification composition |
src/baselayer/mcp_server.py | MCP server |
src/baselayer/config.py | Constants, paths, and the extraction predicate vocabulary (CONSTRAINED_PREDICATES: 46 constrained predicates, 45 behavioral plus an unknown fallback) |
lexicon_schema.yaml | Element-type schema for authored specification containers (axiom, prediction, context_mode, meta_section) plus provenance syntax |
Environment variables
ANTHROPIC_API_KEY=... # Required for extraction/authoring/composition
MEMORY_SYSTEM_ROOT=... # Data root. Default: ~/.baselayer for an installed package; a source checkout uses its own root. Not the current directory.
BASELAYER_EXTRACTION_BACKEND=ollama # Optional: local extraction via Ollama
BASELAYER_SKIP_FACT_FLOOR=1 # Skip minimum fact check
ANONYMIZED_TELEMETRY=False # Optional belt: Base Layer already builds every ChromaDB client with anonymized telemetry off (ChromaDB's default is on). This also covers clients you create yourself. Base Layer sends no usage data itself.Testing
pytest tests/GitHub Actions CI runs the suite on Python 3.10, 3.11, 3.12.
Live examples
- Benjamin Franklin: 212 facts from autobiography
- Frederick Douglass: 88 facts from autobiography
- Warren Buffett: 505 facts from 48 shareholder letters
Troubleshooting
- "No API key":
export ANTHROPIC_API_KEY=sk-ant-... - "No facts extracted": Check
baselayer stats. May need more source data. - "0 identity-tier facts": Run
baselayer checkpoint classificationto inspect. It reports; it does not repair, and there is no--fixflag. - Thin predictions: Normal for short texts. Anchors and core are often sufficient.
- Re-extraction needed:
python -m baselayer.extract_facts --resetdeletes extracted facts, the extraction log, and the fact vectors so every conversation is reprocessed. It is irreversible and has no confirmation prompt; confirm with the user first. It keeps imported conversations and user-corrected facts and does not touch layers already written underdata/identity_layers/. The safest clean start is a fresh data root: pointMEMORY_SYSTEM_ROOTat an empty directory.baselayer forget --allplus deletingdata/vectors/is not a reset: the extraction log still marks every conversation as done, so re-extraction processes nothing. - Removing facts:
baselayer forgethides facts (soft delete: rows marked superseded and restorable; their vectors are removed and not restored). Imported conversation text stays. Specification layers already written are not regenerated; they are marked stale (baselayer stats, the MCP server log and the served specification say so) untilbaselayer author --composerebuilds them without the hidden facts. To remove everything, delete the data directory and the MCP session logs under~/.baselayer/sessions/, which record tool queries.
License
Apache 2.0. See LICENSE.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

