OpenCode — CLI Integration
Setup
Install
bash
npm install -g opencode-aiAuthenticate
bash
opencode auth login https://ai.camer.digital/opencodeBrowser opens for authentication. Login, return to terminal, select model.
Configuration
Initialize project context (AGENTS.md)
bash
opencode
/initUsage
Start OpenCode
bash
# Current directory
opencode
# Specific directory
opencode /path/to/project
# Continue the last session
opencode --continueTUI Commands
| Command | Purpose |
|---|---|
/help | Show help |
/init | Create AGENTS.md |
/connect | Configure provider |
/models | List available models |
/share | Share session |
/undo | Undo last change |
/new | Start a new session |
File References
Explain @src/utils/parser.ts
Refactor @src/api.ts using async/awaitShell Commands
Run shell commands from within the TUI:
!npm test
!git statusNon-Interactive Mode
bash
# Single prompt
opencode run "Explain async/await"
# With a file
opencode run --file src/main.ts "Add error handling"Session Management
bash
# List sessions
opencode session list
# Export a session
opencode export SESSION_ID
# Import a session
opencode import session.jsonWeb Interface
bash
# Start the web server
opencode web --port 4096
# Access at http://localhost:4096Troubleshooting
opencode command not found:
bash
export PATH="$HOME/.local/bin:$PATH"