NaviGator AI

Operate coding agents safely

Verify, supervise, interrupt and recover coding-agent sessions in OpenCode and pi

A coding agent can read files, edit them and run commands on your behalf. The model decides which tool to request, but you remain responsible for what runs and what changes.

This page covers the controls that apply to every session: the layers that limit an agent, a repeatable operating loop and what isolation does and does not protect. Tool-specific setup lives in Install and configure OpenCode, OpenCode Desktop and pi.

Use three layers of control

LayerWhat it doesWhat it does not do
PromptCommunicates the task, allowed scope and stop conditionsPrevent a model from misunderstanding or disregarding instructions
Application tool controlsAllow, ask for approval or deny specific model toolsIsolate the application process, loaded configuration or account permissions
Operating-system isolationRestricts reachable files, processes, credentials and networksMake generated code correct or approve its consequences

For a project you did not write, start with an enforceable tool allowlist that excludes write and shell tools. Add a reviewed sandbox, virtual machine or managed development host when the repository, generated commands or level of autonomy requires stronger isolation.

A safety rule that exists only in a prompt is a request, not a control.

Before the agent acts

  • Classify the task. Note whether it affects production, authentication, infrastructure, billing, regulated data or customer communication.
  • Check the data. Confirm the model is approved for the data classification of everything the agent can read.
  • Choose the environment. Use a feature branch in a reviewed sandbox, virtual machine or development environment. Keep production credentials out of reach.
  • Set the boundary. Decide whether the agent may inspect, edit, run tests, commit, push or deploy. Enforce read-only sessions for unfamiliar projects.
  • Define stop points. Require confirmation before destructive, irreversible, expensive or externally visible actions.
  • Plan recovery. Know how to restore files and stop agent-created processes before work begins.

Use the operating loop

Apply these steps after installation and before every bounded change.

Verify the project and model

Confirm the working directory, Git branch, provider and selected model before entering a request.

  • OpenCode Terminal: Check the footer and composer. Use /models to inspect or change the model.
  • OpenCode Desktop: Check the selected project and model in the project session.
  • pi: Check the footer. Use /model or Ctrl+L to inspect or change the model.

Stop if the project, branch, provider or model is not what you expect. Then send this read-only verification request:

Do not edit files or run commands that change the environment.
Read the project instructions and identify the current branch, main source
folder and documented validation commands. Cite the files used, then stop.

Confirm the cited files and commands yourself.

Inspect loaded context and instructions

Read project instruction files with trusted tools before startup, then check what the application loaded:

  • OpenCode Terminal: Run opencode debug config --pure outside the session to inspect resolved configuration and opencode debug agent <name> to inspect an agent's tools.
  • OpenCode Desktop: Use the Context tab to inspect context categories, messages and the system prompt when the provider makes it available.
  • pi: Press Ctrl+O to expand loaded resource details. Use /session for session metadata.

Project instructions influence model behavior. They do not override your review or create a permission boundary.

Review tool calls and results

Keep tool details visible:

  • OpenCode Terminal: Use /details or the command palette to show tool execution details.
  • OpenCode Desktop: Expand tool entries in the timeline and inspect the changed-file review.
  • pi: Press Ctrl+O to expand tool output.

Read the requested path, command and result. A familiar tool name can still target an unsafe path or external system.

Apply the application's permission behavior

OpenCode can ask before configured actions. For a bounded task, choose Once rather than Always after confirming the exact action. Deny requests outside the agreed scope.

The pi application has no per-tool or per-command approval prompt. Use --tools to withhold bash, edit and write at launch, then start a new process with more tools only after deciding to allow changes. Once pi has the bash tool, it can run any command available to the process.

A command you type yourself is still your action. Review it independently.

Interrupt when assumptions fail

  • OpenCode Terminal: Press Escape. The interface can require a second press to confirm.
  • OpenCode Desktop: Select Stop or press Escape while the session is working.
  • pi: Press Escape to abort streaming or a running Bash action.

Interrupt before answering a permission prompt when the request shows that scope, data or environment assumptions are wrong.

Recover a reviewed edit

OpenCode /undo reverts the previous message and its tracked file changes, and /redo restores them. OpenCode Desktop exposes the same session command. These controls depend on Git and OpenCode snapshot tracking, so inspect git status and the diff before and after using them.

The pi application has no built-in workspace undo. Its /tree, /fork and /clone commands affect the conversation, not your files. Restore from Git in a trusted terminal:

git status --short
git diff -- path/to/known-file
git restore -- path/to/known-file

Restore a path only when every change in it is disposable. Avoid broad cleanup commands.

Separate planning from enforced read-only operation

OpenCode Plan and Build are agent behaviors. Plan asks before edits and Bash by default, but it is not an enforceable read-only boundary. Apply a strict permission profile when changes must be denied.

The pi application has no Plan mode. Launch a read-only process with --tools read,grep,find,ls, then start a new process with edit,write only after deciding to allow changes.

Start fresh when context stops helping

Use /new in OpenCode Terminal, OpenCode Desktop or pi to start a new session. Carry forward a short summary of decisions rather than a long exploratory conversation.

A new conversation does not reset files, revoke credentials or change permissions.

Open an unfamiliar project

A coding agent loads some project files as soon as it starts, before you type anything. A read-only prompt or permission profile begins too late to control that.

  • OpenCode has no project-trust prompt. At startup it loads opencode.json, plugins and commands from .opencode/ and instructions such as AGENTS.md. It can also install dependencies declared in .opencode/package.json.
  • pi asks whether to trust a project before loading its settings, skills and extensions. It always loads context files such as AGENTS.md.

Before opening code you did not write:

  1. Inspect opencode.json, opencode.jsonc, .opencode/, .pi/, .agents/, AGENTS.md, CLAUDE.md, package manifests and scripts with your own tools.
  2. Put the read-only OpenCode profile in your global configuration, or start pi with only its reading tools.
  3. If you cannot review the project safely on your computer, open it only in an isolated environment.

For a first look at an unfamiliar but authorized repository, OpenCode 1.x can skip project configuration and plugins for one run:

OPENCODE_DISABLE_PROJECT_CONFIG=1 opencode --pure path/to/project

OPENCODE_DISABLE_PROJECT_CONFIG is not in OpenCode's public reference, so test it after each upgrade. If it no longer works, use isolation instead.

For pi, decline project trust and start with reading tools only:

pi --no-approve --no-extensions --no-skills --no-prompt-templates --tools read,grep,find,ls

These controls do not restrict file access, child processes, credentials or networks. Stop the agent after the first inspection and decide separately whether to trust the project.

Isolate the process

A sandbox, virtual machine or managed development host limits what the whole application process can reach. Docker Sandboxes provides this for OpenCode and pi.

Isolation does not protect everything:

  • Writable project files. A shared read-write workspace can still be changed or deleted, and changes appear on the host. Keep using Git and a feature branch.
  • Readable information. A read-only mount prevents changes, not disclosure. Readable content can still be sent to a model or service when the network allows it.
  • Permitted credentials. A sandbox can still make authenticated requests with any credential or proxy it can use. Scope credentials to the task.
  • Incorrect output. Isolation does not prevent prompt injection, invented dependencies, weakened tests or vulnerable code.

If no approved isolated environment is available, limit the session to reading and configuration review. Ask your unit IT or security contact rather than weakening controls to make an agent run.

Treat external content as untrusted

Files, issues, web pages, dependency output and tool results can contain text written to manipulate the agent, such as "ignore previous instructions." This is prompt injection.

  • Review what a tool returned before acting on it.
  • Keep the ability to make changes separate from the ability to read.
  • Require approval for actions with external effects.
  • Be more cautious with content from sources you do not control.

A model cannot reliably tell your instructions from instructions embedded in content it reads. Permissions and review have to enforce the boundary. The same risk applies to content returned by connected tools and MCP servers.

Keep external actions separate

Permission to edit files is not permission to commit, push, open a merge request, publish a package, change infrastructure or deploy. Make each of those a separate, explicit decision after reviewing the change.

Stop and ask for help when

  • the agent requests credentials, production access or data you did not plan to share
  • the task turns out to involve Sensitive or Restricted data
  • the agent proposes deleting or overwriting work you cannot restore
  • you cannot explain what a proposed command does
  • the isolation or credential path you need is not approved

For administrators: managed configuration and pinned versions

OpenCode configuration precedence

OpenCode merges configuration sources. Later sources override earlier values only when keys conflict. In OpenCode 1.x the order is:

  1. Remote organization defaults: provider .well-known/opencode configuration
  2. Global user configuration: ~/.config/opencode/opencode.json or opencode.jsonc
  3. Custom configuration file: the path in OPENCODE_CONFIG
  4. Project configuration: opencode.json or opencode.jsonc from the working directory toward the Git root
  5. Resource directories: global and project .opencode/ folders, plus OPENCODE_CONFIG_DIR
  6. Inline configuration: JSON in OPENCODE_CONFIG_CONTENT
  7. Managed configuration files: the platform folders below
  8. macOS managed preferences: the ai.opencode.managed preference domain
PlatformManaged configuration folder
macOS/Library/Application Support/opencode/
Linux/etc/opencode/
Windows%ProgramData%\opencode

Check the resolved result with opencode debug config --pure. Managed configuration is not a sandbox and does not make project plugins safe. Never put credentials in custom or inline configuration.

Pin a version

Pin exact versions when documented controls, permission behavior or audited workflows must stay reproducible:

npm install -g opencode-ai@<approved-version>
npm install -g --ignore-scripts @earendil-works/pi-coding-agent@<approved-version>
opencode --version
pi --version
node --version

After an upgrade, recheck startup controls, resolved permissions, model settings and pi's Windows Bash resolution before using the tools in a documented workflow.

On this page