Skip to content

[FEATURE]: First-class tmpDir config — auto-create and pre-allow a scratch directory #28173

Closed as not planned

Description

@ptandler

Problem

When OpenCode needs to use a temporary directory outside the workspace (e.g. for
intermediate files, scratch work, or agent plans), it currently triggers an
external_directory permission prompt every time — even for a well-known, safe
scratch path like /tmp/opencode.

The workaround is to manually add an external_directory rule in opencode.json,
but this is not obvious, requires knowing the exact path in advance, and the
directory must be created separately.

Proposed Solution

Add a first-class tmpDir config key in opencode.json:

{
  "tmpDir": "/tmp/opencode"
}

Behavior:

  • OpenCode auto-creates the directory on startup if it does not exist
  • All tool access to this directory is implicitly allowed (no external_directory
    prompt) — equivalent to setting external_directory: { "<tmpDir>/**": "allow" }
  • Default value: /tmp/opencode (or a platform-appropriate equivalent)
  • Users/teams can override it to a project-local path if preferred

Why Not Just Use external_directory?

The current external_directory config works but requires manual setup, prior
knowledge of the path, and does not auto-create the directory. A dedicated
tmpDir key makes the common case ergonomic and self-documenting.

Related

Activity

  1. github-actions commented on May 18, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. ptandler commented on May 18, 2026

    @ptandler
    Author

    This issue might be a duplicate of existing issues. Please check:

    this is related: I'd like to set opencode's tmp to /tmp/opencode it should not interfere with other tmp files.

  3. ptandler commented on May 20, 2026

    @ptandler
    Author

    it happens really several times daily that opencode asks for permission to tmp and it takes some time until I noticed that it stopped working and is waiting for a permission. I could allow tmp access in general, but actually I'd like to avoid unrestricted access to the whole /tmp

  4. rekram1-node commented on May 21, 2026

    @rekram1-node
    Contributor

    What version are u on? It should already do this

  5. ptandler commented on May 26, 2026

    @ptandler
    Author

    What version are u on? It should already do this

    currently 1.15.10

    I'm sure in the morning, one session asked again for permission to /tmp/. Do I need to configure something?

  6. rekram1-node commented on May 26, 2026

    @rekram1-node
    Contributor

    what model are u using, the agent is instructed to create things in $TMPDIR/opencode/* if it needs tmp access and htat dir is whitelisted

  7. ptandler commented on May 27, 2026

    @ptandler
    Author

    what model are u using, the agent is instructed to create things in $TMPDIR/opencode/* if it needs tmp access and htat dir is whitelisted

    I usually use Claude Sonnet 4.6 (via Copilot subscription)

    in my config I now white-listed the complete /tmp for now

  8. ptandler commented on Jun 15, 2026

    @ptandler
    Author

    In case there is an update here, I'd gladly remove the /tmp whitelisting again

  9. github-actions commented on Aug 15, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  10. zatricky commented on Sep 15, 2026

    @zatricky

    My workaround based on the comments here is to set an alias in my shell config: alias opencode=TMPDIR=${XDG_RUNTIME_DIR} opencode

    I'm surprised that isn't already the default since raw $TMPDIR is an obsolete place to put user-specific files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions