How to Set Up Continuous Learning from ECC Sessions
ECC's continuous learning pipeline automatically captures tool calls from your sessions, scores reusable patterns as "instincts," and converts high-value workflows into persistent skills stored in ~/.claude/skills/learned/.
The ECC (Everything Claude Code) repository provides a built-in mechanism to transform ad-hoc problem solving into reusable knowledge. By enabling continuous learning, you create a feedback loop where every session contributes to an expanding library of automated skills. This article explains how to configure the hook-based observation system and background processing loop according to the architecture defined in affaan-m/ECC.
Understanding the Continuous Learning Architecture
The continuous learning system operates through four distinct layers that capture, analyze, and persist patterns from your Claude Code sessions.
Hook-Based Observation Capture
Session-wide hooks monitor every tool invocation through the PreToolUse event. Located in scripts/hooks/continuous-learning-hook.ts, this layer registers listeners that detect noteworthy events such as errors, clever workarounds, or recurring command patterns.
When the hook identifies a significant moment, it writes a lightweight JSON record to the session log directory (.claude/session-logs/). The hook specifically captures the tool name, input parameters, error output, and timestamp for downstream analysis.
Background Observer Analysis Loop
A background script—scripts/hooks/continuous-learning-observer.ts—processes the raw observation logs continuously. This observer runs independently of your main session, typically activated via npm run continuous-learning-observe or a scheduled cron job.
The observer performs three critical functions:
- Reads JSON log records from the session logs directory
- Groups similar events and scores each "instinct" based on usefulness, frequency, and safety
- Filters for high-value patterns (typically those scoring above 0.8)
Instinct Persistence and Scoring
High-scoring instincts are persisted as candidate skill files in ~/.claude/skills/learned/. The observer maintains a local "instinct store" at .claude/instincts.json that tracks metadata and drives future recommendations.
Each candidate skill follows a standardized markdown template with frontmatter, problem description, solution code, and activation triggers. The system updates this store continuously, ensuring that frequently useful patterns remain available for automatic activation in future sessions.
Enabling Continuous Learning in ECC
Follow these steps to activate the full continuous learning pipeline in your ECC environment.
Activate the Observation Hook
The hook in scripts/hooks/continuous-learning-hook.ts loads automatically when ECC initializes. Ensure your Claude settings include the hooks directory:
// scripts/hooks/continuous-learning-hook.ts
import { registerHook } from '@claude/hook';
registerHook('PreToolUse', (tool, input) => {
if (input.error) {
logInstinct({ tool, error: input.error, timestamp: Date.now() });
}
});
Once active, the hook begins emitting observation events immediately upon session start, requiring no manual intervention.
Start the Background Observer
Launch the observer to process captured events. Run this in a separate terminal or configure it as a background service:
npm run continuous-learning-observe
The observer reads from .claude/session-logs/ and writes candidate files to ~/.claude/skills/learned/, running the analysis loop every 60 seconds by default.
Extract Patterns with the /learn Command
When you notice a reusable pattern during a session, invoke the built-in extraction command:
/learn
This command parses the current session log, presents a shortlist of detected instincts, and prompts you to confirm skill creation. According to the command specification in commands/learn.md, the process reviews extractable patterns, identifies the most valuable insight, drafts the skill file, and requests user confirmation before persisting to disk.
Review Generated Skill Files
After confirmation, ECC writes a markdown file (e.g., ~/.claude/skills/learned/redis-retry-pattern.md) containing:
- Frontmatter: Name, description, and origin metadata
- Problem Context: When the pattern applies
- Solution Code: The reusable implementation
- Activation Triggers: Conditions for automatic loading
Subsequent sessions automatically benefit from these skills. The hook detects matching triggers and auto-activates the appropriate skill, closing the learning loop.
Code Implementation Examples
Observer Loop Implementation
The background observer in scripts/hooks/continuous-learning-observer.ts implements the scoring and persistence logic:
import { readInstincts, scoreInstinct, persistSkill } from './utils';
async function observe() {
const records = await readInstincts();
const scored = records.map(scoreInstinct);
const top = scored.filter(i => i.score > 0.8);
for (const inst of top) {
await persistSkill(inst);
}
}
setInterval(observe, 60_000);
Generated Skill File Example
A typical learned skill file contains executable code and contextual metadata:
---
name: redis-retry-backoff
description: Automatic retry with exponential backoff for Redis connection failures
origin: ECC
---
# Redis Retry with Exponential Backoff
**Context:** API calls that hit a temporary Redis outage
## Problem
Repeated "Redis connection lost" errors cause request failures.
## Solution
Retry the operation with exponential backoff up to 3 attempts.
```typescript
async function withRedisRetry<T>(fn: () => Promise<T>, attempts = 3): Promise<T> {
for (let i = 0; i < attempts; i++) {
try {
return await fn();
} catch (e) {
if (i === attempts - 1) throw e;
await new Promise(r => setTimeout(r, 2 ** i * 1000));
}
}
throw new Error('Unreachable');
}
## Key Files and Directories
The continuous learning system relies on specific files within the ECC repository and your local configuration:
- **[`scripts/hooks/continuous-learning-hook.ts`](https://github.com/affaan-m/ECC/blob/main/scripts/hooks/continuous-learning-hook.ts)** – Registers `PreToolUse` hooks to log tool usage and errors
- **[`scripts/hooks/continuous-learning-observer.ts`](https://github.com/affaan-m/ECC/blob/main/scripts/hooks/continuous-learning-observer.ts)** – Background process that scores instincts and persists skills
- **[`docs/continuous-learning-v2-spec.md`](https://github.com/affaan-m/ECC/blob/main/docs/continuous-learning-v2-spec.md)** – Complete architectural specification for the pipeline
- **[`commands/learn.md`](https://github.com/affaan-m/ECC/blob/main/commands/learn.md)** – User-facing command reference for manual pattern extraction
- **`~/.claude/skills/learned/`** – Local directory where generated markdown skill files are stored
- **[`.claude/instincts.json`](https://github.com/affaan-m/ECC/blob/main/.claude/instincts.json)** – Local metadata store driving recommendation engine
## Summary
- **ECC continuous learning** captures tool calls automatically via `PreToolUse` hooks defined in [`scripts/hooks/continuous-learning-hook.ts`](https://github.com/affaan-m/ECC/blob/main/scripts/hooks/continuous-learning-hook.ts)
- The **background observer** (`npm run continuous-learning-observe`) processes logs every 60 seconds, scoring patterns and writing candidate skills
- High-scoring instincts are stored in `~/.claude/skills/learned/` as markdown files with standardized frontmatter
- The **`/learn` command** provides manual extraction when automatic detection misses valuable patterns
- Skills auto-activate in future sessions when their defined triggers match current context, creating a self-improving workflow
## Frequently Asked Questions
### How often does the continuous learning observer process session logs?
The observer runs on a fixed interval of **60 seconds** (60,000 milliseconds) as defined in [`scripts/hooks/continuous-learning-observer.ts`](https://github.com/affaan-m/ECC/blob/main/scripts/hooks/continuous-learning-observer.ts). You can modify this interval by adjusting the `setInterval` parameter in the source code or running the observer manually on a different schedule.
### What criteria determines if a pattern becomes a permanent skill?
Patterns must achieve a **score above 0.8** based on the `scoreInstinct` utility function. The scoring algorithm evaluates three dimensions: usefulness (how broadly applicable), frequency (how often it recurs), and safety (whether execution risks are contained). Only high-scoring instincts are persisted to `~/.claude/skills/learned/`.
### Can I disable automatic observation while keeping manual `/learn` functionality?
Yes. You can stop the background observer process without affecting the hook's ability to log events. Simply terminate the `npm run continuous-learning-observe` process. The hooks will continue writing to `.claude/session-logs/`, and you can still invoke `/learn` to manually extract patterns from the accumulated logs.
### Where are the learned skills stored and how do they persist across sessions?
Learned skills are stored as markdown files in **`~/.claude/skills/learned/`** within your home directory. Metadata about instinct scoring and frequency is maintained in **[`.claude/instincts.json`](https://github.com/affaan-m/ECC/blob/main/.claude/instincts.json)**. These files persist independently of individual ECC sessions, allowing skills to auto-activate whenever matching triggers appear in future projects.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →