Claude Code Integration
Kernle integrates with Claude Code via hooks — memory loads automatically, checkpoints save before compaction and at session end, and native memory file writes are intercepted and captured into Kernle.How It Works
Write Interception
When the SI tries to write tomemory/ or MEMORY.md (Claude Code’s native memory), the PreToolUse hook:
- Captures the content as a Kernle raw entry
- Blocks the write
- Returns a message directing the SI to use Kernle commands instead
Installation (Recommended)
The recommended approach useskernle setup which writes hooks directly into .claude/settings.json — no plugin directory or repo access needed.
1
Install Kernle
2
Initialize a Stack
3
Setup Claude Code Hooks
4
Verify
Installation (Plugin Mode)
Alternatively, use the plugin directory (requires access to the Kernle source repo):kernle hook <event> commands.
Configuration
All configuration is via environment variables — no config files needed:Stack ID Resolution
The hooks resolve the stack ID in order:--stackflag baked into hook commands bykernle setupKERNLE_STACK_IDenvironment variable- Project directory name from working directory
- Kernle auto-resolve
KERNLE_STACK_ID in your shell profile:
Hooks
SessionStart — Memory Loading
Fires on startup, resume, clear, and compact. Loads memory and injects it asadditionalContext in the session.
PreToolUse — Write Interception
MatchesWrite, Edit, and NotebookEdit tool calls. When the target path matches a memory file (memory/, MEMORY.md), the hook:
- Captures the content as a Kernle raw entry (for preservation)
- Blocks the write with a deny decision
- Returns a message explaining that memory is handled by Kernle
PreCompact — Pre-Compaction Checkpoint
Fires before context compaction. Reads the transcript to extract the last user message (task) and assistant message (context), then saves a checkpoint prefixed with[pre-compact].
SessionEnd — Final Checkpoint
Fires when the session terminates. Reads the transcript and saves both a checkpoint and a raw entry marking session completion.Graceful Degradation
All hooks exit 0 on any error. If Kernle is not installed, the stack doesn’t exist, or any command fails, the session continues normally with no error messages.What Gets Loaded
The SessionStart hook loads memory containing:- Checkpoint — current task, context, next steps (resume point)
- Values — core principles
- Beliefs — held truths with confidence levels
- Goals — active goals with priority
- Drives — motivations with intensity
- Lessons — extracted from recent episodes
- Relationships — key entities with sentiment
During Work
The SI captures memories via CLI as they happen. Each command writes immediately to local storage:Relationship to Native Features
Claude Code has its own memory mechanisms. Here’s how they interact with Kernle:CLAUDE.md is not replaced by Kernle. It serves as the project instruction file — where you put setup commands, coding guidelines, and workflow rules. Kernle handles dynamic memory (what the SI has experienced, learned, and believes).MCP Server (Alternative)
Kernle also provides an MCP server that works with Claude Code. This is an alternative to the hook approach — use one or the other for memory loading, not both. The hook approach is recommended because:- Memory loads automatically (no manual tool call needed)
- Auto-checkpointing before compaction and at session end
- Native write interception routes all memory through Kernle
- No MCP configuration required
memory_search, memory_anxiety), you can use both: hooks for automatic lifecycle management, and MCP for in-session memory operations. See the MCP Integration guide.
Diagnostics
Verify the integration works:Troubleshooting
Memory not appearing at session start
-
Run the doctor check:
-
Verify hooks are in settings.json:
-
Test the load command manually:
-
Check if stack is initialized: