SNARC: The Salience-Gated Memory System That Makes Claude Code Remember How You Work

SNARC: The Salience-Gated Memory System That Makes Claude Code Remember How You Work

SNARC (formerly Engram) automatically captures your important coding patterns, forgets the noise, and injects relevant memories into Claude Code sessions without manual queries.

18h ago·3 min read·2 views·via hn_claude_code
Share:

SNARC: The Salience-Gated Memory System That Makes Claude Code Remember How You Work

What It Does

SNARC (Surprise, Novelty, Arousal, Reward, Conflict) is a memory system specifically designed for Claude Code that captures what matters and forgets what doesn't. Unlike traditional memory systems that capture everything and rely on search, SNARC uses salience scoring to selectively store only significant observations from your coding sessions.

Every tool Claude uses during a session is observed and scored on five dimensions: surprise, novelty, arousal, reward, and conflict. Observations scoring below the salience threshold stay briefly in a circular buffer before being evicted, while high-salience observations persist. This mirrors biological memory—you don't remember every step, but you remember the one where you tripped.

How It Works In Practice

Context injection happens automatically in three scenarios:

  1. At session start
  2. After each prompt (if related memories exist)
  3. After context compaction

You don't need to query SNARC—it surfaces relevant memories without being asked. Injection is epistemically labeled with three tiers:

  • Tier 1: "observed (directly recorded)"
  • Tier 2: "inferred (heuristic—may not be accurate)"
  • Tier 3: "auto-extracted, verify if unsure"

The system is conservative by design, biased toward omission rather than injection of potentially wrong memories.

The Dream Cycle: Extracting Patterns

At session end, SNARC runs a "dream cycle" that extracts patterns from stored observations. This happens in two ways:

Mechanical (heuristic) extraction:

  • Tool sequences: Recurring workflows (e.g., Edit → Bash(test) → Edit = TDD loop)
  • Error-fix chains: Error followed by fix on the same file within 5 observations
  • Concept clusters: Multiple observations grouped around the same files

Semantic (LLM-powered deep dream):
Sends session observations to Claude via claude --print for deeper pattern extraction:

  • Workflows: Recurring approaches with semantic understanding of intent
  • Error-fix chains: Problem → solution with semantic understanding
  • Insights: Something learned about the codebase
  • Decisions: Architectural choices made during the session
  • Identity facts: Persistent project knowledge

Setting Up Deep Dream

You can trigger deep dream manually:

snarc dream --deep

Or enable automatic deep dream at session end:

export ENGRAM_DEEP_DREAM=1

Safety Features For Identity Facts

Deep dream identity facts are quarantined by default. They go to Tier 2 as proposed_identity patterns—never auto-injected into Claude's context, never promoted to Tier 3 without review.

Review quarantined proposals:

snarc review

Promote a good proposal:

snarc promote 42 "test_framework" "Jest"

Reject a bad proposal:

snarc reject 43

For those who prefer speed over safety:

snarc config auto_promote_identity 1  # deep dream identity → straight to Tier 3
snarc config auto_promote_identity 0  # back to quarantine

Why This Changes Claude Code Workflows

Most developers using Claude Code face the same problem: each session starts from scratch. You might explain your project structure, testing patterns, or common workflows repeatedly. SNARC solves this by building a structured memory of how you work—what tools you reach for, what errors you hit, what fixes you apply.

The salience-gated approach means the system learns what's actually important to you, not just what happens frequently. A one-time configuration error that took hours to debug gets remembered; the hundred times you saved a file without changes gets forgotten.

Getting Started

Install SNARC from the GitHub repository and integrate it with your Claude Code setup. The system works alongside your existing workflow, observing and learning without requiring changes to how you use Claude Code. Over time, you'll notice Claude starting sessions with more context about your project's unique patterns and your personal coding style.

AI Analysis

Claude Code users should install SNARC immediately if they work on the same project across multiple sessions. The automatic context injection means Claude will start remembering your project's quirks—like that one test file that always needs special handling or the specific way you structure API calls. Set `ENGRAM_DEEP_DREAM=1` to enable automatic pattern extraction at session end. This is especially valuable for complex projects where you're establishing new patterns. Review the quarantined identity facts weekly using `snarc review`—this is where SNARC proposes persistent project knowledge that could save you hours of re-explaining. If you work on multiple projects, SNARC's project-aware memory means you won't get confused context from Project A when working on Project B. The system understands project boundaries and keeps memories appropriately scoped. This makes it safe to use across your entire development workflow, not just on single projects.
Original sourcegithub.com

Trending Now

More in Products & Launches

Browse more AI articles