Summary
The remember plugin's auto-save pipeline (PostToolUse hook -> save-session.sh -> Haiku summarization) silently fails on Windows. Four independent bugs combine to make the pipeline completely non-functional. The SessionStart hook and /remember skill work fine since they don't hit the same code paths.
Environment
- Windows 11 Pro
- Claude Code CLI (bash shell via Git Bash)
- Python 3.13
- Plugin version 0.1.0
Bugs
1. save-session.sh and run-consolidation.sh compute wrong PROJECT_DIR
Both scripts use:
PROJECT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
This resolves relative to the script's location in the plugin cache (~/.claude/plugins/cache/claude-plugins-official), not the actual project directory. The session-start-hook.sh correctly uses CLAUDE_PROJECT_DIR, but these two scripts don't.
Fix: Use CLAUDE_PROJECT_DIR (and pass it via env vars from the calling hooks since nohup background processes need it explicitly):
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-.}"
PIPELINE_DIR="${CLAUDE_PLUGIN_ROOT:-$(cd "$SCRIPT_DIR/.." && pwd)}"
2. Wrong session directory slug algorithm
All three shell scripts and extract.py use tr '/' '-' (or .replace("/", "-") in Python) to generate the project slug for finding JSONL session files. On Windows, paths use backslashes and colons (C:\Users\...), so this produces C:-Users-primemate-Solutions-_General.
Claude Code actually generates slugs like C--Users-primemate-Solutions--General -- it replaces all non-alphanumeric characters (not just /) with -.
Fix (shell):
SESSION_DIR="$HOME/.claude/projects/$(echo "$PROJECT" | sed 's/[^a-zA-Z0-9-]/-/g')"
Fix (Python, extract.py _session_dir):
import re
slug = re.sub(r'[^a-zA-Z0-9-]', '-', project_dir)
return os.path.expanduser("~/.claude/projects/" + slug)
3. PIPELINE_DIR points to wrong location
save-session.sh and run-consolidation.sh set:
PIPELINE_DIR="${PROJECT_DIR}/.claude/remember"
But the pipeline module is in the plugin cache, not in the project's .claude/remember/ directory. Should use CLAUDE_PLUGIN_ROOT.
4. Python open() calls lack UTF-8 encoding
Windows Python defaults to cp1252 encoding. The JSONL session files contain UTF-8 characters, causing UnicodeDecodeError in extract.py's count_lines(), extract_messages(), and get_last_save_line(). Multiple open() calls in shell.py and prompts.py have the same issue.
Fix: Either add encoding="utf-8" to all open() calls, or set export PYTHONUTF8=1 in the shell scripts before calling Python.
Affected files
scripts/save-session.sh (bugs 1, 3)
scripts/run-consolidation.sh (bugs 1, 3)
scripts/post-tool-hook.sh (bug 2, also needs to pass env vars to nohup)
scripts/session-start-hook.sh (bug 2, also needs to pass env vars to background calls)
pipeline/extract.py (bugs 2, 4)
pipeline/shell.py (bug 4)
pipeline/prompts.py (bug 4)
Result
After patching all four bugs locally, the full pipeline works: extraction, Haiku summarization, now.md creation, NDC compression to today-*.md, and position tracking via last-save.json.
Summary
The remember plugin's auto-save pipeline (PostToolUse hook -> save-session.sh -> Haiku summarization) silently fails on Windows. Four independent bugs combine to make the pipeline completely non-functional. The SessionStart hook and
/rememberskill work fine since they don't hit the same code paths.Environment
Bugs
1.
save-session.shandrun-consolidation.shcompute wrongPROJECT_DIRBoth scripts use:
PROJECT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"This resolves relative to the script's location in the plugin cache (
~/.claude/plugins/cache/claude-plugins-official), not the actual project directory. Thesession-start-hook.shcorrectly usesCLAUDE_PROJECT_DIR, but these two scripts don't.Fix: Use
CLAUDE_PROJECT_DIR(and pass it via env vars from the calling hooks sincenohupbackground processes need it explicitly):2. Wrong session directory slug algorithm
All three shell scripts and
extract.pyusetr '/' '-'(or.replace("/", "-")in Python) to generate the project slug for finding JSONL session files. On Windows, paths use backslashes and colons (C:\Users\...), so this producesC:-Users-primemate-Solutions-_General.Claude Code actually generates slugs like
C--Users-primemate-Solutions--General-- it replaces all non-alphanumeric characters (not just/) with-.Fix (shell):
SESSION_DIR="$HOME/.claude/projects/$(echo "$PROJECT" | sed 's/[^a-zA-Z0-9-]/-/g')"Fix (Python,
extract.py_session_dir):3.
PIPELINE_DIRpoints to wrong locationsave-session.shandrun-consolidation.shset:PIPELINE_DIR="${PROJECT_DIR}/.claude/remember"But the pipeline module is in the plugin cache, not in the project's
.claude/remember/directory. Should useCLAUDE_PLUGIN_ROOT.4. Python
open()calls lack UTF-8 encodingWindows Python defaults to
cp1252encoding. The JSONL session files contain UTF-8 characters, causingUnicodeDecodeErrorinextract.py'scount_lines(),extract_messages(), andget_last_save_line(). Multipleopen()calls inshell.pyandprompts.pyhave the same issue.Fix: Either add
encoding="utf-8"to allopen()calls, or setexport PYTHONUTF8=1in the shell scripts before calling Python.Affected files
scripts/save-session.sh(bugs 1, 3)scripts/run-consolidation.sh(bugs 1, 3)scripts/post-tool-hook.sh(bug 2, also needs to pass env vars to nohup)scripts/session-start-hook.sh(bug 2, also needs to pass env vars to background calls)pipeline/extract.py(bugs 2, 4)pipeline/shell.py(bug 4)pipeline/prompts.py(bug 4)Result
After patching all four bugs locally, the full pipeline works: extraction, Haiku summarization,
now.mdcreation, NDC compression totoday-*.md, and position tracking vialast-save.json.