Managing AI Coding Tool Local Cache and Freeing Up the C Drive

    This article explains why AI coding tools gradually fill up the system drive and how to reclaim space safely. It breaks down four categories of local data, then shows how to relocate large caches using NTFS junctions or symbolic links while keeping original paths functional. It also covers handling file locks, building a repeatable migration tool with dry-run and rollback support, verification steps, long-term maintenance, and key risks to avoid.

    1. Background: How the System Drive Quietly Fills Up

    AI coding tools—including AI IDEs, code completion engines, and conversational coding assistants—leave far more behind than a single installation directory. As usage time and conversation turns accumulate, free space on the system drive can drop from comfortable to critical within weeks. The problem often surfaces only when creating a new session fails with a disk space error, by which point tens of gigabytes are already consumed, much of it in files that cannot be safely deleted.

    This is a common issue because the growth curve is non-linear: the installer itself is only a few hundred megabytes, but runtime data accumulates over time like compound interest. Understanding how this data is classified is the first step toward managing it.

    2. Root Causes: Four Categories of Local Data

    1. Model and weight caches: To keep response times low, tools cache model files, indexes, and vectorization results locally. This is the largest category. It can be rebuilt, but rebuilding is expensive, and the first use after deletion is noticeably slower.
    2. Plugin and extension directories: Extension binaries, dependency packages, and runtimes (such as bundled script environments) take up considerable space, and multiple versions often coexist.
    3. Inference and session data: Conversation history, context snapshots, and intermediate reasoning artifacts are written as large numbers of small, frequently updated files. They consume space and slow down file system indexing.
    4. Logs and diagnostic files: At the default log level, logs are appended continuously and rarely rotated automatically, reaching gigabyte scale over long-running use.

    The management strategy follows directly from this classification: caches should be relocated, not deleted; logs can be cleaned; plugins can be trimmed; session data should be moved and retained.

    On Windows, the most reliable approach is not to change configuration and move directories, but to keep the original path valid at the file system level. NTFS directory junctions and symbolic links place a pointer at the original location while the actual data resides on the target disk. Applications accessing the original path are completely unaware of the change.

    Illustrative steps (administrator privileges required; the target directory must be empty or the migration already completed):

    1. :: 1. After closing related processes, move the directory to the target drive
    2. robocopy "C:\Users\<username>\.toolcache" "G:\CacheRoot\toolcache" /E /MOVE
    3. :: 2. Create a directory junction at the original location pointing to the new one
    4. mklink /J "C:\Users\<username>\.toolcache" "G:\CacheRoot\toolcache"
    5. :: 3. Verify: the original path lists content normally
    6. dir "C:\Users\<username>\.toolcache"

    For cross-volume symbolic links, replace /J with /D (directory symbolic link), but note that some applications handle link types differently; prefer directory junctions. On Unix-like systems the equivalent is ln -s, and you should confirm the application does not enforce path Realpath validation.

    Key constraint: Before migrating, confirm the target drive has more than 1.2 times the free space of the data to be moved. Do not power off or force a restart during migration, to avoid a half-on-old-drive, half-on-new-drive intermediate state.

    4. Before Migrating: Handling Process Locks and Open Files

    Background helper processes (typically script runtime processes) hold file handles, causing move failures or “file in use” errors. The proper procedure is to enumerate suspicious processes first, confirm their ownership, and then terminate them—not to kill indiscriminately.

    1. # Check what is holding files (example: filter by path pattern)
    2. Get-Process | Where-Object { $_.Path -like "*\.toolcache*" } |
    3. Select-Object Id, ProcessName, Path
    4. # After confirming, terminate the specified process
    5. Stop-Process -Id <PID> -Force

    The engineering recommendation is to make this step a rollback-capable script: record the list of terminated processes, record directory sizes before and after migration, and stop automatically on failure while preserving the current state.

    5. Engineering It: Turning a One-Off Operation into a Reusable Tool

    Manually typing commands is neither repeatable nor auditable. A proper in-house migration tool should contain at least five modules:

    • Path detection: Automatically detect common data directories, allow manual override, and persist the last selection;
    • Pre-checks: Administrator privilege check, target drive free space check, source directory existence check;
    • Lock cleanup: Process enumeration and termination, with cleanup results output;
    • Migration and linking: Move data, create the link, and write a migration log (source path, target path, timestamp);
    • Restore and verify: Read the migration log to reverse the operation and migrate back to the original drive in one step.

    A pseudocode structure:

    1. def migrate(src, dst, dry_run=False):
    2. require_admin()
    3. assert_free_space(dst, size_of(src) * 1.2)
    4. kill_locking_processes(src)
    5. if not dry_run:
    6. move(src, dst)
    7. create_junction(src, dst)
    8. log_record(src, dst) # the sole basis for rollback
    9. verify(src)

    dry_run and the migration log are the two pillars of safety: the former is for rehearsal, and the latter is the only rollback reference. A migration without a log is effectively irreversible and should not be enabled by default.

    6. Verification Checklist and Long-Term Maintenance

    After migration, verify in this order: the original path is accessible → the tool can create a new session → writes take effect (new files appear on the target drive) → everything still works after a reboot. For daily maintenance, set rotation and retention limits for the log directory, set capacity watermark alerts for the cache directory, and periodically clean up historical session snapshots.

    To avoid this class of problem at the architecture level, consider offloading heavy data to general-purpose cloud capabilities: object storage for model and archive data, a log service for centralized collection and rotation, a container platform for running isolated build and indexing tasks, and monitoring and alerting for capacity watermark warnings. This keeps only the necessary hot data locally and naturally reduces pressure on the system drive.

    7. Risks

    Symbolic links mean that “deleting the original path” actually deletes the target data, so backup and migration scripts must validate existence and type first. In enterprise environments, confirm compliance and endpoint management policies before modifying user directory structures. Any “force kill all processes” capability should be scoped to an explicit path range to avoid affecting unrelated business processes.