Skip to content

Instantly share code, notes, and snippets.

@Big-jpg
Created May 26, 2025 15:13
Show Gist options
  • Save Big-jpg/a9c41238544430448e03d0a707057a97 to your computer and use it in GitHub Desktop.
Save Big-jpg/a9c41238544430448e03d0a707057a97 to your computer and use it in GitHub Desktop.
Generate a complete LLM-ready snapshot of any project directory — includes monolithic source dump + ASCII tree structure. Supports offline use via PowerShell and filters out irrelevant/vendor/build files across Node, Python, Go, Rust, .NET, and more.
$projectFolder = ""
if (-not $projectFolder -or -not (Test-Path $projectFolder -PathType Container)) {
do {
$projectFolder = Read-Host "Enter the full path to your project folder"
if (-not (Test-Path $projectFolder -PathType Container)) {
Write-Host "❌ '$projectFolder' is not a valid directory." -ForegroundColor Red
}
} until (Test-Path $projectFolder -PathType Container)
}
$depth = ($projectFolder -split '[\\/]').Where({ $_ -ne '' }).Count
if ($depth -lt 3) {
Write-Host "⚠️ WARNING: This directory is very high-level ($projectFolder)" -ForegroundColor Yellow
$continue = Read-Host "Are you sure you want to continue? (y/n)"
if ($continue -ne "y") {
Write-Host "🚫 Aborting for safety." -ForegroundColor Red
exit
}
}
$root = $projectFolder
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
$outputDir = Join-Path (Split-Path $root -Parent) "llm_snapshot_$timestamp"
$monoFile = Join-Path $outputDir "llm_inference_knowledge_$timestamp.txt"
$treeFile = Join-Path $outputDir "llm_directory_tree_$timestamp.txt"
# Expanded to cover Python, Go, Rust, Java, .NET, etc.
$excludedDirs = @(
# JS / Node
'node_modules', '.next', '.turbo', 'dist', 'build', 'out', 'public',
# Python
'__pycache__', '.venv', 'venv', '.mypy_cache', '.pytest_cache',
# Go
'bin', 'pkg',
# Rust
'target',
# Java / JVM
'target', 'build', '.gradle', '.idea',
# .NET
'bin', 'obj', '.vs',
# General
'.git', '.vscode', '.cache', '.vercel', '.terraform', '.idea', '.DS_Store', 'coverage', '.coverage'
)
$excludedExtensions = @(
# Images & binaries
'.png','.jpg','.jpeg','.gif','.webp','.ico',
'.exe','.dll','.zip','.7z','.tar','.gz','.rar',
# Fonts & media
'.ttf','.woff','.woff2','.eot','.mp4','.mov','.avi',
# Lockfiles & builds
'.lock','.log','.env','.local','.db','.sqlite','.pdb',
# Bytecode & compiled
'.pyc','.class','.o','.so','.a','.dylib','.dll',
# Docs & archives
'.pdf','.docx','.pptx','.xlsx'
)
$excludedFiles = @(
# JS/TS
'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml',
# Python
'Pipfile.lock', 'poetry.lock', 'requirements.txt', 'pyproject.toml',
# Rust
'Cargo.lock',
# Go
'go.sum',
# Java
'.classpath', '.project', '.settings',
# Misc system files
'.DS_Store', 'Thumbs.db', '.editorconfig', '.coverage', '.envrc', '.env.local'
)
if (Test-Path $outputDir) { Remove-Item -Recurse -Force $outputDir }
New-Item -ItemType Directory -Path $outputDir | Out-Null
New-Item -ItemType File -Path $monoFile -Force | Out-Null
New-Item -ItemType File -Path $treeFile -Force | Out-Null
Write-Host "`n📁 Scanning and compiling relevant files from: $root`n"
# Write monolithic file
Get-ChildItem -Path $root -Recurse -File -Force | ForEach-Object {
$filePath = $_.FullName
$relativePath = $filePath.Substring($root.Length).TrimStart('\')
if ($excludedDirs | Where-Object { $filePath -match "\\$_(\\|$)" }) { return }
if ($excludedExtensions -contains $_.Extension.ToLower()) { return }
if ($excludedFiles -contains $_.Name) { return }
if (Test-Path -LiteralPath $filePath) {
Add-Content -Path $monoFile -Value @(
"=================="
"Path: $relativePath"
"=================="
""
(Get-Content -LiteralPath $filePath | Out-String).Trim()
"`n"
)
}
}
# Generate ASCII tree
function Show-Tree {
param (
[string]$path,
[string]$indent = "",
[bool]$last = $true,
[ref]$outputLines
)
$name = Split-Path $path -Leaf
$marker = if ($last) { "└── " } else { "├── " }
$outputLines.Value += "$indent$marker$name"
$childIndent = if ($last) { "$indent " } else { "$indent│ " }
$items = Get-ChildItem -Path $path -Force | Where-Object {
$_.Name -ne '.' -and $_.Name -ne '..' -and
($excludedDirs -notcontains $_.Name)
} | Sort-Object {
if ($_.PSIsContainer) { "0$($_.Name)" } else { "1$($_.Name)" }
}
for ($i = 0; $i -lt $items.Count; $i++) {
$isLast = ($i -eq $items.Count - 1)
$item = $items[$i]
if ($item.PSIsContainer) {
Show-Tree -path $item.FullName -indent $childIndent -last $isLast -outputLines $outputLines
} else {
$outputLines.Value += "$childIndent├── $($item.Name)"
}
}
}
$treeOutput = @()
$treeOutput += (Split-Path $root -Leaf)
Show-Tree -path $root -outputLines ([ref]$treeOutput)
$treeOutput | Set-Content -Path $treeFile -Encoding UTF8
Write-Host "✅ Monolithic snapshot: $monoFile"
Write-Host "✅ Directory tree: $treeFile`n"
# Open the output directory in File Explorer
Start-Process "explorer.exe" $outputDir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment