원클릭으로
smart-fork
Smart Forking - Find and fork from relevant historical sessions using parallel memory search across vault, handoffs, and ledgers
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Smart Forking - Find and fork from relevant historical sessions using parallel memory search across vault, handoffs, and ledgers
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Full orchestration workflow with swarm mode: evaluate -> clarify -> classify -> persist -> plan mode -> spawn teammates -> execute -> validate -> retrospective. Use when: (1) implementing features, (2) complex refactoring, (3) multi-file changes, (4) tasks requiring coordination. Triggers: /orchestrator, /orch, 'orchestrate', 'full workflow', 'implement feature'.
Comprehensive research skill using Zai MCP web search and native Claude Code tools
Apply adversarial opposite-analysis to plans, specs, architecture, code changes, and claims. Use when the user asks for adversarial review, opposing analysis, contrarian review, red-team reasoning, or Z.ai and MiniMax cross-checks through the Ralph MCP router.
Test case mutation and variation generator for adversarial testing
Patterns for using Context7 MCP for library documentation (v2.25)
Codebase defense analysis system for security profiling
| name | smart-fork |
| description | Smart Forking - Find and fork from relevant historical sessions using parallel memory search across vault, handoffs, and ledgers |
| author | Multi-Agent Ralph |
| version | 2.47.2 |
| model | sonnet |
| context | fork |
| allowed-tools | ["Bash","Read","Write","Task"] |
| hooks | {"PostToolUse":[{"event":"Task","script":"~/.claude/hooks/smart-memory-search.sh"}]} |
Based on @PerceptualPeak's Smart Forking concept:
~/.claude/settings.json or CLI/env varsANTHROPIC_DEFAULT_*_MODEL env vars"Why not utilize the knowledge gained from your hundreds/thousands of other Claude code sessions? Don't let that valuable context go to waste!!"
# Find relevant sessions to fork from
/smart-fork "Implement OAuth authentication"
# Show fork suggestions for current task
/smart-fork --suggest
# Generate fork command for specific session
/smart-fork --fork <session_id>
# Show memory statistics
/smart-fork --stats
When you invoke /smart-fork, we search across ALL memory sources in parallel:
┌──────────────────────────────────────────────────────────────┐
│ PARALLEL MEMORY SEARCH │
├──────────────────────────────────────────────────────────────┤
│ │
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
│ │ vault │ │ handoffs │ │ ledgers │ │
│ │ MCP │ │ scan │ │ scan │ │
│ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘ │
│ │ PARALLEL │ PARALLEL │ │
│ └───────────────┴───────────────┘ │
│ ↓ │
│ AGGREGATOR (top 5) │
│ ↓ │
│ .claude/memory-context.json │
└──────────────────────────────────────────────────────────────┘
Results are scored by:
Top 5 most relevant sessions are suggested with:
/smart-fork "task description"Search for relevant sessions based on task description.
Example:
/smart-fork "Implement JWT authentication with refresh tokens"
Output:
SMART FORK RESULTS v2.47
========================
Search: "Implement JWT authentication with refresh tokens"
TOP 5 RELEVANT SESSIONS:
------------------------
1. [HIGH] Session: abc123-def456 (2026-01-15)
Summary: Implemented OAuth2 with JWT, similar auth patterns
Fork: claude --continue abc123-def456
2. [HIGH] Session: xyz789-uvw012 (2026-01-10)
Summary: Token refresh implementation in Node.js
Fork: claude --continue xyz789-uvw012
3. [MEDIUM] Session: pqr345-stu678 (2026-01-05)
Summary: Authentication middleware setup
Fork: claude --continue pqr345-stu678
Memory sources searched: vault (5), handoffs (8), ledgers (2)
Total results: 15
/smart-fork --suggestShow fork suggestions based on current project context.
/smart-fork --fork <session_id>Generate fork command for a specific session.
/smart-fork --statsShow memory statistics across all sources.
The Smart Fork system integrates with the orchestrator at Step 0b:
Step 0: EVALUATE
├── 0a: 3-Dimension Classification (v2.46)
└── 0b: SMART MEMORY SEARCH (v2.47) ◄── NEW
│
├── Search vault for relevant observations
├── Search handoffs for recent context
└── Search ledgers for session continuity
│
▼
.claude/memory-context.json
│
├── past_successes: Implementation patterns that worked
├── past_errors: Mistakes to avoid
├── recommended_patterns: Best practices
└── fork_suggestions: Top 5 sessions to fork from
| Source | Content | Speed | Retention |
|---|---|---|---|
| vault MCP | Semantic observations | Fast | Permanent |
| handoffs | Session context snapshots | Fast | 30 days |
| ledgers | Continuity data | Fast | Permanent |
Past errors are surfaced to prevent the same issues.
Implementation patterns that worked before are recommended.
Fork from a relevant session instead of re-explaining everything.
Patterns from other projects inform current implementation.
Smart Fork is configured via ~/.ralph/config/smart-fork.json:
{
"version": "2.47",
"cache_duration_seconds": 1800,
"max_results_per_source": 10,
"top_k_suggestions": 5,
"search_recency_days": 30,
"parallel_timeout_seconds": 30
}
# Via ralph CLI
ralph fork-suggest "task description"
ralph memory-search "query"
ralph memory-stats
# Via skill
/smart-fork "task description"
.claude/memory-context.json| Path | Purpose |
|---|---|
~/.claude/hooks/smart-memory-search.sh | PreToolUse hook for parallel search |
.claude/memory-context.json | Aggregated memory results |
~/.ralph/config/smart-fork.json | Configuration |
~/.ralph/logs/smart-memory-search-*.log | Search logs |
Cause: None of the 3 memory sources (vault, handoffs, ledgers) are initialized.
Fix:
# Initialize handoffs
ralph handoff create
# Initialize ledgers
ralph ledger save
# Verify Obsidian vault directory
ls ~/Documents/Obsidian/MiVault/ 2>/dev/null && echo "vault OK"
Cause: Memory sources are too large or slow to search within timeout.
Fix:
~/.ralph/config/smart-fork.json
{"parallel_timeout_seconds": 60}
{"search_recency_days": 14}{"max_results_per_source": 5}Cause: Hook execution failed (but usually non-critical).
Fix:
tail -f ~/.ralph/logs/smart-memory-search-*.logchmod +x ~/.claude/hooks/smart-memory-search.shecho '{"tool_name":"Read"}' | bash ~/.claude/hooks/smart-memory-search.shCause: No matching sessions found for your keywords.
Fix:
ls ~/.ralph/handoffs/ls -la ~/.ralph/ledgers/Cause: Cache file still valid within 30-minute window.
Fix:
# Force fresh search by removing cache
rm .claude/memory-context.json
Edit ~/.ralph/config/smart-fork.json:
| Setting | Default | Impact |
|---|---|---|
cache_duration_seconds | 1800 | Lower = fresher results, more searches |
parallel_timeout_seconds | 30 | Higher = more complete results, slower startup |
max_results_per_source | 10 | Higher = more context, slower aggregation |
search_recency_days | 30 | Higher = deeper history, slower search |
top_k_suggestions | 5 | Higher = more options, more tokens |
Fast Startup (minimal latency):
{
"cache_duration_seconds": 3600,
"parallel_timeout_seconds": 10,
"max_results_per_source": 3,
"search_recency_days": 7
}
Comprehensive Search (maximum context):
{
"cache_duration_seconds": 900,
"parallel_timeout_seconds": 60,
"max_results_per_source": 20,
"search_recency_days": 90
}
Balanced (recommended):
{
"cache_duration_seconds": 1800,
"parallel_timeout_seconds": 30,
"max_results_per_source": 10,
"search_recency_days": 30
}
| Configuration | Search Time | Results Quality |
|---|---|---|
| Fast | ~2s | Good (recent only) |
| Balanced | ~5s | Very Good |
| Comprehensive | ~15s | Excellent |
# Check last search duration
tail -1 ~/.ralph/logs/smart-memory-search-*.log | grep "completed in"
# Monitor memory source health
ralph memory-stats
# Profile individual sources
time grep -r "test query" ~/Documents/Obsidian/MiVault/ | head -5
The smart-memory-search hook includes these security hardening measures:
| Vulnerability | Fix | Details |
|---|---|---|
| SECURITY-001 | Command Injection | Keywords escaped before grep -E usage |
| SECURITY-002 | Path Traversal | Symlinks validated via realpath before reading |
| SECURITY-003 | Race Condition | Atomic temp file creation with restrictive permissions |
All security tests pass: pytest tests/test_v2_47_security.py -v