The Deska blog

Safe Defaults for Running Agents: A Defensive Checklist

Learn how to implement safe defaults for running agents in your development workflow. A technical checklist for sandbox security and autonomous execution.

· 9 min read

Developing with autonomous AI entities requires a shift from traditional tool usage to a security first mindset. When you grant a large language model access to your file system and terminal, you are essentially providing a high speed path for both productivity and potential system corruption. Establishing safe defaults for running agents is the only way to ensure that an hallucination or an injection attack does not lead to catastrophic data loss. This checklist focuses on practical, technical configurations that every developer should implement before letting an agent execute commands locally.

The Risks of Unconstrained Execution

Autonomous agents like Claude Code or OpenCode operate by generating and executing shell commands. While this enables them to solve complex refactoring tasks, it also creates an environment where a single misunderstood instruction can lead to unintended consequences.

The primary risks include recursive file deletions, accidental exposure of environment variables, and the execution of malicious code pulled from external documentation. Unlike a human developer who might pause before running a destructive command, an agent follows its internal logic at a speed that makes manual intervention difficult without the right architectural guardrails.

Environment Isolation and Sandboxing

The most effective way to maintain safe defaults for running agents is to limit their reach through OS level isolation. You should never run an agent with root privileges or in a directory that contains sensitive personal data outside the project scope.

File System Scoping

Restrict the agent to a specific project directory. If the tool allows it, use a containerized environment like Docker to wrap the entire execution process. This ensures that even if the agent attempts to access /etc or your home directory, the operation will fail at the system level.

Permission Limits

  1. Use a dedicated user account for agent tasks.
  2. Disable write access to sensitive configuration files like .ssh/config or .bashrc.
  3. Limit the agent to specific binaries. There is rarely a reason for a coding agent to use curl or wget to pull external scripts unless specifically instructed.

Human in the Loop Validation

Automation is the goal, but blind automation is a liability. A robust defense involves creating checkpoints where a human must approve high risk actions.

Command Approval Strategies

Many CLI based agents offer a "y/n" prompt for every command. While this can be tedious, it is a critical safety default. You can optimize this by categorize actions. For example, read operations might be auto approved, while write or delete operations require a manual keystroke.

In a visual workspace like Deska, you can run multiple coding agents side by side. This allows you to compare how different models approach the same task. If one agent proposes a risky rm -rf while another suggests a targeted git rm, the discrepancy serves as a manual red flag.

Terminal Monitoring

Always keep a live view of the terminals where the agent is active. Avoid running agents in background processes where their output is piped to a hidden log file. Real time visibility allows you to kill a process the moment you see a suspicious command sequence.

Secure Secret Management

Agents often need access to API keys or database credentials to run tests or deploy code. Hardcoding these in environment variables that the agent can read via env or printenv is a significant security flaw.

  • Use a .env.example file to show the agent the required structure without providing the values.
  • Inject secrets only at the moment of execution through a secure vault.
  • Configure your .gitignore to be strictly respected by the agent to prevent it from accidentally uploading secrets to a repository.

Leveraging Local First Architectures

The infrastructure where the agent runs matters as much as the code it writes. Using a local-first approach ensures that your source code and session data never leave your hardware. When using tools like Deska, the data and storage remain on your machine, reducing the surface area for data leaks.

Security FeatureStandard CLILocal First Workspace
File PrivacyHigh (Local)High (Local)
Multi Agent ViewSequentialSide by side panels
Remote AccessRequires SSH/VPNSecure Relay (No ports)
History TrackingManual LogsPersistent threads

Monitoring and Remote Oversight

If you must leave an agent running a long task, you need a way to monitor it without being tethered to your desk. Using a mobile application to check in on the workspace allows you to pause execution if you notice the agent has entered an infinite loop or is producing unexpected errors. This remote oversight should use a secure relay to ensure that you are not exposing your local network to the open internet.

AI Security FAQ

How do I prevent agents from deleting files?

The best approach is to initialize a Git repository before starting the agent. Use a safe default of committing all changes immediately. If the agent deletes something, you can perform a hard reset. Additionally, configure your environment to use alias rm='rm -i' to force an interactive prompt for deletions.

Should I give agents internet access?

Limit internet access to the browser widgets or specific documentation sites. A coding agent generally does not need general outbound access to the web to write logic. Disabling networking for the agent process prevents it from exfiltrating data to a third party server.

Are managed inference services safer than BYOK?

Managed services handle the infrastructure for you, but BYOK (Bring Your Own Key) gives you direct control over your usage limits and costs. In terms of agent safety, the primary concern is the permissions granted to the agent on your local machine, regardless of where the model is hosted.

Implement Safer Workflows Today

Securing your agent environment is an ongoing process of refinement. Start by downloading a tool that supports these defensive patterns by design. You can download the Deska app for Mac, Windows, and Linux to begin building your isolated, multi agent workspace. By combining local execution with clear visual boundaries, you create a development environment that is both powerful and protected.

💡 Ideas+🐛 BugsSuggest a feature or report a bug