重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
insight-extraction by oimiragieo/agent-studio
npx skills add https://github.com/oimiragieo/agent-studio --skill insight-extraction分析已完成的编码会话,并为记忆系统提取结构化的学习成果。洞察有助于未来的会话避免错误、遵循既定模式,并更快地理解代码库。
核心原则: 提取可操作的知识,而非日志。每个洞察都应帮助未来的会话更好地完成某些事情。
始终在以下情况使用:
例外情况:
NO SESSION END WITHOUT INSIGHT EXTRACTION FOR NON-TRIVIAL WORK
非平凡的会话应在上下文丢失之前捕获学习成果。
要提取洞察,你需要:
# 获取更改的差异
git diff HEAD~1 --stat
git diff HEAD~1
# 获取提交信息
git log -1 --pretty=format:"%s%n%n%b"
# 获取修改过的文件列表
git diff HEAD~1 --name-only
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
对于每个修改过的文件,提取:
良好示例:
{
"path": "src/stores/terminal-store.ts",
"purpose": "使用 immer 中间件管理终端会话状态的 Zustand 存储",
"changes_made": "添加了 setAssociatedTask 操作以将终端与任务关联",
"patterns_used": ["Zustand 操作模式", "immer 状态突变"],
"gotchas": ["状态更改必须通过操作进行,不能直接突变"]
}
不良示例(过于模糊):
{
"path": "src/stores/terminal-store.ts",
"purpose": "一个存储文件",
"changes_made": "添加了一些代码",
"patterns_used": [],
"gotchas": []
}
仅提取可重用的模式:
良好示例:
{
"pattern": "在具有 onClick 处理程序的容器内的交互式元素上使用 e.stopPropagation()",
"applies_to": "任何嵌套在具有点击处理的父元素内的可点击元素",
"example": "Terminal.tsx 头部 - 下拉菜单需要 stopPropagation 以防止焦点被窃取"
}
必须是具体的和可操作的:
良好示例:
{
"gotcha": "终端头部 onClick 会窃取子交互元素的焦点",
"trigger": "向终端头部添加按钮/下拉菜单而未使用 stopPropagation",
"solution": "在子元素的 onClick 处理程序中调用 e.stopPropagation()"
}
捕获成功或失败的学习成果:
这有助于未来的会话从过去的尝试中学习。
针对未来工作的具体、可操作的建议:
良好: "当向终端头部添加更多控件时,请遵循本次会话中的下拉菜单模式 - 使用 stopPropagation 并相对于头部定位"
不良: "编写优质代码" 或 "彻底测试"
创建结构化的洞察输出:
# 会话洞察:[任务名称]
## 日期
[时间戳]
## 任务
[正在实现的功能描述]
## 结果
[成功/失败]
## 文件洞察
### [文件路径]
- **目的**:[此文件的作用]
- **更改**:[更改了什么以及为什么]
- **模式**:[使用的模式]
- **注意事项**:[需要注意的事项]
## 发现的模式
### [模式名称]
- **模式**:[描述]
- **适用于**:[何时使用]
- **示例**:[文件或代码引用]
## 发现的注意事项
### [注意事项名称]
- **问题**:[要避免什么]
- **触发条件**:[什么会导致它]
- **解决方案**:[如何处理]
## 方法分析
### 有效的方法
[成功方法的描述]
### 失败的方法(如适用)
[失败方法的描述及原因]
### 尝试过的替代方案
[尝试过的其他方法列表]
## 对未来会话的建议
1. [具体建议 1]
2. [具体建议 2]
保存到 .claude/context/memory/learnings.md(追加)。
如果差异非常小或为空:
如果会话失败:
在完成洞察提取之前:
错误原因: "修复了错误" 对任何人都没有帮助。
正确做法: "通过添加清理函数修复了 useEffect 中的竞态条件。模式:始终从异步效果返回清理函数。"
错误原因: "测试你的代码" 是不可操作的。
正确做法: "更改存储逻辑后运行 npm test src/stores - 测试会捕获状态管理错误。"
错误原因: 未来的会话无法理解原因。
正确做法: 包含文件路径、函数名称和具体场景。
此技能与以下技能配合良好:
[CODE]、[WORKFLOW]、[SECURITY] 等)标记洞察 - 未标记的洞察对于按领域搜索的智能体实际上是不可见的。| 反模式 | 失败原因 | 正确方法 |
|---|---|---|
| 记录活动("实现了认证")而非学习成果 | 智能体可以从 git 重建历史;它们无法重建隐性知识 | 记录"为什么"和"注意事项":"Fiber 的 CSRF 中间件必须在路由注册之前,而不是之后" |
| 跳过重复检查 | 重复条目会膨胀内存大小并混淆检索 | 在追加前使用 grep -i "keyword" learnings.md;如果找到则更新现有条目 |
| 没有文件/函数上下文的模糊洞察 | 未来的会话无法定位或应用该洞察 | 包含具体路径:".claude/hooks/routing/routing-guard.cjs 第 47 行:解析错误时退出 0" |
| 仅在会话结束时提取 | 长会话会丢失早期上下文;关键的注意事项被遗忘 | 在每个重要任务完成后提取,而不仅仅是在会话边界 |
| 仅将洞察存储在任务元数据中 | 任务元数据不会被未来的会话或智能体读取 | 始终以标记格式写入 .claude/context/memory/learnings.md |
开始前: 阅读 .claude/context/memory/learnings.md
完成后:
.claude/context/memory/learnings.md.claude/context/memory/issues.md.claude/context/memory/decisions.md假设中断:如果不在记忆中,就等于没发生。
每周安装量
59
仓库
GitHub 星标数
19
首次出现
2026 年 1 月 27 日
安全审计
安装于
github-copilot58
gemini-cli57
cursor57
codex56
opencode56
kimi-cli55
Analyze completed coding sessions and extract structured learnings for the memory system. Insights help future sessions avoid mistakes, follow established patterns, and understand the codebase faster.
Core principle: Extract ACTIONABLE knowledge, not logs. Every insight should help a future session do something better.
Always:
Exceptions:
NO SESSION END WITHOUT INSIGHT EXTRACTION FOR NON-TRIVIAL WORK
Non-trivial sessions should capture learnings before context is lost.
To extract insights, you need:
# Get the diff of changes
git diff HEAD~1 --stat
git diff HEAD~1
# Get commit message
git log -1 --pretty=format:"%s%n%n%b"
# Get list of modified files
git diff HEAD~1 --name-only
For each modified file, extract:
Good example:
{
"path": "src/stores/terminal-store.ts",
"purpose": "Zustand store managing terminal session state with immer middleware",
"changes_made": "Added setAssociatedTask action to link terminals with tasks",
"patterns_used": ["Zustand action pattern", "immer state mutation"],
"gotchas": ["State changes must go through actions, not direct mutation"]
}
Bad example (too vague):
{
"path": "src/stores/terminal-store.ts",
"purpose": "A store file",
"changes_made": "Added some code",
"patterns_used": [],
"gotchas": []
}
Only extract patterns that are reusable :
Good example:
{
"pattern": "Use e.stopPropagation() on interactive elements inside containers with onClick handlers",
"applies_to": "Any clickable element nested inside a parent with click handling",
"example": "Terminal.tsx header - dropdown needs stopPropagation to prevent focus stealing"
}
Must be specific and actionable :
Good example:
{
"gotcha": "Terminal header onClick steals focus from child interactive elements",
"trigger": "Adding buttons/dropdowns to Terminal header without stopPropagation",
"solution": "Call e.stopPropagation() in onClick handlers of child elements"
}
Capture the learning from success or failure:
This helps future sessions learn from past attempts.
Specific, actionable advice for future work:
Good: "When adding more controls to Terminal header, follow the dropdown pattern in this session - use stopPropagation and position relative to header"
Bad: "Write good code" or "Test thoroughly"
Create the structured insight output:
# Session Insights: [Task Name]
## Date
[timestamp]
## Task
[Description of what was being implemented]
## Outcome
[SUCCESS/FAILURE]
## File Insights
### [file-path]
- **Purpose**: [what this file does]
- **Changes**: [what was changed and why]
- **Patterns**: [patterns used]
- **Gotchas**: [things to watch out for]
## Patterns Discovered
### [Pattern Name]
- **Pattern**: [description]
- **Applies to**: [when to use]
- **Example**: [file or code reference]
## Gotchas Discovered
### [Gotcha Name]
- **Issue**: [what to avoid]
- **Trigger**: [what causes it]
- **Solution**: [how to handle]
## Approach Analysis
### What Worked
[Description of successful approach]
### What Failed (if applicable)
[Description of failed approaches and why]
### Alternatives Tried
[List of other approaches attempted]
## Recommendations for Future Sessions
1. [Specific recommendation 1]
2. [Specific recommendation 2]
Save to .claude/context/memory/learnings.md (append).
If the diff is very small or empty:
If the session failed:
Before completing insight extraction:
Why it's wrong: "Fixed the bug" helps no one.
Do this instead: "Fixed race condition in useEffect by adding cleanup function. Pattern: always return cleanup from async effects."
Why it's wrong: "Test your code" is not actionable.
Do this instead: "Run npm test src/stores after changing store logic - the tests catch state management bugs."
Why it's wrong: Future sessions won't understand why.
Do this instead: Include file paths, function names, and specific scenarios.
This skill works well with:
[CODE], [WORKFLOW], [SECURITY], etc.) — untagged insights are effectively invisible to agents searching by domain.| Anti-Pattern | Why It Fails | Correct Approach |
|---|---|---|
| Recording activity ("implemented auth") instead of learnings | Agents can reconstruct history from git; they cannot reconstruct tacit knowledge | Record "why" and "gotcha": "Fiber's CSRF middleware must be before route registration, not after" |
| Skipping deduplication check | Duplicate entries inflate memory size and confuse retrieval | grep -i "keyword" learnings.md before appending; update existing entry if found |
| Vague insights without file/function context | Future sessions can't locate or apply the insight | Include concrete path: "In .claude/hooks/routing/routing-guard.cjs line 47: exit 0 on parse error" |
| Extracting only at session end | Long sessions lose early context; critical gotchas forgotten | Extract after each significant task completion, not just at session boundary |
| Storing insights only in task metadata | Task metadata is not read by future sessions or agents | Always write to with tagged format |
Before starting: Read .claude/context/memory/learnings.md
After completing:
.claude/context/memory/learnings.md.claude/context/memory/issues.md.claude/context/memory/decisions.mdASSUME INTERRUPTION: If it's not in memory, it didn't happen.
Weekly Installs
59
Repository
GitHub Stars
19
First Seen
Jan 27, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot58
gemini-cli57
cursor57
codex56
opencode56
kimi-cli55
AI界面设计评审工具 - 全面评估UI/UX设计质量、检测AI生成痕迹与优化用户体验
58,500 周安装
.claude/context/memory/learnings.md