anomalyco / anomalyco/opencode

[FEATURE]:Add a deterministic bare mode for isolated `opencode run` executions

Open
#43,227 1 comment 1 reaction 1 assignee View on GitHub

@neriousy is already working on this.

Since Aug 18, 2026.

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

Description

Feature hasn't been suggested before.
  • I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request

Summary

Add an opt-in --bare flag to opencode run for automation that must not inherit implicit user or project configuration:

opencode run --bare --model provider/model "review this change"

--bare would start a new local, non-interactive run using only explicitly supplied configuration and non-bypassable organization/managed policy. It would skip automatic configuration discovery and external startup integrations before they can read files, fetch configuration, install dependencies, or execute plugin code.

This is a configuration and startup isolation mode. It is not a filesystem sandbox, an offline mode, or a guarantee that model output is reproducible.

Problem

opencode run is useful in CI jobs, evaluation harnesses, editor integrations, and other subprocess-based automation. However, its result currently depends on ambient machine state even when the caller supplies OPENCODE_CONFIG or OPENCODE_CONFIG_CONTENT.

Depending on the host, a run may automatically inherit or discover:

  • global and parent/project opencode.json(c) files;
  • .opencode commands, agents, plugins, and skills;
  • compatibility resources such as .claude skills and instruction files;
  • global/project AGENTS.md, CLAUDE.md, or nearby instructions;
  • well-known remote configuration;
  • external plugins and their dependency installation;
  • LSP startup and downloads.

This makes the same command behave differently across developer machines and CI runners. It also means that evaluating an untrusted repository can execute or ingest locally discovered configuration before the automation has a chance to constrain it. Combining existing environment flags does not provide one complete, instance-scoped contract and can produce partial behavior, especially for explicitly supplied instructions.

Proposed behavior

CLI scope

The first version should apply only to a new local non-interactive run:

opencode run --bare [other run options] "message"

It should reject these combinations before loading an instance or configuration:

  • --bare --attach
  • --bare --continue
  • --bare --session
  • --bare --fork
  • --bare --interactive

--model, --agent, --command, --file, and --format json should keep their existing semantics when their inputs are available from an allowed source.

Configuration source contract

In bare mode, OpenCode should:

Load:

  • OPENCODE_CONFIG, because it is an explicit file selected by the caller;
  • OPENCODE_CONFIG_CONTENT, because it is explicit inline configuration;
  • current Console organization configuration and managed configuration/policies, so --bare cannot bypass administrator restrictions;
  • normal authentication records needed by explicitly selected providers, without using those records to fetch implicit well-known configuration.

Skip:

  • well-known remote configuration discovery/fetching;
  • user-global config files;
  • upward project config discovery;
  • global, project, and OPENCODE_CONFIG_DIR extension-directory discovery.

Managed configuration must retain its current final precedence over explicit configuration.

Startup and discovery contract

Before side effects occur, bare mode should also disable:

  • installation of configuration-directory dependencies;
  • discovery/import/execution of external plugins;
  • discovery or download of external skills, including configured skill paths and URLs;
  • automatically discovered global, project, compatibility, and nearby instruction files;
  • eager or lazy automatic LSP server startup/downloads.

Internal plugins and built-in skills required for normal OpenCode operation should remain available. Explicit instructions present in the final allowed configuration should continue to work, including their existing local-file or URL semantics. Explicit MCP configuration should retain its existing behavior; bare mode is not an offline mode.

Instance isolation

The startup policy should be instance-scoped rather than implemented by temporarily mutating process-wide environment flags. A normal and a bare instance for the same directory must not share configuration, plugin, skill, instruction, or LSP state through the instance cache.

Running without --bare must remain fully backward compatible.

Observability

At debug level, the run should expose a stable summary of loaded, skipped, and disabled source categories. The summary must not include tokens, headers, complete configuration values, or instruction contents, and it must not pollute --format json stdout.

Example use cases

CI or evaluation harness
OPENCODE_CONFIG_CONTENT='{"model":"provider/model"}' \
  opencode run --bare --format json "analyze this repository"

The result should not depend on the CI account's global agents, plugins, skills, MCP definitions, or instruction files, nor on project configuration found by walking parent directories.

Explicit reusable configuration
OPENCODE_CONFIG=/opt/my-runner/opencode.json \
  opencode run --bare "implement the requested change"

The selected file and its explicit instructions/providers should load, while unrelated global/project discovery remains disabled.

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.