Skip to main content

OpenCode

OpenCode is a web-based code editor that integrates AI models directly into the browser. It can be used to edit code, run scripts, and interact with AI models in real-time. OpenCode can be configured to use NaviGator Toolkit as a provider allowing you to get your own AI coding assistant.

Installing OpenCode

NPM

npm install -g opencode-ai

Bun

bun add -g opencode-ai

Homebrew

brew install opencode-ai/tap/opencode

Linux

curl -fsSL https://opencode.ai/install | bash

Too Install on Windows you should use WSL2 and follow the Linux instructions above or use the NPM or Bun methods.

Once installed you can launch by running opencode

open code launch

Configure OpenCode to use NaviGator Toolkit

To configure OpenCode to use NaviGator Toolkit, you need to create a configuration file in either the global directly of ~/.config/opencode/opencode.json or your project directory. The file should be named opencode.json and should contain the following:

{
"$schema": "https://opencode.ai/config.json",
"model": "navigator/mistral-small-3.1",
"provider": {
"navigator": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.ai.it.ufl.edu/v1",
"apiKey": "<[NAVIGATOR_API_KEY](https://docs.ai.it.ufl.edu/docs/navigator_toolkit/getting_started/quickstart#create-an-api-key)>"
},
"models": {
"mistral-small-3.1": {}
}
}
}
}

This configuration files will get you started with the mistral-small-3.1 model. You can change the model to any other model available in NaviGator Toolkit. For a list of available models, see the NaviGator Toolkit Models page.

To select the NaviGator AI models, while in OpenCode use the /models command.

open code model selection

How to Use OpenCode

OpenCode is a powerful terminal-based AI coding agent that brings AI assistance directly to your command line. Unlike IDE-integrated tools, OpenCode is designed for developers who prefer terminal workflows and need AI assistance that integrates seamlessly with their existing command-line tools and scripts.

Key Features & Capabilities

  • Interactive TUI Interface: Terminal user interface for seamless AI interaction
  • Session Management: Continue previous conversations with --continue or specific --session
  • Multiple Execution Modes: Run with direct messages or interactive sessions
  • Model Selection: Choose from various AI models with -m, --model flag
  • Agent Support: Use specialized agents for different tasks
  • GitHub Integration: Built-in GitHub agent for repository operations
  • Headless Server Mode: Run OpenCode as a server for remote access

Common Use Cases & Examples

1. Code Review & Analysis

Example: "Review this Python module for best practices and potential issues"

opencode
# In the interactive TUI:
# "Analyze the user_auth.py file for security vulnerabilities and code quality issues"

Or use direct message mode:

opencode run "Review the user_auth.py file for security issues and suggest improvements"

OpenCode will:

  • Examine your code structure and patterns
  • Identify potential security issues
  • Suggest improvements for readability and maintainability
  • Generate detailed review comments

2. Debugging & Problem Solving

Example: "Help me debug why my tests are failing"

opencode
# In the interactive session:
# "Run the test suite and help me understand what's failing and why"

Or for quick debugging:

opencode run "My React tests are failing with 'Cannot read property of undefined'. Help me debug this."

OpenCode can:

  • Execute your test commands and analyze output
  • Identify root causes of test failures
  • Suggest specific fixes for failing tests
  • Help trace through complex debugging scenarios

3. Documentation Generation

Example: "Generate comprehensive API documentation for my Express.js routes"

opencode
# In the TUI:
# "Create API documentation for all routes in the routes/ directory"

Or as a direct command:

opencode run "Generate OpenAPI documentation for my Express.js API endpoints"

OpenCode will:

  • Analyze your route definitions and middleware
  • Generate OpenAPI/Swagger specifications
  • Create markdown documentation with examples
  • Add inline code comments where needed

4. Feature Implementation

Example: "Add authentication middleware to my Node.js API"

opencode
# Interactive session for complex implementations:
# "Implement JWT-based authentication middleware with proper error handling"

OpenCode can:

  • Create new middleware files
  • Update existing route configurations
  • Add necessary dependencies to package.json
  • Implement proper error handling and validation

5. GitHub Integration & Repository Management

Example: Working with GitHub repositories

opencode github
# Access GitHub-specific agent for repository operations

This allows you to:

  • Create and manage pull requests
  • Analyze repository structure and issues
  • Automate common GitHub workflows
  • Review code changes across branches

Terminal Workflow Examples

Quick Code Analysis

# Start OpenCode and analyze a specific file
opencode
> "Analyze the performance bottlenecks in database.py and suggest optimizations"

Batch File Processing

# Process multiple files with a single command
opencode
> "Add proper error handling to all Python files in the src/ directory"

Integration with Git Workflows

# Review changes before committing
opencode run "Review the files I've changed in this commit for any issues"

Or use interactive mode for detailed review:

opencode --continue
# "Please review my recent changes and suggest improvements before I commit"

Best Practices for Terminal-Based AI Coding

Effective Command Usage

  • Be Specific: Use precise descriptions of what you want to accomplish
  • Provide Context: Mention file paths, project structure, and constraints
  • Choose the Right Mode: Use interactive mode for complex tasks, direct mode for quick queries

Integration with Existing Workflows

  • Combine with Git: Use OpenCode for pre-commit reviews and analysis
  • Script Integration: Incorporate opencode run commands into your build scripts
  • Session Continuity: Use --continue to maintain context across work sessions

Managing Large Projects

  • Focus on Specific Areas: Target specific directories or file patterns in your prompts
  • Use Session Management: Continue previous sessions to maintain project context
  • Leverage GitHub Agent: Use opencode github for repository-wide operations

Getting Started Tips

  1. Start with Simple Queries: Begin with opencode run for quick tasks to understand capabilities
  2. Try Interactive Mode: Use the TUI for complex, multi-step tasks
  3. Use Session Management: Continue sessions to build on previous conversations
  4. Explore Agents: Try opencode github for repository-specific tasks

Example Terminal Session

$ opencode
OpenCode AI Agent
> "My React app isn't rendering the user list component. Help me debug this."

[OpenCode analyzes your project structure]
[Identifies potential issues in component files]
[Suggests running specific commands to diagnose]

> "Run npm test -- --verbose UserList.test.js"
[Executes test and analyzes output]
[Provides specific recommendations for fixes]

> "The issue is in the useEffect dependency array. Let me fix that."
[Makes targeted changes to resolve the issue]
[Verifies the fix works correctly]

This terminal-first approach makes OpenCode particularly powerful for developers who live in the command line and want AI assistance that fits naturally into their existing workflows.

References

  1. OpenCode https://opencode.ai
  2. OpenCode Docs https://opencode.ai/docs/
  3. Github Repository https://github.com/sst/opencode