opencode is an open source AI coding agent (similar to CC)

Supports API from (virtually all of) providers

run

set environment

Run inside docker container as user because

  • opencode will write files
    • change file permission (root if not configured)
  • opencode will execute
    • require the same environment

For example,

docker run -it\
  ...\  # other options
  --user=$(id -u $(whoami)):$(id -g $(whoami))\  # run as user
  ...\  # other options

And, of course, use tmux to keep your process running

launch

cd /path/to/project
 
# TUI (default)
opencode .
 
# localhost:8080 (phone/table)
opencode web --hostname 0.0.0.0 --port 8080

commands

doc/commands

Only simple ones

per opencode instance

  • /connect
  • /models

per repository

  • /init to create AGENTS.md

per session

  • /new for new session
  • /sessions to list and switch sessions

inside session

  • /redo
  • /undo
  • /export to markdown
  • /compact

Mode

  • Plan: cannot write
  • Build: write

Reference