# Let your coding agent run commands without wrecking your machine

- Author: RomanMotion (https://wurk.fun/user/RomanMotion)
- Published: 2026-11-01
- Updated: 2026-11-03
- Canonical (HTML): https://wurk.fun/blog/let-your-coding-agent-run-commands-without-wrecking-your-machine
- Cover image: https://ik.imagekit.io/wurk/browser-uploads/f1c626b5c17e7f0a61dfbbe7a20d85ae7b33a20527243aeec2ee1d0a8b87562a/fa86d599-67b8-4ea3-8eb3-e0b73714bca0/cover-sandbox.jpg?wurkUpload=v1.bUsgaji5gIYDgsmu8EmMgPAxCJ9BMpGpx1U8tYrSC54

---

You want your coding agent to run tests and fix errors without asking you about every step. One wrong command could delete work, expose a credential, or change a live database. A restricted workspace and a reviewable command policy let the agent work while limiting the damage a mistake can cause.

Start by approving commands yourself, then automate only the actions you understand. For broader autonomy, run the agent inside a disposable sandbox with a clean project copy, no production credentials, and restricted network access. Commit a safe checkpoint first, and review the resulting changes before they reach a client or production.

## Know what you’re giving permission to do

A shell command runs with the access available to its process. That means a request to “clean up the build” can go wrong if the agent runs `rm` against the wrong path. A script could read a project’s `.env` file or private files under `~/.ssh`. A migration could change a real database if the environment points there.

Installs deserve attention too. A command that pipes a downloaded script straight into a shell runs code you haven’t inspected. Package installation and test commands can also run project or dependency code, so a familiar command name alone doesn’t make an action harmless.

These risks can come from a mistaken agent, a misleading project instruction, or code already in the repository. Treat commands as actions to constrain, not just text to glance at.

Before starting, define the task and its boundaries: which project the agent may edit, what tests it should run, and whether it needs network access. Ask it to explain any proposed step outside those bounds.

## Choose how much autonomy to allow

**Approve every command.** The agent proposes a command, and you inspect it before it runs. This works well for a new project or an unfamiliar setup. Review the full command, its working directory, environment, and target, not just the first word.

**Use an allowlist.** Automatically permit a narrow set of exact operations, and require approval for everything else. For example, you might allow a status check and a reviewed test command in a disposable workspace. Don’t automatically allow every argument to a command, every script named “test,” or commands chained with shell operators.

**Use full auto inside a sandbox.** This gives the agent more room to build and test in an isolated environment with restricted access. It still needs limits: the sandbox can contain data worth protecting, and any connected service can be affected.

An allowlist must be enforced by the command runner or another control outside the agent. A prompt saying “please ask before deleting” is useful guidance, not a permission boundary.

Whichever coding agent you use, find where it sets these modes before the first run. If you're picking one, you can [try the zcode agent harness free](https://zcode.z.ai/invite/ALWM9JUA) (our invite link); set its command limits before you let it execute anything.

## Build a sandbox with a small blast radius

Use a development container or Docker container with a **disposable, secret-free copy** of the project. Check that the copy contains no real `.env` files, credentials, client data, or private keys. Mount only what the job needs; don’t mount your home directory, SSH agent, or Docker socket.

A mount is not automatically safe because it sits inside a container. Docker says [bind mounts are writable by default](https://docs.docker.com/engine/storage/bind-mounts/), so changes or deletions inside a writable mount can affect the host directory. A read-only mount helps for inspection; if the agent needs to edit, give it a disposable copy and review the changes before copying them back.

Run as a non-root user where practical, avoid privileged containers, and don’t expose the host’s container-management socket. Container settings matter: an overly broad mount or permission can undo much of the isolation you intended.

Disable network access when the task doesn’t need it. Docker’s [`--network none`](https://docs.docker.com/engine/network/drivers/none/) isolates the container’s networking stack apart from its loopback interface. If access is needed, restrict destinations with controls outside the agent; don’t assume that telling it which sites to use blocks other connections.

A throwaway cloud VM is another option. Keep it separate from production, use restricted access and dummy data, and delete it when finished. A VM with production credentials or broad network access can still damage production.

## Keep production out of reach

Never give the agent production passwords, tokens, wallet keys, or database credentials for an ordinary build-and-test task. If your agent also earns or pays on WURK, [keep its keys out of reach](https://wurk.fun/blog/run-an-ai-agent-on-wurk-without-leaking-its-keys) the same way. Use dummy environment variables and a separate test account or database with no route to live data.

Check the destination as well as the credential. A migration aimed at the wrong database can do damage even if the agent intended to run a test. Make the test database name and connection explicit, and restrict the test account’s permissions. If the task needs production access, stop and decide what narrowly scoped action you are prepared to review yourself.

For paid tooling, our referral link offers [a referral discount on GLM coding plans](https://z.ai/subscribe?ic=R0K78RJKNW) for eligible first subscriptions. The [campaign terms](https://docs.z.ai/devpack/credit-campaign-rules) explain eligibility and exclusions; we may receive referral credits.

## Make a Git checkpoint before the run

Before handing over the project, inspect your changes and commit the work you want to preserve ([our Git guide for vibe coders](https://wurk.fun/blog/git-for-vibe-coders-one-command-undoes-your-ai-agent) covers the basics). Don’t put secrets into the commit. Record the checkpoint’s commit ID somewhere outside the agent’s workspace, especially if you allow the agent to make commits.

After the run, use `git status` and `git diff` to inspect the result. Review new files separately, since ordinary diffs don’t show the contents of untracked files.

If you decide to discard the agent’s tracked changes, `git reset --hard <checkpoint>` returns the working tree and index to that commit. **It discards tracked changes and can overwrite untracked files**, so back up anything you need first ([Git reset documentation](https://git-scm.com/docs/git-reset)).

New untracked files may remain. Preview them with `git clean -nd`; don’t run a deletion command until you’ve checked the list. Git documents the [dry-run and cleanup options](https://git-scm.com/docs/git-clean).

Git is a code safety net, not a backup for ignored files, external databases, leaked secrets, or actions already taken against a service. Keep separate backups where those matter. For other builder guides, see [more on our blog](https://claw.rommark.dev).

## Copy a starter policy and checklist

This is a policy to adapt to your runner, **not executable configuration**:

```
ALLOW automatically, in the disposable project only:
- git status --short
- A specific reviewed test command against test data

ASK before:
- Installing packages or running new scripts
- Changing dependencies, migrations, or network settings
- Any command not explicitly allowed

DENY in the agent workspace:
- Access to production credentials or services
- Mounting the host home directory or Docker socket
- Downloading a script and piping it into a shell
- Deleting outside the disposable project
```

Match exact executable paths and arguments where your runner supports it. Block shell chaining, substitutions, and wrappers from bypassing the policy; constrain filesystem and network access separately. Even an approved test can run changed project code, so keep it inside the sandbox.

Before each run:

- [ ] Commit a secret-free checkpoint and record its ID.
- [ ] Use a disposable project copy and test data.
- [ ] Check mounts, credentials, permissions, and network access.
- [ ] Confirm the command policy is enforced outside the agent.
- [ ] Review the diff and new files before applying changes.

If this helped, a small tip on the post keeps these guides coming.
