This repository contains personal documentation and configurations for OpenCode - an open-source AI coding assistant that works directly in your terminal.
OpenCode is an open-source AI coding agent built from the ground up for the terminal. It provides a powerful, interactive experience that allows developers to integrate AI assistance directly into their workflow. With OpenCode, you can type commands like opencode fix error in main.go and the AI will instantly read your code, identify problems, and suggest solutions.
- Terminal-based AI assistant - Works directly in your command line
- Context-aware - Understands your codebase and current work
- Custom commands - Create reusable workflows and prompts
- Multiple tools - File operations, web fetching, shell commands, and more
- Agent system - Configure different AI agents for specific tasks
pnpm install -g opencode-aiopencodeStarts the OpenCode TUI (Terminal User Interface) for interactive sessions.
opencode run "Explain the most common uses of the 'awk' command with examples"Execute commands without entering the interactive TUI.
Custom commands allow you to create reusable prompts and workflows. Commands can be defined in two ways:
Add commands to your OpenCode config using the command option:
{
"commands": {
"test": {
"template": "Run tests and check for any failures",
"description": "Run test suite"
}
}
}Create markdown files in the command/ directory:
- Global:
~/.config/opencode/command/ - Per-project:
.opencode/command/
Example .opencode/command/test.md:
---
template: "Run tests and check for any failures"
description: "Run test suite"
---
Run tests and check for any failuresUse placeholders to pass arguments:
$ARGUMENTS- All arguments$1,$2,$3- Positional arguments
Inject shell command output with !command:
Check test coverage: !npm run test:coverageInclude files with @filename:
Review this file: @src/main.jsOpenCode provides built-in tools that the AI can use:
- read - Read file contents
- write - Create or overwrite files
- edit - Modify existing files with precise replacements
- list - List directory contents
- glob - Find files by pattern matching
- grep - Search file contents with regex
- patch - Apply patches to files
- bash - Execute shell commands
- webfetch - Fetch and read web content
- todowrite/todoread - Manage task lists
Tools can be configured globally or per-agent, with options to:
- Enable/disable specific tools
- Set permissions for tool usage
- Configure wildcards for bulk tool management
OpenCode includes several built-in commands:
/init- Initialize project/undo- Undo last action/redo- Redo last action/share- Share session/help- Show help
Custom commands with the same name will override built-in commands.
This repository is organized for personal OpenCode configurations and documentation:
.
├── README.md # This file
├── .opencode/ # Project-specific OpenCode config
│ ├── command/ # Custom commands
│ └── config.json # OpenCode configuration
└── docs/ # Additional documentationOpenCode can be configured through:
- Global config:
~/.config/opencode/config.json - Project config:
.opencode/config.json
{
"model": "claude-3-5-sonnet-20241022",
"tools": {
"bash": true,
"write": true,
"edit": true,
"read": true,
"webfetch": true
},
"agents": {
"plan": {
"model": "claude-3-haiku-20240307",
"tools": {
"write": false,
"bash": false
}
}
},
"commands": {
"review": {
"template": "Review the current code for improvements",
"description": "Code review"
}
}
}This is a personal documentation repository for OpenCode configurations and custom commands. Feel free to adapt the configurations and commands for your own use cases.
See LICENSE file for details.