Migrating AI Coding Tool Local Caches and Freeing Up C Drive Space

    This article explains why AI coding tools such as AI IDEs and code assistants gradually fill up the system drive, and how to diagnose, migrate, verify, and govern that disk usage. It classifies local disk consumption into model caches, plugin and extension directories, and inference or session data, then shows how to establish a usage baseline before taking action. The core solution uses directory junctions (symbolic links) to physically move large directories to another local disk while keeping the original paths transparent to applications. The article also covers engineering practices for a repeatable migration workflow, including administrator checks, process handling, post-move verification, and rollback, followed by long-term capacity governance and common pitfalls to avoid.

    1. Background: Why AI Coding Tools Fill Up the System Drive

    Over the past year or two, AI coding tools such as AI IDEs and code assistants have improved productivity, but they have also introduced a new engineering problem: local disk usage keeps expanding, and the growth is almost always concentrated on the system drive. A typical pattern is that after a few weeks of use, free space on the system drive drops from tens of GB to single digits, eventually reaching 0 bytes. At that point, the tool can no longer create new sessions or write logs, and the operating system itself starts to slow down and fail to install updates.

    This is not a product defect. It follows from how these tools work. To understand the usage, it helps to break it into three categories:

    1. Local model caches: To reduce time-to-first-token latency and network overhead, tools cache model weights, tokenizers, and quantized artifacts locally. These files are large, read-only, and rarely change.
    2. Plugin and extension directories: Extensions such as language servers, indexers, and terminal components each carry runtime dependencies. A Node runtime and its dependency tree can easily reach hundreds of MB to several GB in a single directory.
    3. Inference and session data: Conversation history, context snapshots, code indexes, logs, and intermediate artifacts are written frequently. There are many files, they grow quickly, and the payoff from cleaning them is inconsistent.

    Key takeaway: the first category is best suited to migration, the third to cleanup and rotation, and the second sits in between. Treating all three the same way is the root cause of many “one-click cleanup” scripts making things worse.

    2. Diagnose First: Establish a Usage Baseline

    Before any migration, quantify the usage. Collect baseline data in the following order:

    • Locate the directories that actually consume space: Default paths differ across tools, but they are usually found in hidden directories under the user’s home directory, application data directories (Roaming/Local), and temporary directories.
    • Classify by “size × rate of change”: large and nearly static (model caches), large and fast-growing (indexes and inference data), and small but extremely numerous (log fragments).
    • Record a snapshot of free space on the system drive and directory sizes to compare before and after migration.

    A reusable approach to measuring directory size (illustrative, for inventory only, not for deletion):

    1. # Measure the size of each first-level subdirectory under a given path, sorted from largest to smallest
    2. Get-ChildItem -Path $env:USERPROFILE -Directory -Force |
    3. ForEach-Object {
    4. $size = (Get-ChildItem $_.FullName -Recurse -File -Force -ErrorAction SilentlyContinue |
    5. Measure-Object -Property Length -Sum).Sum
    6. [PSCustomObject]@{ Dir = $_.Name; SizeGB = [math]::Round($size / 1GB, 2) }
    7. } | Sort-Object SizeGB -Descending | Select-Object -First 20

    Avoid over-deletion during diagnosis. Logs and caches often contain index metadata and session state. Deleting them outright can force the tool to rebuild its index, which consumes disk and CPU again, and may even make historical sessions unrecoverable.

    3. Core Solution: Directory Junctions for a Physical Move with No Logical Change

    The essence of migration is decoupling the “path” from the “physical location.” The directory junction (or symbolic link) provided by the operating system turns a directory into a pointer to a directory on another disk: applications access the original path, while the data physically resides on the target drive. The path is completely transparent to both the tool and the system, so there is no need to change configuration or reinstall anything.

    Example commands (run with administrator privileges; for demonstration only):

    1. :: 1) After closing the relevant processes, move the directory to the target drive
    2. robocopy "C:\Users\<user>\AppData\Local\<tool>" "D:\Cache\<tool>" /E /MOVE /R:2 /W:2
    3. :: 2) Create a junction at the original location pointing to the target drive
    4. mklink /J "C:\Users\<user>\AppData\Local\<tool>" "D:\Cache\<tool>"

    The advantages and boundaries must be stated together:

    • Advantages: one migration remains effective long term; it does not break the tool’s path assumptions; it is movable, rollback-friendly, and auditable.
    • Boundaries: a junction is a system-level object and requires administrator privileges to create; cross-volume migration requires the target to be a local fixed disk; some tools validate directory attributes at startup and may need extra handling in rare cases; if the target drive is removed or unavailable after sleep, the tool will fail to start.

    4. Engineering the Rollout: Turning Manual Steps into a Repeatable Process

    Typing commands manually is unfriendly for most users and easy to get wrong. The engineering approach is to package the workflow into a small visual tool, following four design principles:

    1. Pre-checks: Verify that the process is running as administrator, that the target drive exists with sufficient free space, and that the source directory actually exists.
    2. Handling process locks: Locked files are the leading cause of migration failure. The tool should enumerate and terminate lingering background runtime processes before moving data. This step carries a risk of losing unsaved content, so the tool should prompt users to save and exit manually first.
    3. A closed loop of migration and verification: After the move, automatically verify that file counts and total bytes match, then create the junction, and finally confirm the junction resolves.
    4. Rollback support: Record the original path, target path, timestamp, and operation log; rollback removes the junction, moves the data back, and restores the initial state.

    Pseudocode for the main flow:

    1. if not isAdmin(): abort("Administrator privileges required")
    2. targets = selectTargets() // user selects, all selected by default
    3. ensureDiskSpace(target.drive, sizeOf(targets))
    4. stopProcesses(occupying(targets)) // clearly communicate the risk
    5. for t in targets:
    6. move(t.source, target.path(t)) // preserve attributes and ACLs
    7. assert(countAndBytesEqual(t.source, target.path(t)))
    8. createJunction(t.source, target.path(t))
    9. log(t.source, target.path(t))
    10. verifyAllJunctions()

    5. Verification, Rollback, and Risk Control

    Migration does not end when the move completes. Verification and rollback mechanisms are required:

    • Functional verification: Restart the tool and confirm it can create new sessions, load history, and run plugins and indexes normally with no path errors.
    • Space verification: Compare free space on the system drive before and after migration and confirm the difference matches the migrated volume.
    • Rollback drill: Test a rollback once during a non-critical period to ensure the junction can be removed and the data moved back.
    • Risk control: Back up non-regenerable data (session history, configuration) separately before migration; avoid running during battery power or when the disk is nearly full; do not perform a “pseudo-migration” when the target and source are the same physical volume, as it frees no space.

    6. Long-Term Governance: From One-Time Firefighting to Ongoing Control

    A one-time migration only solves the immediate problem. Long-term governance requires:

    • Move paths forward: Point cache and data directories to a non-system drive during installation to avoid a second migration.
    • Periodic inspection: Include directory size measurement in routine checks and set threshold alerts (for example, a threshold on system drive free space using general monitoring and alerting capabilities).
    • Hot/cold tiering: Keep large, read-only model caches on a local high-capacity disk; place regenerable indexes and logs in a cleanable directory with rotation configured; when cross-device synchronization is needed, consider general cloud storage such as object storage for cold data.
    • Capacity budget: Set a minimum free-space red line for the system drive on development machines (for example, no less than 15%–20%); below the red line, only cleanup and migration are allowed, not installing large dependencies.

    7. Common Misconceptions

    • Misconception 1: Deleting the cache directory solves the problem. In practice, it triggers a full index rebuild, making things slower and more disk-hungry in the short term.
    • Misconception 2: Treating a junction as a copy. A junction is a pointer; deleting the junction on the source side does not affect the target data, but deleting the target data will immediately break the tool.
    • Misconception 3: Ignoring permissions. Creating a junction without administrator privileges fails, and the error message is often unclear.
    • Misconception 4: Migrating without handling process locks. This is the most common reason a migration “fails at 99%.”

    8. Conclusion

    Disk expansion caused by AI coding tools is an explainable, predictable, and governable engineering problem. Following the main line of “diagnose, classify, junction-migrate, verify, rollback, and inspect periodically,” together with pre-handling of permissions and process locks, can reliably free up tens of GB of system drive space without compromising the tool experience. For teams, codifying this process into internal standards and automation scripts is more reliable than depending on manual individual operations. For scenarios that need to further reduce local pressure, cold data can be tiered to general cloud capabilities such as object storage, forming a capacity governance loop that spans local and cloud.