Managing Local Storage Bloat in AI Coding Tools with Symbolic Links and Directory Junctions

    AI coding tools often cache model fragments, code indexes, session data, logs, and plugin files under the user profile on the system drive. As usage grows, these files can gradually consume the system disk and even affect operating system stability. This article explains how to move large directories to a higher-capacity drive while keeping the original paths transparent, using symbolic links, directory junctions, or Unix-style symbolic links. It covers preparation, locating large directories, terminating locking processes, migrating data with robocopy, verification, rollback, common risks, and optional hot/cold data tiering with cloud object storage.

    1. Why AI Coding Tools Can Fill Up the System Drive

    In recent years, AI-powered coding tools have become a major productivity layer for developers. Most of them run as desktop applications, such as IDEs, and integrate components like model runtimes, language services, and indexing engines on the local machine.

    To provide low-latency code completion and conversational experiences, these tools often write a large amount of intermediate data to local disk. Common examples include:

    • Local models and caches: To accelerate inference, tools may cache model fragments, code indexes, vectorized results, and similar data, often reaching several gigabytes in size.
    • Plugin and extension directories: Language services and helper extensions are usually installed under the user profile and can keep growing as more plugins are added.
    • Session and inference data: Conversation history, context snapshots, and intermediate inference results may be continuously written to disk.
    • Log files: Debug and runtime logs can accumulate quickly under frequent use and are often not cleaned up automatically.

    These files have one important thing in common: by default, they are written under the user directory on the system drive, such as the C drive on Windows.

    As usage deepens, the system drive can be gradually consumed. In severe cases, this may lead to problems such as being unable to create new sessions or failing to write temporary files. A full system drive can also affect the stability of the operating system itself.

    2. Core Idea: Move the Physical Data, Keep the Logical Path

    The root problem is simple: the data is large and keeps growing, while the system drive has limited capacity.

    The most elegant solution is usually not to delete the data, because much of it is still required. Instead, the physical storage can be moved to a larger-capacity drive, such as a D or G drive, while the system and the application continue to believe that the files are still in their original locations.

    The key operating-system mechanism that makes this possible is the link mechanism. A link creates an entry at the original path and transparently redirects reads and writes to another physical location. Applications do not need to change their behavior.

    On Windows, two common directory redirection methods are available:

    • Symbolic Link: Created with mklink /D. It can cross volumes and disks, and can even point to a network path. Creating one usually requires administrator privileges or having Developer Mode enabled.
    • Directory Junction: Created with mklink /J. It can point only to a local absolute path, but it has very good compatibility and usually does not require administrator privileges. This makes it more friendly for non-administrator scenarios.

    For ordinary applications, both methods are transparent for reads and writes. The main differences are in permission requirements, cross-volume capability, and how some older programs handle reparse points.

    2. Equivalent Approach on Linux and macOS

    On Unix-like systems, the equivalent capability is the symbolic link, created with:

    1. ln -s target link_name

    This does not require special privileges and has been a mature, widely used practice for a long time. Therefore, “move the physical location while preserving the logical path” is a general cross-platform engineering pattern.

    3. Preparation Before Migration

    1. Check the Target Disk Capacity

    Before migrating, use File Explorer or a command to confirm that the target drive has enough free space for the data you plan to move.

    2. Locate the Directories That Actually Consume Space

    Do not migrate directories based only on intuition. Use a tool or script to identify the exact locations that are consuming space.

    1. # List the 10 largest subdirectories under the user profile (in MB)
    2. Get-ChildItem -Path $env:USERPROFILE -Directory -Recurse -ErrorAction SilentlyContinue |
    3. ForEach-Object {
    4. $size = (Get-ChildItem $_.FullName -File -Recurse -ErrorAction SilentlyContinue |
    5. Measure-Object -Property Length -Sum).Sum
    6. [PSCustomObject]@{ Path = $_.FullName; SizeMB = [math]::Round($size / 1MB, 2) }
    7. } |
    8. Sort-Object SizeMB -Descending |
    9. Select-Object -First 10

    3. Check Permissions

    If you plan to use symbolic links, run the terminal as an administrator. If you use directory junctions, ordinary permissions are usually sufficient, but it is still recommended to verify read and write access after migration.

    4. Key Difficulty: Cleaning Up Processes That Lock Files

    The most common cause of migration failure is locked files.

    Even after the application window is closed, AI coding tools may still leave many background runtime processes running. For example, services based on Node.js runtimes may continue to hold file handles, preventing the data from being moved.

    Therefore, before migration, all related processes must be fully terminated:

    1. :: Terminate all processes with the specified image name; /T also terminates child processes.
    2. taskkill /F /IM node.exe /T

    Note: /F forces termination, and /T terminates the process tree. Replace the process name as needed. Before doing this, make sure no other important tasks depend on these processes, to avoid accidental disruption.

    5. Step-by-Step Migration on Windows Using Directory Junctions

    The correct order is: move the data first, then create the link. This is because a link cannot be created at the original location while a real directory still exists there.

    1. :: 1. Terminate processes that may lock files
    2. taskkill /F /IM node.exe /T
    3. :: 2. Move the real directory from the system drive to the target drive
    4. :: This command removes the source directory after copying.
    5. robocopy "C:\Users\<username>\.aitool" "G:\AICache\.aitool" /E /MOVE
    6. :: 3. Create a directory junction at the original location, pointing to the target drive
    7. mklink /J "C:\Users\<username>\.aitool" "G:\AICache\.aitool"
    • robocopy /E /MOVE recursively copies all subdirectories, including empty directories, and deletes the source directory after a successful copy.
    • If you need cross-volume capability or stronger functionality, you can use mklink /D to create a symbolic link instead. This requires administrator privileges.

    Verification Steps

    1. :: Check that the link points to the target location
    2. dir "C:\Users\<username>"
    3. :: Enter the linked directory to confirm that the real data is visible
    4. dir "C:\Users\<username>\.aitool"

    Once the link points to the target drive and the data is complete and readable, restart the tool. From then on, the tool will continue to read and write through the original path, but the physical data will reside on the target drive.

    6. Safe Rollback: Always Keep an Undo Path

    Any storage migration should include a rollback plan. Fortunately, because of how links work, deleting the link itself does not delete the real data on the target drive, which makes rollback relatively safe.

    1. :: 1. Terminate processes that may lock files again
    2. taskkill /F /IM node.exe /T
    3. :: 2. Delete the link
    4. :: This removes only the reparse point, not the real data on the target drive.
    5. rmdir "C:\Users\<username>\.aitool"
    6. :: 3. Move the real data back to the original location on the system drive
    7. robocopy "G:\AICache\.aitool" "C:\Users\<username>\.aitool" /E /MOVE

    It is important to understand that when rmdir is applied to a junction or symbolic link, it removes the link, not the real content behind it. This is the key to safe rollback and the essential difference from directly deleting a directory.

    7. Common Risks and Precautions

    • Paths containing spaces: Always wrap paths in double quotes in commands, otherwise the command may be truncated.
    • Insufficient permissions: If symbolic link creation fails, first check whether the terminal is running as administrator, or whether Developer Mode is enabled.
    • Driver and file-system differences: When migrating across different file systems, pay attention to compatibility issues such as case sensitivity and special characters.
    • Back up first: Before any “move plus link” operation, it is recommended to back up important directories first, to avoid data inconsistency if the process is interrupted.
    • Limits of process cleanup: Forcefully terminating processes may interrupt unfinished writes. Make sure no important task is in progress before doing this.

    8. Advanced: Hot/Cold Data Tiering and Cloud Archiving

    Local migration mainly solves the problem of keeping hot data close at hand and fast to access. However, not all data is suitable for long-term local storage. A more systematic storage governance approach can introduce hot/cold tiering:

    • Hot data, such as model caches and indexes for the current project, can remain on a high-speed local drive for low latency.
    • Cold data and backups, such as historical session archives and old index versions, can be moved to cloud object storage, using its pay-as-you-go, low-cost, and high-durability characteristics for long-term retention. The data can be pulled back when needed.

    In cloud archiving scenarios, object storage services such as Baidu AI Cloud can be one option for placing cold data. When combined with monitoring, alerting, and log services, teams can also continuously observe local disk usage and migration results, forming a closed loop of locate, migrate, verify, and monitor.

    9. Best Practices Checklist

    1. Quantify and locate large directories before deciding what to migrate.
    2. Prefer directory junctions for a good balance of compatibility and permission friendliness.
    3. Fully terminate locking processes before migration, and completely verify read/write access afterward.
    4. Always keep and rehearse the rollback steps.
    5. For cold data, introduce cloud object storage for long-term archiving to reduce local storage pressure.

    By combining symbolic links / directory junctions + process cleanup + step-by-step verification + safe rollback, you can smoothly migrate the local storage of AI coding tools from the system drive to a larger-capacity disk or cloud storage, without changing any usage habits, while freeing up valuable space on the system drive. This approach is also a general pattern for managing other local cache bloat problems.