Your coding agent forgets everything. ClawSync remembers.
ClawSync analyzes your Claude Code session files, extracts reusable patterns (error recoveries, dead ends, architecture decisions), deduplicates them, and writes a managed section to your CLAUDE.md — so every future session starts with the hard-won knowledge from your past work.
- Parse — reads Claude Code
.jsonlsession files from~/.claude/projects/ - Extract — heuristically identifies:
- 🔴 Error-recovery patterns: where a tool call failed and the agent recovered
- 🔴 Dead ends: approaches that were abandoned mid-session
- 🟡 Architecture decisions: reasoning captured in assistant messages
- Dedup — exact hash + similarity matching eliminates near-duplicates; tracks frequency across sessions
- Optimize — writes a sentinel-bounded section to
CLAUDE.md, preserving everything outside the sentinels
npm install -g clawsyncOr run without installing:
npx clawsync syncBuild from source:
git clone https://github.com/serflek/clawsync
cd clawsync
npm install
npm run build
node dist/index.js --helpRun the full pipeline: discover sessions → extract patterns → update CLAUDE.md.
clawsync sync
clawsync sync --source ~/.claude/projects/ --target ./CLAUDE.md
clawsync sync --dry-run # Preview without writing
clawsync sync --config ./clawsync.yamlOptions:
| Flag | Description | Default |
|---|---|---|
--source <path> |
Root directory containing .jsonl session files |
~/.claude/projects/ |
--target <path> |
CLAUDE.md file to update |
./CLAUDE.md |
--config <path> |
Config file path | ./clawsync.yaml |
--dry-run |
Print what would be written, don't write | false |
Parse a single .jsonl session file and print what ClawSync sees.
clawsync parse ~/.claude/projects/my-project/abc123.jsonl
clawsync parse --json abc123.jsonl # JSON outputShow the current sync state: processed sessions count, learning count, last run time.
clawsync statusClawSync looks for config in this order:
- Path passed via
--config ./clawsync.yaml./config/default.yaml~/.config/clawsync/config.yaml
If no config is found, defaults are used.
clawsync.yaml example:
mode: personal # personal | team | fleet
source:
type: rsync # rsync | watch | git
path: ~/.claude/projects/
target:
claude_md: ./CLAUDE.md
sync:
interval_minutes: 5
max_sessions_per_run: 50
extraction:
min_confidence: 0.6 # Only keep patterns above this threshold
max_learnings: 100 # Cap stored learnings (prunes oldest/lowest-confidence)
prune_after_days: 30 # Auto-remove stale one-off learnings older than N daysClawSync reads Claude Code .jsonl files line by line. Each line is a structured event:
type: "user"/type: "assistant"— conversation turnstype: "file-history-snapshot"/type: "queue-operation"— metadata (skipped)
The ClaudeCodeProvider extracts:
- Tool calls from
tool_useblocks in assistant messages - Tool results (success/failure) from
tool_resultblocks in user messages - Text content from
textandthinkingblocks
All heuristic, zero LLM calls:
- Error recoveries: looks for failed tool results (non-trivial errors), then scans forward up to 10 turns for a successful call on the same tool/file
- Dead ends: sliding 5-turn window looking for signal density (1 strong signal OR 2+ weak signals)
- Decisions: scans assistant text for decision signal phrases, extracts surrounding sentences
Two-pass:
- Exact hash — SHA-256 of normalized
summary + detail(first 32 chars). Exact matches bump frequency. - Similarity — Levenshtein similarity ≥ 0.7 on same-type learnings. Near-duplicates are merged, keeping the more recent version.
The managed section is bounded by sentinel comments:
<!-- clawsync:start -->
## ClawSync Session Learnings
...
<!-- clawsync:end -->ClawSync never touches content outside the sentinels. If you manually edit inside the sentinels, ClawSync detects the hash mismatch and skips the write until you delete the sentinels.
Writes are atomic: tmp → backup → rename.
Business Source License 1.1 (BSL 1.1)
ClawSync is source-available. You may use it freely for personal and internal organizational use. You may not offer it as a hosted/managed service or incorporate it as a primary component in a commercial product sold to third parties.
See LICENSE for full terms.
For commercial licensing: autosoul@serflek.com
npm run dev # Run with tsx (no build step)
npm test # Run tests with vitest
npm run lint # TypeScript type check
npm run build # Compile to dist/Tests live in tests/. Fixtures are in tests/fixtures/.