eagle-mem 1.6.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/scripts/help.sh CHANGED
@@ -13,58 +13,37 @@ version=$(jq -r .version "$PACKAGE_DIR/package.json" 2>/dev/null || echo "unknow
13
13
  eagle_banner
14
14
 
15
15
  echo -e " ${BOLD}Eagle Mem${RESET} ${DIM}v${version}${RESET}"
16
- echo -e " ${DIM}Lightweight persistent memory for Claude Code${RESET}"
17
- echo ""
18
- echo -e " ${BOLD}Usage:${RESET}"
19
- echo -e " eagle-mem ${CYAN}<command>${RESET}"
16
+ echo -e " ${DIM}Persistent memory for Claude Code${RESET}"
20
17
  echo ""
21
18
  echo -e " ${BOLD}Commands:${RESET}"
22
- echo -e " ${CYAN}search${RESET} Search past sessions, files, and observations"
23
- echo -e " ${CYAN}tasks${RESET} View mirrored Claude Code tasks"
19
+ echo -e " ${CYAN}search${RESET} Search past sessions, memories, and code"
24
20
  echo -e " ${CYAN}overview${RESET} View or set project overview"
25
- echo -e " ${CYAN}memories${RESET} Browse and search Claude Code memories, plans, and tasks"
26
- echo -e " ${CYAN}scan${RESET} Analyze a project and generate an overview"
27
- echo -e " ${CYAN}index${RESET} Index source files for code-level search"
21
+ echo -e " ${CYAN}scan${RESET} Analyze codebase structure"
22
+ echo -e " ${CYAN}index${RESET} Index source files for FTS5 code search"
23
+ echo -e " ${CYAN}memories${RESET} View/sync mirrored Claude Code memories"
24
+ echo -e " ${CYAN}tasks${RESET} View mirrored Claude Code tasks"
25
+ echo -e " ${CYAN}refresh${RESET} Full project sync: scan (if needed) + index + memories"
28
26
  echo -e " ${CYAN}prune${RESET} Remove old observations and orphaned chunks"
29
- echo -e " ${CYAN}install${RESET} Set up hooks, database, and skills"
27
+ echo -e " ${CYAN}install${RESET} First-time setup: hooks, database, skills"
28
+ echo -e " ${CYAN}update${RESET} Re-deploy hooks and run migrations"
30
29
  echo -e " ${CYAN}uninstall${RESET} Remove hooks and optionally delete data"
31
- echo -e " ${CYAN}update${RESET} Re-deploy hooks and run new migrations"
32
- echo -e " ${CYAN}help${RESET} Show this help message"
33
- echo -e " ${CYAN}version${RESET} Show version number"
34
30
  echo ""
35
31
  echo -e " ${BOLD}Examples:${RESET}"
36
- echo -e " ${DIM}\$${RESET} eagle-mem search \"auth bug\" ${DIM}# Search memory${RESET}"
37
- echo -e " ${DIM}\$${RESET} eagle-mem search --timeline ${DIM}# Recent sessions${RESET}"
38
- echo -e " ${DIM}\$${RESET} eagle-mem tasks ${DIM}# View pending tasks${RESET}"
39
- echo -e " ${DIM}\$${RESET} eagle-mem tasks search \"X\" ${DIM}# Search task history${RESET}"
40
- echo -e " ${DIM}\$${RESET} eagle-mem overview ${DIM}# View overview${RESET}"
41
- echo -e " ${DIM}\$${RESET} eagle-mem scan . ${DIM}# Scan current project${RESET}"
42
- echo -e " ${DIM}\$${RESET} eagle-mem index . ${DIM}# Index source files${RESET}"
43
- echo -e " ${DIM}\$${RESET} eagle-mem memories ${DIM}# List mirrored memories${RESET}"
44
- echo -e " ${DIM}\$${RESET} eagle-mem memories sync ${DIM}# Backfill memories + plans + tasks${RESET}"
45
- echo -e " ${DIM}\$${RESET} eagle-mem memories plans ${DIM}# List captured plans${RESET}"
46
- echo -e " ${DIM}\$${RESET} eagle-mem memories tasks ${DIM}# List captured tasks${RESET}"
47
- echo -e " ${DIM}\$${RESET} eagle-mem prune ${DIM}# Clean old data${RESET}"
48
- echo -e " ${DIM}\$${RESET} eagle-mem install ${DIM}# First-time setup${RESET}"
49
- echo ""
50
- echo -e " ${BOLD}What it does:${RESET}"
51
- echo -e " ${DOT} Saves session summaries to a shared SQLite database"
52
- echo -e " ${DOT} Injects relevant memory at session start"
53
- echo -e " ${DOT} Searches past sessions when you ask related questions"
54
- echo -e " ${DOT} Tracks file operations across sessions"
55
- echo -e " ${DOT} Mirrors Claude Code memories, plans, and tasks into FTS5-searchable storage"
56
- echo -e " ${DOT} Uses Claude Code's native task system (TaskCreate/TaskUpdate) for multi-step work"
57
- echo ""
58
- echo -e " ${BOLD}Skills${RESET} ${DIM}(available inside Claude Code):${RESET}"
59
- echo -e " ${CYAN}/eagle-mem-search${RESET} Search past sessions and observations"
60
- echo -e " ${CYAN}/eagle-mem-tasks${RESET} Break work into Claude Code tasks with dependencies"
61
- echo -e " ${CYAN}/eagle-mem-overview${RESET} Generate a persistent project summary"
32
+ echo -e " ${DIM}\$${RESET} eagle-mem search \"auth bug\" ${DIM}# keyword search${RESET}"
33
+ echo -e " ${DIM}\$${RESET} eagle-mem search --timeline ${DIM}# recent sessions${RESET}"
34
+ echo -e " ${DIM}\$${RESET} eagle-mem refresh ${DIM}# full project sync${RESET}"
35
+ echo -e " ${DIM}\$${RESET} eagle-mem overview ${DIM}# view overview${RESET}"
36
+ echo -e " ${DIM}\$${RESET} eagle-mem prune --dry-run ${DIM}# preview cleanup${RESET}"
37
+ echo -e " ${DIM}\$${RESET} eagle-mem install ${DIM}# first-time setup${RESET}"
38
+ echo ""
39
+ echo -e " ${BOLD}Skills${RESET} ${DIM}(inside Claude Code sessions):${RESET}"
40
+ echo -e " ${CYAN}/eagle-mem-search${RESET} Search memory and past sessions"
41
+ echo -e " ${CYAN}/eagle-mem-overview${RESET} Build or update project overview"
42
+ echo -e " ${CYAN}/eagle-mem-scan${RESET} Analyze codebase structure"
62
43
  echo -e " ${CYAN}/eagle-mem-index${RESET} Index source files for code search"
63
- echo -e " ${CYAN}/eagle-mem-scan${RESET} Scan and analyze a project"
64
- echo -e " ${CYAN}/eagle-mem-memories${RESET} Browse Claude Code memories, plans, tasks"
65
- echo -e " ${CYAN}/eagle-mem-prune${RESET} Clean up old observations and chunks"
66
- echo ""
67
- echo -e " ${DIM}Skills use these CLI commands under the hood — no raw SQL.${RESET}"
44
+ echo -e " ${CYAN}/eagle-mem-memories${RESET} View/sync Claude Code memories"
45
+ echo -e " ${CYAN}/eagle-mem-tasks${RESET} TaskAware Compact Loop for multi-step work"
46
+ echo -e " ${CYAN}/eagle-mem-prune${RESET} Clean up stale data"
68
47
  echo ""
69
48
  echo -e " ${DIM}https://github.com/eagleisbatman/eagle-mem${RESET}"
70
49
  echo ""
@@ -88,7 +88,7 @@ overview_set() {
88
88
  exit 1
89
89
  fi
90
90
 
91
- eagle_upsert_overview "$project" "$content"
91
+ eagle_upsert_overview "$project" "$content" "manual"
92
92
 
93
93
  if [ "$json_output" = true ]; then
94
94
  jq -nc --arg project "$project" '{project: $project, updated: true}'
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env bash
2
+ # ═══════════════════════════════════════════════════════════
3
+ # Eagle Mem — Refresh
4
+ # Full project sync: scan (if needed) + index + memories sync
5
+ # One command to bring everything up to date
6
+ # ═══════════════════════════════════════════════════════════
7
+ set -euo pipefail
8
+
9
+ SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd)"
10
+ LIB_DIR="$SCRIPTS_DIR/../lib"
11
+
12
+ . "$SCRIPTS_DIR/style.sh"
13
+ . "$LIB_DIR/common.sh"
14
+ . "$LIB_DIR/db.sh"
15
+
16
+ eagle_ensure_db
17
+
18
+ TARGET_DIR="${1:-.}"
19
+ if [ ! -d "$TARGET_DIR" ]; then
20
+ eagle_err "Directory not found: $TARGET_DIR"
21
+ exit 1
22
+ fi
23
+ TARGET_DIR="$(cd "$TARGET_DIR" && pwd)"
24
+ PROJECT=$(eagle_project_from_cwd "$TARGET_DIR")
25
+
26
+ eagle_header "Refresh"
27
+ eagle_info "Syncing ${BOLD}$PROJECT${RESET} at $TARGET_DIR"
28
+ echo ""
29
+
30
+ failed=0
31
+ STEP_LOG=$(mktemp)
32
+ trap 'rm -f "$STEP_LOG"' EXIT
33
+
34
+ run_step() {
35
+ local label="$1"; shift
36
+ if "$@" > "$STEP_LOG" 2>&1; then
37
+ tail -5 "$STEP_LOG"
38
+ eagle_ok "$label complete"
39
+ else
40
+ cat "$STEP_LOG"
41
+ eagle_warn "$label had issues (non-fatal)"
42
+ failed=$((failed + 1))
43
+ fi
44
+ }
45
+
46
+ # ─── 1. Structural scan (scan.sh guards against overwriting manual overviews) ──
47
+ eagle_info "Step 1/4: Scanning codebase structure..."
48
+ run_step "Scan" bash "$SCRIPTS_DIR/scan.sh" "$TARGET_DIR"
49
+ echo ""
50
+
51
+ # ─── 2. Code indexing ────────────────────────────────────
52
+ eagle_info "Step 2/4: Indexing source files..."
53
+ run_step "Index" bash "$SCRIPTS_DIR/index.sh" "$TARGET_DIR"
54
+ echo ""
55
+
56
+ # ─── 3. Memory sync ─────────────────────────────────────
57
+ eagle_info "Step 3/4: Syncing Claude Code memories, plans, and tasks..."
58
+ run_step "Memory sync" bash "$SCRIPTS_DIR/memories.sh" sync
59
+ echo ""
60
+
61
+ # ─── 4. Stats ────────────────────────────────────────────
62
+ eagle_info "Step 4/4: Verifying..."
63
+
64
+ project_sql=$(eagle_sql_escape "$PROJECT")
65
+ sessions=$(eagle_db "SELECT COUNT(*) FROM sessions WHERE project = '$project_sql';")
66
+ summaries=$(eagle_db "SELECT COUNT(*) FROM summaries WHERE project = '$project_sql';")
67
+ chunks=$(eagle_db "SELECT COUNT(*) FROM code_chunks WHERE project = '$project_sql';")
68
+ memories=$(eagle_db "SELECT COUNT(*) FROM claude_memories WHERE project = '$project_sql';")
69
+ tasks=$(eagle_db "SELECT COUNT(*) FROM claude_tasks WHERE project = '$project_sql';")
70
+
71
+ echo ""
72
+ eagle_kv "Sessions:" "${sessions:-0}"
73
+ eagle_kv "Summaries:" "${summaries:-0}"
74
+ eagle_kv "Code chunks:" "${chunks:-0}"
75
+ eagle_kv "Memories:" "${memories:-0}"
76
+ eagle_kv "Tasks:" "${tasks:-0}"
77
+
78
+ if [ "$failed" -eq 0 ]; then
79
+ eagle_footer "Refresh complete. Run /eagle-mem-overview inside Claude Code for a rich project briefing."
80
+ else
81
+ eagle_footer "Refresh complete with $failed warning(s)."
82
+ fi
package/scripts/scan.sh CHANGED
@@ -15,7 +15,17 @@ LIB_DIR="$SCRIPTS_DIR/../lib"
15
15
 
16
16
  eagle_ensure_db
17
17
 
18
- TARGET_DIR="${1:-.}"
18
+ # ─── Parse arguments ─────────────────────────────────────
19
+ force=false
20
+ args=()
21
+ for arg in "$@"; do
22
+ case "$arg" in
23
+ --force|-f) force=true ;;
24
+ *) args+=("$arg") ;;
25
+ esac
26
+ done
27
+
28
+ TARGET_DIR="${args[0]:-.}"
19
29
  TARGET_DIR="$(cd "$TARGET_DIR" && pwd)"
20
30
  PROJECT=$(eagle_project_from_cwd "$TARGET_DIR")
21
31
 
@@ -23,6 +33,17 @@ eagle_header "Scan"
23
33
  eagle_info "Scanning ${BOLD}$PROJECT${RESET} at $TARGET_DIR"
24
34
  echo ""
25
35
 
36
+ # ─── Guard: skip if manual overview exists ───────────────
37
+ # Scan produces a structural one-liner. If a manual (rich) overview
38
+ # exists, skip unless --force is passed.
39
+ existing_source=$(eagle_get_overview_source "$PROJECT")
40
+
41
+ if [ "$force" = false ] && [ "$existing_source" = "manual" ]; then
42
+ eagle_ok "Manual overview exists — skipping scan"
43
+ eagle_dim "Run 'eagle-mem scan --force' to overwrite"
44
+ exit 0
45
+ fi
46
+
26
47
  # ─── Collect files ─────────────────────────────────────────
27
48
 
28
49
  is_git=false
@@ -344,7 +365,7 @@ if [ -n "$configs" ]; then
344
365
  fi
345
366
 
346
367
  # Store in database
347
- eagle_upsert_overview "$PROJECT" "$overview"
368
+ eagle_upsert_overview "$PROJECT" "$overview" "scan"
348
369
 
349
370
  eagle_ok "Overview saved for project '$PROJECT'"
350
371
  echo ""
package/scripts/update.sh CHANGED
@@ -77,6 +77,16 @@ fi
77
77
 
78
78
  if [ -d "$PACKAGE_DIR/skills" ]; then
79
79
  mkdir -p "$EAGLE_SKILLS_DIR"
80
+ # Remove stale symlinks for deleted skills
81
+ for existing in "$EAGLE_SKILLS_DIR"/eagle-mem-*/; do
82
+ local_path="${existing%/}"
83
+ [ ! -L "$local_path" ] && continue
84
+ skill_name=$(basename "$local_path")
85
+ if [ ! -d "$PACKAGE_DIR/skills/$skill_name" ]; then
86
+ rm "$local_path"
87
+ eagle_ok "Removed stale skill: $skill_name"
88
+ fi
89
+ done
80
90
  for skill_dir in "$PACKAGE_DIR"/skills/*/; do
81
91
  [ ! -d "$skill_dir" ] && continue
82
92
  skill_name=$(basename "$skill_dir")
@@ -1,49 +1,120 @@
1
1
  ---
2
2
  name: eagle-mem-index
3
3
  description: >
4
- Index source files into FTS5-searchable chunks for code-level search. Use when: 'eagle index',
5
- 'index this project', 'index codebase', 'eagle mem index', 'make code searchable',
6
- 'update code index'. Uses the eagle-mem CLI.
4
+ Index source files into FTS5-searchable chunks. Use when: 'eagle index', 'index this project',
5
+ 'make code searchable', 'reindex', 'update index', 'index after pull',
6
+ 'code search setup'. Uses the eagle-mem CLI.
7
7
  ---
8
8
 
9
9
  # Eagle Mem — Index
10
10
 
11
- Chunk and index source files into Eagle Mem's FTS5 search index. Enables code-level search across sessions.
11
+ ## Purpose
12
12
 
13
- ## What it does
13
+ **For the user:** Claude Code can find code they wrote weeks ago -- across sessions, without needing to remember which file it was in. Every prompt automatically surfaces relevant code chunks from the index, so past work stays accessible.
14
14
 
15
- - Walks the project directory for source files
16
- - Splits each file into chunks (default 80 lines)
17
- - Stores chunks in the `code_chunks` table with FTS5 indexing
18
- - Incremental: only re-indexes files modified since the last run (via mtime)
15
+ **For you (Claude Code):** The UserPromptSubmit hook searches `code_chunks` on every user prompt and injects matching file references into your context. You don't call a search command for this -- it happens automatically. But the index must exist and be current for it to work. That's what this skill manages.
19
16
 
20
- ## Commands
17
+ ## Judgment
21
18
 
22
- ### Index current project
19
+ **Index when:**
20
+ - First time setting up Eagle Mem on a project (`eagle-mem index .`)
21
+ - After a `git pull` or branch switch that brought in significant changes
22
+ - After a major refactor (renamed files, moved directories, new modules)
23
+ - The user says "index this project" or "make code searchable"
24
+ - You notice the UserPromptSubmit hook isn't surfacing relevant code -- the index may be stale
25
+
26
+ **Don't index when:**
27
+ - You just need to read a specific file -- use Read directly
28
+ - The project was recently indexed and no files changed (mtime dedup handles this, but don't waste time running it)
29
+ - You're in the middle of a task -- index at session boundaries, not mid-work
30
+
31
+ **Decision rule:** Index is a maintenance task, not a search tool. Run it to *prepare* the database, then rely on the automatic hook to *use* it. If the hook isn't surfacing what you expect, the index is stale -- re-run.
32
+
33
+ ## Steps
34
+
35
+ ### 1. Run the indexer
23
36
 
24
37
  ```bash
25
38
  eagle-mem index .
26
39
  ```
40
+ Indexes the current directory. The script:
41
+ - Collects source files (respects `.gitignore`, skips binaries/lockfiles)
42
+ - Filters to known source extensions (sh, js, ts, py, go, rs, java, etc.)
43
+ - Skips files over 1MB
44
+ - Compares mtime against stored mtime -- only re-indexes changed files
45
+ - Chunks each file into segments (default 80 lines) and inserts into `code_chunks` with FTS5
46
+
47
+ The mtime check makes re-running cheap. On a project with 200 files where 5 changed, it processes only those 5.
27
48
 
28
- ### Index a specific directory
49
+ ### 2. Understand chunk size
29
50
 
51
+ Default: 80 lines per chunk. Override with:
30
52
  ```bash
31
- eagle-mem index /path/to/project
53
+ EAGLE_MEM_CHUNK_SIZE=40 eagle-mem index .
32
54
  ```
33
55
 
34
- ## When to use
56
+ **Smaller chunks (30-50):** More precise search matches. Better for codebases with many small, distinct functions. Produces more chunks -- larger DB.
57
+
58
+ **Larger chunks (100-150):** More context per match. Better for files with long, cohesive blocks. Fewer chunks -- smaller DB.
59
+
60
+ **When to change:** If the hook is surfacing irrelevant matches (chunks too big, mixing unrelated code), shrink. If matches lack context (cutting functions in half), grow. The default of 80 works well for most projects.
61
+
62
+ ### 3. Know what gets indexed
63
+
64
+ The indexer processes files matching these extensions:
65
+ `sh bash zsh js jsx mjs cjs ts tsx mts py rb go rs java kt kts swift c h cpp cc cxx hpp cs php sql html htm css scss vue svelte dart ex exs zig lua r scala yaml yml toml json md`
66
+
67
+ Silently skipped: images, binaries, lockfiles (`package-lock.json` etc. are over 1MB), `.git/` contents, anything in `.gitignore`.
68
+
69
+ ### 4. Understand how indexed code reaches the user
70
+
71
+ The flow is:
72
+ 1. You run `eagle-mem index .` -- code is chunked and stored in `code_chunks` table
73
+ 2. User submits a prompt in any future session
74
+ 3. UserPromptSubmit hook extracts keywords from the prompt
75
+ 4. Hook searches `code_chunks` FTS5 index for matches
76
+ 5. Matching file paths + line ranges are injected into your context as "EAGLE MEM — Relevant Code"
77
+
78
+ There is no manual "search code" CLI command. The index feeds the hook, and the hook feeds you. Your job is to keep the index current.
79
+
80
+ ### 5. Verify the index
81
+
82
+ After indexing, confirm it worked:
83
+ ```bash
84
+ eagle-mem search --stats
85
+ ```
86
+ Check the "Code chunks" count. For a typical project:
87
+ - 50-file project ~ 200-500 chunks
88
+ - 200-file project ~ 800-2000 chunks
89
+ - 0 chunks after indexing = something went wrong (check file extensions, directory path)
90
+
91
+ Also verify the hook is using it: on the next user prompt with 3+ words, you should see "EAGLE MEM — Relevant Code" injected if any chunks match.
92
+
93
+ ### 6. When indexing gets stale
94
+
95
+ The index reflects the state of files *when you last ran it*. It goes stale when:
96
+ - `git pull` brings in changes from others
97
+ - `git checkout` switches branches (different file contents, possibly different files)
98
+ - A major refactor renames or moves files (old paths stay in the index, new paths are missing)
99
+ - Dependencies are updated and source files regenerate
100
+
101
+ **After any of these, re-run `eagle-mem index .`** The mtime check ensures only changed files are re-processed. Old chunks for unchanged files are kept. Chunks for changed files are atomically replaced (DELETE + INSERT in a transaction).
35
102
 
36
- - After initial project setup to make code searchable
37
- - After pulling significant changes
38
- - When `/eagle-mem-search` isn't finding code you know exists
103
+ ## What makes a good indexing practice
39
104
 
40
- ## How it integrates
105
+ **Good:**
106
+ > Indexed the project after pulling the team's changes from main. Stats show 1,247 chunks across 189 files. The UserPromptSubmit hook should now surface the new API routes the team added.
41
107
 
42
- Once indexed, the UserPromptSubmit hook can surface relevant code chunks when you ask questions. The `/eagle-mem-search` skill also searches indexed code.
108
+ **Bad:**
109
+ > Indexed once when Eagle Mem was installed and never again. The hook keeps surfacing stale code from deleted files, and misses the 30 new files added over the past month.
43
110
 
44
- ## Notes
111
+ ## Reference
45
112
 
46
- - Respects .gitignore only indexes tracked/untracked source files
47
- - Skips binary files and files over 1MB
48
- - Chunk size is configurable via `EAGLE_MEM_CHUNK_SIZE` env var (default: 80 lines)
49
- - Re-running is safe unchanged files are skipped automatically
113
+ | Command / Flag | What it does |
114
+ |---|---|
115
+ | `eagle-mem index .` | Index current directory (incremental via mtime) |
116
+ | `eagle-mem index /path/to/dir` | Index a specific directory |
117
+ | `EAGLE_MEM_CHUNK_SIZE=N` | Override chunk size (default: 80 lines) |
118
+ | `eagle-mem search --stats` | Verify chunk count after indexing |
119
+ | Max file size | 1MB (larger files silently skipped) |
120
+ | Dedup | mtime-based -- re-running is cheap and safe |
@@ -2,74 +2,145 @@
2
2
  name: eagle-mem-memories
3
3
  description: >
4
4
  View and sync Claude Code auto-memories, plans, and tasks mirrored in Eagle Mem. Use when:
5
- 'eagle memories', 'show memories', 'list memories', 'sync memories', 'eagle mem memories',
6
- 'what does claude remember', 'show plans', 'show tasks'. Uses the eagle-mem CLI.
5
+ 'eagle memories', 'show memories', 'sync memories', 'what does claude remember',
6
+ 'show plans', 'show tasks', 'mirror memories', 'onboard project',
7
+ 'what did past sessions learn'. Uses the eagle-mem CLI.
7
8
  ---
8
9
 
9
10
  # Eagle Mem — Memories
10
11
 
11
- View, search, and sync Claude Code's auto-memories, plans, and tasks that are mirrored into Eagle Mem's SQLite + FTS5 database.
12
+ ## Purpose
12
13
 
13
- ## Commands
14
+ **For the user:** Claude Code remembers across sessions. Decisions, preferences, project context, and architectural plans survive session boundaries. The user never has to re-explain "we chose Postgres because..." or "don't use semicolons in this project."
14
15
 
15
- ### List mirrored memories
16
+ **For you (Claude Code):** Access to what past Claude sessions learned about this project. Memories tell you *why* decisions were made. Plans tell you *what's coming*. Tasks tell you *what's in flight*. Together they're the knowledge bridge that makes you effective from message one.
16
17
 
17
- ```bash
18
- eagle-mem memories
19
- eagle-mem memories list
20
- ```
18
+ ## Judgment
21
19
 
22
- ### Search memories
20
+ **Check memories when:**
21
+ - The user references a past decision ("remember when we decided to...", "what's our convention for...")
22
+ - You're about to make an architectural or style choice -- memories may record the user's preference
23
+ - You need project context that isn't in CLAUDE.md or README (relationships between services, deployment quirks, naming conventions)
24
+ - The user asks "what does Claude remember about X?"
23
25
 
24
- ```bash
25
- eagle-mem memories search "auth middleware"
26
- ```
26
+ **Check plans when:**
27
+ - The user asks about upcoming work or roadmap
28
+ - You need to understand a multi-session effort that's in progress
29
+ - The user says "continue where we left off"
30
+
31
+ **Check tasks when:**
32
+ - The user asks about in-flight work across sessions
33
+ - You need to understand what sub-tasks are pending/completed in a larger effort
34
+
35
+ **Don't check memories when:**
36
+ - The answer is in the current code -- read the file instead
37
+ - The question is about *what the code does now* (memories record past decisions, code records current state)
38
+ - You already have the context from SessionStart injection
27
39
 
28
- ### Show a specific memory
40
+ **Decision rule:** Memories = *why we decided*. Code = *what it does now*. If the question is about rationale, conventions, or preferences, check memories first. If the question is about current behavior, read code first.
29
41
 
42
+ ## Steps
43
+
44
+ ### 1. Know the three data types
45
+
46
+ **Memories** -- Claude Code's auto-memory files (`~/.claude/projects/*/memory/*.md`). These contain user preferences, project conventions, and feedback. Each has a name, type (user/feedback/project/reference), and description.
30
47
  ```bash
31
- eagle-mem memories show <name>
48
+ eagle-mem memories list # all memories
49
+ eagle-mem memories search "typescript" # FTS5 search
50
+ eagle-mem memories show <file_path> # full content
32
51
  ```
33
52
 
34
- ### List mirrored plans
53
+ **Plans** -- Claude Code's plan files (`~/.claude/plans/*.md`). Multi-step strategies for complex work. Each has a title, optional project tag, and markdown content.
54
+ ```bash
55
+ eagle-mem memories plans # all plans
56
+ eagle-mem memories plans search "migration"
57
+ eagle-mem memories plans show <file_path>
58
+ ```
35
59
 
60
+ **Tasks** -- Claude Code's task JSON (`~/.claude/tasks/<session>/*.json`). Individual units of work with status tracking (pending/in_progress/completed).
36
61
  ```bash
37
- eagle-mem memories plans
62
+ eagle-mem memories tasks # all tasks
63
+ eagle-mem memories tasks search "refactor"
64
+ eagle-mem memories tasks show <file_path>
38
65
  ```
39
66
 
40
- ### List mirrored tasks
67
+ ### 2. Understand how data flows in
68
+
69
+ Two paths feed the mirror:
41
70
 
71
+ **Real-time (PostToolUse hook).** Every time Claude Code writes or edits a memory file, plan file, or creates/updates a task, the hook intercepts it and mirrors it into Eagle Mem's SQLite with FTS5 indexing. This happens automatically -- no user action needed.
72
+
73
+ **Backfill (sync command).** For memories, plans, and tasks that existed before Eagle Mem was installed, or that were written outside a Claude Code session:
42
74
  ```bash
43
- eagle-mem memories tasks
75
+ eagle-mem memories sync
44
76
  ```
77
+ This scans all three directories, hashes each file, skips unchanged ones, and mirrors anything new or modified. It also backfills project names from Claude Code transcripts. Safe to run repeatedly -- content-hash dedup prevents double-insertion.
45
78
 
46
- ### Sync all from Claude Code
79
+ ### 3. Search effectively
47
80
 
48
- Backfill all memories, plans, and tasks from Claude Code's filesystem into Eagle Mem:
81
+ The search hits FTS5 indexes across all three types independently. Start with the most likely container:
49
82
 
83
+ - User asked about a preference or convention? Search **memories** first.
84
+ - User asked about a multi-step plan? Search **plans** first.
85
+ - User asked about what's been done vs. what's left? Search **tasks** first.
86
+ - Not sure? Search all three -- they're fast:
50
87
  ```bash
51
- eagle-mem memories sync
88
+ eagle-mem memories search "auth"
89
+ eagle-mem memories plans search "auth"
90
+ eagle-mem memories tasks search "auth"
52
91
  ```
53
92
 
54
- ## Options
93
+ ### 4. Scope by project when needed
55
94
 
56
- | Flag | Description |
57
- |------|-------------|
58
- | `-p, --project <name>` | Target a specific project (default: current directory) |
59
- | `-n, --limit <N>` | Max results (default: 20) |
60
- | `-j, --json` | Output as JSON |
95
+ Unlike `eagle-mem search` (which auto-scopes to the current project), memories commands are **cross-project by default** -- list and search show everything across all projects. This makes sense because memories, plans, and preferences often apply broadly.
61
96
 
62
- ## How it works
97
+ To narrow to a specific project:
98
+ ```bash
99
+ eagle-mem memories search "testing" -p eagle-mem
100
+ eagle-mem memories plans -p my-api
101
+ ```
63
102
 
64
- Eagle Mem automatically mirrors Claude Code writes via the PostToolUse hook:
65
- - **Memories** from `~/.claude/projects/*/memory/*.md`
66
- - **Plans** from `~/.claude/plans/*.md`
67
- - **Tasks** from Claude Code's TaskCreate/TaskUpdate calls
103
+ This asymmetry is intentional but easy to forget. If you're getting too many irrelevant results from other projects, add `-p`.
68
104
 
69
- The `sync` command does a full backfill for anything the hooks missed.
105
+ ### 5. Onboard an existing project
70
106
 
71
- ## When to use
107
+ When Eagle Mem is installed on a project that already has Claude Code history:
108
+ ```bash
109
+ eagle-mem memories sync
110
+ ```
111
+ This is the first thing to run. It pulls in all existing memories, plans, and tasks. The output shows counts: "12 synced, 3 unchanged" -- verify the numbers make sense given the project's history.
112
+
113
+ ### 6. Verify the mirror is working
72
114
 
73
- - To check what Claude Code has auto-saved about this project
74
- - To search across memories from multiple projects
75
- - After installing Eagle Mem on an existing project (run `sync` to backfill)
115
+ After sync or after expecting the hook to fire:
116
+ ```bash
117
+ eagle-mem memories list # should show recent memories
118
+ eagle-mem search --stats # check counts are non-zero
119
+ ```
120
+ If memories list is empty after sync, check that `~/.claude/projects/` contains memory files for this project. If the hook isn't capturing new writes, check that PostToolUse hook is registered in settings.json.
121
+
122
+ ## What makes a good memory lookup
123
+
124
+ **Good:**
125
+ > I checked Eagle Mem's memories before choosing an error handling pattern. Memory "project_error-conventions" [project type] records that you prefer Result types over try/catch in this codebase, and that error messages should include the operation name and original error. Following that convention here.
126
+
127
+ **Bad:**
128
+ > I'll use try/catch for error handling here.
129
+ > *(Didn't check -- missed a recorded preference that would have changed the approach.)*
130
+
131
+ ## Reference
132
+
133
+ | Command | What it does |
134
+ |---|---|
135
+ | `memories list` | All mirrored memories (name, type, description, date) |
136
+ | `memories search "query"` | FTS5 search across memory content |
137
+ | `memories show <path>` | Full content of one memory |
138
+ | `memories plans` | All captured plans |
139
+ | `memories plans search "query"` | FTS5 search across plan content |
140
+ | `memories plans show <path>` | Full content of one plan |
141
+ | `memories tasks` | All captured tasks |
142
+ | `memories tasks search "query"` | FTS5 search across task content |
143
+ | `memories tasks show <path>` | Full content of one task |
144
+ | `memories sync` | Backfill all memories + plans + tasks from disk |
145
+ | `-p <name>` / `--project` | Filter by project name |
146
+ | `-l N` / `--limit` | Max results (default: 20) |