Running Out of Disk Space? A Practical Guide to Relocating AI Coding Tool Caches with Symbolic Links

    As AI coding tools shift toward hybrid architectures that combine cloud models with local caching, their indexes, model slices, and reasoning data can quietly consume tens of gigabytes on the Windows system drive until editors fail to create sessions or crash. This guide explains where these caches live, why simply cutting and pasting the folders breaks the tools, and how to move them to another drive with symbolic links created via mklink /D or ln -s. It includes step-by-step PowerShell migration and verification, a Python automation example, a module breakdown for building a repeatable script or GUI utility, and four key risks with mitigations, from interrupted transfers and post-upgrade path resets to cleanup tools and NTFS permission inheritance. It closes with longer-term cache governance practices such as size caps, declarative directory redirection, cloud offloading, and scheduled monitoring.

    1. When AI Coding Goes Local: Where the Disk Pressure Comes From

    As developers rely on AI coding assistants for code completion, context retrieval, and natural language interaction, these tools have moved from early cloud-only inference toward a hybrid architecture that pairs cloud models with local caching. That shift has two immediate consequences: AI-generated context data must be written to the local machine, and model slices, vocabularies, and index files are cached under the user profile to speed up subsequent loads.

    The most common scenario plays out on Windows: the system drive is usually the smallest SSD in the machine (256 GB or 512 GB), while development tools write their caches to hidden folders under %USERPROFILE% by default. As conversations accumulate and repository indexes grow, those folders can swell to tens of gigabytes within weeks. Once free space on the system drive hits zero, the editor starts showing errors like “unable to create a new session” or “index write failed,” and may even crash outright. Diagnosing the problem often eats up a lot of time.


    2. Locating the Real Space Hogs

    Before moving anything, identify which directories are actually worth relocating. For mainstream AI coding tools, caches tend to concentrate in these places:

    1. Tool-specific folders under the user profile

    Hidden directories such as C:\Users\<username>\.tool-name\ hold global configuration, plugins, session history, and inference caches. Subfolders like .code-reasoning deserve particular attention, since they store the intermediate data from every AI inference pass and their growth curve is nearly linear.

    2. Model cache directories

    Some tools create a models folder under AppData\Local\ to store downloaded embedding models or small local models. A single model file can range from hundreds of megabytes to several gigabytes, making this the most rigid, non-negotiable portion of the cache.

    3. Logs and telemetry files

    Frequently written log files can balloon out of control under abnormal conditions. Individual logs may be small, but when no rotation policy is in place, the cumulative effect is hard to ignore.


    3. Why Simply Moving the Files Breaks Things

    Many developers try to cut the cache folder over to the D drive, only to find the tool errors out at startup saying it can’t find its configuration. The reason: most desktop tools rely on hard-coded or registry-recorded absolute paths, so the moment the files change location, the program can no longer locate its own data.

    What’s needed here is a low-level filesystem capability: the symbolic link. On Windows these are created with the mklink /D command; on Linux and macOS the equivalent is ln -s. A symbolic link works by placing a “pointer” at the original path that points to the real directory at its new location. From the application’s point of view, it is still reading and writing C:\Users\...\.tool-name, while the actual data sits in a folder on the D drive, completely transparently.


    4. Manual Migration: From Environment Check to Command Execution

    For developers who prefer the command line, manual migration takes three steps:

    Step 1: Terminate all related processes completely

    Even after you close the window, AI coding tools often leave behind a number of Node.js or Electron child processes. These processes hold file handles that cause moves to fail. In PowerShell, run:

    1. # List all associated processes
    2. Get-Process | Where-Object {$_.Path -like "*tool-name*"}
    3. # Force-terminate them
    4. Get-Process | Where-Object {$_.Path -like "*tool-name*"} | Stop-Process -Force

    Step 2: Move the files and create the link

    1. # Create the target directory on the destination drive
    2. New-Item -ItemType Directory -Path "D:\DevCache\.tool-name" -Force
    3. # Move files with robocopy (more reliable than move, supports resuming)
    4. robocopy "C:\Users\<username>\.tool-name" "D:\DevCache\.tool-name" /E /MOVE
    5. # Create the symbolic link
    6. cmd /c mklink /D "C:\Users\<username>\.tool-name" "D:\DevCache\.tool-name"

    Step 3: Verify the link works

    1. # Check that the link points to the correct target
    2. Get-Item "C:\Users\<username>\.tool-name" | Select-Object LinkType, Target

    If LinkType shows SymbolicLink and Target points to the D drive path, the migration succeeded. Restart the coding tool and check that it loads its configuration normally.


    5. Automating the Migration: Script Wrappers and a GUI Approach

    Manual operation is direct, but it involves multiple steps and easy-to-miss details. In real team usage, it’s better to package the flow into a repeatable script or a small GUI utility. The core functional modules should include:

    Module Responsibility Implementation notes
    Path detection Automatically discover the tool’s install path and cache directory Scan common locations plus registry queries
    Process cleanup Terminate processes holding the files Match processes by path pattern
    File migration Safe copy, verify, then delete originals Prefer robocopy over move
    Link creation Create the symbolic link at the original path Call mklink with administrator privileges
    State tracking Record each migrated directory’s original and current location Persist in a local JSON or INI file
    One-click rollback Reverse operation: delete the link, move the files back Check destination drive has enough free space first

    A simplified migration function example:

    1. import os
    2. import shutil
    3. import subprocess
    4. def migrate_cache_dir(source: str, target: str):
    5. """
    6. Migrate the source directory to target and create a symbolic link at source.
    7. Must be run with administrator privileges.
    8. """
    9. if not os.path.exists(source):
    10. raise FileNotFoundError(f"Source directory does not exist: {source}")
    11. # 1. Create the target directory
    12. os.makedirs(target, exist_ok=True)
    13. # 2. Move the files
    14. for item in os.listdir(source):
    15. src_item = os.path.join(source, item)
    16. dst_item = os.path.join(target, item)
    17. shutil.move(src_item, dst_item)
    18. # 3. Remove the empty source directory, then create the symbolic link
    19. os.rmdir(source)
    20. subprocess.run(
    21. ['cmd', '/c', 'mklink', '/D', source, target],
    22. check=True,
    23. capture_output=True
    24. )
    25. print(f"[OK] {source} -> {target}")

    6. Key Risks and How to Handle Them

    Risk 1: Power loss or a forced shutdown during migration

    If the file copy is interrupted halfway, you end up with inconsistent data. The mitigation is to take a full backup before migrating, or use a copy tool that supports log-based recovery. For critical directories such as session history, keep the original copy for 72 hours after migration.

    Risk 2: Path reset after a tool upgrade

    Some tools check the cache path during major version updates and “repair” it back to the default location, potentially overwriting the symbolic link. Check LinkType immediately after upgrading. If you find the link has become an ordinary directory, re-run the migration.

    Risk 3: Accidental deletion by system restore points or disk cleanup tools

    Windows Disk Cleanup and some third-party cleanup utilities may treat symbolic links as “redundant items that are safe to delete.” After migrating, add the target path to the cleanup tool’s allowlist.

    Risk 4: Permission inheritance across drive letters

    Under NTFS, permission inheritance for symbolic links behaves differently than for ordinary directories. If the target drive uses a different security policy, the tool may hit a false failure where it “can’t read the cache.” In that case, manually align the target directory’s permissions with the original:

    1. icacls "D:\DevCache\.tool-name" /grant "<username>:(OI)(CI)F"

    7. Longer-Term Thinking: Sustainable Local Cache Management

    Symbolic link migration solves the urgent problem of insufficient existing space, but from an architectural standpoint, more fundamental management approaches include:

    1. Cache size caps: Set a maximum cache capacity in the tool’s configuration so the oldest data is automatically evicted once the limit is exceeded.
    2. Declarative directory redirection: Some tools support customizing the cache root directory via environment variables or configuration files, achieving path changes without symbolic links at all.
    3. Coordinated cloud storage: Sync non-real-time index data to object storage or a NAS, keeping only hot data locally.
    4. Periodic inspection: Use scheduled tasks to monitor cache directory size and trigger alerts or automatic cleanup when a threshold is crossed.

    Developers using cloud services such as Baidu AI Cloud can also map cache directories onto a mounted cloud drive, achieving elastic expansion that combines the local experience with cloud capacity, while using monitoring and alerting capabilities to visually track disk utilization and avoid development interruptions caused by running out of space.


    8. Summary

    Bloat in AI coding tool caches is an inevitable product of the hybrid architecture, not an occasional glitch. As a mature filesystem capability, symbolic links offer a low-cost, highly transparent migration path. The key points: terminate all processes before migrating, use a reliable copy tool during migration, verify the link status afterward, and prepare contingency plans for possible upgrade overwrites and accidental cleanup deletion. For developers who use AI coding tools heavily, building a standardized cache management workflow pays off far beyond any one-off rescue.