continuous-learning-v2

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Continuous Learning v2 - Instinct-Based Architecture

持续学习v2 - 基于本能的架构

An advanced learning system that turns your Claude Code sessions into reusable knowledge through atomic "instincts" - small learned behaviors with confidence scoring.
这是一个高级学习系统,通过原子化的「本能」——带有置信度评分的小型习得行为,将你的Claude Code会话转化为可复用的知识。

What's New in v2

v2版本新特性

Featurev1v2
ObservationStop hook (session end)PreToolUse/PostToolUse (100% reliable)
AnalysisMain contextBackground agent (Haiku)
GranularityFull skillsAtomic "instincts"
ConfidenceNone0.3-0.9 weighted
EvolutionDirect to skillInstincts → cluster → skill/command/agent
SharingNoneExport/import instincts
特性v1版本v2版本
观测方式停止钩子(会话结束时触发)PreToolUse/PostToolUse钩子(100%可靠)
分析方式主上下文分析后台Agent(Haiku)分析
颗粒度完整技能原子化「本能」
置信度0.3-0.9加权评分
演化路径直接生成技能本能→聚类→技能/命令/Agent
共享功能导出/导入本能

The Instinct Model

本能模型

An instinct is a small learned behavior:
yaml
---
id: prefer-functional-style
trigger: "when writing new functions"
confidence: 0.7
domain: "code-style"
source: "session-observation"
---
本能是一种小型的习得行为:
yaml
---
id: prefer-functional-style
trigger: "when writing new functions"
confidence: 0.7
domain: "code-style"
source: "session-observation"
---

Prefer Functional Style

Prefer Functional Style

Action

Action

Use functional patterns over classes when appropriate.
Use functional patterns over classes when appropriate.

Evidence

Evidence

  • Observed 5 instances of functional pattern preference
  • User corrected class-based approach to functional on 2025-01-15

**Properties:**
- **Atomic** — one trigger, one action
- **Confidence-weighted** — 0.3 = tentative, 0.9 = near certain
- **Domain-tagged** — code-style, testing, git, debugging, workflow, etc.
- **Evidence-backed** — tracks what observations created it
  • Observed 5 instances of functional pattern preference
  • User corrected class-based approach to functional on 2025-01-15

**特性:**
- **原子化** — 一个触发条件,一个对应行为
- **带置信度加权** — 0.3=暂定,0.9=近乎确定
- **领域标记** — 代码风格、测试、Git、调试、工作流等
- **有证据支撑** — 记录生成该本能的观测来源

How It Works

工作流程

Session Activity
      │ Hooks capture prompts + tool use (100% reliable)
┌─────────────────────────────────────────┐
│         observations.jsonl              │
│   (prompts, tool calls, outcomes)       │
└─────────────────────────────────────────┘
      │ Observer agent reads (background, Haiku)
┌─────────────────────────────────────────┐
│          PATTERN DETECTION              │
│   • User corrections → instinct         │
│   • Error resolutions → instinct        │
│   • Repeated workflows → instinct       │
└─────────────────────────────────────────┘
      │ Creates/updates
┌─────────────────────────────────────────┐
│         instincts/personal/             │
│   • prefer-functional.md (0.7)          │
│   • always-test-first.md (0.9)          │
│   • use-zod-validation.md (0.6)         │
└─────────────────────────────────────────┘
      │ /evolve clusters
┌─────────────────────────────────────────┐
│              evolved/                   │
│   • commands/new-feature.md             │
│   • skills/testing-workflow.md          │
│   • agents/refactor-specialist.md       │
└─────────────────────────────────────────┘
会话活动
      │ 钩子捕获提示词 + 工具使用记录(100%可靠)
┌─────────────────────────────────────────┐
│         observations.jsonl              │
│   (提示词、工具调用、执行结果)           │
└─────────────────────────────────────────┘
      │ 观测Agent读取记录(后台运行,基于Haiku模型)
┌─────────────────────────────────────────┐
│          模式检测                       │
│   • 用户修正操作 → 生成本能              │
│   • 错误解决过程 → 生成本能              │
│   • 重复工作流 → 生成本能                │
└─────────────────────────────────────────┘
      │ 创建/更新
┌─────────────────────────────────────────┐
│         instincts/personal/             │
│   • prefer-functional.md (0.7)          │
│   • always-test-first.md (0.9)          │
│   • use-zod-validation.md (0.6)         │
└─────────────────────────────────────────┘
      │ /evolve 聚类
┌─────────────────────────────────────────┐
│              evolved/                   │
│   • commands/new-feature.md             │
│   • skills/testing-workflow.md          │
│   • agents/refactor-specialist.md       │
└─────────────────────────────────────────┘

Quick Start

快速开始

1. Enable Observation Hooks

1. 启用观测钩子

Add to your
~/.claude/settings.json
.
If installed as a plugin (recommended):
json
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh pre"
      }]
    }],
    "PostToolUse": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh post"
      }]
    }]
  }
}
If installed manually to
~/.claude/skills
:
json
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh pre"
      }]
    }],
    "PostToolUse": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh post"
      }]
    }]
  }
}
添加到你的
~/.claude/settings.json
文件中。
以插件形式安装(推荐):
json
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh pre"
      }]
    }],
    "PostToolUse": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh post"
      }]
    }]
  }
}
手动安装到
~/.claude/skills
目录
json
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh pre"
      }]
    }],
    "PostToolUse": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh post"
      }]
    }]
  }
}

2. Initialize Directory Structure

2. 初始化目录结构

The Python CLI will create these automatically, but you can also create them manually:
bash
mkdir -p ~/.claude/homunculus/{instincts/{personal,inherited},evolved/{agents,skills,commands}}
touch ~/.claude/homunculus/observations.jsonl
Python命令行工具会自动创建这些目录,你也可以手动创建:
bash
mkdir -p ~/.claude/homunculus/{instincts/{personal,inherited},evolved/{agents,skills,commands}}
touch ~/.claude/homunculus/observations.jsonl

3. Use the Instinct Commands

3. 使用本能相关命令

bash
/instinct-status     # Show learned instincts with confidence scores
/evolve              # Cluster related instincts into skills/commands
/instinct-export     # Export instincts for sharing
/instinct-import     # Import instincts from others
bash
/instinct-status     # 查看已学习的本能及其置信度评分
/evolve              # 将相关本能聚类为技能/命令
/instinct-export     # 导出本能以便共享
/instinct-import     # 导入他人的本能

Commands

命令列表

CommandDescription
/instinct-status
Show all learned instincts with confidence
/evolve
Cluster related instincts into skills/commands
/instinct-export
Export instincts for sharing
/instinct-import <file>
Import instincts from others
命令描述
/instinct-status
显示所有已学习的本能及其置信度
/evolve
将相关本能聚类为技能/命令
/instinct-export
导出本能用于共享
/instinct-import <file>
从文件导入他人的本能

Configuration

配置说明

Edit
config.json
:
json
{
  "version": "2.0",
  "observation": {
    "enabled": true,
    "store_path": "~/.claude/homunculus/observations.jsonl",
    "max_file_size_mb": 10,
    "archive_after_days": 7
  },
  "instincts": {
    "personal_path": "~/.claude/homunculus/instincts/personal/",
    "inherited_path": "~/.claude/homunculus/instincts/inherited/",
    "min_confidence": 0.3,
    "auto_approve_threshold": 0.7,
    "confidence_decay_rate": 0.05
  },
  "observer": {
    "enabled": true,
    "model": "haiku",
    "run_interval_minutes": 5,
    "patterns_to_detect": [
      "user_corrections",
      "error_resolutions",
      "repeated_workflows",
      "tool_preferences"
    ]
  },
  "evolution": {
    "cluster_threshold": 3,
    "evolved_path": "~/.claude/homunculus/evolved/"
  }
}
编辑
config.json
文件:
json
{
  "version": "2.0",
  "observation": {
    "enabled": true,
    "store_path": "~/.claude/homunculus/observations.jsonl",
    "max_file_size_mb": 10,
    "archive_after_days": 7
  },
  "instincts": {
    "personal_path": "~/.claude/homunculus/instincts/personal/",
    "inherited_path": "~/.claude/homunculus/instincts/inherited/",
    "min_confidence": 0.3,
    "auto_approve_threshold": 0.7,
    "confidence_decay_rate": 0.05
  },
  "observer": {
    "enabled": true,
    "model": "haiku",
    "run_interval_minutes": 5,
    "patterns_to_detect": [
      "user_corrections",
      "error_resolutions",
      "repeated_workflows",
      "tool_preferences"
    ]
  },
  "evolution": {
    "cluster_threshold": 3,
    "evolved_path": "~/.claude/homunculus/evolved/"
  }
}

File Structure

文件结构

~/.claude/homunculus/
├── identity.json           # Your profile, technical level
├── observations.jsonl      # Current session observations
├── observations.archive/   # Processed observations
├── instincts/
│   ├── personal/           # Auto-learned instincts
│   └── inherited/          # Imported from others
└── evolved/
    ├── agents/             # Generated specialist agents
    ├── skills/             # Generated skills
    └── commands/           # Generated commands
~/.claude/homunculus/
├── identity.json           # 你的个人资料、技术水平
├── observations.jsonl      # 当前会话观测记录
├── observations.archive/   # 已处理的观测记录归档
├── instincts/
│   ├── personal/           # 自动学习到的本能
│   └── inherited/          # 从他人处导入的本能
└── evolved/
    ├── agents/             # 生成的专业Agent
    ├── skills/             # 生成的技能
    └── commands/           # 生成的命令

Integration with Skill Creator

与Skill Creator集成

When you use the Skill Creator GitHub App, it now generates both:
  • Traditional SKILL.md files (for backward compatibility)
  • Instinct collections (for v2 learning system)
Instincts from repo analysis have
source: "repo-analysis"
and include the source repository URL.
当你使用Skill Creator GitHub应用时,它现在会同时生成:
  • 传统的SKILL.md文件(用于向后兼容)
  • 本能集合(用于v2学习系统)
来自代码库分析的本能会标记
source: "repo-analysis"
,并包含源代码库的URL。

Confidence Scoring

置信度评分机制

Confidence evolves over time:
ScoreMeaningBehavior
0.3TentativeSuggested but not enforced
0.5ModerateApplied when relevant
0.7StrongAuto-approved for application
0.9Near-certainCore behavior
Confidence increases when:
  • Pattern is repeatedly observed
  • User doesn't correct the suggested behavior
  • Similar instincts from other sources agree
Confidence decreases when:
  • User explicitly corrects the behavior
  • Pattern isn't observed for extended periods
  • Contradicting evidence appears
置信度会随时间演化:
评分含义行为
0.3暂定仅作为建议,不强制执行
0.5中等相关场景下自动应用
0.7较高自动批准并应用
0.9近乎确定作为核心行为应用
置信度提升场景
  • 模式被重复观测到
  • 用户未修正建议的行为
  • 来自其他来源的相似本能达成一致
置信度下降场景
  • 用户明确修正了该行为
  • 长时间未观测到该模式
  • 出现矛盾的证据

Why Hooks vs Skills for Observation?

为什么选择钩子而非技能进行观测?

"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:
  • Every tool call is observed
  • No patterns are missed
  • Learning is comprehensive
"v1版本依赖技能进行观测。技能是概率性的——基于Claude的判断,触发率约为50-80%。"
钩子会100%确定性触发,这意味着:
  • 每一次工具调用都会被观测到
  • 不会遗漏任何模式
  • 学习过程全面覆盖

Backward Compatibility

向后兼容性

v2 is fully compatible with v1:
  • Existing
    ~/.claude/skills/learned/
    skills still work
  • Stop hook still runs (but now also feeds into v2)
  • Gradual migration path: run both in parallel
v2版本完全兼容v1版本:
  • 现有的
    ~/.claude/skills/learned/
    目录下的技能仍可正常使用
  • 停止钩子仍会运行(但现在也会为v2版本提供数据)
  • 提供渐进式迁移路径:可以同时运行两个版本

Privacy

隐私说明

  • Observations stay local on your machine
  • Only instincts (patterns) can be exported
  • No actual code or conversation content is shared
  • You control what gets exported
  • 观测记录全程保存在本地设备
  • 仅能导出本能(模式),不会包含实际代码或对话内容
  • 你完全控制哪些内容可以被导出

Related

相关资源


Instinct-based learning: teaching Claude your patterns, one observation at a time.

基于本能的学习:通过一次次观测,教会Claude你的行为模式。