用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/evanfang0054/cc-system-creator-scripts --skill deepagents-memory命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | deepagents-memory |
| description | 在 Deep Agents 中实现长期内存,使用 StoreBackend、CompositeBackend 和 InMemoryStore 进行跨会话的持久化数据存储。 |
| language | js |
短期(StateBackend):仅单会话 长期(StoreBackend):跨会话持久化 混合(CompositeBackend):两者结合
import { createDeepAgent, CompositeBackend, StateBackend, StoreBackend } from "deepagents";
import { InMemoryStore } from "@langchain/langgraph";
const store = new InMemoryStore();
const agent = await createDeepAgent({
backend: (config) => new CompositeBackend(
new StateBackend(config),
{ "/memories/": new StoreBackend(config) }
),
store
});
// /memories/* 文件跨会话持久化
// 其他文件是临时的
import { createDeepAgent, CompositeBackend, StateBackend, StoreBackend } from "deepagents";
import { InMemoryStore } from "@langchain/langgraph";
const store = new InMemoryStore();
const agent = await createDeepAgent({
backend: (config) => new CompositeBackend(
new StateBackend(config),
{ "/memories/": new StoreBackend(config) }
),
store
});
// 会话 1:保存偏好
const config1 = { configurable: { thread_id: "thread-1" } };
await agent.invoke({
messages: [{
role: "user",
content: "将我的编码风格保存到 /memories/style.txt:TypeScript、async/await、Jest"
}]
}, config1);
// 会话 2:访问偏好
const config2 = { configurable: { thread_id: "thread-2" } };
await agent.invoke({
messages: [{
role: "user",
content: "阅读我的偏好并编写一个用户获取函数"
}]
}, config2);
import { tool } from "langchain";
import { createAgent } from "langchain";
import { InMemoryStore } from "@langchain/langgraph";
import { z } from "zod";
const getUserPreference = tool(
async ({ key }) => {
const value = await store.get(["user_prefs"], key);
return value ? String(value) : "未找到";
},
{
name: "get_user_preference",
description: "获取用户偏好",
schema: z.object({ key: z.string() }),
}
);
const saveUserPreference = tool(
async ({ key, value }) => {
await store.put(["user_prefs"], key, { value });
return `已保存 ${key}=${value}`;
},
{
name: "save_user_preference",
description: "保存用户偏好",
schema: z.object({ key: z.string(), value: z.string() }),
}
);
store = ();
agent = ({
: ,
: [getUserPreference, saveUserPreference],
store
});
agent.({
: [{ : , : }]
});
agent.({
: [{ : , : }]
});
const agent = await createDeepAgent({
backend: (config) => new CompositeBackend(
new StateBackend(config),
{
"/memories/": new StoreBackend(config),
"/workspace/": new StateBackend(config),
}
),
store: new InMemoryStore()
});
// 构建知识
await agent.invoke({
messages: [{
role: "user",
content: "在 /memories/db-schema.md 中记录数据库架构"
}]
}, { configurable: { thread_id: "thread-1" } });
// 后续使用知识
await agent.invoke({
messages: [{
role: "user",
content: "编写一个迁移来为用户添加邮箱"
}]
}, { configurable: { thread_id: "thread-2" } });
| 模式 | 后端 | 使用场景 |
|---|---|---|
| 全部临时 | StateBackend | 单会话任务 |
| 全部持久化 | StoreBackend | 记住所有内容 |
| 混合 | CompositeBackend | /memories/ 持久化,其余临时 |
✅ 将文件保存到持久化存储 ✅ 跨会话访问持久化文件 ✅ 混合临时和持久化存储 ✅ 使用 Store 命名空间/键模式
❌ 没有 Store 访问内存 ❌ 跨会话持久化 StateBackend 文件 ❌ 在没有共享 Store 的情况下在 agent 之间共享内存
// ❌ 缺少 store
await createDeepAgent({
backend: (config) => new StoreBackend(config)
});
// ✅ 提供 store
await createDeepAgent({
backend: (config) => new StoreBackend(config),
store: new InMemoryStore()
});
// ❌ 不持久化(路径错误)
await agent.invoke({
messages: [{ role: "user", content: "保存到 /prefs.txt" }]
});
// ✅ 持久化(匹配 /memories/ 路由)
await agent.invoke({
messages: [{ role: "user", content: "保存到 /memories/prefs.txt" }]
});
// ❌ 重启时丢失
const store = new InMemoryStore();
// ✅ 生产环境使用持久化存储
import { PostgresStore } from "@langchain/langgraph";
const store = new PostgresStore({ connectionString: "postgresql://..." });
const backend = (config) => new CompositeBackend(
new StateBackend(config),
{
"/mem/": new StoreBackend(config),
"/mem/temp/": new StateBackend(config), // 更具体
}
);
// /mem/file.txt -> StoreBackend
// /mem/temp/file.txt -> StateBackend(更长的匹配)
Mac 系统深度清理和优化工具。使用 Mole (mo 命令) 执行系统清理、磁盘分析、应用卸载、系统优化等任务。 触发场景(当用户提到以下任一内容时使用此 skill): - 清理 Mac、清理磁盘、释放空间、清理缓存、清理系统 - 卸载应用、删除应用、移除应用及其残留 - 磁盘分析、查看磁盘占用、大文件查找、空间分析 - 系统优化、系统维护、刷新系统、重建缓存 - 系统状态、系统监控、CPU/内存/磁盘监控 - 清理 node_modules、清理构建产物、清理项目依赖 - 清理安装包、删除 dmg/pkg 文件 - Mac 清理工具、类似 CleanMyMac 的功能 - "我的 Mac 太慢了"、"磁盘空间不足"、"电脑卡顿" - 即使没有明确说 "Mole",只要涉及上述场景就应使用
构建 CLI / command-line 工具时使用,支持两种模式。模式 A 人类 CLI(终端 UX、彩色、交互式提示、进度条、Shell 自动补全),关键词包括 commander / yargs / oclif / typer / click / cobra。模式 B agent-native CLI(JSON envelope / schema 自省 / dry-run 写入安全 / 契约驱动),关键词包括 agent-native CLI、JSON envelope、friction signal。混合场景默认走 B(agent 约束更严格)。只要用户提到 CLI、command-line、命令行工具、agent-native、envelope、schema、friction signal,或要给 agent 提供可调用的 CLI 工具,就应主动使用此 skill。
快速搭建和配置 pnpm monorepo 项目结构,包含 TypeScript、tsup 构建、私有 npm registry 配置。当用户需要"创建 monorepo"、"初始化 monorepo 项目"、"配置 pnpm workspace"、"设置 monorepo 构建"、"monorepo setup"时使用。特别适合需要统一管理多个包、配置构建工具、处理 TypeScript 路径问题的场景。即使用户只是说"帮我搭建项目结构"或"配置构建",如果涉及多包管理也应该使用此 skill。