OpenCode : Assistant IA pour le Développement
Démarrage Rapide
Section intitulée « Démarrage Rapide »# 1. Installer OpenCodenpm install -g @opencode/cli
# 2. Créer la configuration minimalemkdir -p ~/.config/opencodecat > ~/.config/opencode/config.json << 'EOF'{ "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://127.0.0.1:11434/v1" }, "models": { "qwen2.5-coder:14b": { "name": "Qwen Coder 14B" } } } }}EOF
# 3. Lancer OpenCodeopencodePrésentation
Section intitulée « Présentation »OpenCode est un assistant de développement IA en CLI. Il permet d’interagir avec différents LLM (locaux ou cloud) pour assister dans vos tâches de développement.
- Agents personnalisables pour différentes tâches (UX/UI, backend, DevOps…)
- Support multi-providers : Ollama, OpenRouter, OpenAI, Anthropic
- Tools personnalisés pour étendre les capacités
- Intégration locale avec Ollama pour la confidentialité
Configuration
Section intitulée « Configuration »Le fichier de configuration se trouve dans ~/.config/opencode/config.json.
Avec Ollama (local)
Section intitulée « Avec Ollama (local) »{ "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama (local)", "options": { "baseURL": "http://127.0.0.1:11434/v1" }, "models": { "devstral:latest": { "name": "Devstral" }, "qwen3-coder:30b": { "name": "Qwen3 Coder 30B" }, "gpt-oss:30b-32k": { "name": "GPT-OSS 30B (32k)" }, "gpt-oss:120b": { "name": "GPT-OSS 120B" } } } }}Multi-providers
Section intitulée « Multi-providers »Ajoutez d’autres providers dans le même fichier :
{ "provider": { "ollama": { "..." : "..." }, "anthropic": { "npm": "@ai-sdk/anthropic", "name": "Anthropic Claude", "options": { "apiKey": "votre-clé-api" }, "models": { "claude-sonnet-4-5-20250929": { "name": "Claude 4.5 Sonnet" } } } }}Les agents sont des assistants spécialisés stockés dans ~/.config/opencode/agent/. Chaque agent est un fichier Markdown avec un front matter YAML.
Exemple : Agent DevOps
Section intitulée « Exemple : Agent DevOps »~/.config/opencode/agent/devops.md :
---description: DevOps engineer specialized in Docker, Kubernetes, and CI/CDmode: subagentmodel: ollama/qwen3-coder:30btemperature: 0.2tools: write: true edit: true bash: true read: true---
# Identity and Purpose
You are a **DevOps Engineer** specialized in containerization,orchestration, and automation.
# Competencies
- Docker, Docker Compose, multi-stage builds- Kubernetes, Helm charts- GitLab CI, GitHub Actions, ArgoCD- Terraform, Ansible
# Guidelines
1. Security First: least privilege, secrets management2. Reproducibility: tout en Infrastructure as Code3. Testing: health checks et tests automatisésParamètres d’un agent
Section intitulée « Paramètres d’un agent »| Paramètre | Description | Valeurs |
|---|---|---|
description | Description courte | Texte libre |
mode | Mode d’exécution | subagent, chat |
model | Modèle LLM | ollama/model-name, anthropic/model-name |
temperature | Créativité (0-1) | 0 (précis) à 1 (créatif) |
tools | Outils disponibles | write, edit, bash, read |
Utilisation
Section intitulée « Utilisation »# Démarrer dans le répertoire courantopencode
# Avec un agent spécifiqueopencode --agent devops
# Avec un modèle spécifiqueopencode --model ollama/qwen3-coder:30bCommandes internes
Section intitulée « Commandes internes »/agents # Lister les agents/agent devops # Changer d'agent/model ollama/gpt-oss:30b-32k # Changer de modèle/help # Aide/exit # QuitterCustom Tools
Section intitulée « Custom Tools »OpenCode supporte des tools personnalisés dans ~/.config/opencode/tools/. Consultez la documentation officielle pour les créer.