Urgent.News

What's breaking now, across thousands of outlets.

Tech

Isolation, file ownership and cleanup: the boring half of running coding agents in parallel on Windows

Someone left a comment on my last post that was a better outline than the post was: Parallel agents are only practical when the workspace boundaries are boring and explicit. On Windows especially, I would care less about the launch trick and more about isolation, logs, file ownership, and cleanup after failed runs. That is Alex Shev, and he is right. Four agents in a pane grid is the screenshot.…

Running coding agents in parallel on Windows can be a tedious task, particularly when it comes to isolation, logs, file ownership, and cleanup after failed runs. On Windows, isolation is a major concern as shared workspace boundaries can cause issues. Four key factors determine whether you are still using the setup after a month: isolation, logs, file ownership, and cleanup.

Isolation is not as simple as setting a HOME variable, as two agents running under the same Windows account share the same directories for config files like ~/.claude, ~/.codex, and ~/.gemini. This shared session can lead to conflicts when trying to run two separate accounts side by side. To avoid this, each process needs its own HOME, USERPROFILE, HOMEDRIVE, and HOMEPATH variables.

Another trap to watch out for is Node's os.homedir() function on Windows, which may not accurately reflect a USERPROFILE variable injected at spawn time. To avoid this issue, it is recommended to use a dedicated environment variable for storage and a separate function for where a new shell should start.

Despite the preference for full isolation, sharing CLAUDE.md, settings.json, and skills between panes is beneficial. Shared config files can be linked using mklink for directories or hardlinks for files. However, there can be issues with detecting hardlinked files and their impact on detached account functionality, making it necessary to compare file IDs to ensure proper functionality.

File ownership on Windows can also present challenges, as open handles can prevent the deletion of directories currently in use by a process. This issue can be observed when trying to remove a worktree directory, leading to a "Permission denied" error. This problem can be resolved by using the appropriate command, such as PowerShell's -WorkingDirectory or cmd, to set the actual working directory.

In addition to isolation and file ownership, working with Git worktrees on Windows can be tricky. A failed git worktree remove does not result in a no-op, as Git deletes the worktree contents, administrative directory, and removes the entry from git worktree list. The surviving empty folder poses a challenge, as Git no longer recognizes it, making recovery a manual process.

To ensure proper cleanup, it is crucial to identify which processes are holding onto the directory at spawn time and kill them by path prefix, normalized, as the same worktree may show up differently depending on the user.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Sunday 23 August →