Repository navigation
Expand file tree
/
Copy pathexport_context.ps1
More file actions
50 lines (40 loc) · 1.7 KB
/
Copy pathexport_context.ps1
File metadata and controls
50 lines (40 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# export_context.ps1
# Exports all Claude memory files across all projects into a single context file
# for pasting into the Claude app.
$projectsDir = "$PSScriptRoot\projects"
$outputFile = "$PSScriptRoot\context_export.md"
$output = [System.Collections.Generic.List[string]]::new()
$output.Add("# Claude - Full Context Export")
$output.Add("Generated: $(Get-Date -Format 'yyyy-MM-dd HH:mm')")
$output.Add("")
$output.Add("This file contains all persistent memory from all Claude Code sessions.")
$output.Add("")
foreach ($projectDir in Get-ChildItem $projectsDir -Directory) {
$memoryDir = Join-Path $projectDir.FullName "memory"
if (-not (Test-Path $memoryDir)) { continue }
$memFiles = Get-ChildItem $memoryDir -Filter "*.md"
if ($memFiles.Count -eq 0) { continue }
$output.Add("---")
$output.Add("# Project: $($projectDir.Name)")
$output.Add("")
# MEMORY.md index first
$memoryIndex = Join-Path $memoryDir "MEMORY.md"
if (Test-Path $memoryIndex) {
$output.Add("## MEMORY.md (index)")
$output.Add("")
$output.Add((Get-Content $memoryIndex -Raw).TrimEnd())
$output.Add("")
}
# Then all other memory files
foreach ($file in $memFiles | Where-Object { $_.Name -ne "MEMORY.md" } | Sort-Object Name) {
$output.Add("## $($file.Name)")
$output.Add("")
$output.Add((Get-Content $file.FullName -Raw).TrimEnd())
$output.Add("")
}
}
$output | Out-File -FilePath $outputFile -Encoding UTF8
$sizeKB = [math]::Round((Get-Item $outputFile).Length / 1KB, 1)
Write-Host "Context exported to: $outputFile"
Write-Host "Size: $sizeKB KB"
Write-Host "You can now attach this file to a Claude app conversation for full context."