graph-memory
Logseq-inspired persistent knowledge graph for Claude Code. Stores learnings, patterns, decisions as interconnected nodes with bidirectional links, automatic decay, and contextual recall. Grows smarter with every conversation. Triggers on memory, remember, recall, learn, knowledge graph, note, journal keywords.
- License 许可
- MIT
- 最近更新
- 2026-05-18
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- graph-memory
- description
- Logseq-inspired persistent knowledge graph for Claude Code. Stores learnings, patterns, decisions as interconnected nodes with bidirectional links, automatic decay, and contextual recall. Grows smarter with every conversation. Triggers on memory, remember, recall, learn, knowledge graph, note, journal keywords.
03 SKILL.md 正文
Graph Memory — Persistent Knowledge Graph for Claude Code
Architecture
Inspired by Logseq/Obsidian: every piece of knowledge is a node connected by edges. Bidirectional links ([[topic]]), tags (#tag), and automatic relationship inference create a living knowledge graph that grows with each conversation.
.claude/graph-memory/
├── engine.cjs ← Node.js graph engine (CLI)
├── data/
│ ├── nodes.json ← All knowledge nodes
│ ├── edges.json ← Relationships between nodes
│ ├── index.json ← Full-text + tag index
│ ├── journal/ ← Daily journal entries (YYYY-MM-DD.md)
│ └── pages/ ← Named pages (like Logseq pages)
Node Types
| Type | Purpose | Example |
|---|---|---|
knowledge |
Verified facts, patterns | "Supabase RLS requires auth.uid()" |
decision |
Architectural decisions | "Chose Zustand over Redux for state" |
pattern |
Reusable code patterns | "Clerk JWT bridge pattern for tools" |
bug |
Bug discoveries + fixes | "CSRF token missing → silent 403" |
insight |
Performance/design insights | "Lazy loading cuts bundle 40%" |
page |
Named topic pages | "Authentication Flow" |
journal |
Daily session logs | Auto-generated per session |
Engine CLI Reference
All commands via: node .claude/graph-memory/engine.cjs <command> [args]
Core Commands
# Learn something new (accumulates on existing topics)
node engine.cjs learn "CSRF Tokens" "Missing X-CSRF-Token causes silent 403 on auth'd POSTs" "debugging" 0.95
# Add a node (type: knowledge|decision|pattern|bug|insight|page)
node engine.cjs add pattern "Clerk JWT Bridge" "Clerk getToken() → TOOL_AUTH_SECRET → postMessage → Supabase RLS" '{"tool":"all"}'
# Journal entry (daily log)
node engine.cjs journal "Fixed credit deduction race condition in deduct_credits()" "credits,bugfix"
# Link two topics bidirectionally
node engine.cjs link "CSRF Tokens" "Authentication Flow" "requires"
# Search the graph
node engine.cjs search "authentication" 5
# Deep recall with neighbor context (depth=2, limit=5)
node engine.cjs recall "credit system" 2 5
# Get graph neighbors
node engine.cjs neighbors <nodeId> 2
# Graph statistics
node engine.cjs stats
# Decay old unused nodes (run periodically)
node engine.cjs decay 0.02
# Export full graph (for visualization)
node engine.cjs export
Workflow — How to Use in Every Session
Session Start
# 1. Check what the graph knows about current task
node .claude/graph-memory/engine.cjs recall "<current task topic>" 2 5
# 2. Review today's journal
# Check .claude/graph-memory/data/journal/YYYY-MM-DD.md
# 3. Check graph stats
node .claude/graph-memory/engine.cjs stats
During Work
# When you discover something
node .claude/graph-memory/engine.cjs learn "Topic" "What you learned" "source" 0.9
# When you make a decision
node .claude/graph-memory/engine.cjs add decision "Decision Title" "Why this choice was made and alternatives considered"
# When you find a bug
node .claude/graph-memory/engine.cjs add bug "Bug Title" "Root cause, symptoms, and fix applied"
# When you notice a pattern
node .claude/graph-memory/engine.cjs add pattern "Pattern Name" "Description with [[linked topics]]"
# Connect related concepts
node .claude/graph-memory/engine.cjs link "Topic A" "Topic B" "depends-on"
Session End
# Log session summary
node .claude/graph-memory/engine.cjs journal "Session summary: what was done, blockers, next steps" "session,progress"
# Decay stale nodes
node .claude/graph-memory/engine.cjs decay
Bidirectional Links & Tags
Use Logseq-style syntax in content:
[[Topic Name]]→ auto-creates edge to existing node with that title#tag→ auto-extracted and indexed for fast filtering
Example:
"The [[CSRF Token]] system integrates with [[Clerk Auth]] to protect all auth'd POST endpoints. Uses #security #middleware pattern."
This auto-links to "CSRF Token" and "Clerk Auth" nodes and indexes under #security and #middleware.
Strength & Decay
- Strength: Starts at 1.0, increases +0.15 each time
learnupdates a topic (max 2.0) - Access count: Incremented on every search hit
- Decay: Nodes untouched for 7+ days with <3 accesses lose strength (-0.02/run)
- Edge weight: Reinforced +0.1 each time a link is re-created (max 2.0)
- Pruning: Edges below 0.1 weight are auto-removed during decay
Recall Context
recall doesn't just return matching nodes — it traverses the graph:
- Find top matches via full-text + tag search
- For each match, walk edges up to
depthlevels - Return nodes with their context subgraph (neighbors, relations, weights)
This means asking about "credits" might surface:
- Direct: credit deduction logic, billing patterns
- Context (depth 1): Stripe webhooks, monthly reset
- Context (depth 2): User plans, rate limiting
Relation Types
| Relation | Meaning |
|---|---|
reference |
Auto-created from [[links]] |
related |
General association |
requires |
Dependency |
depends-on |
Technical dependency |
caused-by |
Bug/issue causality |
solved-by |
Fix/solution link |
part-of |
Component belongs to system |
alternative-to |
Design alternatives |
evolved-from |
Iteration/improvement |
Integration with Hooks
The PostToolUse hook automatically journals significant edits. The Notification hook logs activity. Combined, the graph builds passively even without explicit learn calls.
Quality Rules
- Always recall before starting work — check what the graph already knows
- Learn after every bug fix — future sessions benefit
- Link related concepts — isolated nodes are useless
- Journal at session end — continuity between conversations
- Run decay weekly — keep the graph fresh and relevant
- High confidence (0.9+) for verified facts, lower (0.5-0.7) for hypotheses
04 同仓库更多 Skills
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
web-design-guidelines
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
vercel-react-view-transitions
Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter/exit of components, animate list reorder, implement directional (forward/back) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.
vercel-react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
vercel-composition-patterns
React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.
vercel-cli-with-tokens
Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".