BaseLayer
CLAUDE.md4 starsChanged 9 months agoApache-2.0View on GitHub
Claude Code-specific guide for working in the Base Layer repo. This file complements AGENTS.md (provider-neutral) with Claude Code harness specifics. For background on the project, read AGENTS.md and README.md first. This file is shorter on purpose. Base Layer is the interpretive layer above memory. The pipeline takes text (conversations, journals, essays, books) and produces a behavioral specification: a 5,000 to 10,000 token structured document that captures how a specific person interprets information, decides, and communicates. Memory systems retrieve facts. The…
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
13 rules. About 0 are common, 9 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
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 11
If you are running in this repo as Claude Code, you are most likely doing one of four things:
- Distinctive: line 18
If the user's request is ambiguous, ask before running anything that spends API budget.
- Distinctive: line 22
When you generate user-facing text in this repo (commit messages, doc edits, blog drafts, paper edits, recipes, comments in source), follow …
- Distinctive: line 24
No em-dashes. Restructure sentences.
- Distinctive: line 25
No GTM language ("beats", "crushes", "outperforms", "wins").
- Distinctive: line 27
No marketing prose. Action-first.
- Very specific: line 34
All commands invoked as baselayer <subcommand>.
- Very specific: line 86
Monitoring: Every resource read and tool call emits a stderr log line of the form [base-layer] INFO: mcp_call name=<tool> [k=v ...].
- Distinctive: line 120
When writing new prose, use "specification" and "interpretive layer".
- Very specific: line 125
Do not invent commands or flags: If a flag is not in cli.py, it does not exist.
- Distinctive: line 126
Do not POST to unknown endpoints: Read the route handler first.
- Very specific: line 129
Do not run the pipeline without the cost-estimate gate: Use baselayer run (which gates by default) or run baselayer estimate before …
- Distinctive: line 135
Ask the user before doing anything irreversible.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.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
CLAUDE.md
Claude Code-specific guide for working in the Base Layer repo. This file complements AGENTS.md (provider-neutral) with Claude Code harness specifics.
For background on the project, read AGENTS.md and README.md first. This file is shorter on purpose.
Project context
Base Layer is the interpretive layer above memory. The pipeline takes text (conversations, journals, essays, books) and produces a behavioral specification: a 5,000 to 10,000 token structured document that captures how a specific person interprets information, decides, and communicates. Memory systems retrieve facts. The specification supplies the framework those facts are read through.
If you are running in this repo as Claude Code, you are most likely doing one of four things:
- Running the pipeline on the user's text data (ChatGPT export, journal directory, document corpus).
- Debugging extraction, authoring, or composition (a stage produced too few facts, a layer regenerated wrong, etc.).
- Exploring example specifications under
examples/to understand the output format. - Connecting the local MCP server to inject the specification into a Claude conversation.
If the user's request is ambiguous, ask before running anything that spends API budget.
Voice and prose constraints
When you generate user-facing text in this repo (commit messages, doc edits, blog drafts, paper edits, recipes, comments in source), follow the project's voice constraints:
- No em-dashes. Restructure sentences. Do not substitute hyphens.
- No GTM language ("beats", "crushes", "outperforms", "wins"). Scientific framing only.
- Canonical terms: "interpretive layer" and "specification" body-primary. "Behavioral specification" on first mention. Do not use "behavioral compression" or "identity model" in new prose.
- No marketing prose. Action-first. Direct.
- Aarik wrote the project. He does not write code; he architects and directs. Write for an audience of one technical product owner.
The voice constraints exist as user-memory entries (e.g. feedback_no_em_dashes.md). Do not duplicate their contents here; just follow them.
Commands an AI agent should know
All commands invoked as baselayer <subcommand>. Source of truth: src/baselayer/cli.py.
| Command | One-liner |
baselayer init | Initialize a fresh database under the data root (MEMORY_SYSTEM_ROOT; not the current directory). |
baselayer import <file> | Import ChatGPT/Claude export, journal, text file, or directory. |
baselayer estimate | Rough preview of API cost. The extraction figure is computed from the imported text; the authoring and composition figures are fixed values. |
baselayer extract | Extract facts via Haiku (46 constrained predicates, AUDN lifecycle). |
baselayer embed | Generate ChromaDB vectors for provenance tracing. |
baselayer author --layer all | Author anchors, core, and predictions layers (Sonnet). |
baselayer compose | Compose unified specification from the three layers (Opus). |
baselayer run <file> | Full pipeline with cost-gate. Runs import -> extract -> embed -> author -> compose. |
baselayer brief "<message>" | Print a context-tailored specification to stdout. |
baselayer stats | Database stats: conversations, facts, tier breakdown. |
baselayer search "<query>" | FTS keyword search across active facts. |
baselayer provenance --claim A1 | Trace a specification claim back to its supporting facts. |
baselayer verify --layer all | Run the four-check provenance audit on authored claims. |
baselayer checkpoint extraction | Quality gate after extraction. Reports only; no --fix flag exists. |
baselayer forget --all | Hide (soft-delete) all active facts. Raw text stays and written layers are not regenerated. Not a reset. Confirm before running. |
baselayer journal | Guided prompts when the user has no conversation history. |
For long-form usage details and step-by-step pipeline structure, see AGENTS.md. Do not invent commands. If a flag does not appear in cli.py, it does not exist.
MCP server quick-connect
Register the Base Layer MCP server with Claude Code:
claude mcp add --transport stdio base-layer -- baselayer-mcpOnce registered, the next Claude Code session loads two resources and seven tools.
Resources (always-on, client-controlled):
memory://specification. The structural specification inline: CORE (communication and context), ANCHORS (foundational beliefs and reasoning patterns), PREDICTIONS (situation-to-response patterns), plus a brief manifest. Approximately 6 to 8K tokens. Loaded into every conversation.memory://identity. Deprecated alias formemory://specification. Forwards to the same content. Retained for backward compatibility.
On-demand specification tool:
get_brief(reason). Unified narrative portrait of the user (~3,000 tokens). The model fetches this when the query is broad, abstract, or self-reflective. Provides a private one-sentence rationale viareason; not user-facing.
Memory tools (model-controlled, called on demand):
recall_memories(query). Semantic retrieval of relevant facts plus episodic memories for a query.search_facts(query, limit=15). Keyword search across active facts (FTS5 with LIKE fallback).trace_claim(claim_id). Provenance from a specification claim (e.g.A1,P3,C2) back to source facts and conversations.verify_claims(claim_id="", layer="all"). Run the binary verification checks (existence, recurrence, cross-domain coverage, temporal consistency, contradictions).get_stats(). Database summary: conversations, messages, active and superseded facts, tier and source breakdowns.get_call_log(limit, name_filter). Recent MCP calls in this session.get_help(topic). Comprehensive Base Layer agent reference. Consult any time the user asks about Base Layer itself; the guide includes intent-to-action mappings so the agent can run the right command rather than telling the user what to type.
Monitoring. Every resource read and tool call emits a stderr log line of the form [base-layer] INFO: mcp_call name=<tool> [k=v ...]. Per-session traces live at ~/.baselayer/sessions/<pid>/log.jsonl. The baselayer log list/show/tail/stats CLI inspects them.
Design note (0.4.0). Earlier 0.3.0 split CORE on the resource and ANCHORS/PREDICTIONS behind on-demand get_anchors/get_predictions tools. Live use surfaced two issues: the model had to make routing decisions about layers it could not see, and the token savings were negligible. 0.4.0 inlines all three structural layers so the spec is fully present without a routing decision. Only the unified narrative brief stays on-demand.
Where to find what
| Path | Contents |
src/baselayer/cli.py | CLI entry point. Source of truth for all subcommands and flags. |
src/baselayer/extract_facts.py | Fact extraction with the AUDN lifecycle (Add, Update, Delete, NOOP; delete is a soft supersession). |
src/baselayer/author_layers.py | Three-layer authoring (anchors, core, predictions). |
src/baselayer/agent_pipeline.py | Specification composition (Opus). |
src/baselayer/mcp_server.py | MCP server. Resources + tools. |
src/baselayer/config.py | Constants, paths, database singletons. Also the extraction predicate vocabulary: CONSTRAINED_PREDICATES, 46 constrained predicates (45 behavioral plus an unknown fallback). |
src/baselayer/verify_provenance.py | The four-check verifier. |
lexicon_schema.yaml | Element-type schema for authored specification containers (axiom, prediction, context_mode, meta_section) plus provenance syntax. Not the predicate vocabulary; that lives in config.py. |
tests/ | The test suite. pytest tests/ runs it. |
docs/core/ | Architecture, decisions, design principles. Read on demand, not at session start. |
docs/internal/ | Internal plans (refactor plans, agent-facing reviews, runbooks). Exists only in the private working copy; not tracked in this repo. |
examples/ | Live example specifications (Franklin, Buffett, Douglass, Roosevelt, Wollstonecraft, Marks, patents). |
recipes/ | Copy-paste agent task recipes. |
data/ | User data (database, vectors, layers, briefs). Do not touch unless the task requires it. |
Phase A naming alignment status
Phase A of the identity-to-specification refactor shipped 2026-05-06. The pattern is additive aliases, not renames. Both old and new names live forever; the new name is canonical.
memory://specificationis the canonical MCP resource URI.memory://identityis the deprecated alias. Forwards to the same content.- The CLI flag
--identity-onlywill gain a--specification-onlyalias in Phase B. - The Python class
IdentityLayerand moduleidentity_layerswill gainSpecificationLayerandspecification_layersaliases in Phase B.
Full plan: docs/internal/identity_to_specification_refactor_plan.md (private working copy only; not tracked in this repo). Do not duplicate that plan in new docs; reference it by path.
When writing new prose, use "specification" and "interpretive layer". Do not reintroduce "identity" terminology.
Things NOT to do
- Do not run destructive commands without confirmation.
baselayer forget --allhides every active fact.python -m baselayer.extract_facts --resetpermanently deletes extracted facts, the extraction log, and the fact vectors, with no confirmation prompt of its own.baselayer init --forcere-runs initialization (it drops nothing). If the user did not explicitly request the action, ask first. - Do not invent commands or flags. If a flag is not in
cli.py, it does not exist. Read the source before running anything you have not run before. - Do not POST to unknown endpoints. Read the route handler first. The S101 incident wiped tracking data for 48 subjects because an agent called a cleanup endpoint without reading it.
- Do not modify
lexicon_schema.yamlorCONSTRAINED_PREDICATEScasually.lexicon_schema.yamlgoverns the element types of authored layers;CONSTRAINED_PREDICATESinconfig.pygoverns extraction, and predicate changes invalidate stored facts under the AUDN lifecycle. Readdocs/core/ARCHITECTURE.mdand the extraction code first. - Do not re-extract without clearing both SQLite and ChromaDB. Old vectors cause AUDN to return NOOP and you get 12-42 facts instead of 200+.
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. - Do not run the pipeline without the cost-estimate gate. Use
baselayer run(which gates by default) or runbaselayer estimatebeforebaselayer extract. - Do not use the
brieforchatsubcommands for new work. Both are archived. Usecomposefor the V4 unified specification. - Do not retry the same failing approach more than twice. Diagnose and redesign. If extraction returns zero facts twice, stop and read
extract_facts.py.
When in doubt
Ask the user before doing anything irreversible. Read the source before invoking unfamiliar commands. Prefer one fewer step over one extra step.
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.

