Memory Schema
Manage structured note types using Basic Memory's Picoschema system. Schemas define what fields a note type should have, making notes uniform, queryable, and validatable.
When to Use
- New note type emerging — you notice several notes share the same structure (meetings, people, decisions)
- Validation check — confirm existing notes conform to their schema
- Schema drift — detect fields that notes use but the schema doesn't define (or vice versa)
- Schema evolution — add/remove/change fields as requirements evolve
- On demand — user asks to create, check, or manage schemas
Picoschema Syntax Reference
Schemas are defined in YAML frontmatter using Picoschema — a compact notation for describing note structure.
Basic Types
Supported types: string, integer, number, boolean.
Optional Fields
Append ? to the field name:
Enums
Use (enum) with a list of allowed values:
Optional enum:
Arrays
Use (array) for list fields:
Relations
Reference other entity types directly:
Relations create edges in the knowledge graph, linking notes together.
Validation Settings
Complete Example
Discovering Unschemaed Notes
Look for clusters of notes that share structure but have no schema:
-
Search by type:
search_notes(query="type:Meeting")— if many notes share atypebut noschema/Meeting.mdexists, it's a candidate. -
Infer a schema: Use
schema_inferto analyze existing notes and generate a suggested schema:The threshold (0.0–1.0) controls how common a field must be to be included. Default is usually fine; lower it to catch rarer fields.
-
Review the suggestion — the inferred schema shows field names, types, and frequency. Decide which fields to keep, make optional, or drop.
Creating a Schema
Write the schema note to schema/<EntityName>:
Key Principles
- Schema notes live in
schema/— one note per entity type note_type="schema"marks it as a schema definitionentity: Meetingin metadata names the type it applies toversion: 1in metadata — increment when making breaking changessettings.validation: warnis recommended to start — it logs issues without blocking writes
Validating Notes
Check how well existing notes conform to their schema:
Validation reports:
- Missing required fields — the note lacks a field the schema requires
- Unknown fields — the note has fields the schema doesn't define
- Type mismatches — a field value doesn't match the expected type
- Invalid enum values — a value isn't in the allowed set
Handling Validation Results
warnmode: Review warnings periodically. Fix notes that are clearly wrong; add optional fields to the schema for legitimate new patterns.errormode: Use for strict schemas where conformance matters (e.g., automated pipelines consuming notes).
Detecting Drift
Over time, notes evolve and schemas lag behind. Use schema_diff to find divergence:
Diff reports:
- Fields in notes but not in schema — candidates for adding to the schema (as optional)
- Schema fields rarely used — consider making optional or removing
- Type inconsistencies — fields used as different types across notes
Schema Evolution
When note structure changes:
- Run diff to see current state:
schema_diff(noteType="Meeting") - Update the schema note via
edit_note: - Add/remove/modify fields in the
schema:block - Re-validate to confirm existing notes still pass:
schema_validate(noteType="Meeting") - Fix outliers — update notes that don't conform to the new schema
Evolution Guidelines
- Additive changes (new optional fields) are safe — no version bump needed
- Breaking changes (new required fields, removed fields, type changes) should bump
version - Prefer optional over required — most fields should be optional to start
- Don't over-constrain — schemas should describe common structure, not enforce rigid templates
- Schema as documentation — even if validation is set to
warn, the schema serves as living documentation for what notes of that type should contain


