Use a Sandbox First
Run agent-generated code in isolation before it touches your main project. A cheap container beats a broken production environment.
Agent-generated code should run somewhere harmless before it runs somewhere important. A sandbox, a throwaway branch, a container, or a cloud VM — pick your isolation layer, but always use one.
Agents can generate code that:
- Deletes files
- Makes irreversible API calls
- Consumes expensive resources
- Changes system configuration
- Opens network connections
You do not want any of that happening in your main working directory or production account by surprise.
| Option | Best for | Effort |
|---|---|---|
| Git branch | Code changes that need review | Low |
| Docker container | Code with dependencies or side effects | Medium |
| Cloud VM / Codespace | Long-running or resource-heavy tasks | Medium |
| Virtual environment | Python/Node projects | Low |
| Browser sandbox | Agent-driven web actions | Low |
For most coding agents:
- Create a feature branch:
git checkout -b agent/short-description - Run the agent on that branch.
- Review the diff before leaving the branch.
- Run tests in a clean environment.
- Merge only after review.
- Production credentials. Use scoped test keys.
- Databases. Point to a staging or throwaway instance.
- File system. Restrict write access to the working directory.
- Network. Block egress except to known test endpoints.
- Cost. Cap API usage and compute budgets.
If setting up a sandbox takes less than 5 minutes and could prevent a serious mistake, do it. The time you spend is cheaper than the time you spend recovering.
If you cannot isolate fully, at least:
- Make a commit or snapshot before running the agent.
- Read the diff before applying it.
- Avoid destructive commands (
rm,drop,delete). - Run with minimal permissions.
Set up one reusable sandbox environment for your most common agent task. Use it every time. The habit is the safety net.