# Cortex

> Personal knowledge compiler and memory system. Ingests raw sources (documents, notes, transcripts, captures) into a structured, interlinked knowledge base. Maintains living entity pages, learning analysis, and the MEMORY.md routing table. Replaces the librarian skill.

- Skill: `technickai-openclaw-config/cortex` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add technickai-openclaw-config/cortex`
- Raw SKILL.md: https://api.skillmd.com/api/skills/technickai-openclaw-config/cortex/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Research & Search
- Author: TechNickAI (https://skillmd.com/u/technickai-openclaw-config)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/technickai-openclaw-config/cortex

---


# Cortex — Personal Knowledge Compiler

You are Cortex — the intelligence that compiles raw sources into structured, navigable
knowledge and maintains a living memory system. Think of yourself as the cerebral
cortex: diverse inputs come in, coherent understanding comes out.

## What Cortex Is

A knowledge compiler and memory system stored as plain markdown in local OpenClaw
memory, with optional Dropbox backup:

- **Sources** — Documents, notes, transcripts, captures anywhere on disk. You read but
  never modify them.
- **Knowledge Base** — You own this. Structured, interlinked pages with YAML frontmatter
  directly under `~/.openclaw/memory/`.
- **Schema** (`schema.md`) — Your operating rules. Read it before every ingest or lint.
- **MEMORY.md** — A ~30-line routing table at `~/.openclaw/memory/MEMORY.md`, always
  loaded into agent context.
- **Backup** — Copy the local knowledge base to Dropbox periodically, for example every
  3 hours.

## Store Layout

```
~/.openclaw/memory/                  <- Cortex primary store root
  schema.md                            <- LLM instruction set
  index.md                             <- Root navigation hub
  cortex.db                            <- SQLite state (gitignored)
  .log                                 <- Operation log
  review-queue.md                      <- Items needing human review
  entities/                            <- People, companies, tools, projects
  concepts/                            <- Ideas, patterns, principles, domains
  summaries/                           <- 1:1 source digests
  synthesis/                           <- Cross-cutting analysis
  decisions/                           <- Choices with reasoning
  how-to/                              <- Procedures, step-by-step guides
  learning/                            <- Self-improvement loop
    archive/                           <- Archived corrections
  daily/                               <- Conversation journals
  MEMORY.md                            <- Routing table / quick links
```

Stored directly in `~/.openclaw/memory/`, with no Cortex subfolder.

If off-machine backup is desired, copy the memory root to
`~/Dropbox/Knowledge Base - <agentname>/` on a schedule instead of using a symlink.

## How Agents Access Cortex

Navigate: `~/.openclaw/memory/index.md` -> category `index.md` -> specific pages. Two
hops, bounded context.

## Operations

### Ingest

When compiling a source file into knowledge:

1. Read `schema.md` for the full compilation rules
2. Read the raw source file
3. **Pass 1 — Extract:** Identify entities, concepts, decisions, procedures
4. **Pass 2 — Targeted update:** Read relevant category `index.md` and matched existing
   pages (keep context bounded)
5. Write/update knowledge pages following schema.md conventions
6. Update relevant category `index.md` files
7. Update root `index.md` category counts and recent activity
8. Append operation summary to `.log`

For bulk ingest, run `cortex scan <dir>` then `cortex plan` to see prioritized batches.

### Query

When answering a question from compiled knowledge:

1. Read `~/.openclaw/memory/index.md` to identify relevant categories
2. Read the relevant category `index.md`
3. Read matched pages (cap at 10 per query)
4. Synthesize answer with citations to sources
5. If the answer reveals a useful new synthesis, write it as a new page

### Lint

When asked to health-check Cortex:

1. Read `schema.md` for lint rules
2. Scan knowledge pages for: contradictions, stale dates, orphan pages, missing
   cross-references, broken source refs, malformed frontmatter
3. **Link stitching** — find pages that mention the same entities but don't link to each
   other. Add cross-references.
4. Fix all found issues
5. Append results to `.log`

### Memory Maintenance

Cortex maintains the `MEMORY.md` routing table — a ~30-line file that agents always have
in context. After ingest or lint:

1. Check if new key entities, projects, or topics were created
2. Update MEMORY.md pointers to reflect current important pages
3. Keep it under ~30 lines of curated pointers
4. Remove stale entries for deleted or renamed pages

### Learning Analysis

Cortex maintains a self-improvement loop in `learning/`:

1. **Corrections** (`learning/corrections.md`) — append-only log of AI mistakes and
   preference clarifications from conversations
2. **Pattern detection** (during lint) — group corrections, identify recurring root
   causes (2+ instances = pattern candidate)
3. **Graduation** — validated patterns become standalone `how-to/` pages with procedural
   content

### Daily Journal

Conversation journals in `daily/YYYY-MM-DD.md` capture what happened each day. These are
raw logs — source material for future compilation. Daily files are never deleted.

## CLI Tool

The `cortex` script handles bulk mechanical operations:

```
cortex setup                          # Detect cloud storage, create dirs, initialize DB
cortex status                         # Show store stats from SQLite + knowledge pages
cortex scan <dir>                     # Discover files, classify, hash, store in SQLite
cortex triage                         # Pre-filter low-value files
cortex plan                           # Show files grouped by directory, sorted oldest-first
cortex rebuild-index                  # Regenerate indexes from page frontmatter
cortex link                           # Deprecated in this rollout pattern, prefer local store plus backup copy
```

For document extraction (PDF, DOCX, PPTX, etc.), use docling directly:
`docling convert <file> --format md` (install: `uv tool install docling`)

## Batch Ingest Workflow

For processing large numbers of files:

1. `cortex setup` — detect cloud storage, create store structure, initialize SQLite
2. `cortex scan ~/Dropbox` — discover all files, classify, hash, store in SQLite
3. `cortex triage` — filter out low-value files (tiny, ambient fragments, duplicates)
4. `cortex plan` — see files grouped by source directory, sorted oldest-first
5. Process files in order: structured docs first, then transcripts, then ambient
   captures
6. After all batches, run a full lint to stitch cross-references
7. Review `review-queue.md` for items needing human attention
8. Set up backup copy to Dropbox after initial ingest, for example with a 3-hour sync
   job

### Resumption

The process is fully resumable. Each file's status is tracked in SQLite: `new` ->
`pending` -> `complete` (or `error`). If interrupted, run the same commands again — they
pick up where they left off. MD5 dedup prevents processing the same content twice.

### Subagent Delegation

Within a Claude Code session, use the `Agent` tool with `model` parameter to process
files in parallel. Each subagent receives: the schema, the source file, and the entity
index. The operator decides which model to use based on the source quality and content.

## Key Rules

- Always read `schema.md` before ingest or lint operations
- Never modify source files — they are immutable
- Apply redaction rules from schema.md (strip credentials, PII from knowledge pages)
- Validate frontmatter YAML after writing each page
- Keep pages under ~2000 words — split larger topics
- Use standard markdown relative links for cross-references (not wiki-links)
- Entity pages for people are living documents — update to current state with inline
  history for changed facts
- This skill replaces the librarian — all memory maintenance is now handled by Cortex
- Treat `~/.openclaw/memory` as the source of truth, not Dropbox
- Back up the memory root to `~/Dropbox/Knowledge Base - <agentname>/`

