Memory to Notion
This skill retrieves the user's past conversation history, analyzes it for valuable and meaningful
content, decomposes conversations into atomic memory entries, and writes them as rows into
the Memory Store Notion Database.
Database Discovery
This skill uses a zero-config convention: the database is always named "Memory Store".
Locate the database:
CODEBLOCK0
From the results, find the item with object: "data_source" whose title is "Memory Store".
Extract both:
- -
data_source_id -- for querying (POST /v1/data_sources/{id}/query) - INLINECODE3 -- for creating pages (
POST /v1/pages with parent: {"database_id": "..."})
- - If found -> use
data_source_id for queries, database_id for page creation. - If not found -> ask the user: "No 'Memory Store' database found in your Notion workspace.
Which page should I create it under? Please provide a Notion page URL or page ID."
Then create the database (see Database Creation below).
Schema
| Property | Type | Description |
|---|
| Title | Title | One-line memory summary (searchable) |
| Category |
Select | Fact / Decision / Preference / Context / Pattern / Skill|
| Content | Rich Text | Detailed memory content |
| Source | Select | Claude.ai / ClaudeCode / Manual / OpenClaw / Other |
| Status | Select | Active / Archived / Contradicted |
| Scope | Select | Global / Project |
| Project | Rich Text | Project name (set when Scope=Project, leave empty for Global) |
| Expiry | Select | Never / 30d / 90d / 1y |
| Source Date | Date | When the original conversation happened |
Database Creation
When the database does not exist, create it under the user-specified parent page.
Use the Notion create-database API with the schema above.
Category Definitions
- - Fact: Objective facts -- user's identity, background, tech stack, tools, environment, organization
- Decision: Architecture decisions, technology choices, approach selections
- Preference: User preferences -- coding style, tool configuration, interaction habits
- Context: Background information -- project context, domain knowledge, observations
- Pattern: Behavioral patterns -- workflows, recurring needs
- Skill: Skills and knowledge -- commands, APIs, techniques learned
Platform Adaptation
This skill describes operations using generic Notion REST API format.
Each platform's AI should translate to its available tools using the fixed mappings below.
Do NOT guess -- follow these mappings exactly.
Claude Code / Claude.ai (Notion MCP Tools)
| Operation | SKILL.md Describes | Use MCP Tool | Key Parameters |
|---|
| Discover database | INLINECODE8 | INLINECODE9 | INLINECODE10 , INLINECODE11 |
| Get IDs |
-- |
notion-fetch | Fetch the database, extract
data_source_id from
<data-source url="collection://..."> tag |
| Dedup query |
POST /v1/data_sources/{id}/query |
Not available | Fall back to
notion-search with
data_source_url (see Step 3 note) |
| Create page |
POST /v1/pages |
notion-create-pages |
parent: { "data_source_id": "..." } |
| Update page status |
PATCH /v1/pages/{id} |
notion-update-page |
command: "update_properties" |
| Create database |
POST /v1/databases |
notion-create-database | Uses SQL DDL syntax (see Database Creation) |
| Fetch page |
GET /v1/pages/{id} |
notion-fetch |
id: "<page_id>" |
Critical notes:
- - Discovery MUST use
content_search_mode: "workspace_search" (default ai_search mode may not return databases) - Structured query for dedup is not available in MCP. Use semantic search as fallback:
notion-search with
data_source_url: "collection://<data_source_id>" and keywords from the candidate memory.
Then
notion-fetch each result to compare full properties.
- - Do NOT parallel-call multiple
notion-search against the same data_source_url -- MCP will error.
When deduping multiple candidate memories, run searches sequentially. Deduplicate results by page id before fetching.
- -
notion-create-database uses SQL DDL syntax, not JSON. See Database Creation section for the DDL.
OpenClaw
OpenClaw accesses Notion through a separately installed "notion" skill
(clawhub.ai/steipete/notion).
This skill must be installed before using memory-to-notion.
When executing, first read the notion skill's SKILL.md to learn the Notion API access patterns
(API key setup, curl commands, endpoints). Then follow this workflow using those patterns.
- - All operations described in this skill (search, query, create page, update page, create database)
map directly to the notion skill's REST API patterns
- - All operations including structured query for dedup are fully supported
Important: This skill (memory-to-notion) is a workflow skill that depends on Notion
connectivity. It does NOT provide Notion access itself -- it relies on the platform's Notion
integration (MCP tools on Claude Code/Claude.ai, notion skill on OpenClaw).
Workflow
Step 1: Discover Database
Locate the "Memory Store" database. If not found, create it (see above).
Step 2: Gather Conversation Content
Choose a strategy based on the current platform:
Claude.ai (has conversation history API):
- - Use
recent_chats(n=20) to fetch recent conversations - Use
after/before parameters to filter by time range - Use
conversation_search for keyword-based retrieval - For comprehensive archival, paginate up to ~5 rounds
Claude Code (current session only):
- - Extract valuable information from the current conversation context
- Triggered when the user says "summarize memory" or similar
- Review facts, decisions, preferences produced in this session
- Cannot access past sessions -- only processes current conversation
Step 3: Check Existing Memories (Dedup & Conflict Detection)
Before writing, query the database to check for duplicates and conflicts.
For each candidate memory, search Title and Content:
CODEBLOCK1
MCP platforms (Claude Code / Claude.ai): Structured query is not available.
Use notion-search with data_source_url: "collection://<data_source_id>" and keywords
from the candidate memory as query. Run dedup searches sequentially (not in parallel).
Deduplicate results by page id across searches, then notion-fetch only unique results to compare properties.
The query returns full page properties. Check for:
- 1. Duplicates: Same fact already stored -> skip
- Updates: Same topic but info changed -> update existing, mark old as Contradicted if needed
- Conflicts: New info contradicts existing -> create new as Active, mark old as Contradicted
Step 4: Decompose into Atomic Memories
Each conversation may yield 0-N memory entries. The key principle is one fact per row.
Decomposition rules:
- - Each memory should be self-contained and independently meaningful
- Don't store entire conversation summaries -- extract individual facts, decisions, preferences
- Title should be a single declarative sentence (searchable)
- Content provides enough detail to be useful without the original conversation
Examples of good decomposition:
A conversation about "setting up a new Python project" might yield:
CODEBLOCK2
What NOT to store:
- - Transient Q&A that can be easily re-searched ("What is Python's GIL")
- Pleasantries and small talk
- Failed attempts with no useful outcome
- Information the user explicitly asked to forget
Step 5: Write to Memory Store
Create pages in the database. For each memory entry, set properties:
CODEBLOCK3
Scope guidelines:
- - Global: Cross-project universal -- user preferences, general toolchain, personal habits, global decisions
- Project: Project-specific -- project architecture, dedicated config, project-scoped technical decisions
- When uncertain, default to Global
- Project field should match the user's project directory name or repository name (e.g., "OpenClaw")
Expiry guidelines:
- - Never: Stable facts and preferences (name, tools, architecture)
- 1y: May become outdated (tool versions, project status)
- 90d: Limited shelf life (current tasks, temporary decisions)
- 30d: Very transient (this week's todos, temporary workarounds)
Step 6: Handle Conflicts
If Step 3 found conflicting memories:
- 1. Update the old memory's Status to "Contradicted":
PATCH /v1/pages/{old_page_id}
{ "properties": { "Status": { "select": { "name": "Contradicted" } } } }
- 2. Create the new memory with Status "Active" (default)
- Optionally note in new Content what it supersedes: "(Updated: previously recorded as XX)"
Step 7: Report Results
After writing, provide the user with a summary:
- - Conversations processed
- Memories created / updated / skipped
- List of new entries with Titles and Categories
- Conflicts detected and how resolved
Example:
CODEBLOCK5
Important Notes
- - Atomic entries: One fact per row. Never dump a whole conversation summary into one entry.
- Language: Title and Content should be written in the user's primary language (the language they most frequently use in conversations). This ensures memories are searchable and readable in the language the user naturally uses. Do NOT force English -- match the user's language.
- Idempotent: Always check for existing memories before writing. Running twice should not create duplicates.
- Source accuracy: Auto-set Source based on current platform (Claude.ai -> "Claude.ai", Claude Code -> "ClaudeCode", OpenClaw -> "OpenClaw").
- Preserve details: Keep code snippets, commands, config values, URLs verbatim in Content.
- User control: Don't store anything the user wouldn't want to see. When in doubt, ask.
- Cross-platform ready: Write Content so any AI platform can understand and use it.
Example Interaction
User: summarize memory
Claude:
- 1. Searches for "Memory Store" database, obtains
data_source_id and INLINECODE45 - Reviews current session (Claude Code) or recent chats (Claude.ai)
- Queries database for existing entries to avoid duplicates
- Decomposes conversations into atomic memories
- Writes entries to the database
- Reports: "Processed 5 conversations, generated 8 new memories, updated 1, skipped 2."
Memory to Notion
此技能用于检索用户的过往对话历史,分析其中有价值、有意义的内容,将对话分解为原子化记忆条目,并将其作为行写入 Memory Store Notion 数据库。
数据库发现
此技能采用零配置约定:数据库始终命名为 Memory Store。
定位数据库:
POST /v1/search
{
query: Memory Store
}
从结果中找到 object: data_source 且标题为 Memory Store 的条目。提取以下两项:
- - datasourceid —— 用于查询(POST /v1/datasources/{id}/query)
- databaseid —— 用于创建页面(POST /v1/pages,附带 parent: {database_id: ...})
- - 如果找到 -> 使用 datasourceid 进行查询,使用 database_id 创建页面。
- 如果未找到 -> 询问用户:在您的 Notion 工作区中未找到 Memory Store 数据库。请问我应在哪个页面下创建它?请提供 Notion 页面 URL 或页面 ID。 然后创建数据库(参见下方数据库创建)。
数据模式
选择 | 事实 / 决策 / 偏好 / 背景 / 模式 / 技能 |
| 内容 | 富文本 | 详细的记忆内容 |
| 来源 | 选择 | Claude.ai / ClaudeCode / 手动 / OpenClaw / 其他 |
| 状态 | 选择 | 活跃 / 已归档 / 已矛盾 |
| 范围 | 选择 | 全局 / 项目 |
| 项目 | 富文本 | 项目名称(范围=项目时设置,全局时留空) |
| 过期时间 | 选择 | 永不过期 / 30天 / 90天 / 1年 |
| 来源日期 | 日期 | 原始对话发生的时间 |
数据库创建
当数据库不存在时,在用户指定的父页面下创建。使用上述数据模式调用 Notion 创建数据库 API。
类别定义
- - 事实:客观事实——用户身份、背景、技术栈、工具、环境、组织
- 决策:架构决策、技术选型、方案选择
- 偏好:用户偏好——编码风格、工具配置、交互习惯
- 背景:背景信息——项目背景、领域知识、观察记录
- 模式:行为模式——工作流程、重复性需求
- 技能:技能与知识——命令、API、已学技术
平台适配
此技能使用通用的 Notion REST API 格式描述操作。各平台的 AI 应使用下方固定映射翻译为其可用工具。不要猜测——严格遵循这些映射。
Claude Code / Claude.ai(Notion MCP 工具)
| 操作 | SKILL.md 描述 | 使用 MCP 工具 | 关键参数 |
|---|
| 发现数据库 | POST /v1/search | notion-search | query: Memory Store, contentsearchmode: workspacesearch |
| 获取 ID |
-- | notion-fetch | 获取数据库,从
标签中提取 datasource_id |
| 去重查询 | POST /v1/datasources/{id}/query | 不可用 | 回退到 notion-search,使用 datasource_url(参见步骤 3 说明) |
| 创建页面 | POST /v1/pages | notion-create-pages | parent: { datasourceid: ... } |
| 更新页面状态 | PATCH /v1/pages/{id} | notion-update-page | command: update_properties |
| 创建数据库 | POST /v1/databases | notion-create-database | 使用 SQL DDL 语法(参见数据库创建) |
| 获取页面 | GET /v1/pages/{id} | notion-fetch | id: |
关键说明:
- - 发现操作必须使用 contentsearchmode: workspacesearch(默认的 aisearch 模式可能不返回数据库)
- MCP 中不可用结构化去重查询。使用语义搜索作为回退方案:notion-search 附带 datasourceurl: collection://sourceid> 和候选记忆中的关键词。然后对每个结果执行 notion-fetch 以比较完整属性。
- 不要并行调用多个针对同一 datasourceurl 的 notion-search——MCP 会报错。当对多个候选记忆进行去重时,按顺序执行搜索。在获取之前按页面 ID 对结果进行去重。
- notion-create-database 使用 SQL DDL 语法,而非 JSON。参见数据库创建部分的 DDL。
OpenClaw
OpenClaw 通过单独安装的 notion 技能(clawhub.ai/steipete/notion)访问 Notion。在使用 memory-to-notion 之前,必须先安装此技能。
执行时,首先阅读 notion 技能的 SKILL.md 以了解 Notion API 的访问模式(API 密钥设置、curl 命令、端点)。然后使用这些模式遵循本工作流程。
- - 本技能描述的所有操作(搜索、查询、创建页面、更新页面、创建数据库)直接映射到 notion 技能的 REST API 模式
- 包括用于去重的结构化查询在内的所有操作均完全支持
重要提示:本技能(memory-to-notion)是一个工作流技能,依赖于 Notion 连接。它本身不提供 Notion 访问——它依赖于平台的 Notion 集成(Claude Code/Claude.ai 上的 MCP 工具,OpenClaw 上的 notion 技能)。
工作流程
步骤 1:发现数据库
定位 Memory Store 数据库。如果未找到,则创建它(参见上文)。
步骤 2:收集对话内容
根据当前平台选择策略:
Claude.ai(有对话历史 API):
- - 使用 recentchats(n=20) 获取最近的对话
- 使用 after/before 参数按时间范围筛选
- 使用 conversationsearch 进行基于关键词的检索
- 如需全面归档,可分页获取约 5 轮
Claude Code(仅当前会话):
- - 从当前对话上下文中提取有价值的信息
- 当用户说总结记忆或类似内容时触发
- 审查本次会话中产生的事实、决策、偏好
- 无法访问过去的会话——仅处理当前对话
步骤 3:检查现有记忆(去重与冲突检测)
在写入之前,查询数据库以检查重复和冲突。对每个候选记忆,搜索标题和内容:
POST /v1/datasources/{datasource_id}/query
{
filter: {
or: [
{ property: Title, title: { contains: <新记忆中的关键词> } },
{ property: Content, rich_text: { contains: <新记忆中的关键词> } }
]
},
page_size: 10
}
MCP 平台(Claude Code / Claude.ai): 结构化查询不可用。使用 notion-search,附带 datasourceurl: collection://sourceid> 和候选记忆中的关键词作为查询。按顺序执行去重搜索(不要并行)。按页面 ID 对搜索结果进行去重,然后仅对唯一结果执行 notion-fetch 以比较属性。
查询返回完整的页面属性。检查以下情况:
- 1. 重复:相同事实已存储 -> 跳过
- 更新:相同主题但信息已变更 -> 更新现有条目,必要时将旧条目标记为已矛盾
- 冲突:新信息与现有信息矛盾 -> 创建新条目为活跃状态,将旧条目标记为已矛盾
步骤 4:分解为原子化记忆
每个对话可能产生 0-N 条记忆条目。关键原则是每行一个事实。
分解规则:
- - 每条记忆应自包含且独立有意义
- 不要存储整个对话摘要——提取单个事实、决策、偏好
- 标题应为单个陈述句(可搜索)
- 内容应提供足够细节,无需原始对话即可使用
良好分解