agentleFS
KubementatKubementat/ai_agent_skills/skills/opencode-cli/SKILL.md

opencode-cli

Skill2 starsChanged 8 months agoMITView on GitHub

Expert control of opencode via the command line. Use when running opencode TUI, headless server, web UI, or the `run` non-interactive mode; managing sessions, providers, agents, MCP servers, models, stats, import/export, GitHub integration, debugging, database tools, upgrades, or shell completions.

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

opencode CLI

opencode is an AI coding agent. This skill covers every CLI command and flag.

Global Options (apply to every command)

FlagTypeDefaultDescription
--print-logsboolfalsePrint logs to stderr
--log-levelstring—DEBUG / INFO / WARN / ERROR
--portnumber0 (random)Port to listen on
--hostnamestring127.0.0.1Hostname to listen on
--mdnsboolfalseEnable mDNS (sets hostname → 0.0.0.0)
--mdns-domainstringopencode.localCustom mDNS domain
--corsarray[]Extra CORS domains
-m, --modelstring—provider/model
-c, --continuebool—Continue last session
-s, --sessionstring—Session ID to continue
--forkbool—Fork session (with -c/-s)
--promptstring—Prompt to use
--agentstring—Agent to use

Commands

TUI / Default

opencode [project]          # start TUI in current or given directory

run — Non-interactive execution

opencode run [message..] [flags]
FlagDefaultNotes
--command—Command to run (message = args)
--sharefalseShare the session
--formatdefaultdefault or json (raw events)
-f, --file—Attach file(s)
--title—Session title
--attach—Attach to running server (URL)
-p, --password—Basic auth password (OPENCODE_SERVER_PASSWORD)
--dir—Directory (local or remote)
--portrandomLocal server port
--variant—Model reasoning effort: high/max/minimal
--thinkingfalseShow thinking blocks

serve — Headless server

opencode serve [server-flags]
# Server flags: --port, --hostname, --mdns, --mdns-domain, --cors

web — Server + browser UI

opencode web [server-flags]

attach — Attach to running server

opencode attach <url>           # e.g. http://localhost:4096
  --dir        # directory on remote
  -c/--continue / -s/--session / --fork
  -p, --password

acp — ACP server

opencode acp [server-flags]
  --cwd        # working directory (default: cwd)

Session Management

opencode session list [-n <N>] [--format table|json]
opencode session delete <sessionID>
opencode export [sessionID]               # → stdout JSON
opencode import <file|url>                # import JSON

Providers / Auth

opencode providers list                   # (alias: auth list)
opencode providers login [url] [-p <id>] [-m <method>]
opencode providers logout

Models

opencode models [provider]
  --verbose    # include cost metadata
  --refresh    # refresh cache from models.dev

Agents

opencode agent list
opencode agent create \
  [--path <dir>] \
  [--description "..."] \
  [--mode all|primary|subagent] \
  [--tools "bash,read,write,edit,list,glob,grep,webfetch,task,todowrite,todoread"] \
  [-m provider/model]
opencode debug agent <name> [--tool <id>] [--params <json>]

MCP Servers

opencode mcp list                         # list + status
opencode mcp add                          # interactive add
opencode mcp auth [name]                  # OAuth authenticate
opencode mcp auth list                    # list OAuth status
opencode mcp logout [name]                # remove OAuth credentials
opencode mcp debug <name>                 # debug OAuth connection

Stats

opencode stats
  --days <N>       # last N days (default: all time)
  --tools <N>      # top N tools
  --models [N]     # model stats (show all, or top N)
  --project <str>  # filter by project (empty string = current)

GitHub Integration

opencode github install
opencode github run [--event <mock-event>] [--token <github_pat_...>]
opencode pr <number>          # checkout PR branch then launch opencode

Database Tools

opencode db [query]           # sqlite3 shell or run query [--format json|tsv (default: tsv)]
opencode db path              # print db path
opencode db migrate           # migrate JSON → SQLite

Debug / Diagnostics

opencode debug config                            # show resolved config
opencode debug paths                             # data/config/cache/state dirs
opencode debug scrap                             # list all known projects
opencode debug skill                             # list available skills
opencode debug agent <name>                      # agent config details

# LSP
opencode debug lsp diagnostics <file>
opencode debug lsp symbols <query>
opencode debug lsp document-symbols <uri>

# Ripgrep
opencode debug rg tree
opencode debug rg files
opencode debug rg search <pattern>

# Filesystem
opencode debug file read <path>
opencode debug file status
opencode debug file list <path>
opencode debug file search <query>
opencode debug file tree [dir]

# Snapshots
opencode debug snapshot track
opencode debug snapshot patch <hash>
opencode debug snapshot diff <hash>

Lifecycle

opencode upgrade [target]           # e.g. 0.1.48 or v0.1.48
  -m, --method  curl|npm|pnpm|bun|brew|choco|scoop

opencode uninstall
  -c, --keep-config   # keep config files (default: false)
  -d, --keep-data     # keep sessions/snapshots (default: false)
      --dry-run       # preview only (default: false)
  -f, --force         # skip confirmations (default: false)

Shell Completion

opencode completion >> ~/.bashrc    # bash
opencode completion >> ~/.bash_profile  # macOS

Common Workflows

Run a one-shot task non-interactively:

opencode run "fix the failing tests" -m anthropic/claude-opus-4-5

Continue last session non-interactively:

opencode run "add docs" --continue

Start a headless server on a fixed port:

opencode serve --port 4096

Attach a TUI client to a remote server:

opencode attach http://192.168.1.10:4096 -p mypassword

Export/import sessions:

opencode export > backup.json
opencode import backup.json

List sessions, delete one:

opencode session list -n 10 --format json
opencode session delete <sessionID>

Add a provider and list models:

opencode providers login -p anthropic
opencode models anthropic --verbose

Create a custom subagent:

opencode agent create --description "security reviewer" --mode subagent --tools "read,grep,glob"

Check cost stats for this week:

opencode stats --days 7 --models 5

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.