Memory Tasks
Manage work-in-progress using Basic Memory's schema system. Tasks are just notes with type: Task — they live in the knowledge graph, validate against a schema, and survive context compaction.
When to Use
- - Starting multi-step work (3+ steps, or anything that might outlast the context window)
- After compaction/restart — search for active tasks to resume
- Pre-compaction flush — update all active tasks with current state
- On demand — user asks to create, check, or manage tasks
Task Schema
Tasks use the BM schema system (SPEC-SCHEMA). The schema note lives at memory/schema/Task.md:
CODEBLOCK0
Creating a Task
When work qualifies, create a task note. Use write_note with note_type="Task" and put queryable fields in metadata:
CODEBLOCK1
Why both frontmatter and observations? Fields in metadata (stored as frontmatter) power search_notes with metadata_filters. Fields as observations (- [status] active) power schema_validate. Include queryable fields in both places for full coverage.
Key Principles
- - Steps are concrete and checkable — "Implement X in file Y", not "figure out stuff"
- Context is for post-amnesia resumption — Write it as if explaining to a smart person who knows nothing about what you've been doing
- Relations link to other entities —
parent_task [[Other Task]], INLINECODE11 note_types is case-sensitive — write_note(note_type="Task") stores the type as lowercase task in frontmatter. Use note_types=["task"] (lowercase) in search queries.
Resuming After Compaction
On session start or after compaction:
- 1. Search for active tasks:
CODEBLOCK2
- 2. Read the task note to get full context
- 3. Resume from
current_step using the context field
- 4. Update as you progress — increment
current_step, update context, check off steps
Updating Tasks
As work progresses, update the task note:
CODEBLOCK3
Update frontmatter too:
CODEBLOCK4
Completing Tasks
When done:
CODEBLOCK5
Add a brief summary of what was accomplished and any follow-up needed.
Pre-Compaction Flush
When a compaction event is imminent:
- 1. Find all active tasks: INLINECODE19
- For each, update:
-
current_step to reflect actual progress
-
context with everything needed to resume
- Step checkboxes to show what's done
- 3. This is critical — context not written down is context lost
Querying Tasks
With BM's schema system, tasks are fully queryable:
| Query | What it finds |
|---|
| INLINECODE22 | All tasks |
| INLINECODE23 |
Active tasks |
|
search_notes(note_types=["task"], status="blocked") | Blocked tasks |
|
search_notes(note_types=["task"], metadata_filters={"assigned_to": "claude"}) | My tasks |
|
search_notes("blockers", note_types=["task"]) | Tasks with blockers |
|
schema_validate(noteType="Task") | Validate all tasks against schema |
|
schema_diff(noteType="Task") | Detect drift between schema and actual task notes |
Guidelines
- - One task per unit of work — Don't cram multiple projects into one task
- Externalize early — If you think "I should remember this", write it down NOW
- Context > steps — Steps tell you what to do; context tells you why and how
- Close finished tasks — Don't leave completed work as INLINECODE29
- Link related tasks — Use
parent_task [[X]] or relations to connect related work - Schema validation is your friend — Run
schema_validate(noteType="Task") periodically to catch incomplete tasks
记忆任务
使用Basic Memory的schema系统管理工作进度。任务只是带有type: Task的笔记——它们存在于知识图谱中,根据schema进行验证,并在上下文压缩后仍然保留。
何时使用
- - 开始多步骤工作(3步以上,或任何可能超出上下文窗口的内容)
- 压缩/重启后——搜索活跃任务以恢复工作
- 压缩前刷新——用当前状态更新所有活跃任务
- 按需使用——用户要求创建、检查或管理任务
任务Schema
任务使用BM schema系统(SPEC-SCHEMA)。schema笔记位于memory/schema/Task.md:
yaml
title: Task
type: schema
entity: Task
version: 1
schema:
description: string, 需要完成什么
status?(enum): [active, blocked, done, abandoned], 当前状态
assigned_to?: string, 谁在执行此任务
steps?(array): string, 按顺序的完成步骤
current_step?: integer, 当前进行到第几步(从1开始)
context?: string, 记忆丢失后恢复所需的关键上下文
started?: string, 工作开始时间
completed?: string, 工作完成时间
blockers?(array): string, 阻碍进展的因素
parent_task?: Task, 父任务(如果这是子任务)
settings:
validation: warn
创建任务
当工作符合条件时,创建一个任务笔记。使用writenote并设置notetype=Task,将可查询字段放入metadata:
python
write_note(
title=描述性任务名称,
directory=tasks,
note_type=Task,
metadata={
status: active,
priority: high,
current_step: 1,
steps: [第一步, 第二步, 第三步]
},
tags=[task],
content=# 描述性任务名称
观察记录
- - [description] 需要完成什么,简洁明了
- [status] active
- [assignedto] claude
- [currentstep] 1
步骤
- 1. [ ] 第一个具体步骤
- [ ] 第二个具体步骤
- [ ] 第三个具体步骤
上下文
未来的你需要什么来接手这项工作。包括:
- - 涉及的关键文件路径和仓库
- 已做出的决定及其原因
- 尝试过的方法及有效/无效的
- 在哪里查找相关上下文
)
为什么同时需要前置元数据和观察记录? metadata中的字段(存储为前置元数据)支持使用metadatafilters进行searchnotes。作为观察记录的字段(- [status] active)支持schema_validate。在两个位置都包含可查询字段以获得完整覆盖。
关键原则
- - 步骤要具体且可检查——在文件Y中实现X,而不是搞清楚问题
- 上下文用于失忆后恢复——就像向一个对你所做工作一无所知的聪明人解释一样来写
- 关系链接到其他实体——parenttask [[其他任务]],relatedto [[某个笔记]]
- notetypes区分大小写——writenote(notetype=Task)将类型存储为前置元数据中的小写task。在搜索查询中使用notetypes=[task](小写)。
压缩后恢复
在会话开始或压缩后:
- 1. 搜索活跃任务:
python
search
notes(notetypes=[task], status=active)
- 2. 阅读任务笔记以获取完整上下文
- 3. 从current_step恢复,使用context字段
- 4. 随着进展更新——递增current_step,更新上下文,勾选完成步骤
更新任务
随着工作进展,更新任务笔记:
markdown
步骤
- 1. [x] 第一步——已完成,产生了X结果
- [x] 第二步——已完成,因Y原因改变了方法
- [ ] 第三步——下一步进行
上下文
反映当前状态的更新上下文...
同时更新前置元数据:
yaml
current_step: 3
完成任务
完成后:
yaml
status: done
completed: YYYY-MM-DD
添加完成内容的简要总结以及任何后续需要处理的事项。
压缩前刷新
当压缩事件即将发生时:
- 1. 查找所有活跃任务:searchnotes(notetypes=[task], status=active)
- 对每个任务更新:
- current_step以反映实际进展
- context包含恢复所需的所有内容
- 步骤复选框以显示已完成的内容
- 3. 这至关重要——未写下的上下文就是丢失的上下文
查询任务
使用BM的schema系统,任务完全可查询:
| 查询 | 查找内容 |
|---|
| searchnotes(notetypes=[task]) | 所有任务 |
| searchnotes(notetypes=[task], status=active) |
活跃任务 |
| search
notes(notetypes=[task], status=blocked) | 受阻任务 |
| search
notes(notetypes=[task], metadata
filters={assignedto: claude}) | 我的任务 |
| search
notes(blockers, notetypes=[task]) | 有阻碍因素的任务 |
| schema_validate(noteType=Task) | 根据schema验证所有任务 |
| schema_diff(noteType=Task) | 检测schema与实际任务笔记之间的偏差 |
指南
- - 每个工作单元一个任务——不要将多个项目塞进一个任务
- 尽早外化——如果你觉得我应该记住这个,现在就写下来
- 上下文 > 步骤——步骤告诉你做什么;上下文告诉你为什么和怎么做
- 关闭已完成的任务——不要让完成的工作保持active状态
- 链接相关任务——使用parenttask [[X]]或关系来连接相关工作
- Schema验证是你的朋友——定期运行schemavalidate(noteType=Task)以捕获不完整的任务