Files
daymade ccc10f3417 docs: update docs for directory structure preservation (v1.0.2)
Update SKILL.md and workflow_examples.md to reflect the new behavior
of recover_content.py which now preserves original directory structure:

- SKILL.md: Add 'preserving the original directory structure' note
- SKILL.md: Update verification examples to use find command and
  show subdirectory paths (e.g., ./recovered_content/src/components/)
- workflow_examples.md: Update diff example to account for nested paths

Version bump: 1.0.1 → 1.0.2

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 13:47:47 +08:00

2.7 KiB

Workflow Examples

Detailed workflow examples for common session history recovery scenarios.

Recover Files Deleted in Cleanup

Scenario: Files were deleted during code review, need to recover specific components.

# 1. Find sessions mentioning the deleted files
python3 scripts/analyze_sessions.py search /path/to/project \
    DeletedComponent ModelScreen RemovedFeature

# 2. Recover content from most relevant session
python3 scripts/recover_content.py ~/.claude/projects/.../session-id.jsonl \
    -k DeletedComponent ModelScreen \
    -o ./recovered/

# 3. Review recovered files
ls -lh ./recovered/

Track File Evolution Across Sessions

Scenario: Understand how a file changed over multiple sessions.

# 1. Find sessions that modified the file
python3 scripts/analyze_sessions.py search /path/to/project \
    "componentName.jsx"

# 2. Analyze each session's file operations
for session in session1.jsonl session2.jsonl session3.jsonl; do
    python3 scripts/analyze_sessions.py stats $session --show-files | \
        grep "componentName.jsx"
done

# 3. Recover all versions
python3 scripts/recover_content.py session1.jsonl -k componentName -o ./v1/
python3 scripts/recover_content.py session2.jsonl -k componentName -o ./v2/
python3 scripts/recover_content.py session3.jsonl -k componentName -o ./v3/

# 4. Compare versions (files retain original directory structure)
# Use find to locate the file in subdirectories, or reference the recovery_report.txt
find ./v1/ -name "componentName.jsx" -exec diff {} ./v2/{} \;

Find Session with Specific Implementation

Scenario: Remember implementing a feature but can't find which session.

# Search for distinctive keywords from that implementation
python3 scripts/analyze_sessions.py search /path/to/project \
    "useModelStatus" "downloadProgress" "ModelScope"

# Review top match
python3 scripts/analyze_sessions.py stats <top-result-session.jsonl>

Batch Recovery Across Multiple Sessions

Scenario: Recover files containing a keyword from all matching sessions.

# Find relevant sessions
sessions=$(python3 scripts/analyze_sessions.py search /path/to/project \
    keyword --limit 999 | grep "Path:" | awk '{print $2}')

# Recover from each session
for session in $sessions; do
    output_dir="./recovery_$(basename $session .jsonl)"
    python3 scripts/recover_content.py "$session" -k keyword -o "$output_dir"
done

Custom Extraction from Raw JSONL

For extraction needs not covered by bundled scripts:

import json

with open('session.jsonl', 'r') as f:
    for line in f:
        data = json.loads(line)
        # Custom extraction logic
        # See references/session_file_format.md for structure