Disk Usage Governance and Migration for AI Coding Tools

    This article explains why AI coding tools consume large amounts of local disk space and how to address it safely. It covers the three main sources of on-disk data, a four-dimension framework for evaluating coding assistants, how directory symbolic links enable transparent cross-drive migration on Windows, how to handle locked files before migrating, and a reusable migration workflow with snapshot logging and rollback. It also outlines long-term capacity governance practices and common pitfalls to avoid.

    1. The Problem: Why AI Coding Tools Fill Up Your System Drive

    As AI-assisted coding evolves from completing snippets to understanding an entire repository, the amount of data kept locally keeps growing. Many developers run into the same scenario: the system drive quietly goes from tens of gigabytes free to 0 bytes, the editor can no longer create sessions, index builds fail, and dependency installs abort. Only after digging in do they find that the main consumer is the coding tool itself.

    To address this, you first need to understand where the usage comes from. Common AI coding tools typically write three categories of data to disk locally:

    1. Model and index caches: To reduce time-to-first-token, tools cache model-related files, vector indexes of code chunks, and summary data. The larger the repository and the more often you switch projects, the faster these caches grow.
    2. Plugin and runtime directories: Dot-prefixed hidden configuration directories usually hold plugins, extensions, runtime dependencies, and user settings at the same time, and they contain a large number of small files.
    3. Inference and log data: Session records, context snapshots, and debug logs (such as *.log files and .code-reasoning-style directories) accumulate linearly with usage and often have no automatic expiration policy.

    An easily overlooked fact: most files in these directories are “rebuildable but worth keeping.” Deleting them outright forces re-indexing and re-downloading, which is actually slower, yet they genuinely take up space. That is exactly why the right move is to relocate them rather than clean them out.

    2. Evaluation Criteria: How to Compare AI Coding Capabilities Objectively

    Instead of arguing about which single tool is “the strongest,” build a quantifiable evaluation framework. Score four dimensions from 1 to 5 and apply weights based on your team’s actual priorities:

    • Context understanding length and accuracy: Can it correctly reference cross-file symbols and recognize project conventions and existing abstractions, rather than producing code that merely “looks right”?
    • Generated code quality: Does it pass compilation and static checks, cover edge cases, avoid introducing unnecessary dependencies, and follow the existing style?
    • Response speed: Distinguish time-to-first-token from total time to a complete solution; for long tasks, also consider the stability of streaming output.
    • Total cost of ownership: Look beyond subscription fees to local disk usage, memory footprint, build waiting time, and manual review time.

    Run a fixed set of real tasks as a benchmark, for example “add unit tests to an existing module,” “locate an intermittent null pointer,” or “rewrite callbacks into async/await style,” and record the first-pass success rate and the number of lines manually modified. This is far more reliable than subjective impressions.

    3. How Migration Works: Letting Programs Run Unaware

    On Windows, directory junctions and symbolic links (Symbolic Links created with mklink /D) let a logical path point to a physical directory on another drive. To the editor and runtime, the original path still exists, and reads and writes are transparently forwarded to the new location.

    Example commands (administrator privileges required; the target directory must not already exist):

    1. :: 1. Move the original directory to the target drive
    2. robocopy "C:\Users\<you>\.toolcache" "G:\Cache\.toolcache" /E /MOVE /R:1 /W:1
    3. :: 2. Create a directory symbolic link at the original location pointing to the new one
    4. mklink /D "C:\Users\<you>\.toolcache" "G:\Cache\.toolcache"

    How to verify:

    1. dir "C:\Users\<you>" :: Check whether <SYMLINKD> appears after the directory entry

    Before migrating across drives, confirm the target volume is NTFS and is not a network mapped drive or an encrypted virtual drive; otherwise the link may break.

    4. The Critical Step Before Migration: Handling Locked Files

    The most common cause of migration failure is not permissions but files being in use. After the editor’s main process exits, multiple Node.js runtime processes may still linger and hold handles to index files. Enumerate them first, then decide:

    1. Get-Process node -ErrorAction SilentlyContinue |
    2. Select-Object Id, StartTime, @{n='Cmd';e={(Get-CimInstance Win32_Process -Filter "ProcessId=$($_.Id)").CommandLine}}

    Once you confirm these processes are child processes of the editor, terminate them. The safer approach is to exit the editor normally, wait about 10 seconds for indexes to flush to disk, and then run the migration; use force termination only when you have confirmed there is no unsaved content. Force termination risks session data not being written to disk, so it should not be the default path.

    5. A Reusable Migration Workflow with Rollback Design

    A reliable migration workflow should be observable, interruptible, and reversible:

    1. Snapshot record: Before migrating, write each directory’s original path, target path, file count, and total size into a manifest file (such as migration-log.json). This is the sole basis for rollback.
    2. Copy first, delete after verification: Copy everything completely, compare file counts and total bytes, then delete the source directory and finally create the link. This avoids the irreversible risk of “move equals delete.”
    3. Idempotent design: On repeated runs, detect existing links and skip them instead of stacking new ones.
    4. One-command rollback: Read the manifest, delete the links, copy the data back to the original paths, verify consistency, and then clean up the target directory.

    Example manifest structure:

    1. [
    2. {"src": "C:\\Users\\me\\.toolcache", "dst": "G:\\Cache\\.toolcache",
    3. "files": 18342, "bytes": 9663676416, "linked": true}
    4. ]

    Note that the migration script should run as administrator, because creating system-level links requires the appropriate privileges. The script should also validate paths against a whitelist and forbid system-critical directories (such as the Windows directory or the user root directory) from being used as source or target, to avoid accidental damage.

    6. Long-Term Governance: From a One-Time Move to Capacity Discipline

    A one-time migration only solves the immediate problem; the long term depends on policy:

    • Set capacity watermark alerts: Trigger a reminder when free space on the system drive falls below a threshold (for example 15%), rather than waiting until it hits 0 bytes.
    • Cap cache directories: Periodically clean sessions and logs older than N days, and keep indexes for only the most recent few projects.
    • Project-level isolation: Keep large repositories on a non-system drive so indexes and build artifacts naturally land on the same disk.
    • Observability: Collect disk usage trends with monitoring alerts or a logging service to form a capacity curve and enable capacity expansion in advance.
    • Cloud extension: If the team needs to store build artifacts and index snapshots centrally, object storage can be used for archiving, with lifecycle policies handling automatic tiering and expiration; container platforms and image registries are suited to hosting a unified build environment and reducing duplicate local caches.

    7. Common Pitfalls

    • Deleting the cache directory outright: This forces a full index rebuild and makes the short-term experience worse.
    • Moving only plugins but not caches: The main consumers are usually indexes and inference data; the plugin directory is often not the bottleneck.
    • Creating links on non-NTFS volumes: Compatibility is poor and links may break after an upgrade.
    • Not restarting the tool after migration: Some runtimes cache paths at startup and need a restart to re-resolve the link.
    • Treating migration as a performance optimization: Migration solves a capacity problem; response speed still depends on the model and network conditions.

    8. Summary

    Local growth of AI coding tools is an explainable, predictable engineering problem: three categories of directories—caches, plugins, and inference data—stack up and eventually crush the system drive. The path forward is clear: quantify usage first, safely terminate the processes holding files, use symbolic links for transparent migration, keep a manifest to support rollback, and then make governance routine with capacity watermarks and lifecycle policies. If you use relevant Baidu AI Cloud products to host archiving and build environments, it is likewise advisable to make “capacity watermark + lifecycle + alerting” the default configuration, so that local and cloud space management form a closed loop.