continuous-learning
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseContinuous Learning
持续学习
Pattern Extraction Framework
模式提取框架
After every significant coding session, extract and categorize learnings into three buckets:
- Corrections - Mistakes caught during review or by the user
- Successful Approaches - Patterns that worked well and should be repeated
- Anti-Patterns - Approaches that caused problems and should be avoided
每次重要编码会话结束后,将所学内容提取并归类到三个类别中:
- 修正内容 - 评审过程中或用户发现的错误
- 成功实践方案 - 效果良好、值得重复使用的模式
- 反模式 - 引发问题、应避免使用的方案
Learning Entry Format
学习条目格式
yaml
pattern:
id: "LEARN-2025-0042"
category: "error-handling"
type: "correction" # correction | success | anti-pattern
confidence: 0.85 # 0.0 to 1.0
language: "typescript"
context: "API error responses"
observation: "Returning raw error messages from database exceptions exposes internals"
lesson: "Always map database errors to application-level error codes before returning"
example:
before: "catch (e) { res.status(500).json({ error: e.message }) }"
after: "catch (e) { logger.error(e); res.status(500).json({ error: 'INTERNAL_ERROR' }) }"
frequency: 3 # times this pattern has been observed
last_seen: "2025-06-15"yaml
pattern:
id: "LEARN-2025-0042"
category: "error-handling"
type: "correction" # correction | success | anti-pattern
confidence: 0.85 # 0.0 to 1.0
language: "typescript"
context: "API error responses"
observation: "Returning raw error messages from database exceptions exposes internals"
lesson: "Always map database errors to application-level error codes before returning"
example:
before: "catch (e) { res.status(500).json({ error: e.message }) }"
after: "catch (e) { logger.error(e); res.status(500).json({ error: 'INTERNAL_ERROR' }) }"
frequency: 3 # times this pattern has been observed
last_seen: "2025-06-15"Confidence Scoring
置信度评分
| Score | Meaning | Action |
|---|---|---|
| 0.95+ | Verified across multiple projects | Apply automatically |
| 0.80-0.94 | Confirmed in this codebase | Apply and mention |
| 0.60-0.79 | Observed but not fully validated | Suggest with caveat |
| 0.40-0.59 | Hypothesis based on limited data | Ask before applying |
| <0.40 | Speculative, needs validation | Document but do not apply |
Update confidence based on:
- +0.10 when pattern is confirmed correct by user
- +0.05 when pattern is observed again in a different context
- -0.15 when pattern leads to a correction
- -0.20 when pattern is explicitly rejected by user
| 评分 | 含义 | 操作建议 |
|---|---|---|
| 0.95+ | 已在多个项目中验证 | 自动应用 |
| 0.80-0.94 | 已在当前代码库中确认 | 应用并标注 |
| 0.60-0.79 | 已观察到但未完全验证 | 建议使用并附加说明 |
| 0.40-0.59 | 基于有限数据的假设 | 应用前需询问 |
| <0.40 | 推测性内容,需验证 | 仅记录暂不应用 |
根据以下规则更新置信度:
- 用户确认模式正确时,+0.10
- 在不同场景下再次观察到该模式时,+0.05
- 模式引发修正时,-0.15
- 用户明确拒绝该模式时,-0.20
Session Wrap-Up Protocol
会话收尾流程
At the end of each session or before context compaction:
- Review changes made - Scan diffs for patterns
- Identify corrections - What was changed after initial implementation?
- Note successful first-attempts - What worked without revision?
- Record environment details - Framework versions, config specifics
- Update confidence scores - Adjust based on session outcomes
- Write to knowledge base - Append new entries to CLAUDE.md or LEARNED.md
markdown
undefined在每次会话结束时或上下文压缩前:
- 回顾所做更改 - 扫描差异内容寻找模式
- 识别修正内容 - 初始实现后有哪些修改?
- 记录首次尝试成功的方案 - 哪些内容无需修改就生效?
- 记录环境细节 - 框架版本、配置详情
- 更新置信度评分 - 根据会话结果调整评分
- 写入知识库 - 将新条目追加到CLAUDE.md或LEARNED.md中
markdown
undefinedSession Learnings (2025-06-15)
会话学习记录(2025-06-15)
Corrections Applied
已应用的修正内容
- [0.85] TypeScript: Use instead of
satisfiesfor type narrowing with object literalsas - [0.90] Next.js: Server Actions must be async functions, even for synchronous operations
- [0.85] TypeScript:在对象字面量的类型收窄中使用而非
satisfiesas - [0.90] Next.js:Server Actions必须是异步函数,即使是同步操作也需如此
Successful Patterns
成功模式
- [0.80] PostgreSQL: Partial indexes on status columns reduced query time by 60%
- [0.75] React: Extracting data fetching into Server Components eliminated 3 useEffect hooks
- [0.80] PostgreSQL:对状态列创建部分索引后,查询时间缩短60%
- [0.75] React:将数据提取逻辑移至Server Components,消除了3个useEffect钩子
Anti-Patterns Identified
已识别的反模式
- [0.70] Avoid: Nesting more than 2 levels of Suspense boundaries (causes waterfall)
- [0.65] Avoid: Using to suppress TypeScript errors in catch blocks (use
any)unknown
undefined- [0.70] 避免:嵌套超过2层的Suspense边界(会导致请求瀑布)
- [0.65] 避免:在catch块中使用来抑制TypeScript错误(应使用
any)unknown
undefinedKnowledge Base Organization
知识库组织结构
Structure the knowledge base by domain:
knowledge/
error-handling.md # Error patterns across languages
testing.md # Test patterns and anti-patterns
performance.md # Optimization learnings
api-design.md # API design decisions
deployment.md # Infrastructure learnings
project-specific.md # Current project conventionsEach file follows the same entry format. Deduplicate entries with matching fields by incrementing and updating .
observationfrequencyconfidence按领域划分知识库结构:
knowledge/
error-handling.md # 跨语言错误模式
testing.md # 测试模式与反模式
performance.md # 优化经验
api-design.md # API设计决策
deployment.md # 基础设施经验
project-specific.md # 当前项目约定每个文件遵循相同的条目格式。对于字段匹配的重复条目,增加并更新以实现去重。
observationfrequencyconfidenceCorrection Tracking
修正跟踪
When a user corrects code or approach:
- Record what was originally produced
- Record what the correction was
- Identify the root cause (wrong assumption, missing context, outdated pattern)
- Create or update a learning entry
- Search for similar patterns that might need the same correction
markdown
undefined当用户修正代码或方案时:
- 记录最初的实现内容
- 记录修正后的内容
- 识别根本原因(错误假设、缺失上下文、过时模式)
- 创建或更新学习条目
- 搜索可能需要相同修正的类似模式
markdown
undefinedCorrection Log
修正日志
- Original: Used to fetch data on mount
useEffect - Correction: Moved data fetching to Server Component
- Root cause: Applied client-side SPA pattern in Server Component context
- Generalization: In Next.js App Router, prefer server-side data fetching for initial page data
- Confidence: 0.90 (confirmed across 4 components)
undefined- 初始实现:使用在组件挂载时获取数据
useEffect - 修正内容:将数据获取逻辑移至Server Component
- 根本原因:在Server Component环境中应用了客户端SPA模式
- 通用结论:在Next.js App Router中,初始页面数据优先使用服务端数据获取
- 置信度:0.90(已在4个组件中确认)
undefinedPattern Reinforcement
模式强化
Track how often patterns are applied and whether they hold:
Pattern: "Use zod for API input validation"
Applied: 12 times
Confirmed: 11 times
Corrected: 1 time (edge case with file uploads)
Confidence: 0.92
Status: ESTABLISHEDStatuses:
- EMERGING (frequency < 3) - New pattern, needs validation
- GROWING (frequency 3-7) - Building evidence, apply with mention
- ESTABLISHED (frequency 8+, confidence > 0.85) - Apply automatically
- DEPRECATED - Once valid, now superseded by a better approach
跟踪模式的应用次数及有效性:
Pattern: "Use zod for API input validation"
Applied: 12 times
Confirmed: 11 times
Corrected: 1 time (edge case with file uploads)
Confidence: 0.92
Status: ESTABLISHED状态说明:
- EMERGING(应用次数<3)- 新模式,需验证
- GROWING(应用次数3-7)- 证据积累中,应用时需标注
- ESTABLISHED(应用次数≥8,置信度>0.85)- 自动应用
- DEPRECATED - 曾有效,但已被更优方案取代
Integration with Memory Files
与记忆文件的集成
Store learnings in the project's memory file (CLAUDE.md or equivalent):
- High-confidence learnings (>0.85) go in the main instructions section
- Medium-confidence (0.60-0.84) go in a dedicated "Learnings" section
- Low-confidence (<0.60) stay in session notes until validated
- Deprecated patterns move to an archive section with reason for deprecation
Review and prune the knowledge base monthly. Remove entries that have not been referenced in 90 days and have confidence below 0.70.
将学习内容存储在项目的记忆文件(CLAUDE.md或同类文件)中:
- 高置信度学习内容(>0.85)放入主说明部分
- 中等置信度内容(0.60-0.84)放入专门的“学习记录”部分
- 低置信度内容(<0.60)保留在会话笔记中,直至验证通过
- 已废弃的模式移至归档部分,并注明废弃原因
每月回顾并精简知识库。移除90天内未被引用且置信度低于0.70的条目。