Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To keep Visual Studio Code from filling your drive during AI coding, first identify which folders are actually using the space, then review and remove inactive agent worktrees with VS Code’s built-in cleanup tool. If the system drive is still constrained, move VS Code-managed data to another location. AI tokens and context-window use are separate from local disk storage; the documented storage concern here is that worktree-isolated agent sessions can accumulate and use significant space.

Find what is using disk space

Start with your operating system’s storage settings or a trusted disk-usage tool to identify the largest directories. Then check whether VS Code’s inactive agent worktrees are a significant part of the total. The cleanup tool can show estimated worktree sizes before you choose what to remove.

Do not assume that long prompts or a large conversation context are filling the drive. Context refers to information supplied to the model, such as conversation inputs and workspace files; it is not a measure of local disk capacity. VS Code identifies isolated agent worktrees as a concrete source of disk use, but its documentation does not establish that token or context-window use fills local storage.

Clean up inactive agent worktrees safely

  1. Open the Command Palette in VS Code.
  2. Run Chat: Open Worktree Cleanup.
  3. Choose an inactivity filter: 7, 15, 30, 60, or 90 days.
  4. Review the listed sessions and their estimated sizes, then select only the inactive worktrees you no longer need.

VS Code is designed to preserve work during cleanup: it commits uncommitted changes to the session branch before removing a worktree. If changes cannot be preserved or removal cannot be completed safely, the worktree is left in place. The session and branch history remain, and restoring a session can recreate its worktree.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

This cleanup targets inactive session worktrees. It is not a general-purpose cleaner for extension folders, caches, build artifacts, or every other file associated with VS Code.

Use cleanup suggestions as a prompt, not a quota

To enable an in-product reminder, set chat.agentSessions.sessionStorageCleanupSuggestion.enabled to true. This experimental setting is disabled by default. The suggestion may appear when eligible inactive worktrees use at least 5 GiB or when 20 worktrees qualify.

Rank #2
Sale
Samsung T7 Portable SSD 1TB Titan Gray, USB 3.2 Gen 2, Up to 1,050MB/s
  • MADE FOR THE MAKERS: Create; Explore; Store; The T7 Portable SSD delivers fast speeds and durable features to back up any endeavor; Build your video editing empire, file your photographs or back up your blogs all in an instant
  • SHARE IDEAS IN A FLASH: Don’t waste a second waiting and spend more time doing; The T7 is embedded with PCIe NVMe technology that brings fast read and write speeds up to 1,050/1,000 MB/s¹, making it almost twice as fast as the T5
  • ALWAYS MAKE THE SAVE: Compact design with massive capacity; With capacities up to 4TB, save exactly what you need to your drive – from large working files to game data and everything in between
  • ADAPTS TO EVERY NEED: Whether using a PC or mobile phone, count on the T7 for extensive compatibility²; It’s a true team player when it comes to heavy-duty application usage or file-saving
  • HI RESOLUTION VIDEO RECORDING: Record Ultra High Resolution (4K 60fs) videos directly onto the T7 Portable SSD with your favorite camera or mobile devices; Supports iPhone 15 Pro Res 4K at 60fps video and more³

Those numbers are triggers for a suggestion, not a recommended storage limit and not an estimate of all VS Code data. Use the cleanup editor to review individual worktrees rather than treating either trigger as a quota.

Move VS Code-managed data off a constrained system drive

Relocation is useful when the system drive is tight and you want VS Code-managed data stored elsewhere. It changes where data is stored; it does not delete existing files or prevent storage from growing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Samsung T7 Portable SSD 2TB Titan Gray, USB 3.2 Gen 2, Up to 1,050MB/s
  • MADE FOR THE MAKERS: Create; Explore; Store; The T7 Portable SSD delivers fast speeds and durable features to back up any endeavor; Build your video editing empire, file your photographs or back up your blogs all in an instant
  • SHARE IDEAS IN A FLASH: Don’t waste a second waiting and spend more time doing; The T7 is embedded with PCIe NVMe technology that brings fast read and write speeds up to 1,050/1,000 MB/s¹, making it almost twice as fast as the T5
  • ALWAYS MAKE THE SAVE: Compact design with massive capacity; With capacities up to 4TB, save exactly what you need to your drive – from large working files to game data and everything in between
  • ADAPTS TO EVERY NEED: Whether using a PC or mobile phone, count on the T7 for extensive compatibility²; It’s a true team player when it comes to heavy-duty application usage or file-saving
  • HI RESOLUTION VIDEO RECORDING: Record Ultra High Resolution (4K 60fs) videos directly onto the T7 Portable SSD with your favorite camera or mobile devices; Supports iPhone 15 Pro Res 4K at 60fps video and more³

Portable Mode

Portable Mode keeps VS Code-managed data near the application. For supported Windows ZIP and Linux TAR.GZ distributions, create a data folder beside the application. On macOS, create a code-portable-data folder beside the application. VS Code’s Portable Mode documentation also explains migrating existing user data and extensions.

A portable external SSD can be a practical destination if it stays connected and you have a backup plan. That is a user choice based on the relocation option, not an official VS Code hardware recommendation.

Rank #4
Lexar ES3 1TB Portable SSD Silver, USB 3.2 Gen 2 up to 1050MB/s
  • Note: Magsafe is not available in this version
  • High-speed Data Transfer: Lexar external SSD ES3 supports USB 3.2 Gen 2 up to 1050MB/s read and 1000MB/s write to transfer files fast for more efficient work. (Performance may be lower if not supporting USB 3.2 Gen 2 on Mac and other systems)
  • Wide Compatibility: Lexar Portable SSD ES3 compatibility with iPhone 17 series (Not supported on iPhone 14 and older models), Android mobile devices, laptops, cameras, Xbox X|S, PS4, PS5, gaming console, and more
  • On The Go: Lexar external solid state drive ES3's thin, stylish, and durable design, weighs 42g and is only 10.5mm thick, making it smaller than a card and easily fits in your pocket. It comes with a Type-C cable for plug-and-play convenience
  • Data Safety First: Lexar SSD ES3 includes Lexar DataShieldTM 256-bit AES encryption software to protect files

Custom directories

Alternatively, launch VS Code with --user-data-dir <dir> to choose a user-data directory and --extensions-dir <dir> to choose an extensions directory. Portable Mode takes precedence over these command-line directory options.

Choose between cleanup and relocation

Option Best when What it changes Trade-offs
Worktree cleanup Inactive agent worktrees are confirmed to be using space. Removes selected inactive worktrees while preserving branch history. Review sessions before cleanup; it does not target other VS Code storage.
Portable Mode or custom directories The system drive is constrained and you want VS Code-managed data elsewhere. Changes the storage location; it does not remove data or cap future growth. The destination must remain available. Portable Mode overrides the custom-directory CLI options.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Understand session history and sync

VS Code’s Copilot session-history documentation describes searchable agent-session history stored in a local SQLite database. Session sync is on by default in that documentation. Setting chat.sessionSync.enabled to false keeps session data local by changing sync behavior; it does not delete existing local data.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sandisk 2TB Extreme Portable SSD, Up to 1050MB/s, USB-C, USB 3.2 Gen 2, IP65 Water and Dust Resistance, Updated Firmware, External Solid State Drive, SDSSDE61-2T00-G25
  • Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
  • Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
  • Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
  • Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
  • Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C

If you need to delete session history or address a corrupted history database, follow the official session-history instructions rather than manually removing undocumented database files.

Quick Recap

SaleBestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.99
Bestseller No. 4
Lexar ES3 1TB Portable SSD Silver, USB 3.2 Gen 2 up to 1050MB/s
Lexar ES3 1TB Portable SSD Silver, USB 3.2 Gen 2 up to 1050MB/s
Note: Magsafe is not available in this version
$179.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.