Notion Sync Skill
将对话内容结构化地同步到 Notion 数据库。触发词:同步到 notion、更新到 notion、存到 notion、记录到 notion、保存到 notion、写入 notion。首次使用需交互式配置 API Token 和数据库 ID,自动读取属性结构并设置映射。
Free to install — no account needed
Copy the command below and paste into your agent.
Instant access • No coding needed • No account needed
What you get in 5 minutes
- Full skill code ready to install
- Works with 1 AI agent
- Lifetime updates included
Description
--- name: notion-sync description: 将对话内容结构化地同步到 Notion 数据库。触发词:同步到 notion、更新到 notion、存到 notion、记录到 notion、保存到 notion、写入 notion。首次使用需交互式配置 API Token 和数据库 ID,自动读取属性结构并设置映射。 --- # Notion Sync Skill 将 Claude 对话中的关键内容以结构化方式写入 Notion 数据库。自动区分用户输入和 AI 回答,提炼总结用户核心需求。 ## 目录结构 ``` notion-sync/ ├── SKILL.md # Skill 定义 ├── scripts/ │ └── notion_client.py # Notion API 辅助脚本 ├── config.json # 本地配置(含 API Token,不提交到 Git) └── .gitignore ``` ## 初始化流程(首次触发时执行) 当检测到配置文件(`config.json`)不存在时,执行以下流程: ### 步骤 1:引导用户获取必要信息 告知用户需要提前准备两样东西: **1. Notion API Token(Internal Integration Secret)** 引导用户前往 https://www.notion.so/my-integrations: - 点击 "New Integration" → 填写名称(如 "Claude Sync") - 选择关联的工作空间 → 点击 Submit - 复制 "Internal Integration Secret"(以 `secret_` 开头) **2. Database ID** 用户在 Notion 中打开目标数据库页面,URL 格式为: `https://www.notion.so/{workspace}/{page_id}?v=...` 其中 `page_id` 的 32 位 UUID 即为 database_id。 ### 步骤 2:交互式初始化 通过辅助脚本的 init 命令进行初始化,脚本路径相对于 Skill 目录: ```bash python3 ./scripts/notion_client.py init ``` 此脚本会: 1. 提示用户输入 API Token 和 Database ID 2. 自动验证连接有效性 3. 读取并展示数据库所有属性(名称、类型、说明) 4. 标记 title 属性 5. 询问用户是否要自定义属性映射 6. 保存配置到 `config.json` ### 步骤 3:授权提醒 如果初始化时报 404 错误,提醒用户: - 确保 Integration 已被邀请到目标数据库 - 在数据库页面右上角 → Share → Invite → 选择刚才创建的 Integration ## 主流程(每次触发时执行) 每次用户触发"同步到 Notion"时,执行以下步骤: ### 步骤 1:读取配置 通过辅助脚本检查配置是否已存在: ```bash python3 ./scripts/notion_client.py show-config ``` 如果配置文件存在 → 继续主流程 如果配置文件不存在 → 转入初始化流程 ### 步骤 2:提取对话内容 从当前对话上下文中提取以下内容: **a) 用户原始输入** — 用户最近一次输入的全部内容 **b) AI 回答** — 对该次输入的全部回答内容(如果本次对话同时有多次问答,提取最近一次完整问答) **c) 提炼用户核心需求** — 对用户输入进行结构化提炼,格式示例: ``` 核心问题:xxx(一句话概括用户想解决的问题) 关键要点: - 要点 1 - 要点 2 背景信息:xxx(如有) ``` 注意:提炼时去除口语化表达、重复内容,保留核心信息。 ### 步骤 3:生成标题 根据提炼的核心需求,生成 30 字以内的简洁标题。 ### 步骤 4:生成结构化 JSON 将内容组装为 JSON,通过管道传给辅助脚本的 `create-page` 命令: ```bash cat << 'JSONEOF' | python3 ./scripts/notion_client.py create-page { "title": "生成的标题", "user_summary": "提炼后的用户核心需求\n- 要点1\n- 要点2", "user_raw": "用户的原始输入内容", "ai_response": "AI 的回答内容" } JSONEOF ``` ### 步骤 5:反馈结果 - 成功:告知用户 "✅ 已同步到 Notion",附上页面 URL - 失败:输出错误信息,根据错误类型给出修复建议: - 401 → Token 失效,需要重新初始化 - 404 → 数据库访问权限问题 - 400 → 请求体格式问题(通常是属性类型不匹配) ## 管理命令 用户可以通过以下方式管理配置: - **查看配置** → `python3 ./scripts/notion_client.py show-config`(或在对话中询问 "查看 notion 配置") - **重置配置** → `python3 ./scripts/notion_client.py reset`(或在对话中询问 "重置 notion 配置") ## 关键注意事项 1. **API Token 安全**:token 只存储在本地 `config.json`,已加入 `.gitignore`,不会提交到仓库 2. **Notion API 版本**:固定使用 `2022-06-28` 3. **属性兼容**:不同的属性类型对应不同的 JSON 格式(helper 脚本已内置处理) 4. **Blocks 限制**:正文 children 不超过 100 个 block,长文本自动分段 5. **区分内容来源**:页面正文必须明确标识"用户原始输入"和"AI 回答"两个部分 6. **用户输入需要提炼**:不要直接把用户的口语化输入贴上去,要先提炼再呈现
Security Status
Unvetted
Not yet security scanned
Related AI Tools
More Grow Business tools you might like
Linear
FreeManaging Linear issues, projects, and teams. Use when working with Linear tasks, creating issues, updating status, querying projects, or managing team workflows.
codex-collab
FreeUse when the user asks to invoke, delegate to, or collaborate with Codex on any task. Also use PROACTIVELY when an independent, non-Claude perspective from Codex would add value — second opinions on code, plans, architecture, or design decisions.
Rails Upgrade Analyzer
FreeAnalyze Rails application upgrade path. Checks current version, finds latest release, fetches upgrade notes and diffs, then performs selective upgrade preserving local customizations.
Asta MCP — Academic Paper Search
FreeDomain expertise for Ai2 Asta MCP tools (Semantic Scholar corpus). Intent-to-tool routing, safe defaults, workflow patterns, and pitfall warnings for academic paper search, citation traversal, and author discovery.
Hand Drawn Diagrams
FreeCreate hand-drawn Excalidraw diagrams, flows, explainers, wireframes, and page mockups. Default to monochrome sketch output; allow restrained color only for page mockups when the user explicitly wants webpage-like fidelity.
Move Code Quality Checker
FreeAnalyzes Move language packages against the official Move Book Code Quality Checklist. Use this skill when reviewing Move code, checking Move 2024 Edition compliance, or analyzing Move packages for best practices. Activates automatically when working