memory-schema
npx skills add https://github.com/basicmachines-co/basic-memory-skills --skill memory-schema
Agent 安装分布
Skill 文档
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
schema:
name: string, person's full name
age: integer, age in years
score: number, floating-point rating
active: boolean, whether currently active
Supported types: string, integer, number, boolean.
Optional Fields
Append ? to the field name:
schema:
title: string, required field
subtitle?: string, optional field
Enums
Use (enum) with a list of allowed values:
schema:
status(enum): [active, blocked, done, abandoned], current state
Optional enum:
schema:
priority?(enum): [low, medium, high, critical], task priority
Arrays
Use (array) for list fields:
schema:
tags(array): string, categorization labels
steps?(array): string, ordered steps to complete
Relations
Reference other entity types directly:
schema:
parent_task?: Task, parent task if this is a subtask
attendees?(array): Person, people who attended
Relations create edges in the knowledge graph, linking notes together.
Validation Settings
settings:
validation: warn # warn (log issues) or error (strict)
Complete Example
---
title: Meeting
type: schema
entity: Meeting
version: 1
schema:
topic: string, what was discussed
date: string, when it happened (YYYY-MM-DD)
attendees?(array): Person, who attended
decisions?(array): string, decisions made
action_items?(array): string, follow-up tasks
status?(enum): [scheduled, completed, cancelled], meeting state
settings:
validation: warn
---
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:schema_infer(noteType="Meeting") schema_infer(noteType="Meeting", threshold=0.5) # fields in 50%+ of notesThe 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>:
write_note(
title="Meeting",
directory="schema",
note_type="schema",
metadata={
"entity": "Meeting",
"version": 1,
"schema": {
"topic": "string, what was discussed",
"date": "string, when it happened",
"attendees?(array)": "Person, who attended",
"decisions?(array)": "string, decisions made"
},
"settings": {"validation": "warn"}
},
content="""# Meeting
Schema for meeting notes.
## Observations
- [convention] Meeting notes live in memory/meetings/ or as daily entries
- [convention] Always include date and topic
- [convention] Action items should become tasks when complex"""
)
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:
# Validate all notes of a type
schema_validate(noteType="Meeting")
# Validate a single note
schema_validate(identifier="meetings/2026-02-10-standup")
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:
schema_diff(noteType="Meeting")
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:edit_note( identifier="schema/Meeting", operation="find_replace", find_text="version: 1", content="version: 2", expected_replacements=1 ) - 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
Workflow Summary
1. Notice repeated note structure â infer schema (schema_infer)
2. Review + create schema note â write to schema/ (write_note)
3. Validate existing notes â check conformance (schema_validate)
4. Fix outliers â edit non-conforming notes (edit_note)
5. Periodically check drift â detect divergence (schema_diff)
6. Evolve schema as needed â update schema note (edit_note)