continuous-learning-v2 by affaan-m/everything-claude-code
npx skills add https://github.com/affaan-m/everything-claude-code --skill continuous-learning-v2一个先进的学习系统,通过原子化的“本能”——带有置信度评分的小型习得行为——将你的 Claude Code 会话转化为可复用的知识。
v2.1 版本新增了项目作用域的本能——React 模式保留在你的 React 项目中,Python 约定保留在你的 Python 项目中,而通用模式(如“始终验证输入”)则在全局共享。
| 特性 | v2.0 | v2.1 |
|---|---|---|
| 存储 | 全局 (~/.claude/homunculus/) | 项目作用域 (projects//) |
| 作用域 | 所有本能随处适用 | 项目作用域 + 全局 |
| 检测 | 无 | git remote URL / 仓库路径 |
| 提升 | 不适用 | 在 2+ 个项目中出现时,项目 → 全局 |
| 命令 | 4 个 (status/evolve/export/import) |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 6 个 (+promote/projects) |
| 跨项目 | 存在污染风险 | 默认隔离 |
| 特性 | v1 | v2 |
|---|---|---|
| 观察 | Stop 钩子(会话结束) | PreToolUse/PostToolUse(100% 可靠) |
| 分析 | 主上下文 | 后台智能体(Haiku) |
| 粒度 | 完整技能 | 原子化的“本能” |
| 置信度 | 无 | 0.3-0.9 加权 |
| 进化 | 直接生成技能 | 本能 -> 聚类 -> 技能/命令/智能体 |
| 共享 | 无 | 导出/导入本能 |
一个本能是一个小型习得行为:
---
id: prefer-functional-style
trigger: "when writing new functions"
confidence: 0.7
domain: "code-style"
source: "session-observation"
scope: project
project_id: "a1b2c3d4e5f6"
project_name: "my-react-app"
---
# Prefer Functional Style
## Action
Use functional patterns over classes when appropriate.
## Evidence
- Observed 5 instances of functional pattern preference
- User corrected class-based approach to functional on 2025-01-15
属性:
project(默认)或 globalSession Activity (in a git repo)
|
| Hooks capture prompts + tool use (100% reliable)
| + detect project context (git remote / repo path)
v
+---------------------------------------------+
| projects/<project-hash>/observations.jsonl |
| (prompts, tool calls, outcomes, project) |
+---------------------------------------------+
|
| Observer agent reads (background, Haiku)
v
+---------------------------------------------+
| PATTERN DETECTION |
| * User corrections -> instinct |
| * Error resolutions -> instinct |
| * Repeated workflows -> instinct |
| * Scope decision: project or global? |
+---------------------------------------------+
|
| Creates/updates
v
+---------------------------------------------+
| projects/<project-hash>/instincts/personal/ |
| * prefer-functional.yaml (0.7) [project] |
| * use-react-hooks.yaml (0.9) [project] |
+---------------------------------------------+
| instincts/personal/ (GLOBAL) |
| * always-validate-input.yaml (0.85) [global]|
| * grep-before-edit.yaml (0.6) [global] |
+---------------------------------------------+
|
| /evolve clusters + /promote
v
+---------------------------------------------+
| projects/<hash>/evolved/ (project-scoped) |
| evolved/ (global) |
| * commands/new-feature.md |
| * skills/testing-workflow.md |
| * agents/refactor-specialist.md |
+---------------------------------------------+
系统自动检测你当前的项目:
CLAUDE_PROJECT_DIR 环境变量(最高优先级)git remote get-url origin —— 哈希化以生成可移植的项目 ID(不同机器上的同一仓库获得相同的 ID)git rev-parse --show-toplevel —— 备用方案,使用仓库路径(机器特定)每个项目会获得一个 12 字符的哈希 ID(例如 a1b2c3d4e5f6)。~/.claude/homunculus/projects.json 处的注册表文件将 ID 映射到人类可读的名称。
添加到你的 ~/.claude/settings.json。
如果作为插件安装(推荐):
{
"hooks": {
"PreToolUse": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh"
}]
}],
"PostToolUse": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh"
}]
}]
}
}
如果手动安装到 ~/.claude/skills:
{
"hooks": {
"PreToolUse": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh"
}]
}],
"PostToolUse": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh"
}]
}]
}
}
系统会在首次使用时自动创建目录,但你也可以手动创建:
# 全局目录
mkdir -p ~/.claude/homunculus/{instincts/{personal,inherited},evolved/{agents,skills,commands},projects}
# 项目目录会在钩子首次在 git 仓库中运行时自动创建
/instinct-status # 显示已学习的本能(项目 + 全局)
/evolve # 将相关本能聚类成技能/命令
/instinct-export # 将本能导出到文件
/instinct-import # 从他人处导入本能
/promote # 将项目本能提升到全局作用域
/projects # 列出所有已知项目及其本能数量
| 命令 | 描述 |
|---|---|
/instinct-status | 显示所有本能(项目作用域 + 全局)及其置信度 |
/evolve | 将相关本能聚类成技能/命令,建议提升 |
/instinct-export | 导出本能(可按作用域/领域过滤) |
/instinct-import <file> | 导入本能,可控制作用域 |
/promote [id] | 将项目本能提升到全局作用域 |
/projects | 列出所有已知项目及其本能数量 |
编辑 config.json 以控制后台观察器:
{
"version": "2.1",
"observer": {
"enabled": false,
"run_interval_minutes": 5,
"min_observations_to_analyze": 20
}
}
| 键 | 默认值 | 描述 |
|---|---|---|
observer.enabled | false | 启用后台观察器智能体 |
observer.run_interval_minutes | 5 | 观察器分析观察记录的频率 |
observer.min_observations_to_analyze | 20 | 运行分析前所需的最小观察记录数 |
其他行为(观察捕获、本能阈值、项目作用域、提升标准)通过 instinct-cli.py 和 observe.sh 中的代码默认值进行配置。
~/.claude/homunculus/
+-- identity.json # 你的个人资料,技术水平
+-- projects.json # 注册表:项目哈希 -> 名称/路径/远程地址
+-- observations.jsonl # 全局观察记录(回退)
+-- instincts/
| +-- personal/ # 全局自动学习的本能
| +-- inherited/ # 全局导入的本能
+-- evolved/
| +-- agents/ # 全局生成的智能体
| +-- skills/ # 全局生成的技能
| +-- commands/ # 全局生成的命令
+-- projects/
+-- a1b2c3d4e5f6/ # 项目哈希(来自 git remote URL)
| +-- observations.jsonl
| +-- observations.archive/
| +-- instincts/
| | +-- personal/ # 项目特定的自动学习本能
| | +-- inherited/ # 项目特定的导入本能
| +-- evolved/
| +-- skills/
| +-- commands/
| +-- agents/
+-- f6e5d4c3b2a1/ # 另一个项目
+-- ...
| 模式类型 | 作用域 | 示例 |
|---|---|---|
| 语言/框架约定 | project | "使用 React hooks", "遵循 Django REST 模式" |
| 文件结构偏好 | project | "测试放在 __tests__/", "组件放在 src/components/" |
| 代码风格 | project | "使用函数式风格", "优先使用 dataclasses" |
| 错误处理策略 | project | "使用 Result 类型处理错误" |
| 安全实践 | global | "验证用户输入", "清理 SQL" |
| 通用最佳实践 | global | "先写测试", "始终处理错误" |
| 工具工作流偏好 | global | "编辑前先 Grep", "写之前先读" |
| Git 实践 | global | "约定式提交", "小而专注的提交" |
当同一个本能在多个项目中以高置信度出现时,它就有资格被提升到全局作用域。
自动提升标准:
如何提升:
# 提升一个特定的本能
python3 instinct-cli.py promote prefer-explicit-errors
# 自动提升所有符合条件的本能
python3 instinct-cli.py promote
# 预览而不做更改
python3 instinct-cli.py promote --dry-run
/evolve 命令也会建议提升候选。
置信度随时间演变:
| 分数 | 含义 | 行为 |
|---|---|---|
| 0.3 | 试探性 | 建议但不强制执行 |
| 0.5 | 中等 | 在相关时应用 |
| 0.7 | 强 | 自动批准应用 |
| 0.9 | 近乎确定 | 核心行为 |
置信度增加当:
置信度降低当:
"v1 依赖技能进行观察。技能是概率性的——它们根据 Claude 的判断大约在 50-80% 的情况下触发。"
钩子100% 触发,是确定性的。这意味着:
v2.1 与 v2.0 和 v1 完全兼容:
~/.claude/homunculus/instincts/ 中现有的全局本能仍作为全局本能工作~/.claude/skills/learned/ 技能仍然有效基于本能的学习:一个项目接一个项目地教会 Claude 你的模式。
每周安装量
1.4K
仓库
GitHub Stars
70.6K
首次出现
Jan 26, 2026
安全审计
安装于
opencode1.1K
codex1.1K
gemini-cli1.0K
claude-code977
github-copilot956
cursor904
-Based Architecture
An advanced learning system that turns your Claude Code sessions into reusable knowledge through atomic "instincts" - small learned behaviors with confidence scoring.
v2.1 adds project-scoped instincts — React patterns stay in your React project, Python conventions stay in your Python project, and universal patterns (like "always validate input") are shared globally.
| Feature | v2.0 | v2.1 |
|---|---|---|
| Storage | Global (~/.claude/homunculus/) | Project-scoped (projects//) |
| Scope | All instincts apply everywhere | Project-scoped + global |
| Detection | None | git remote URL / repo path |
| Promotion | N/A | Project → global when seen in 2+ projects |
| Commands | 4 (status/evolve/export/import) | 6 (+promote/projects) |
| Cross-project | Contamination risk | Isolated by default |
| Feature | v1 | v2 |
|---|---|---|
| Observation | Stop hook (session end) | PreToolUse/PostToolUse (100% reliable) |
| Analysis | Main context | Background agent (Haiku) |
| Granularity | Full skills | Atomic "instincts" |
| Confidence | None | 0.3-0.9 weighted |
| Evolution | Direct to skill | Instincts -> cluster -> skill/command/agent |
| Sharing | None | Export/import instincts |
An instinct is a small learned behavior:
---
id: prefer-functional-style
trigger: "when writing new functions"
confidence: 0.7
domain: "code-style"
source: "session-observation"
scope: project
project_id: "a1b2c3d4e5f6"
project_name: "my-react-app"
---
# Prefer Functional Style
## Action
Use functional patterns over classes when appropriate.
## Evidence
- Observed 5 instances of functional pattern preference
- User corrected class-based approach to functional on 2025-01-15
Properties:
project (default) or globalSession Activity (in a git repo)
|
| Hooks capture prompts + tool use (100% reliable)
| + detect project context (git remote / repo path)
v
+---------------------------------------------+
| projects/<project-hash>/observations.jsonl |
| (prompts, tool calls, outcomes, project) |
+---------------------------------------------+
|
| Observer agent reads (background, Haiku)
v
+---------------------------------------------+
| PATTERN DETECTION |
| * User corrections -> instinct |
| * Error resolutions -> instinct |
| * Repeated workflows -> instinct |
| * Scope decision: project or global? |
+---------------------------------------------+
|
| Creates/updates
v
+---------------------------------------------+
| projects/<project-hash>/instincts/personal/ |
| * prefer-functional.yaml (0.7) [project] |
| * use-react-hooks.yaml (0.9) [project] |
+---------------------------------------------+
| instincts/personal/ (GLOBAL) |
| * always-validate-input.yaml (0.85) [global]|
| * grep-before-edit.yaml (0.6) [global] |
+---------------------------------------------+
|
| /evolve clusters + /promote
v
+---------------------------------------------+
| projects/<hash>/evolved/ (project-scoped) |
| evolved/ (global) |
| * commands/new-feature.md |
| * skills/testing-workflow.md |
| * agents/refactor-specialist.md |
+---------------------------------------------+
The system automatically detects your current project:
CLAUDE_PROJECT_DIR env var (highest priority)git remote get-url origin -- hashed to create a portable project ID (same repo on different machines gets the same ID)git rev-parse --show-toplevel -- fallback using repo path (machine-specific)Each project gets a 12-character hash ID (e.g., a1b2c3d4e5f6). A registry file at ~/.claude/homunculus/projects.json maps IDs to human-readable names.
Add to your ~/.claude/settings.json.
If installed as a plugin (recommended):
{
"hooks": {
"PreToolUse": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh"
}]
}],
"PostToolUse": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh"
}]
}]
}
}
If installed manually to ~/.claude/skills:
{
"hooks": {
"PreToolUse": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh"
}]
}],
"PostToolUse": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh"
}]
}]
}
}
The system creates directories automatically on first use, but you can also create them manually:
# Global directories
mkdir -p ~/.claude/homunculus/{instincts/{personal,inherited},evolved/{agents,skills,commands},projects}
# Project directories are auto-created when the hook first runs in a git repo
/instinct-status # Show learned instincts (project + global)
/evolve # Cluster related instincts into skills/commands
/instinct-export # Export instincts to file
/instinct-import # Import instincts from others
/promote # Promote project instincts to global scope
/projects # List all known projects and their instinct counts
| Command | Description |
|---|---|
/instinct-status | Show all instincts (project-scoped + global) with confidence |
/evolve | Cluster related instincts into skills/commands, suggest promotions |
/instinct-export | Export instincts (filterable by scope/domain) |
/instinct-import <file> | Import instincts with scope control |
/promote [id] | Promote project instincts to global scope |
/projects |
Edit config.json to control the background observer:
{
"version": "2.1",
"observer": {
"enabled": false,
"run_interval_minutes": 5,
"min_observations_to_analyze": 20
}
}
| Key | Default | Description |
|---|---|---|
observer.enabled | false | Enable the background observer agent |
observer.run_interval_minutes | 5 | How often the observer analyzes observations |
observer.min_observations_to_analyze | 20 | Minimum observations before analysis runs |
Other behavior (observation capture, instinct thresholds, project scoping, promotion criteria) is configured via code defaults in instinct-cli.py and observe.sh.
~/.claude/homunculus/
+-- identity.json # Your profile, technical level
+-- projects.json # Registry: project hash -> name/path/remote
+-- observations.jsonl # Global observations (fallback)
+-- instincts/
| +-- personal/ # Global auto-learned instincts
| +-- inherited/ # Global imported instincts
+-- evolved/
| +-- agents/ # Global generated agents
| +-- skills/ # Global generated skills
| +-- commands/ # Global generated commands
+-- projects/
+-- a1b2c3d4e5f6/ # Project hash (from git remote URL)
| +-- observations.jsonl
| +-- observations.archive/
| +-- instincts/
| | +-- personal/ # Project-specific auto-learned
| | +-- inherited/ # Project-specific imported
| +-- evolved/
| +-- skills/
| +-- commands/
| +-- agents/
+-- f6e5d4c3b2a1/ # Another project
+-- ...
| Pattern Type | Scope | Examples |
|---|---|---|
| Language/framework conventions | project | "Use React hooks", "Follow Django REST patterns" |
| File structure preferences | project | "Tests in __tests__/", "Components in src/components/" |
| Code style | project | "Use functional style", "Prefer dataclasses" |
| Error handling strategies | project | "Use Result type for errors" |
| Security practices | global | "Validate user input", "Sanitize SQL" |
| General best practices | global | "Write tests first", "Always handle errors" |
| Tool workflow preferences |
When the same instinct appears in multiple projects with high confidence, it's a candidate for promotion to global scope.
Auto-promotion criteria:
How to promote:
# Promote a specific instinct
python3 instinct-cli.py promote prefer-explicit-errors
# Auto-promote all qualifying instincts
python3 instinct-cli.py promote
# Preview without changes
python3 instinct-cli.py promote --dry-run
The /evolve command also suggests promotion candidates.
Confidence evolves over time:
| Score | Meaning | Behavior |
|---|---|---|
| 0.3 | Tentative | Suggested but not enforced |
| 0.5 | Moderate | Applied when relevant |
| 0.7 | Strong | Auto-approved for application |
| 0.9 | Near-certain | Core behavior |
Confidence increases when:
Confidence decreases when:
"v1 relied on skills to observe. Skills are probabilistic -- they fire ~50-80% of the time based on Claude's judgment."
Hooks fire 100% of the time , deterministically. This means:
v2.1 is fully compatible with v2.0 and v1:
~/.claude/homunculus/instincts/ still work as global instincts~/.claude/skills/learned/ skills from v1 still workInstinct-based learning: teaching Claude your patterns, one project at a time.
Weekly Installs
1.4K
Repository
GitHub Stars
70.6K
First Seen
Jan 26, 2026
Security Audits
Gen Agent Trust HubWarnSocketFailSnykWarn
Installed on
opencode1.1K
codex1.1K
gemini-cli1.0K
claude-code977
github-copilot956
cursor904
97,600 周安装
| List all known projects and their instinct counts |
| global |
| "Grep before Edit", "Read before Write" |
| Git practices | global | "Conventional commits", "Small focused commits" |