mhl42.ai · MHL Academy · Set up a Windows computer for coding agents · December 2026
Mostly Harmless · MHL · 42

MHL Academy · Guide 04

Set up a Windows computer for coding agents

A practical guide for a developer who lets AI coding agents such as Claude Code or Codex work on a Windows 11 computer. It is for a developer who works alone and for a small team. Each step limits the damage if the agent or the computer is compromised.

01The short version

An AI coding agent is a program in which an AI model reads files, runs commands and changes code. By default, the agent acts with the rights of your Windows account. This guide gives the agent a limited place to work. One question tests each step.

If this agent obeys an attacker at this moment, what can it read, what can it change, and where can it send data?

The central assumption is: assume a breach. An agent cannot reliably separate instructions from data, so a web page or a file can steer it. The UK National Cyber Security Centre writes that such attacks "may never be totally mitigated" NCSC. Thus plan as if the agent already obeys an attacker, and as if the computer already runs malicious software. The steps make sure that one failure stays small.

  1. Prepare the computer. Install updates, encrypt the disk and use a standard account.
  2. Separate agent work from personal data. Give agent work its own Linux system in WSL 2 (Windows Subsystem for Linux 2), or its own Windows account.
  3. Turn on the sandbox. Let the operating system limit files and websites.
  4. Use a stronger boundary for unattended work. Use a virtual machine or a cloud session.
  5. Protect keys and secrets. Use a password manager and a hardware security key.
  6. Control what the agent installs and loads. Delay new packages, and review instruction files.
  7. Share the settings in a team. Send them in a form that a user cannot change.
THE WINDOWS COMPUTERPersonal accountmail and documentsbrowser sessionssaved passwordsAGENT WORK AREA (WSL 2)SANDBOX (BUBBLEWRAP)Coding agentruns commandsProject folderread and writeKey files and other foldersrules block the accessNETWORKPermitted hostsa proxy compares eachhost with a listSECRETS STAY OUTSIDEPassword managerHardware security key
Figure 1. The boundaries of this guide on a Windows computer. The agent can write only to the project folder. The personal data, the key files and the secrets stay outside its reach.

02Prepare the computer

These settings protect against a lost computer, an open screen and malicious software that tries to get administrator rights.

Setting What to do Where
Updates Install all available updates. Start > Settings > Windows Update
Disk encryption Turn on "Device encryption" or BitLocker. Settings > Privacy & security > Device encryption, or "Manage BitLocker" in the Start menu
Screen lock Press the Windows key and L when you leave. Make the screen saver show the sign-in screen. Settings > Personalization > Lock screen > Screen saver. Select "On resume, display logon screen".
Windows Security Keep the firewall and the real-time virus protection on. The Windows Security application
Remote access Turn off Remote Desktop if you do not use it. Start > Settings > System > Remote Desktop

Disk encryption makes the disk unreadable without your sign-in. Windows 11 Home has Device encryption, and BitLocker needs the Pro, Enterprise or Education edition. Keep the recovery key in the password manager, not with the computer. Microsoft documents each setting updates; device encryption; BitLocker; recovery key; screen saver; firewall; Windows Security; Remote Desktop.

Do your daily work with a standard account, which is an account without administrator rights. Microsoft calls this the recommended and more secure method Microsoft. When a program needs administrator rights, Windows asks for the password of an administrator account. An agent in the standard account cannot give that answer.

  1. Open Settings > Accounts > Other users. Select "Add account" and then "Add a user without a Microsoft account".
  2. Select the new account, select "Change account type" and make it an administrator.
  3. Sign in with the new account. Change your daily account to a standard user Microsoft.

03Separate agent work from personal data

An agent that starts in your daily account can read what that account can read. Give agent work a separate place. A separate computer or a virtual machine separates most. The two options below need no second system.

Option What the agent can reach Limit
A WSL 2 distribution with the Windows drives not mounted The Linux files of that distribution. Windows programs in your account can read the Linux files.
A separate Windows account The files and the stored sign-ins of that account. The accounts use the same Windows system.

We recommend the first option for Claude Code, because its sandbox needs WSL 2, which runs Linux in a small virtual machine. A distribution is one installed Linux system. With the default settings, WSL 2 separates nothing. It mounts each fixed Windows drive below /mnt, so drive C: is at /mnt/c. A Linux command can also start Windows programs settings; file systems.

Install one distribution that you use only for agent work. Run these commands in PowerShell.

wsl --install -d <DistroName>
wsl --list --verbose

The second command must show version 2 for the distribution Microsoft. Then open the distribution, run sudo nano /etc/wsl.conf and write this content to the file.

[automount]
enabled = false

[interop]
enabled = false
appendWindowsPath = false

The first section stops the automatic mount of the Windows drives. The second section stops the start of Windows programs from Linux. Then run wsl --shutdown in PowerShell, so that the settings apply at the next start. As a test, ls /mnt/c must show no Windows files. A user with root rights can mount a drive manually, so do not give the sudo password to the agent.

Keep all projects in one folder, for example ~/projects in the Linux file system. Start the agent only in the folder of one project, not in your user profile folder or in Downloads. An agent loads instruction files such as AGENTS.md from its start folder, and one reported attack put such a file in Downloads BleepingComputer.

Use a separate browser profile for agent work, because a profile has its own sign-ins Anthropic.

04Turn on the sandbox

A sandbox is an enclosed work area that the operating system enforces. Inside it, a command can change only the permitted folders and can connect only to the permitted websites.

Tool On native Windows In WSL 2
Claude Code No sandbox. Each command runs with your full access. A sandbox is available. It is off by default.
Codex A sandbox limits writes to the project folder and keeps the network off by default. The Linux sandbox of Codex, with the same defaults.

Thus run Claude Code in the WSL 2 distribution setup; sandboxing. First install the two programs that the sandbox needs.

sudo apt-get install bubblewrap socat

The program bubblewrap enforces the file limits. The program socat sends the network traffic to a proxy that checks each website. Then write this content to the file ~/.claude/settings.json in the distribution.

{
  "sandbox": {
    "enabled": true,
    "failIfUnavailable": true,
    "allowUnsandboxedCommands": false,
    "network": { "allowedDomains": ["github.com", "registry.npmjs.org"] },
    "filesystem": { "denyRead": ["~/.ssh", "~/.aws", "/mnt"] }
  },
  "permissions": {
    "disableBypassPermissionsMode": "disable",
    "deny": ["Read(~/.ssh/**)", "Read(~/.aws/**)", "Read(//mnt/**)", "Read(./.env)", "Read(./.env.*)"]
  }
}

The file turns the sandbox on. It stops Claude Code if the sandbox cannot start, and it forbids a second try outside the sandbox. It permits two websites and blocks the folders that hold keys. Run /sandbox in a session to see the status. Put the same file in %USERPROFILE%\.claude\settings.json on the Windows side. Claude Code then refuses to start on native Windows settings.

The sandbox has limits Claude Code.

  • File tools. The sandbox covers shell commands only. The tools that read and edit files obey the deny rules, so the example has both.
  • Helper programs. Local MCP servers (programs that give the agent more tools) and hooks (scripts that run at fixed events) run with your full access.
  • Reading. A sandboxed command can read most of the computer until a denyRead entry blocks a folder.
  • Websites. The proxy checks only the name of the website. A broad entry such as github.com can be a path for data theft.
  • Windows programs. In WSL 2, a sandboxed command can start a Windows program unless an optional filter is installed. The [interop] setting above closes this path.

On native Windows, Codex has three sandbox implementations. OpenAI recommends mxc, which needs a current build of Windows 11. The fallback elevated needs a setup that an administrator approves. The fallback unelevated has weaker network isolation, so use it last approvals; Windows sandbox.

05Use a stronger boundary for unattended work

An agent that nobody watches needs a boundary around the full agent program, not only around its shell commands Claude Code. A virtual machine is such a boundary. It is a second computer that software simulates.

Option Windows requirement What it isolates
Docker Sandboxes Windows 11 on an Intel or AMD processor, with the feature "Windows Hypervisor Platform" Each agent runs in a small virtual machine and sees only the project folder.
Windows Sandbox Pro, Enterprise or Education edition A temporary Windows desktop. Windows deletes its content when you close it. Its network is on by default.
Hyper-V virtual machine Pro or Enterprise edition A permanent second system. Keep no personal keys in it.
Cloud session Each edition The agent works on a server of the vendor.

Docker Sandboxes do not need Docker Desktop. Run these commands in PowerShell install; get started.

Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform -All
winget install -h Docker.sbx
sbx login
sbx run --name my-sandbox claude

The first command needs an administrator PowerShell. The last command starts Claude Code in a sandbox for the current folder. A proxy on the Windows side adds the access keys to the requests, so the keys do not enter the virtual machine. The project folder has write access, so review changed scripts before you run them on Windows Docker.

Microsoft gives the commands that turn on Windows Sandbox and Hyper-V Windows Sandbox; Hyper-V.

The command claude --cloud "<task>" starts a cloud session of Claude Code. Your GitHub credentials do not enter its virtual machine. Codex cloud removes the configured secrets before the agent starts Claude Code; Codex.

Do not turn off all checks outside such a boundary. The flags are --dangerously-skip-permissions in Claude Code and --yolo in Codex. Anthropic says to use this mode only in isolated environments Claude Code. In August 2025, malicious versions of the package Nx started AI coding tools with such flags, to search for keys Snyk.

06Protect keys and secrets

Assume that the agent can read each file in its work area and each variable in its shell. Thus keep secrets in places that the agent cannot read.

Keep each key in the vault of a password manager, for example 1Password. Install its command-line tool, and turn on "Integrate with 1Password CLI" in Settings > Developer 1Password.

winget install 1password-cli
op run --env-file="./node.env" -- node app.js

The file node.env holds references such as op://vault/item/field, not secrets. The command op run gets the values from the vault and gives them only to the program that it starts 1Password. Thus do not start the agent with it. Do not keep a secret in a .env file, because the deny rules do not stop a script that opens the file Claude Code.

A hardware security key, for example a YubiKey, is a small USB device that holds a sign-in secret. The secret stays inside the device, software cannot copy it, and each use needs a touch. Thus malicious software that steals passwords and key files gets no credential that works later or from a different computer. This is isolation of the credential, and not only protection against a false sign-in page. One limit stays: malicious software can use a session that is already open. Register two keys on the code host, the password manager and the mailbox.

An SSH key proves your identity to the code host. Create it on the hardware key in PowerShell.

ssh-keygen -t ed25519-sk -C "your_email@example.com"

The command creates the key when you touch the device. It needs OpenSSH for Windows 8.9 or later, and ssh -V shows the version release notes. If it fails, use the type ecdsa-sk GitHub. The key file on the disk is only a reference, and an agent that reads it cannot use it without the device. WSL 2 has no direct access to USB devices, so keep this key on the Windows side Microsoft.

Give the agent its own credential, and assume that the agent can read it. On GitHub, create a fine-grained access token for the named repositories, with an expiry date GitHub. Git for Windows stores your own sign-in in Windows Credential Manager, and Git uses it when it connects by HTTPS GitHub. An agent that runs Git in your account thus acts with your full rights.

07Control what the agent installs and loads

An agent installs packages when a task needs them. In 2026, malicious versions of the packages TanStack and LiteLLM were online for some hours before their removal TanStack. A waiting period tells the package manager to ignore a version that is too new npm; pnpm; uv.

Tool Setting Meaning
npm min-release-age=7 in the file .npmrc npm installs only versions that are a minimum of 7 days old.
pnpm minimumReleaseAge: 1440 in the file pnpm-workspace.yaml The value is in minutes, and 1440 is the documented default.
uv exclude-newer = "1 week" in the file uv.toml uv ignores versions that are less than one week old.

Write one exact version in the start command of each local MCP server, so that a later start cannot load a new version. Claude Code asks for approval before it uses a server from the project file .mcp.json Claude Code. Read the entry before you approve.

The files CLAUDE.md, AGENTS.md and .mcp.json and the folder .claude/ steer the agent, and some of them can start programs. Read them before you start an agent in a repository of other people.

An editor extension is also code with your rights. Microsoft states that an extension has the same permissions as VS Code VS Code. Install few extensions, and check the publisher of each one.

08Settings for a team

A settings file in the repository or in the user profile is only a default, because each developer can change it. Managed settings are settings of the organisation that a user file cannot override. Claude Code has three methods on Windows managed settings; console.

Method Where Note
Organisation console Organization settings > Claude Code > Managed settings, on Claude Team and Enterprise Each client gets the settings at the start and then each hour. No device management is necessary.
Managed settings file C:\Program Files\ClaudeCode\managed-settings.json. In WSL 2: /etc/claude-code/managed-settings.json Claude Code does not read the old folder C:\ProgramData\ClaudeCode.
Registry value Value Settings in HKLM\SOFTWARE\Policies\ClaudeCode Device management such as Microsoft Intune or Group Policy can send it.

Put the sandbox block of this guide in the managed settings. Add allowManagedPermissionRulesOnly and allowManagedMcpServersOnly, so that only the rules and the MCP servers of the organisation apply. A developer with administrator rights can edit a local managed file, and in WSL 2 the user can write to /etc/claude-code. Thus keep the standard account, and use the console method for WSL 2.

Codex has the same function in the file %ProgramData%\OpenAI\Codex\requirements.toml. This example permits two profiles and denies the profile with full access Codex.

[allowed_permission_profiles]
":read-only" = true
":workspace" = true

09Things to avoid

  • Do not run an agent in your daily Windows account with no sandbox.
  • Do not use WSL 2 with the default settings as a separation.
  • Do not keep secrets in .env files, in shell variables or in a prompt.
  • Do not give the agent your own token or your stored Git sign-in.
  • Do not start an agent in the user profile folder or in Downloads.
  • Do not approve an administrator prompt that you did not cause.

10If something suspicious occurs

Do these steps in order if the agent runs an unexpected command or an account reports an unknown sign-in.

  1. Stop the agent. Close the terminal. To stop a distribution, run wsl --terminate <DistroName> in PowerShell.
  2. Disconnect the computer from the network. Do not delete files or logs.
  3. Continue on a different, clean device. In a team, tell the person who is responsible for security.
  4. Cancel the access. Cancel the token of the agent. End all sessions on the code host, the AI provider, the password manager and the mailbox.
  5. Replace each secret that the agent could reach. A secret on a hardware key was not copied, but check the list of registered keys.
  6. Examine the repositories. Look for changes to instruction files, git hooks and build scripts.
  7. Rebuild before you continue. The command wsl --unregister <DistroName> deletes a distribution with all its data Microsoft. If the Windows account was affected, install Windows again.

11Monthly self-check

  • Windows and the agent tools have all updates.
  • Disk encryption is on, and the recovery key is in the password manager.
  • The firewall is on, and Remote Desktop is off.
  • The daily account is a standard account.
  • In the agent distribution, ls /mnt/c shows no Windows files.
  • /sandbox in Claude Code shows that the sandbox is on.
  • The list of permitted websites has only necessary entries.
  • No .env file in the projects folder holds a secret.
  • The token of the agent has an expiry date and the minimum rights.
  • The code host shows no unknown SSH key, token or session.

12Sources