关于 memory-tasks
Memory Tasks 是一项技能,可在 Basic Memory 的知识图谱中将进行中的工作记录为经过模式验证的任务笔记。它帮助 Agent 在长任务、上下文压缩或会话重启后保留进度。
主要功能
- 01将任务创建为类型化笔记
- 02按模式验证任务
- 03跟踪状态、优先级和当前步骤
- 04压缩后恢复进行中的任务
- 05通过关系关联相关工作
- 06随进展更新任务上下文
适用场景
- 01记录多步骤工作事项
- 02会话重启后恢复任务
- 03上下文压缩前保存进度
- 04查找并验证进行中或受阻任务
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ basicmachines-co/ basic-memory-skills --skill memory-tasks安装后在 Claude Code 中输入/memory-tasks确认已加载。
详细介绍
任务管理
使用 Basic Memory 的架构系统管理进行中的工作。任务只是带有 type: Task 的笔记——它们位于知识图谱中,根据架构进行验证,并且在上下文压缩后仍会保留。
适用时机
- 开始多步骤工作时(3 步以上,或任何可能持续到上下文窗口耗尽之后的工作)
- 压缩/重启后——搜索活动任务以继续工作
- 压缩前刷新——用当前状态更新所有活动任务
- 按需处理——用户要求创建、检查或管理任务
任务架构
任务使用 BM 架构系统(SPEC-SCHEMA)。架构笔记位于 memory/schema/Task.md:
---
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
---
创建任务
符合条件时,创建一条任务笔记。使用 write_note,并设置 note_type="Task",将可查询字段放入 metadata:
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
- [description] What needs to be done, concisely
- [status] active
- [assigned_to] claude
- [current_step] 1
## Steps
1. [ ] First concrete step
2. [ ] Second concrete step
3. [ ] Third concrete step
## 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"""
)
为什么要同时写入 frontmatter 和观察项? metadata 中的字段(存储为 frontmatter)可供带有 metadata_filters 的 search_notes 使用。作为观察项的字段(- [status] active)可供 schema_validate 使用。要全面覆盖,请在两处都包含可查询字段。
关键原则
- 步骤应具体且可检查——写“在文件 Y 中实现 X”,而不是“想办法处理一下”
- 上下文用于失忆后的恢复——写得仿佛是在向一个聪明但完全不了解你已做工作的人解释
- 关系用于关联其他实体——
parent_task [[Other Task]]、related_to [[Some Note]] note_types区分大小写——write_note(note_type="Task")会将类型以小写task存入 frontmatter。在搜索查询中使用小写的note_types=["task"]。
压缩后继续工作
在会话开始或压缩后:
-
搜索活动任务:
search_notes(note_types=["task"], status="active") -
阅读任务笔记以获取完整上下文
-
使用
context字段,从current_step开始继续 -
随进度更新——递增
current_step,更新上下文,并勾选已完成的步骤
更新任务
随着工作推进,更新任务笔记:
## Steps
1. [x] First step — done, resulted in X
2. [x] Second step — done, changed approach because Y
3. [ ] Third step — next up
## Context
Updated context reflecting current state...
同时更新 frontmatter:
current_step: 3
完成任务
完成后:
status: done
completed: YYYY-MM-DD
简要总结已完成的工作以及需要进行的后续事项。
压缩前刷新
即将发生压缩事件时:
- 找出所有活动任务:
search_notes(note_types=["task"], status="active") - 对每个任务,更新:
current_step,使其反映实际进度context,包含继续工作所需的一切信息- 步骤复选框,标明已完成的内容
- 这至关重要——未写下来的上下文就是丢失的上下文
查询任务
借助 BM 的架构系统,任务完全可查询:
| 查询 | 查找内容 |
|---|---|
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_diff(noteType="Task") | 检测架构与实际任务笔记之间的偏差 |
指南
- 每项工作对应一个任务——不要把多个项目塞进一个任务
- 尽早记录到外部——如果你想到“我应该记住这个”,现在就把它写下来
- 上下文胜过步骤——步骤告诉你要做什么;上下文告诉你原因和方法
- 关闭已完成的任务——不要让已完成的工作仍处于
active状态 - 关联相关任务——使用
parent_task [[X]]或关系来连接相关工作 - 架构验证是好帮手——定期运行
schema_validate(noteType="Task"),以发现不完整的任务
评论
支持 Markdown