OpenCode
OpenCode is an open-source AI coding agent that runs in the terminal and works directly with local repositories.
Installation
OpenCode is installed through the opencode Ansible role.
ansible-playbook -i inventory -K playbooks/lab-stack.yml --tags opencodeThe role also installs CLI tools commonly used when exploring and working with repositories: ripgrep, fd-find, jq, gh, git-delta, fzf, bat, ShellCheck, and tree.
The role also installs the OpenCode Voice plugin in the target user’s global OpenCode configuration. Restart OpenCode after installation or an update. On first use, choose a local transcription model; its runtime and model files are downloaded automatically.
✅ Check
opencode --version
rg --version
fd --version
jq --version
gh --version
delta --version
fzf --version
bat --version
shellcheck --version
tree --versionAuthentication
Authentication is configured manually and is not managed by Ansible.
Launch OpenCode:
opencodeInside OpenCode, enter /connect, select a provider, and follow its authentication prompts. Providers may use an API key or an account sign-in flow. Then run /models to select an available model. See the OpenCode provider guide for provider-specific instructions.
OpenCode stores credentials locally; do not commit credentials or local authentication files to this repository.
Voice input
Press Ctrl+R to start recording, then press it again to stop and transcribe into the prompt. Use /voice-settings to change the model, microphone, language, and recording hotkey. Voice transcription runs locally.
Working with repositories
Launch OpenCode from the repository root:
cd ~/repos/colrev
opencodeUse Plan mode to review proposed changes before allowing edits.
Review modifications using:
git status
git diffBest practices and useful links
Start OpenCode from the repository root so it can read the project guidance in AGENTS.md. If the project does not have one, run /init, review the generated instructions, and commit the file with the project.
For larger changes, use Plan mode (Tab) to agree on an approach before editing. Before committing, review git status and git diff and run the project’s relevant checks.
To fork the conversation history of the most recent session (e.g., in a new tab):
opencode --continue --fork
# alternatively
opencode session list
opencode -s <session-id> --forkChange reasoning effort using ctrl+t.
Attach files to prompt using @filename.
Interrupt and continue: Esc , /undo, Enter (to keep changes and continue, give a prompt like “The network connection was interrupted. Check what has already been completed and continue the remaining work without repeating completed steps.”)
Provide pytest output (adding @pytest.log in the prompt):
pytest -v 2>&1 | tee pytest.logUseful references:
Updates
OpenCode is managed by the workstation Ansible role. The regular configuration run ensures it is installed.
To upgrade OpenCode explicitly:
opencode upgradeRestart OpenCode after upgrading so it reloads the installed CLI and plugins.