Skip to main content
The Continuous Learning v2 system automatically learns from your Claude Code sessions through atomic “instincts” — small learned behaviors with confidence scoring.

Overview

What's New in v2.1

Project-scoped instincts — React patterns stay in React projects, Python conventions in Python projects. Universal patterns (like “always validate input”) are shared globally.

v2.1 Features

Featurev2.0v2.1
StorageGlobal onlyProject-scoped + global
ScopeAll instincts everywhereIsolated by project
DetectionNonegit remote URL / repo path
PromotionN/AProject → global (2+ projects)
Commands46 (+promote/projects)
Cross-projectContamination riskIsolated by default

v2 vs v1 Comparison

| Feature | v1 | v2 | |---------|----|----|| | Observation | Stop hook (session end) | PreToolUse/PostToolUse hooks | | Reliability | ~50-80% | 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 |

The Instinct Model

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

Instinct Properties

Atomic

One trigger, one action. Focused and reusable.

Confidence-Weighted

0.3 = tentative, 0.9 = near certain. Evolves over time.

Domain-Tagged

code-style, testing, git, debugging, workflow, etc.

Evidence-Backed

Tracks what observations created it. Transparent learning.

How It Works

1

Session Activity Captured

Hooks capture every prompt and tool use (100% reliable). Project context is auto-detected from git remote.Stored in: ~/.claude/homunculus/projects/<project-hash>/observations.jsonl
2

Pattern Detection

Observer agent (background, Haiku) reads observations and detects:
  • User corrections → instinct
  • Error resolutions → instinct
  • Repeated workflows → instinct
  • Scope decision: project or global?
3

Instinct Creation

Creates/updates instincts in:
  • projects/<hash>/instincts/personal/ (project-scoped)
  • instincts/personal/ (global)
Each with confidence score (0.3-0.9).
4

Evolution

/evolve clusters related instincts into:
  • commands/ — new slash commands
  • skills/ — reusable workflows
  • agents/ — specialized subagents

Project Detection

The system automatically detects your current project:
1

Environment Variable (Highest Priority)

export CLAUDE_PROJECT_DIR="/path/to/project"
2

Git Remote URL

git remote get-url origin
Hashed to create portable project ID. Same repo on different machines gets same ID.
3

Git Repo Path (Fallback)

git rev-parse --show-toplevel
Machine-specific fallback.
4

Global Fallback

If no project detected, instincts go to global scope.
Each project gets a 12-character hash ID (e.g., a1b2c3d4e5f6). A registry at ~/.claude/homunculus/projects.json maps IDs to human-readable names.

Quick Start

1. Enable Observation Hooks

Add to ~/.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"
      }]
    }]
  }
}

2. Initialize Directory Structure

Directories are auto-created on first use. Manual creation is optional.
# Global directories
mkdir -p ~/.claude/homunculus/{instincts/{personal,inherited},evolved/{agents,skills,commands},projects}

# Project directories auto-created when hooks run in git repos

3. Use Instinct Commands

/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 instinct counts

Commands Reference

/instinct-status

Show all instincts (project-scoped + global) with confidence scores.

/evolve

Cluster related instincts into skills/commands. Suggests promotions.

/instinct-export

Export instincts. Filter by scope (project/global) or domain.

/instinct-import <file>

Import instincts from others. Control scope on import.

/promote [id]

Promote project instincts to global scope.

/projects

List all known projects and their instinct counts.

Configuration

Edit ~/.claude/skills/continuous-learning-v2/config.json:
{
  "version": "2.1",
  "observer": {
    "enabled": false,
    "run_interval_minutes": 5,
    "min_observations_to_analyze": 20
  }
}
KeyDefaultDescription
observer.enabledfalseEnable background observer agent
observer.run_interval_minutes5How often observer analyzes observations
observer.min_observations_to_analyze20Minimum observations before analysis
Other behavior (observation capture, instinct thresholds, project scoping, promotion criteria) is configured in instinct-cli.py and observe.sh.

File Structure

~/.claude/homunculus/
├── identity.json              # Your profile, technical level
├── projects.json              # Registry: 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)
    │   ├── observations.jsonl
    │   ├── observations.archive/
    │   ├── instincts/
    │   │   ├── personal/      # Project-specific auto-learned
    │   │   └── inherited/     # Project-specific imported
    │   └── evolved/
    │       ├── skills/
    │       ├── commands/
    │       └── agents/
    └── f6e5d4c3b2a1/          # Another project
        └── ...

Scope Decision Guide

Pattern TypeScopeExamples
Language/framework conventionsproject”Use React hooks”, “Follow Django patterns”
File structure preferencesproject”Tests in __tests__/”, “Components in src/“
Code styleproject”Use functional style”, “Prefer dataclasses”
Error handling strategiesproject”Use Result type for errors”
Security practicesglobal”Validate user input”, “Sanitize SQL”
General best practicesglobal”Write tests first”, “Handle all errors”
Tool workflowglobal”Grep before Edit”, “Read before Write”
Git practicesglobal”Conventional commits”, “Small commits”

Instinct Promotion

When the same instinct appears in multiple projects with high confidence, promote to global scope.

Auto-Promotion Criteria

  • Same instinct ID in 2+ projects
  • Average confidence >= 0.8

Promote Instincts

# Promote 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 Scoring

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

Why Hooks vs Skills?

v1 used skills for observation. Skills fire ~50-80% of the time based on Claude’s judgment.
Hooks fire 100% of the time, deterministically:
  • Every tool call is observed
  • No patterns are missed
  • Learning is comprehensive

Backward Compatibility

v2.1 is fully compatible with v2.0 and v1:
  • Existing global instincts in ~/.claude/homunculus/instincts/ work as global instincts
  • Existing ~/.claude/skills/learned/ skills from v1 still work
  • Stop hook still runs (but now also feeds into v2)
  • Gradual migration: run both in parallel

Privacy

Local-First Learning

  • Observations stay local on your machine
  • Project-scoped instincts isolated per project
  • Only patterns (instincts) can be exported — not raw observations
  • No code or conversation content shared
  • You control what gets exported and promoted
  • Skill Creator — Generate instincts from repo history
  • Homunculus — Community project that inspired the v2 architecture
  • The Longform Guide — Continuous learning section

Example Workflow

1

Work Normally

Use Claude Code as usual. Hooks capture all activity automatically.
2

Check Learned Patterns

/instinct-status
Review instincts learned from your sessions.
3

Evolve Into Skills

/evolve
Cluster related instincts into reusable skills, commands, or agents.
4

Promote Universal Patterns

/promote
Move patterns that apply across projects to global scope.
5

Share With Team

/instinct-export
Export instincts for team members to import.

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