ワンクリックで
learning
Extracts reusable patterns from sessions. Use at session end to capture debugging insights and project-specific knowledge.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Extracts reusable patterns from sessions. Use at session end to capture debugging insights and project-specific knowledge.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Frontend patterns: component design, state management, performance, accessibility. Use when building web frontends, components, or client-side apps.
Git version control best practices: branching, commits, merging, conflict resolution, PR workflows. Use when managing branches, creating commits, merging code, or resolving conflicts.
Model selection strategy and routing. Use when choosing between models for different task types, subagent configurations, or optimizing token cost vs quality tradeoffs.
Security review skill: comprehensive security checklist and patterns. Use when adding authentication, handling user input, working with secrets, or creating API endpoints.
Strategic compaction skill: suggests context compression at logical breakpoints. Use to suggest compaction at logical intervals during development sessions.
DevOps patterns: containerization, CI/CD, deployment strategies, monitoring. Use when containerizing apps, setting up pipelines, or deploying services.
| name | learning |
| description | Extracts reusable patterns from sessions. Use at session end to capture debugging insights and project-specific knowledge. |
| allowed-tools | Read, Write, Edit, Bash, Grep, Glob |
| parent | session |
本技能用于从开发会话中提取可复用的模式和知识,实现持续学习和改进。
evaluate-session.js)+ 观察 Hook(observe-patterns.js)当解决了一个错误,记录:
## 错误: Cannot read property 'xxx' of undefined
### 场景
访问嵌套对象属性时
### 根本原因
异步数据未加载完成就访问
### 解决方案
```typescript
// 使用可选链
const value = obj?.nested?.property;
// 或提供默认值
const value = obj?.nested?.property ?? defaultValue;
```
### 2. 调试技巧
```markdown
## 技巧: 调试 Next.js API 路由
### 场景
API 路由返回意外结果
### 技巧
1. 在 route.ts 开头添加日志
```typescript
export async function GET(request: NextRequest) {
console.log('[API] GET /api/xxx', {
url: request.url,
headers: Object.fromEntries(request.headers)
})
// ...
}
### 3. 变通方案
```markdown
## 变通: Prisma 不支持的复杂查询
### 场景
需要执行 Prisma 不原生支持的 SQL
### 变通方案
```typescript
// 使用 $queryRaw 执行原生 SQL
const result = await prisma.$queryRaw`
SELECT * FROM users
WHERE LOWER(name) LIKE ${`%${search.toLowerCase()}%`}
`
// 或使用 $executeRaw 执行命令
await prisma.$executeRaw`
UPDATE users SET updated_at = NOW()
WHERE id = ${userId}
`
### 4. 项目特定知识
```markdown
## 项目: 用户认证流程
### 流程
1. 用户提交凭证 → POST /api/auth/login
2. 验证凭证 → 检查数据库
3. 生成 JWT → 设置 httpOnly cookie
4. 返回用户信息
### 关键文件
- `src/app/api/auth/login/route.ts` - 登录接口
- `src/lib/auth.ts` - 认证工具函数
- `src/middleware.ts` - 路由保护
### 注意事项
- Token 有效期 7 天
- 刷新 Token 在 /api/auth/refresh
- 受保护路由在 middleware.ts 配置
会话结束时,检查以下内容:
- [ ] 解决了一个复杂的 Bug?
- [ ] 发现了一个调试技巧?
- [ ] 创建了一个可复用的代码片段?
- [ ] 学到了框架/库的新用法?
- [ ] 遇到并解决了性能问题?
- [ ] 找到了一个变通方案?
- [ ] 了解了项目特定的知识?
- [ ] 简单的拼写错误
- [ ] 一次性的配置问题
- [ ] 外部 API 临时故障
- [ ] 已知的简单问题
.claude/
└── learned/
├── errors/
│ ├── prisma-connection-issues.md
│ └── react-hydration-mismatch.md
├── debugging/
│ ├── next-api-routes.md
│ └── database-query-slow.md
├── workarounds/
│ ├── prisma-raw-queries.md
│ └── nextauth-custom-session.md
├── patterns/
│ ├── error-handling.md
│ └── api-response-format.md
└── project/
├── auth-flow.md
└── data-models.md
---
title: [标题]
category: [errors|debugging|workarounds|patterns|project]
tags: [tag1, tag2]
created: YYYY-MM-DD
updated: YYYY-MM-DD
---
# [标题]
## 场景
[描述遇到这个问题/使用这个模式的场景]
## 问题/需求
[具体的问题描述或需求说明]
## 解决方案
[详细的解决方案,包括代码示例]
## 相关文件
- `path/to/file.ts` - [说明]
## 参考
- [链接1](url)
- [链接2](url)
## 注意事项
[使用时需要注意的点]
会话评估已通过 Node.js Hook 自动化,无需手动触发:
scripts/node/hooks/evaluate-session.js(运行 --help 查看详情){
"min_session_length": 10,
"extraction_threshold": "medium",
"auto_approve": false,
"learned_skills_path": "~/.claude/learned/",
"patterns_to_detect": [
"error_resolution",
"debugging_techniques",
"workarounds",
"project_specific"
],
"ignore_patterns": ["simple_typos", "one_time_fixes", "external_api_issues"]
}
本能是介于"观察"和"正式技能"之间的中间状态,用于捕捉重复出现的模式。
观察 ──→ 记录 ──→ 本能 ──→ 演化
│ │ │ │
│ │ │ └─→ 技能/命令/智能体
│ │ └─→ 置信度评估
│ └─→ observations.jsonl
└─→ Hook 自动捕获
| 置信度 | 含义 | 动作 |
|---|---|---|
| 0.3 | 首次观察 | 记录但不采取行动 |
| 0.5 | 重复出现 | 形成初步本能 |
| 0.7 | 多次验证 | 考虑演化为技能 |
| 0.9 | 高度可靠 | 正式演化为技能/命令 |
## 本能: [名称]
### 触发模式
[什么情况下触发]
### 推荐行为
[应该如何响应]
### 置信度: 0.X
[基于多少次观察]
### 观察记录
- 2025-01-20: [场景1]
- 2025-01-22: [场景2]
### 演化候选
- [ ] 升级为技能
- [ ] 升级为命令
- [ ] 写入 CLAUDE.md
通过 PostToolUse hook 自动捕获工具调用模式,无需手动触发。
scripts/node/hooks/observe-patterns.js(运行 --help 查看详情)memory-bank/observations.jsonl(JSONL 格式,自动轮转)/learn 命令在 Step 0 自动读取观察数据作为分析输入记住: 每次调试都是学习机会。记录下来,下次就能更快解决类似问题。本能系统让学习更系统化,从观察到技能的演化让知识沉淀更有效。