anomalyco / anomalyco/opencode

external_directory does not fire for many bash commands that write outside the project

Open
#40,159 1 comment 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 2, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

The docs say external_directory is "triggered when a tool touches paths outside the project working directory". The file tools do that on every call, but the bash tool only checks a short list of command names, so anything outside that list writes outside the project silently.

Separately, any argument containing a $ is discarded before it can be resolved, so even a command that is on the list gets skipped when the path is written with a variable.

This happens with the default config, since external_directory defaults to "ask", so no opt-in is needed to hit it.

Plugins

None

OpenCode version

1.18.11

Steps to reproduce
  1. Open any project.
  2. Ask the agent to run: echo test | tee ~/opencode-external-test
    No prompt appears and the file is created in your home directory.
  3. For contrast, ask it to run: cp ./README.md ~/opencode-external-test2
    This one does prompt, because cp is on the list.
  4. Now the $ case. Ask it to run: rm $HOME/opencode-external-test
    No prompt, even though rm is on the list.
  5. For contrast, run the same path written literally: rm /home//opencode-external-test
    This one does prompt.
Screenshot and/or share link

No response

Operating System

Ubuntu 26.04

Terminal

GNOME Terminal (Ubuntu default)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.