memory-tasks

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Memory Tasks

基于Basic Memory的任务管理

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.
使用Basic Memory的schema系统管理进行中的工作。任务本质是标记为
type: Task
的笔记——它们存储在知识图谱中,可通过schema验证,且能在上下文压缩后留存。

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
  • 启动多步骤工作(3个及以上步骤,或任何可能超出上下文窗口的工作)
  • 压缩/重启后——搜索活跃任务以恢复工作
  • 压缩前同步——更新所有活跃任务的当前状态
  • 按需操作——用户要求创建、检查或管理任务

Task Schema

任务Schema

Tasks use the BM schema system (SPEC-SCHEMA). The schema note lives at
memory/schema/Task.md
:
yaml
---
title: Task
type: schema
entity: Task
version: 1
schema:
  description: string, what needs to be done
  status?(enum): [active, blocked, done, abandoned], current state
  assigned_to?: string, who is working on this
  steps?(array): string, ordered steps to complete
  current_step?: integer, which step number we're on (1-indexed)
  context?: string, key context needed to resume after memory loss
  started?: string, when work began
  completed?: string, when work finished
  blockers?(array): string, what's preventing progress
  parent_task?: Task, parent task if this is a subtask
settings:
  validation: warn
---
任务采用BM的schema系统(SPEC-SCHEMA)。Schema笔记存储在
memory/schema/Task.md
yaml
---
title: Task
type: schema
entity: Task
version: 1
schema:
  description: string, what needs to be done
  status?(enum): [active, blocked, done, abandoned], current state
  assigned_to?: string, who is working on this
  steps?(array): string, ordered steps to complete
  current_step?: integer, which step number we're on (1-indexed)
  context?: string, key context needed to resume after memory loss
  started?: string, when work began
  completed?: string, when work finished
  blockers?(array): string, what's preventing progress
  parent_task?: Task, parent task if this is a subtask
settings:
  validation: warn
---

Creating a Task

创建任务

When work qualifies, create a task note. Use
write_note
with
note_type="Task"
and put queryable fields in
metadata
:
python
write_note(
  title="Descriptive task name",
  directory="tasks",
  note_type="Task",
  metadata={
    "status": "active",
    "priority": "high",
    "current_step": 1,
    "steps": ["First step", "Second step", "Third step"]
  },
  tags=["task"],
  content="""# Descriptive task name
当工作符合条件时,创建任务笔记。使用
write_note
函数并指定
note_type="Task"
,将可查询字段放入
metadata
python
write_note(
  title="Descriptive task name",
  directory="tasks",
  note_type="Task",
  metadata={
    "status": "active",
    "priority": "high",
    "current_step": 1,
    "steps": ["First step", "Second step", "Third step"]
  },
  tags=["task"],
  content="""# Descriptive task name

Observations

Observations

  • [description] What needs to be done, concisely
  • [status] active
  • [assigned_to] claude
  • [current_step] 1
  • [description] What needs to be done, concisely
  • [status] active
  • [assigned_to] claude
  • [current_step] 1

Steps

Steps

  1. First concrete step
  2. Second concrete step
  3. Third concrete step
  1. First concrete step
  2. Second concrete step
  3. Third concrete step

Context

Context

What future-you needs to pick up this work. Include:
  • Key file paths and repos involved
  • Decisions already made and why
  • What was tried and what worked/didn't
  • Where to look for related context""" )

**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.
What future-you needs to pick up this work. Include:
  • Key file paths and repos involved
  • Decisions already made and why
  • What was tried and what worked/didn't
  • Where to look for related context""" )

**为何同时使用前置元数据(frontmatter)和观测项?** `metadata`中的字段(存储为前置元数据)支持`search_notes`的`metadata_filters`功能。观测项中的字段(如`- [status] active`)支持`schema_validate`功能。将可查询字段同时放入两处以实现全面覆盖。

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]]
    ,
    related_to [[Some Note]]
  • 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.
  • 步骤需具体且可核查——例如“在文件Y中实现X”,而非“处理相关事项”
  • 上下文用于失忆后恢复——撰写时假设要向完全不了解当前工作的聪明人解释
  • 关联关系链接至其他实体——使用
    parent_task [[Other Task]]
    或关联关系连接相关工作
  • note_types
    区分大小写
    ——
    write_note(note_type="Task")
    会将类型以小写
    task
    存储在前置元数据中。搜索查询时需使用
    note_types=["task"]
    (小写)。

Resuming After Compaction

上下文压缩后恢复任务

On session start or after compaction:
  1. Search for active tasks:
    python
    search_notes(note_types=["task"], status="active")
  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
在会话启动或压缩后:
  1. 搜索活跃任务:
    python
    search_notes(note_types=["task"], status="active")
  2. 读取任务笔记以获取完整上下文
  3. current_step
    恢复工作
    ,借助
    context
    字段
  4. 随进度更新——递增
    current_step
    ,更新上下文,标记已完成步骤

Updating Tasks

更新任务

As work progresses, update the task note:
markdown
undefined
随着工作推进,更新任务笔记:
markdown
undefined

Steps

Steps

  1. First step — done, resulted in X
  2. Second step — done, changed approach because Y
  3. Third step — next up
  1. First step — done, resulted in X
  2. Second step — done, changed approach because Y
  3. Third step — next up

Context

Context

Updated context reflecting current state...

Update frontmatter too:
```yaml
current_step: 3
Updated context reflecting current state...

同时更新前置元数据:
```yaml
current_step: 3

Completing Tasks

完成任务

When done:
yaml
status: done
completed: YYYY-MM-DD
Add a brief summary of what was accomplished and any follow-up needed.
任务完成时:
yaml
status: done
completed: YYYY-MM-DD
添加一段简要总结说明完成的内容及后续需处理的事项。

Pre-Compaction Flush

压缩前同步

When a compaction event is imminent:
  1. Find all active tasks:
    search_notes(note_types=["task"], status="active")
  2. 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
当即将发生压缩事件时:
  1. 查找所有活跃任务:
    search_notes(note_types=["task"], status="active")
  2. 对每个任务进行更新:
    • current_step
      反映实际进度
    • context
      包含恢复工作所需的所有信息
    • 步骤复选框标记已完成项
  3. 这一步至关重要——未记录的上下文将会丢失

Querying Tasks

查询任务

With BM's schema system, tasks are fully queryable:
QueryWhat it finds
search_notes(note_types=["task"])
All tasks
search_notes(note_types=["task"], status="active")
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
借助BM的schema系统,任务可被全面查询:
查询语句查询结果
search_notes(note_types=["task"])
所有任务
search_notes(note_types=["task"], status="active")
活跃任务
search_notes(note_types=["task"], status="blocked")
受阻任务
search_notes(note_types=["task"], metadata_filters={"assigned_to": "claude"})
我的任务
search_notes("blockers", note_types=["task"])
包含阻碍项的任务
schema_validate(noteType="Task")
验证所有任务是否符合schema
schema_diff(noteType="Task")
检测schema与实际任务笔记之间的偏差

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
    active
  • 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
  • 每项任务对应一个工作单元——不要将多个项目塞进一个任务
  • 尽早外部化记录——当你觉得“我应该记住这个”时,立即写下来
  • 上下文优先于步骤——步骤告诉你要做什么;上下文告诉你原因和方法
  • 关闭已完成任务——不要将已完成的工作标记为
    active
  • 关联相关任务——使用
    parent_task [[X]]
    或关联关系连接相关工作
  • Schema验证是好帮手——定期运行
    schema_validate(noteType="Task")
    以发现不完整的任务