Utilities for safely cleaning local GitHub Copilot and VS Code chat session storage from VS Code Stable and VS Code Insiders.
The repository also includes a Docker-based PowerShell lint environment so the Windows cleanup script can be checked from macOS or Linux without needing a Windows host for the purposes of CI.
| Platform | |
| Runtime | |
| Lint |
Are you also done with Github Copilot after they decided to go to usage based billing? If so, this repo is for you!
VS Code and extensions can keep per-workspace chat and extension state under workspaceStorage. Over time, Copilot Chat sessions and related local state can accumulate across many workspace hashes. This project provides cleanup scripts that target that local state without uninstalling VS Code extensions or deleting project files.
The cleanup scripts are designed to be conservative:
- Dry-run by default
- Support VS Code Stable and VS Code Insiders
- Remove known local Copilot and chat session storage
- Avoid removing installed extension packages
- Prefer reversible deletion behavior where practical
.
├── Dockerfile.psscriptanalyzer
├── PSScriptAnalyzerSettings.psd1
├── README.md
├── cleanup-vscode-copilot.ps1
├── cleanup-vscode-copilot.sh
├── cspell.json
├── makefile
└── psscriptanalyzer.ps1
The scripts target these VS Code local storage folders:
chatSessions
chatEditingSessions
*copilot*
For VS Code Stable:
macOS:
~/Library/Application Support/Code/User/workspaceStorage
Windows:
%APPDATA%\Code\User\workspaceStorage
For VS Code Insiders:
macOS:
~/Library/Application Support/Code - Insiders/User/workspaceStorage
Windows:
%APPDATA%\Code - Insiders\User\workspaceStorage
When the global cleanup option is enabled, the scripts also target Copilot-named folders in:
macOS:
~/Library/Application Support/Code/User/globalStorage
~/Library/Application Support/Code - Insiders/User/globalStorage
Windows:
%APPDATA%\Code\User\globalStorage
%APPDATA%\Code - Insiders\User\globalStorage
The scripts intentionally do not remove installed VS Code extensions.
These locations are left alone:
macOS:
~/.vscode/extensions
~/.vscode-insiders/extensions
Windows:
%USERPROFILE%\.vscode\extensions
%USERPROFILE%\.vscode-insiders\extensions
This means the cleanup resets local Copilot or chat state, but it does not uninstall GitHub Copilot, GitHub Copilot Chat, or any other VS Code extension.
Both cleanup scripts print the folders they would clean without moving or deleting anything.
The macOS script moves matching folders to:
~/.Trash/vscode-copilot-cleanup-<timestamp>/
The Windows script attempts to move matching folders to the Recycle Bin.
If the Recycle Bin operation fails, it falls back to a quarantine directory:
%LOCALAPPDATA%\vscode-copilot-cleanup\<timestamp>\
Close VS Code and VS Code Insiders before running cleanup.
Make the script executable:
chmod +x cleanup-vscode-copilot.shRun a dry run:
./cleanup-vscode-copilot.shClean workspace-level Copilot and chat session folders:
./cleanup-vscode-copilot.sh --deleteAlso clean Copilot folders from globalStorage:
./cleanup-vscode-copilot.sh --delete --include-globalShow help:
./cleanup-vscode-copilot.sh --helpClose VS Code and VS Code Insiders before running cleanup.
Run a dry run:
.\cleanup-vscode-copilot.ps1Clean workspace-level Copilot and chat session folders:
.\cleanup-vscode-copilot.ps1 -DeleteAlso clean Copilot folders from globalStorage:
.\cleanup-vscode-copilot.ps1 -Delete -IncludeGlobalIf script execution is blocked for the current PowerShell session:
Set-ExecutionPolicy -Scope Process BypassThen rerun the script.
Start with a dry run:
./cleanup-vscode-copilot.shor on Windows:
.\cleanup-vscode-copilot.ps1Review the matching folders.
Then run workspace cleanup:
./cleanup-vscode-copilot.sh --deleteor on Windows:
.\cleanup-vscode-copilot.ps1 -DeleteOpen VS Code and confirm old Copilot or chat sessions are gone.
Only use global cleanup if stale Copilot state still appears:
./cleanup-vscode-copilot.sh --delete --include-globalor on Windows:
.\cleanup-vscode-copilot.ps1 -Delete -IncludeGlobalVS Code can display chat sessions from more than one provider. Removing Copilot and VS Code chat session storage does not necessarily remove history owned by other tools.
For example, Claude Code keeps its own local history under:
~/.claude/
Common Claude Code history locations include:
~/.claude/projects/
~/.claude/history.jsonl
~/.claude/file-history/
Those paths are outside the scope of these scripts.
This repository includes a Docker-based PSScriptAnalyzer environment. It lets macOS or Linux users lint the PowerShell script without a Windows system.
The Docker image uses:
- .NET 10 SDK image with PowerShell and latest PSScriptAnalyzer from PSGallery
- Latest available
PSScriptAnalyzerfrom PSGallery at image build time - Repository-mounted lint execution
make buildOr directly:
docker build --pull \
-f Dockerfile.psscriptanalyzer \
-t pssa-lint:latest \
.make rebuildOr directly:
docker build --pull --no-cache \
-f Dockerfile.psscriptanalyzer \
-t pssa-lint:latest \
.make lintOr directly:
docker run --rm \
-v "$(pwd):/workspace" \
pssa-lint:latestdocker run --rm \
-v "$(pwd):/workspace" \
pssa-lint:latest \
/workspace/cleanup-vscode-copilot.ps1The analyzer settings are defined in:
PSScriptAnalyzerSettings.psd1
The current configuration keeps useful formatting and maintainability checks enabled while suppressing rules that are noisy for this repository's utility-script style.
Excluded rules:
PSAvoidUsingWriteHost
PSUseSingularNouns
PSUseApprovedVerbs
Rationale:
Write-Hostis acceptable here because these scripts are interactive cleanup utilities with human-facing dry-run and status output.- Some helper function names are clearer in plural form, such as functions that return collections.
- Approved verb enforcement is useful for modules, but too noisy for small standalone cleanup utilities.
Enabled formatting and quality rules include:
PSAvoidUsingCmdletAliases
PSUseConsistentIndentation
PSUseConsistentWhitespace
PSPlaceOpenBrace
PSPlaceCloseBrace
PSAlignAssignmentStatement
make build
Builds the lint image.
make rebuild
Rebuilds the lint image with --no-cache.
make lint
Builds the lint image if needed and runs PSScriptAnalyzer against the repository.
make clean
Removes the local lint image.
The repository should include a .dockerignore that uses an allowlist-style build context. The lint image only needs the Dockerfile and lint entrypoint at build time.
Recommended .dockerignore:
# Ignore everything by default.
**
# Keep Dockerfile and analyzer entrypoint.
!Dockerfile.psscriptanalyzer
!psscriptanalyzer.ps1
# Keep analyzer settings.
!PSScriptAnalyzerSettings.psd1
# Optional repo metadata/config.
!README.md
!cspell.json
!makefile
# Keep scripts for validation and examples.
!cleanup-vscode-copilot.ps1
!cleanup-vscode-copilot.sh
# Always exclude Git and local/editor noise.
.git
.gitignore
.github
.vscode
.idea
.DS_Store
*.swp
*.swo
# Exclude runtime/build artifacts.
tmp
temp
.cache
coverage
dist
build
bin
obj
Check the PowerShell version:
docker run --rm \
--entrypoint pwsh \
pssa-lint:latest \
-NoLogo -NoProfile -Command '$PSVersionTable.PSVersion'Check the installed PSScriptAnalyzer version:
docker run --rm \
--entrypoint pwsh \
pssa-lint:latest \
-NoLogo -NoProfile -Command 'Import-Module PSScriptAnalyzer; Get-Module PSScriptAnalyzer'A successful run should end with:
PSScriptAnalyzer passed. No diagnostics found.
If findings are present, the wrapper prints diagnostics in this format:
<file>:<line>:<column>: <severity>: <rule>: <message>
The container exits non-zero when diagnostics are found, which makes it suitable for CI.
Example GitHub Actions workflow:
name: lint
on:
pull_request:
push:
branches:
- main
jobs:
psscriptanalyzer:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Build lint image
run: docker build --pull -f Dockerfile.psscriptanalyzer -t pssa-lint:latest .
- name: Run PSScriptAnalyzer
run: docker run --rm -v "$PWD:/workspace" pssa-lint:latestIf you see an error similar to this:
Minimum supported version of PSScriptAnalyzer for PowerShell Core is 7.4.6
Rebuild the image without cache:
make rebuildThe Dockerfile uses the .NET 10 SDK image, which includes PowerShell.
Remove the local image and rebuild:
make clean
make rebuildOr directly:
docker image rm pssa-lint:latest
docker build --pull --no-cache \
-f Dockerfile.psscriptanalyzer \
-t pssa-lint:latest \
.That usually means there are no matching local Copilot or chat session folders left in the known VS Code storage paths.
You can manually inspect workspace storage on macOS:
find "$HOME/Library/Application Support/Code/User/workspaceStorage" \
\( -name "chatSessions" -o -name "chatEditingSessions" -o -iname "*copilot*" \) \
-type d \
-print 2>/dev/nullFor VS Code Insiders:
find "$HOME/Library/Application Support/Code - Insiders/User/workspaceStorage" \
\( -name "chatSessions" -o -name "chatEditingSessions" -o -iname "*copilot*" \) \
-type d \
-print 2>/dev/nullThese scripts clean local VS Code state. They do not control or delete:
- GitHub account-level Copilot data
- GitHub service-side data
- Claude Code local history under
~/.claude - Other AI extension histories stored outside VS Code
workspaceStorage - Installed VS Code extension packages
Use dry-run output before deletion and close VS Code before cleanup.