Claude Code Skills与Memory:Agent的长期记忆与技能进化
引言:从无状态到有经验
在前两篇文章中,我们分析了Claude Code的架构设计和Hooks系统。但有一个根本问题:如何让Agent变得越来越聪明?
传统的AI工具是无状态的:每次调用都是全新的开始,不会学习,不会积累经验。Claude Code通过两个核心系统解决了这个问题:
- Skills(技能系统):可定义、可复用的工作流
- Memory(记忆系统):持久化、可检索的经验积累
核心观点:Skills让Agent从”通用能力”进化为”专业能力”,Memory让Agent从”无状态”进化为”有经验”。
第一部分:Skills系统深度解析
什么是Skills
Skills不是简单的”命令”或”模板”,而是结构化的专业知识。
1# 传统方式:每次都要重复指令
2def deploy_to_production():
3 # 1. 运行测试
4 run_tests()
5
6 # 2. 构建生产版本
7 build_production()
8
9 # 3. 部署到AWS
10 deploy_aws()
11
12 # 4. 验证部署
13 verify_deployment()
14
15 # 问题:每次都要重新告诉AI这些步骤
16 # 问题:不同项目可能有不同的部署流程
17 # 问题:无法积累和复用部署经验
18
19# Skills方式:定义可复用的专业知识
20@skill("deploy_to_production")
21def deploy_production_skill():
22 """
23 生产环境部署技能
24
25 触发条件:用户要求部署到生产环境
26 前置条件:所有测试通过,有部署权限
27 后置条件:部署成功,监控正常
28 """
29 return {
30 "steps": [
31 {"action": "run_tests", "required": True},
32 {"action": "build_production", "required": True},
33 {"action": "deploy_to_cloud", "required": True},
34 {"action": "verify_deployment", "required": True},
35 {"action": "update_monitoring", "required": False}
36 ],
37 "triggers": ["部署", "deploy", "发布到生产"],
38 "prerequisites": ["tests_passing", "has_deploy_permission"],
39 "rollback": "revert_to_previous_version"
40 }
41
Skills的层次结构
1Skills层次:
2 L1 - 内置技能:
3 - 代码生成: 根据需求生成代码
4 - 代码重构: 重构现有代码
5 - 测试生成: 自动生成测试用例
6 - 文档生成: 生成技术文档
7
8 L2 - 项目技能:
9 - deploy_web_app: Web应用部署
10 - database_migration: 数据库迁移
11 - api_versioning: API版本管理
12 - performance_optimization: 性能优化
13
14 L3 - 团队技能:
15 - code_review_standards: 团队代码审查标准
16 - naming_conventions: 团队命名规范
17 - architecture_patterns: 团队架构模式
18 - security_practices: 团队安全实践
19
20 L4 - 个人技能:
21 - my_debugging_workflow: 个人调试流程
22 - my_development_setup: 个人开发环境
23 - my_learning_notes: 个人学习笔记
24 - my_productivity_hacks: 个人效率技巧
25
Skills的定义语法
1# SKILL.md - 技能定义文件
2
3## 元数据
4name: python-debugging
5description: Python代码调试技能
6version: 1.0
7author: AI学习笔记
8tags: [python, debugging, troubleshooting]
9
10## 触发条件
11triggers:
12 - "Python代码出错"
13 - "调试Python程序"
14 - "修复Python bug"
15
16## 前置条件
17prerequisites:
18 - "Python环境已安装"
19 - "代码文件存在"
20
21## 工作流程
22steps:
23 1. 复现问题:
24 - 运行代码确认错误
25 - 收集错误信息
26 - 确定错误范围
27
28 2. 分析原因:
29 - 检查错误堆栈
30 - 分析相关代码
31 - 查找类似问题
32
33 3. 制定方案:
34 - 提出修复方案
35 - 评估方案风险
36 - 选择最佳方案
37
38 4. 实施修复:
39 - 修改代码
40 - 运行测试
41 - 验证修复
42
43 5. 预防复发:
44 - 添加测试用例
45 - 更新文档
46 - 记录经验
47
48## 工具使用
49tools:
50 - terminal: 运行Python命令
51 - read_file: 读取代码文件
52 - write_file: 修改代码文件
53 - execute_code: 执行Python代码
54
55## 成功标准
56success_criteria:
57 - "错误不再出现"
58 - "所有测试通过"
59 - "代码符合规范"
60
61## 失败处理
62on_failure:
63 - "尝试其他方案"
64 - "寻求人工帮助"
65 - "记录失败原因"
66
Skills的动态发现
1# Skills的动态发现和加载机制
2class SkillManager:
3 def __init__(self):
4 self.skills = {}
5 self.skill_index = {} # 关键词索引
6
7 def discover_skills(self):
8 """
9 动态发现技能
10 扫描多个位置:内置、项目、用户、团队
11 """
12 # 1. 内置技能
13 self.load_builtin_skills()
14
15 # 2. 项目技能
16 project_skills = scan_directory(".claude/skills/")
17 self.load_skills(project_skills)
18
19 # 3. 用户技能
20 user_skills = scan_directory("~/.claude/skills/")
21 self.load_skills(user_skills)
22
23 # 4. 团队技能
24 team_skills = scan_directory("/team/shared/skills/")
25 self.load_skills(team_skills)
26
27 # 5. 构建索引
28 self.build_skill_index()
29
30 def find_relevant_skill(self, user_request):
31 """
32 根据用户请求找到相关技能
33 """
34 # 1. 关键词匹配
35 keywords = extract_keywords(user_request)
36 candidate_skills = self.match_keywords(keywords)
37
38 # 2. 语义匹配
39 if not candidate_skills:
40 candidate_skills = self.semantic_search(user_request)
41
42 # 3. 评分排序
43 scored_skills = self.score_skills(candidate_skills, user_request)
44
45 # 4. 返回最佳匹配
46 return scored_skills[0] if scored_skills else None
47
48 def execute_skill(self, skill, context):
49 """
50 执行技能
51 """
52 # 1. 检查前置条件
53 if not self.check_prerequisites(skill, context):
54 raise SkillError("前置条件不满足")
55
56 # 2. 执行步骤
57 results = []
58 for step in skill.steps:
59 result = self.execute_step(step, context)
60 results.append(result)
61
62 # 3. 检查是否继续
63 if result.status == "failed" and step.required:
64 return self.handle_failure(skill, step, result)
65
66 # 4. 验证成功标准
67 if self.verify_success_criteria(skill, results):
68 return SkillResult(success=True, results=results)
69 else:
70 return SkillResult(success=False, results=results)
71
第二部分:Memory系统深度解析
记忆的层次结构
1# 记忆的三层架构
2class MemorySystem:
3 def __init__(self):
4 # 第1层:会话记忆(短期)
5 self.session_memory = SessionMemory()
6
7 # 第2层:项目记忆(中期)
8 self.project_memory = ProjectMemory()
9
10 # 第3层:长期记忆(长期)
11 self.long_term_memory = LongTermMemory()
12
13 def remember(self, information, memory_type="auto"):
14 """
15 存储记忆
16 """
17 if memory_type == "auto":
18 memory_type = self.classify_memory_type(information)
19
20 if memory_type == "session":
21 self.session_memory.store(information)
22 elif memory_type == "project":
23 self.project_memory.store(information)
24 elif memory_type == "long_term":
25 self.long_term_memory.store(information)
26
27 def recall(self, query, scope="all"):
28 """
29 检索记忆
30 """
31 results = []
32
33 if scope in ["all", "session"]:
34 results.extend(self.session_memory.search(query))
35
36 if scope in ["all", "project"]:
37 results.extend(self.project_memory.search(query))
38
39 if scope in ["all", "long_term"]:
40 results.extend(self.long_term_memory.search(query))
41
42 # 按相关性排序
43 return sorted(results, key=lambda x: x.relevance, reverse=True)
44
第1层:会话记忆
1class SessionMemory:
2 """
3 会话记忆:当前对话的上下文
4 生命周期:单次会话
5 """
6 def __init__(self):
7 self.conversation_history = []
8 self.decisions = []
9 self.context = {}
10
11 def store(self, information):
12 """存储会话信息"""
13 if information.type == "conversation":
14 self.conversation_history.append(information)
15 elif information.type == "decision":
16 self.decisions.append(information)
17 elif information.type == "context":
18 self.context.update(information.data)
19
20 def search(self, query):
21 """检索会话记忆"""
22 results = []
23
24 # 搜索对话历史
25 for conv in self.conversation_history:
26 if query_matches(conv.content, query):
27 results.append(MemoryItem(
28 content=conv,
29 source="session",
30 relevance=calculate_relevance(conv, query)
31 ))
32
33 # 搜索决策记录
34 for decision in self.decisions:
35 if query_matches(decision.description, query):
36 results.append(MemoryItem(
37 content=decision,
38 source="session",
39 relevance=calculate_relevance(decision, query)
40 ))
41
42 return results
43
第2层:项目记忆
1class ProjectMemory:
2 """
3 项目记忆:特定项目的知识和经验
4 生命周期:项目存在期间
5 """
6 def __init__(self, project_path):
7 self.project_path = project_path
8 self.memory_file = os.path.join(project_path, ".claude/memory.json")
9 self.memory = self.load_memory()
10
11 def load_memory(self):
12 """加载项目记忆"""
13 if os.path.exists(self.memory_file):
14 with open(self.memory_file, 'r') as f:
15 return json.load(f)
16 return {
17 "conventions": {}, # 项目约定
18 "decisions": [], # 技术决策
19 "patterns": [], # 代码模式
20 "mistakes": [], # 错误教训
21 "preferences": {} # 项目偏好
22 }
23
24 def store(self, information):
25 """存储项目记忆"""
26 if information.type == "convention":
27 self.memory["conventions"].update(information.data)
28 elif information.type == "decision":
29 self.memory["decisions"].append(information)
30 elif information.type == "pattern":
31 self.memory["patterns"].append(information)
32 elif information.type == "mistake":
33 self.memory["mistakes"].append(information)
34
35 # 保存到文件
36 self.save_memory()
37
38 def search(self, query):
39 """检索项目记忆"""
40 results = []
41
42 # 搜索所有类型的记忆
43 for memory_type, items in self.memory.items():
44 if isinstance(items, list):
45 for item in items:
46 if query_matches(str(item), query):
47 results.append(MemoryItem(
48 content=item,
49 source=f"project:{memory_type}",
50 relevance=calculate_relevance(item, query)
51 ))
52 elif isinstance(items, dict):
53 for key, value in items.items():
54 if query_matches(f"{key}: {value}", query):
55 results.append(MemoryItem(
56 content={key: value},
57 source=f"project:{memory_type}",
58 relevance=calculate_relevance({key: value}, query)
59 ))
60
61 return results
62
第3层:长期记忆
1class LongTermMemory:
2 """
3 长期记忆:跨项目的通用知识和经验
4 生命周期:永久
5 """
6 def __init__(self):
7 self.memory_path = os.path.expanduser("~/.claude/memory/")
8 self.ensure_directory()
9
10 # 记忆分类
11 self.categories = {
12 "knowledge": [], # 技术知识
13 "skills": [], # 技能经验
14 "preferences": {}, # 用户偏好
15 "patterns": [], # 通用模式
16 "lessons": [] # 经验教训
17 }
18
19 def store(self, information):
20 """存储长期记忆"""
21 category = self.classify_information(information)
22
23 if category == "knowledge":
24 self.store_knowledge(information)
25 elif category == "skills":
26 self.store_skill_experience(information)
27 elif category == "preferences":
28 self.store_preference(information)
29 elif category == "patterns":
30 self.store_pattern(information)
31 elif category == "lessons":
32 self.store_lesson(information)
33
34 def compile_knowledge_article(self, information):
35 """
36 将信息编译为知识文章
37 借鉴Karpathy的LLM知识库架构
38 """
39 # 1. 提取关键概念
40 concepts = extract_concepts(information)
41
42 # 2. 创建或更新概念文章
43 for concept in concepts:
44 article_path = os.path.join(
45 self.memory_path,
46 "knowledge",
47 f"{concept.name}.md"
48 )
49
50 if os.path.exists(article_path):
51 # 更新现有文章
52 update_article(article_path, concept)
53 else:
54 # 创建新文章
55 create_article(article_path, concept)
56
57 # 3. 更新索引
58 self.update_knowledge_index()
59
60 def search(self, query):
61 """检索长期记忆"""
62 results = []
63
64 # 搜索知识库
65 knowledge_results = self.search_knowledge_base(query)
66 results.extend(knowledge_results)
67
68 # 搜索技能经验
69 skill_results = self.search_skill_experiences(query)
70 results.extend(skill_results)
71
72 # 搜索用户偏好
73 preference_results = self.search_preferences(query)
74 results.extend(preference_results)
75
76 # 搜索模式库
77 pattern_results = self.search_patterns(query)
78 results.extend(pattern_results)
79
80 # 搜索经验教训
81 lesson_results = self.search_lessons(query)
82 results.extend(lesson_results)
83
84 return sorted(results, key=lambda x: x.relevance, reverse=True)
85
第三部分:Skills与Memory的协同
协同模式
1# Skills和Memory的协同工作
2class AgentWithSkillsAndMemory:
3 def __init__(self):
4 self.skills = SkillManager()
5 self.memory = MemorySystem()
6
7 def handle_request(self, user_request):
8 """
9 处理用户请求:Skills和Memory协同工作
10 """
11 # 1. 检索相关记忆
12 relevant_memories = self.memory.recall(user_request)
13
14 # 2. 查找相关技能
15 relevant_skill = self.skills.find_relevant_skill(user_request)
16
17 # 3. 结合记忆执行技能
18 if relevant_skill:
19 # 使用技能处理
20 context = self.build_context(user_request, relevant_memories)
21 result = self.skills.execute_skill(relevant_skill, context)
22 else:
23 # 使用通用能力处理
24 result = self.general_execution(user_request, relevant_memories)
25
26 # 4. 从执行中学习
27 self.learn_from_execution(user_request, result, relevant_memories)
28
29 return result
30
31 def learn_from_execution(self, request, result, memories):
32 """
33 从执行中学习:更新技能和记忆
34 """
35 # 1. 更新技能(如果发现更好的方法)
36 if result.new_approach:
37 self.skills.update_skill(result.skill_used, result.new_approach)
38
39 # 2. 更新记忆
40 learning = extract_learning(request, result)
41 self.memory.remember(learning)
42
43 # 3. 如果是新模式,创建新技能
44 if result.is_new_pattern:
45 self.skills.create_skill_from_pattern(result.pattern)
46
实战案例:调试技能
1# 调试技能的定义
2@skill("python_debugging")
3def python_debugging_skill():
4 """
5 Python调试技能
6 结合记忆系统,越用越聪明
7 """
8 return {
9 "name": "python_debugging",
10 "description": "智能Python代码调试",
11
12 # 工作流程
13 "steps": [
14 {
15 "action": "recall_similar_errors",
16 "description": "回忆类似错误的解决方案"
17 },
18 {
19 "action": "analyze_error",
20 "description": "分析当前错误"
21 },
22 {
23 "action": "generate_solutions",
24 "description": "生成可能的解决方案"
25 },
26 {
27 "action": "select_best_solution",
28 "description": "选择最佳方案(基于记忆)"
29 },
30 {
31 "action": "implement_solution",
32 "description": "实施方案"
33 },
34 {
35 "action": "verify_fix",
36 "description": "验证修复"
37 },
38 {
39 "action": "update_memory",
40 "description": "更新调试经验记忆"
41 }
42 ],
43
44 # 触发条件
45 "triggers": [
46 "Python代码出错",
47 "调试Python程序",
48 "修复Python bug",
49 "这个Python代码有问题"
50 ],
51
52 # 成功标准
53 "success_criteria": [
54 "错误不再出现",
55 "所有测试通过",
56 "代码符合规范"
57 ]
58 }
59
60# 调试技能的执行
61def execute_python_debugging(error_info, memory_system):
62 """
63 执行Python调试技能
64 """
65 # 步骤1:回忆类似错误
66 similar_errors = memory_system.recall(
67 f"Python错误: {error_info.message}",
68 scope="all"
69 )
70
71 # 步骤2:分析当前错误
72 analysis = analyze_python_error(error_info)
73
74 # 步骤3:生成解决方案
75 solutions = generate_solutions(analysis, similar_errors)
76
77 # 步骤4:选择最佳方案(基于记忆)
78 best_solution = select_best_solution(
79 solutions,
80 similar_errors, # 基于过去的成功经验
81 memory_system.user_preferences # 基于用户偏好
82 )
83
84 # 步骤5:实施方案
85 fix_result = implement_solution(best_solution)
86
87 # 步骤6:验证修复
88 verification = verify_fix(fix_result)
89
90 # 步骤7:更新记忆
91 if verification.success:
92 memory_system.remember({
93 "type": "debugging_experience",
94 "error": error_info,
95 "solution": best_solution,
96 "success": True,
97 "context": analysis.context
98 })
99 else:
100 memory_system.remember({
101 "type": "debugging_failure",
102 "error": error_info,
103 "solution": best_solution,
104 "reason": verification.failure_reason
105 })
106
107 return fix_result
108
第四部分:记忆的编译与压缩
Karpathy的LLM知识库架构借鉴
1# 借鉴Karpathy的LLM知识库架构
2class KnowledgeCompiler:
3 """
4 知识编译器:将原始经验编译为结构化知识
5 """
6 def __init__(self, memory_system):
7 self.memory = memory_system
8
9 def compile_daily_logs(self):
10 """
11 编译每日日志为知识文章
12 """
13 # 1. 读取当天的经验
14 daily_experiences = self.memory.get_daily_experiences()
15
16 # 2. 提取关键知识点
17 knowledge_atoms = extract_knowledge_atoms(daily_experiences)
18
19 # 3. 创建或更新知识文章
20 for atom in knowledge_atoms:
21 if self.knowledge_article_exists(atom.topic):
22 self.update_knowledge_article(atom)
23 else:
24 self.create_knowledge_article(atom)
25
26 # 4. 创建连接文章(跨概念关系)
27 connections = find_connections(knowledge_atoms)
28 for connection in connections:
29 self.create_connection_article(connection)
30
31 # 5. 更新索引
32 self.update_knowledge_index()
33
34 def create_knowledge_article(self, knowledge_atom):
35 """
36 创建知识文章
37 """
38 article_content = f"""# {knowledge_atom.title}
39
40## 核心概念
41{knowledge_atom.description}
42
43## 关键要点
44{format_key_points(knowledge_atom.key_points)}
45
46## 实战案例
47{format_examples(knowledge_atom.examples)}
48
49## 常见陷阱
50{format_pitfalls(knowledge_atom.pitfalls)}
51
52## 最佳实践
53{format_best_practices(knowledge_atom.best_practices)}
54
55## 相关主题
56{format_related_topics(knowledge_atom.related_topics)}
57
58---
59*编译自 {knowledge_atom.source_experiences} 个实战经验*
60*最后更新: {knowledge_atom.last_updated}*
61"""
62
63 # 保存文章
64 article_path = os.path.join(
65 self.memory.memory_path,
66 "knowledge",
67 f"{knowledge_atom.slug}.md"
68 )
69
70 with open(article_path, 'w') as f:
71 f.write(article_content)
72
记忆的检索优化
1class MemoryRetrievalOptimizer:
2 """
3 记忆检索优化器
4 使用索引引导的检索,而非RAG
5 """
6 def __init__(self, memory_system):
7 self.memory = memory_system
8 self.index = self.build_index()
9
10 def build_index(self):
11 """
12 构建记忆索引
13 """
14 index = {
15 "by_topic": {}, # 按主题索引
16 "by_type": {}, # 按类型索引
17 "by_recency": [], # 按时间索引
18 "by_relevance": {} # 按相关性索引
19 }
20
21 # 遍历所有记忆
22 for memory in self.memory.get_all_memories():
23 # 按主题索引
24 for topic in memory.topics:
25 if topic not in index["by_topic"]:
26 index["by_topic"][topic] = []
27 index["by_topic"][topic].append(memory)
28
29 # 按类型索引
30 if memory.type not in index["by_type"]:
31 index["by_type"][memory.type] = []
32 index["by_type"][memory.type].append(memory)
33
34 # 按时间索引
35 index["by_recency"].append({
36 "memory": memory,
37 "timestamp": memory.timestamp
38 })
39
40 # 按时间排序
41 index["by_recency"].sort(
42 key=lambda x: x["timestamp"],
43 reverse=True
44 )
45
46 return index
47
48 def search(self, query, max_results=10):
49 """
50 优化后的记忆检索
51 """
52 # 1. 读取主索引
53 index = self.index
54
55 # 2. LLM选择相关主题
56 relevant_topics = llm_select_relevant(
57 query,
58 list(index["by_topic"].keys())
59 )
60
61 # 3. 从相关主题中检索
62 candidate_memories = []
63 for topic in relevant_topics:
64 candidate_memories.extend(index["by_topic"][topic])
65
66 # 4. 评分排序
67 scored_memories = []
68 for memory in candidate_memories:
69 relevance = calculate_relevance(memory, query)
70 recency = calculate_recency(memory.timestamp)
71 importance = memory.importance_score
72
73 # 综合评分
74 score = (
75 relevance * 0.5 +
76 recency * 0.3 +
77 importance * 0.2
78 )
79
80 scored_memories.append({
81 "memory": memory,
82 "score": score
83 })
84
85 # 5. 返回Top N
86 scored_memories.sort(key=lambda x: x["score"], reverse=True)
87 return [m["memory"] for m in scored_memories[:max_results]]
88
第五部分:实战案例
案例1:个人学习笔记系统
1# 个人学习笔记技能
2@skill("learning_note_system")
3def learning_note_system():
4 """
5 个人学习笔记系统
6 结合Memory实现知识积累
7 """
8 return {
9 "name": "learning_note_system",
10 "description": "创建和管理个人学习笔记",
11
12 "workflow": [
13 # 1. 学习新知识
14 {
15 "action": "learn_new_topic",
16 "triggers": ["学习", "了解", "研究"],
17 "steps": [
18 "搜索相关资料",
19 "阅读和理解",
20 "提取关键概念",
21 "创建笔记文章",
22 "建立知识连接"
23 ]
24 },
25
26 # 2. 复习已有知识
27 {
28 "action": "review_knowledge",
29 "triggers": ["复习", "回顾", "温习"],
30 "steps": [
31 "检索相关笔记",
32 "测试理解程度",
33 "更新过时内容",
34 "深化理解"
35 ]
36 },
37
38 # 3. 应用知识
39 {
40 "action": "apply_knowledge",
41 "triggers": ["应用", "使用", "实践"],
42 "steps": [
43 "检索相关知识",
44 "应用到实际问题",
45 "记录实践经验",
46 "更新知识文章"
47 ]
48 }
49 ],
50
51 # 与Memory的集成
52 "memory_integration": {
53 "store": "learning_notes/{topic}.md",
54 "index": "learning_index.json",
55 "connections": "knowledge_connections.md"
56 }
57 }
58
案例2:代码审查专家
1# 代码审查技能
2@skill("code_review_expert")
3def code_review_expert():
4 """
5 代码审查专家技能
6 结合Memory积累审查经验
7 """
8 return {
9 "name": "code_review_expert",
10 "description": "智能代码审查,越审查越精准",
11
12 # 审查维度
13 "review_dimensions": {
14 "security": {
15 "checks": ["SQL注入", "XSS", "CSRF", "敏感信息泄露"],
16 "memory_key": "security_vulnerabilities"
17 },
18 "performance": {
19 "checks": ["N+1查询", "内存泄漏", "循环优化"],
20 "memory_key": "performance_issues"
21 },
22 "maintainability": {
23 "checks": ["代码复杂度", "命名规范", "文档完整性"],
24 "memory_key": "maintainability_patterns"
25 },
26 "best_practices": {
27 "checks": ["设计模式", "SOLID原则", "DRY原则"],
28 "memory_key": "best_practice_patterns"
29 }
30 },
31
32 # 审查流程
33 "workflow": [
34 "1. 检索类似代码的审查经验",
35 "2. 执行多维度审查",
36 "3. 生成审查报告",
37 "4. 更新审查经验记忆"
38 ],
39
40 # 学习机制
41 "learning": {
42 "from_feedback": "根据开发者反馈调整审查重点",
43 "from_mistakes": "从漏检问题中学习",
44 "from_patterns": "从高质量代码中学习模式"
45 }
46 }
47
结论:让Agent越用越聪明
Claude Code的Skills和Memory系统实现了AI工具的革命性突破:
- 从无状态到有经验:Memory让Agent积累经验
- 从通用到专业:Skills让Agent获得专业能力
- 从被动到主动:结合Memory和Skills,Agent能主动学习和优化
核心启示:
好的AI工具不是替代人类,而是增强人类。Skills和Memory系统让Claude Code成为人类开发者的”第二大脑”,而不是简单的代码生成器。
技术深度:
- Skills借鉴了专家系统:将专家知识编码为可执行的技能
- Memory借鉴了认知科学:模拟人类的记忆层次结构
- 编译借鉴了Karpathy架构:将原始经验编译为结构化知识
这种设计让Claude Code能够:
- 记住你的偏好和习惯
- 学习你的项目和团队规范
- 积累调试和开发经验
- 越用越懂你,越用越聪明
延伸阅读:
- 第1篇:Claude Code架构设计哲学与核心创新
- 第2篇:Hooks系统深度解析 - 可扩展的Agent生命周期
- 第4篇:Claude Code vs 竞品 - 为什么它是Top 1 Agent框架
参考资料:
- Karpathy的LLM知识库架构
- 专家系统设计模式
- 认知科学中的记忆理论
- 知识图谱构建方法