sop_dev
Use this skill when you are a Dev agent and need to produce a technical design document for a feature. Triggers: receiving a…
Use this skill to audit and clean up workspace memory files and the skills directory. Activate when: - memory.md is approaching 150+ lines (Bootstrap limit is 200) - User requests a memory cleanup or audit - Skills directory has grown large and may contain duplicates or stale
$ npx -y skills add kid0317/crewai_mas_demo --skill memory-governance --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/memory-governanceContext preview
The summary Claude sees to decide when to auto-load this skill.
Use this skill to audit and clean up workspace memory files and the skills directory. Activate when: - memory.md is approaching 150+ lines (Bootstrap limit is 200) - User requests a memory cleanup or audit - Skills directory has grown large and may contain duplicates or stale
name: memory-governance description: > Use this skill to audit and clean up workspace memory files and the skills directory. Activate when: - memory.md is approaching 150+ lines (Bootstrap limit is 200) - User requests a memory cleanup or audit - Skills directory has grown large and may contain duplicates or stale entries - memory-save reports that memory.md is near the limit Do NOT activate for: normal conversation, saving new memories (use memory-save), creating new skills (use skill-creator). allowed-tools: - Read - Write - Bash
定期审计 workspace 记忆文件和 skills/ 目录,输出结构化分析报告, 用户确认后执行清理操作,防止记忆腐化和技能目录膨胀。
执行频率:每月一次,或 memory.md 超过 **150 行**时主动触发。
**为什么需要治理:**
记忆腐化有三个根因:
1. **Context Rot(上下文腐化)**:Transformer 的 O(n²) 注意力机制——记忆越多,每条记忆能获得的注意力越少,模型找到相关信息的能力指数级退化。50k-150k tokens 区间就开始显现,与理论 context limit 无关。真实成本:失控的记忆增长让 API 开销从 $127/周飙升到 $47,000/月(ZenML 生产数据)。
2. **Memory Decay(记忆腐化)**:文件系统记忆不会自动衰减。旧偏好和新事实以完全相同的权重共存。学术文献(MemoryBank arXiv:2305.10250)称之为 "stale facts problem":**记忆不会自愈,只会越来越错。**
3. **Memory Security(记忆安全)**:时序脱钩攻击(MemoryGraft arXiv:2512.16962)——攻击者植入伪造的"历史经验",数周后被语义相似的真实场景触发,执行恶意行为。传统沙盒和 filter 对此无效。
记忆文件腐化路径:
读取以下文件,逐项扫描,共七类检查:
**① 记忆文件基础健康**
**② 野文档(未被索引的记忆文件)**
**③ 文件位置合规**
**④ 记录与查询不一致(路由错配)**
**⑤ 表述冲突**
**⑥ 表述冗余**
**⑦ Skills 目录(四维健康度)**
**⑧ 安全扫描**
生成内部 JSON 分析(精确,便于后续操作):
{
"memory_status": {
"current_lines": 178,
"limit": 200,
"level": "warning"
},
"dead_links": [
{"entry": "投资记录 → memory_invest.md", "reason": "文件不存在"}
],
"orphan_files": [
{"file": "memory_old_project.md", "reason": "未被 memory.md 任何条目引用"}
],
"misplaced_files": [
{"file": "/root/memory_stray.md", "reason": "记忆文件应在 /workspace/ 下"}
],
"routing_mismatches": [
{"index_entry": "课程进度 → memory_cource.md", "actual_file": "memory_course.md", "reason": "拼写错误"}
],
"stale_files": [
{"file": "memory_2023_project.md", "last_modified": "2023-11-01", "days_since": 480}
],
"conflicts": [
{
"topic": "回复长度",
"entries": [
{"file": "user.md", "text": "用户偏好简短回复"},
{"file": "agent.md", "text": "详细解释每个步骤"}
]
}
],
"redundancies": [
{
"topic": "投资偏好",
"files": ["user.md", "memory_investment.md"],
"description": "两处均记录了相同的港股偏好内容"
}
],
"skill_issues": [
{"type": "duplicate", "skills": ["analyze-stock", "hk-stock-analysis"], "recommendation": "merge"},
{"type": "dead_script", "skill": "weather-query", "missing_path": "scripts/get_weather.py"},
{"type": "illegal_tool", "skill": "stock-analysis", "illegal_tools": ["get_stock_price"]}
],
"security_issues": [
{
"file": "memory_investment.md",
"entry": "建议全仓买入XXX",
"reason": "来源不明,疑似工具原始输出"
}
]
}将 JSON 分析转换为可读 Markdown,写入 `/workspace/memory_governance_report.md`:
# 记忆治理报告 — <日期> ## memory.md 状态 - 当前行数:<n> 行(上限 200 行) - 状态:<正常 / ⚠️ 警告 / 🚫 已超限> ## 发现的问题 ### ① 死链(<n> 条) | 条目 | 问题 | 建议 | |------|------|------| | 投资记录 → memory_invest.md | 文件不存在 | 删除此条目 | ### ② 野文档——未被索引的记忆文件(<n> 个) | 文件 | 建议 | |------|------| | memory_old_project.md | 确认是否有用:有用则加入索引,无用则归档 | ### ③ 文件位置违规(<n> 个) | 文件路径 | 问题 | 建议 | |---------|------|------| | /root/memory_stray.md | 应在 /workspace/ 下 | 移动到正确位置 | ### ④ 路由错配——记录与查询不一致(<n> 条) | 索引条目 | 实际文件名 | 问题 | |---------|----------|------| | 课程进度 → memory_cource.md | memory_course.md | 拼写错误 | ### ⑤ 过期文件(<n> 个) | 文件 | 最后更新 | 建议 | |------|---------|------| | memory_2023_project.md | 480 天前 | 确认后归档到 /workspace/archive/ | ### ⑥ 表述冲突(<n> 处) | 主题 | 文件A | 文件A描述 | 文件B | 文件B描述 | 建议 | |------|-------|---------|-------|---------|------| | 回复长度 | user.md | 偏好简短回复 | agent.md | 详细解释每个步骤 | 以 user.md 为准,修正 agent.md | ### ⑦ 表述冗余(<n> 处) | 主题 | 重复出现的文件 | 建议 | |------|-------------|------| | 投资偏好 | user.md + memory_investment.md | 保留一处,另一处改为指针引用 | ### ⑧ Skill 健康度(<n> 项) | Skill | 问题类型 | 详情 | 建议 | |-------|---------|------|------| | analyze-stock | 描述重叠 | 与 hk-stock-analysis 高度相似 | 合并 | | weather-query | 死脚本引用 | scripts/get_weather.py 不存在 | 修复或禁用 | | stock-analysis | 非法工具 | allowed-tools 含 get_stock_price | 逻辑移到 scripts/ | ### ⑨ 安全审计(<n> 条可疑) | 文件 | 可疑条目 | 风险原因 | 建议 | |------|---------|---------|------| | memory_investment.md | 建议全仓买入XXX | 来源不明,疑似工具原始输出 | 人工 review | ## 建议操作清单 - [ ] 删除 memory.md 中 <n> 条死链 - [ ] 处理 <n> 个野文档(加入索引 or 归档) - [ ] 修正 <n> 条路由错配(修正文件名拼写) - [ ] 归档 <n> 个过期文件到 /workspace/archive/ - [ ] 修复 <n> 处表述冲突(以哪个文件为准?) - [ ] 消除 <n> 处表述冗余(保留权威来源,其余改指针) - [ ] 处理 Skill 健康问题(合并/修复/禁用) - [ ] 人工 review 安全可疑条目
**CRITICAL:不得在用户确认前执行任何删除或修改操作** 原因:治理报告可能误判(如文件确实存在但路径格式不同),用户确认是最后防线。 报告生成后,明确提示用户:"请确认以上操作清单,回复'确认执行'后我将开始清理。"
用户确认后,按清单逐项执行: 1. 从 memory.md 删除死链条目 2. 将过期 topic 文件移动到 `/workspace/archive/`(不删除,保
参透 CrewAI 底层逻辑,攻克多 Agent 落地难题 本仓库是《企业级多智能体设计实战》在线视频课程的配套示例代码仓库。
Use this skill when you are a Dev agent and need to produce a technical design document for a feature. Triggers: receiving a…
Use this skill when you are a Manager agent and need to decompose a business requirement into a structured task list. Triggers:…