An open-source AI-powered code assistant that runs locally
Privacy-first β’ Secure β’ Customizable
OpenCode is a fully-featured, open-source alternative to Claude Code that runs entirely on your local machine using Ollama. It provides a powerful CLI interface for AI-assisted coding, code analysis, and project management while ensuring complete privacy and security.
- π Privacy-First: All processing happens locally - no data leaves your machine
- π‘οΈ Secure: File operations restricted to current working directory
- π€ AI-Powered: Uses local Ollama models for code assistance
- π» Interactive CLI: Rich terminal interface with conversation history
- π§ Tool System: File operations, search, Git integration, and command execution
- π¦ Easy Installation: One-command bootstrap setup
- ποΈ Customizable: Flexible configuration and model selection
Linux/macOS:
git clone https://github.com/your-username/openCode.git
cd openCode
./scripts/bootstrap.shWindows:
git clone https://github.com/your-username/openCode.git
cd openCode
scripts\bootstrap.batCross-platform:
git clone https://github.com/your-username/openCode.git
cd openCode
python scripts/bootstrap.pyThe bootstrap script will:
- Install Ollama automatically
- Download and setup an AI model
- Install OpenCode as a system command
- Run tests to verify everything works
If you prefer manual installation, see Installation Guide.
opencodeStart a conversation with the AI assistant:
π§ > Create a Python function to calculate fibonacci numbers
π§ > read main.py
π§ > Add error handling to the parseConfig function
π§ > run the tests
π§ > git status
# Generate code
opencode "Create a REST API endpoint for user authentication"
# Analyze files
opencode --file main.py "Review this code for potential bugs"
# Use specific model
opencode --model deepseek-coder:6.7b "Optimize this algorithm"File Operations:
read config.py- Read and analyze fileswrite to new_file.py- Create new filesedit the main function- Modify existing code
Code Analysis:
search for TODO comments- Find patterns in codebaseexplain this function- Code documentationreview for security issues- Code auditing
Git Integration:
git status- Check repository statusgit diff- Review changesshow recent commits- Git history
Command Execution:
run python tests.py- Execute commandsinstall dependencies- Package managementbuild the project- Build automation
OpenCode prioritizes security with several protective measures:
- All file operations are restricted to the current working directory
- No access to system files (
/etc/passwd, user directories, etc.) - Blocks directory traversal attacks using
../paths - Safe by default - operates only within your project
- Allowed commands only (git, npm, pip, python, node, etc.)
- Timeout protection prevents hanging processes
- Working directory scoped execution
- No shell injection vulnerabilities
- 100% local processing - no data sent to external servers
- No telemetry or usage tracking
- Open source - fully auditable codebase
- Configurable - control all aspects of operation
For complete security details, see Security Features.
OpenCode supports various AI models via Ollama:
| Model | Size | Best For | Speed |
|---|---|---|---|
llama3.2:3b |
2GB | General coding, fast responses | β‘β‘β‘ |
deepseek-coder:6.7b |
4GB | Code generation, debugging | β‘β‘ |
codestral:7b |
4GB | Code completion, refactoring | β‘β‘ |
llama3.1:8b |
5GB | Complex reasoning, documentation | β‘ |
# List available models
ollama list
# Download new model
ollama pull deepseek-coder:6.7b
# Switch models in OpenCode
opencode --model deepseek-coder:6.7b "your prompt"OpenCode is highly configurable via config.yaml:
model:
name: "llama3.2:3b"
temperature: 0.1
max_tokens: 4096
tools:
enabled:
- file_read
- file_write
- bash_execute
- grep_search
- git_operations
restrict_to_working_dir: true # Security feature
interface:
syntax_highlighting: true
auto_save: false
confirm_destructive: true| Document | Description |
|---|---|
| Installation Guide | Detailed installation instructions |
| Usage Guide | Comprehensive usage examples |
| Bootstrap Guide | Automated installation documentation |
| Security Features | Security implementation details |
openCode/
βββ opencode/ # Main package
β βββ cli.py # Command-line interface
β βββ interactive.py # Interactive mode
β βββ ollama_client.py # Ollama integration
β βββ tools.py # Tool system
β βββ config.py # Configuration management
βββ scripts/ # Installation scripts
β βββ bootstrap.sh # Linux/macOS installer
β βββ bootstrap.py # Cross-platform installer
β βββ bootstrap.bat # Windows installer
βββ tests/ # Test suite
βββ docs/ # Documentation
βββ examples/ # Usage examples
We welcome contributions! OpenCode is designed to be:
- Extensible - Easy to add new tools and features
- Secure - All changes must maintain security standards
- Tested - Comprehensive test suite for reliability
- Documented - Clear documentation for all features
- Python 3.8+
- Ollama (automatically installed by bootstrap)
- 4GB+ RAM (for AI models)
- 2-10GB storage (depends on models)
| Feature | OpenCode | Cloud Services |
|---|---|---|
| Privacy | β 100% local | β Data sent to servers |
| Security | β Sandboxed operation | β Potential data breaches |
| Cost | β Free after setup | β Ongoing subscription |
| Offline | β Works without internet | β Requires connection |
| Customization | β Full control | β Limited options |
| Transparency | β Open source | β Proprietary |
OpenCode is optimized for local execution:
- Response time: 1-5 seconds (depends on model and hardware)
- Memory usage: 2-8GB (depends on model size)
- CPU usage: Efficient inference with modern hardware
- Storage: Models cached locally for fast access
Command not found:
# Restart terminal or check PATH
echo $PATHOllama not running:
# Start Ollama service
ollama serveModel not available:
# Pull required model
ollama pull llama3.2:3bSecurity restrictions:
# Check you're in the correct directory
pwd
# OpenCode works within current directory onlyFor more troubleshooting, see Installation Guide.
Run the test suite to verify installation:
# Security tests
python tests/test_security.py
# Installation tests
python tests/test_installation.pyOpenCode is released under the MIT License. See LICENSE for details.
- Documentation: Check the docs/ directory
- Issues: Open an issue on GitHub
- Security: Report security issues privately
- Plugin system for custom tools
- Web interface option
- Advanced code analysis features
- Team collaboration features
- IDE integrations
OpenCode - Your local AI coding assistant
Built with privacy, security, and productivity in mind