> For the complete documentation index, see [llms.txt](https://docs.tabnine.com/main/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tabnine.com/main/getting-started/tabnine-plugin-for-opencode/scripts-and-ci.md).

# Scripts and CI

Run `tabnine` non-interactively in scripts, pipelines, and CI jobs. There's no separate CLI to install for headless use: the same `tabnine` command drives interactive and non-interactive runs.

### Authenticate with a token

Create a Tabnine Personal Access Token (PAT), store it in your CI secret store, then expose it as the `TABNINE_TOKEN` environment variable. With `TABNINE_TOKEN` set, the agent behaves the same as a signed-in user, with no browser interaction. An environment token takes precedence over any prior interactive sign-in on the machine and overwrites it.

For the full list of authentication environment variables, see [Signing In and Working with Models](/main/getting-started/tabnine-plugin-for-opencode/sign-in-and-models.md).

### Run a prompt non-interactively

Use the [`run`](https://opencode.ai/docs/cli/) command with your prompt as the argument:

```bash
TABNINE_TOKEN=<your-pat> tabnine run "Summarize the TODO comments in this repository"
```

To pick a specific model and get machine-readable output:

```bash
TABNINE_TOKEN=<your-pat> tabnine run --model tabnine/claude-4-5-sonnet --format json "List the public functions in src/"
```

* `--model tabnine/<key>`: run with a specific Tabnine-served model. See [Signing In and Working with Models](/main/getting-started/tabnine-plugin-for-opencode/sign-in-and-models.md) for model keys and default-model configuration.
* `--format default|json`: choose the output format. Use `json` for machine-readable output.

### Other `run` flags

`run` also accepts the flags below (descriptions as printed by `--help`), with the most script-relevant first:

| Flag               | Description                                                                |
| ------------------ | -------------------------------------------------------------------------- |
| `--continue`, `-c` | continue the last session                                                  |
| `--session`, `-s`  | session id to continue                                                     |
| `--fork`           | fork the session before continuing (requires --continue or --session)      |
| `--file`, `-f`     | file(s) to attach to message                                               |
| `--agent`          | agent to use                                                               |
| `--title`          | title for the session (uses truncated prompt if no value provided)         |
| `--share`          | share the session                                                          |
| `--command`        | the command to run, use message for args                                   |
| `--attach`         | attach to a running opencode server (e.g., <http://localhost:4096>)        |
| `--username`, `-u` | basic auth username (defaults to OPENCODE\_SERVER\_USERNAME or 'opencode') |
| `--password`, `-p` | basic auth password (defaults to OPENCODE\_SERVER\_PASSWORD)               |

**opencode reference:** `run` and its flags are standard opencode features; see the opencode [CLI docs](https://opencode.ai/docs/cli/) and [Commands docs](https://opencode.ai/docs/commands/).

### What still applies in headless runs

Everything your organization governs in interactive sessions also governs `run` mode: agent guidelines, tool approvals, MCP governance, code-attribution checks, and quota and license limits all still apply.

{% hint style="info" %}
**Ask-first tools block in headless runs.** When there's no UI, opencode automatically **rejects** any permission prompt. So if your organization sets a tool class, such as running commands or editing files, to ask-first, that tool can't complete in a script or CI run. This includes service accounts. If your CI job needs a governed tool, ask your Tabnine admin to set that tool class to auto-approve. See [Native Tools](/main/administering-tabnine/managing-your-team/settings/native-tools.md) and [Service Accounts and Token Limits](/main/administering-tabnine/managing-your-team/user-management/service-accounts-and-token-limits.md). A tool your organization has disabled is blocked in every mode.
{% endhint %}

If a headless run fails, see [Troubleshooting](/main/getting-started/tabnine-plugin-for-opencode/troubleshooting.md) for debug logs and common issues.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tabnine.com/main/getting-started/tabnine-plugin-for-opencode/scripts-and-ci.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
