Install any skill in seconds. Free to start, no credit card required.
Get Started Free →description: Delegate coding tasks to OpenCode CLI agent for feature implementation,
.claude/skills/graniet-opencode/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 108% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 95% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 83% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 100% | 0% |
| case-18 | ✗→✓ | ▲ Improved | -5% | 0% |
description: Delegate coding tasks to OpenCode CLI agent for feature implementation, refactoring, PR review, and long-running autonomous sessions. Requires the opencode CLI installed and authenticated. version: 1.2.0 license: MIT metadata: catalog: tags:
related_skills:
---
This skill is repo-local and stays inactive until explicitly activated.
When the original instructions refer to legacy tool names, use these Kheish mappings:
terminal => bashweb_extract => web_fetch, plus web_search when discovery is neededsearch_files => grep_search and glob_searchbrowser_* tools require a browser-capable surfaced tool or MCP; if none is available, use the closest available surface and say so explicitlyWhen the instructions mention local helper files, resolve them from ${KHEISH_SKILL_DIR}.
Use OpenCode as an autonomous coding worker orchestrated by Kheish terminal/process tools. OpenCode is a provider-agnostic, open-source AI coding agent with a TUI and CLI.
npm i -g opencode-ai@latest or brew install anomalyco/tap/opencodeopencode auth login or set provider env vars (OPENROUTER_API_KEY, etc.)opencode auth list should show at least one providerpty=true for interactive TUI sessionsShell environments may resolve different OpenCode binaries. If behavior differs between your terminal and Kheish, check:
terminal(command="which -a opencode")
terminal(command="opencode --version")If needed, pin an explicit binary path:
terminal(command="$HOME/.opencode/bin/opencode run '...'", workdir="~/project", pty=true)Use opencode run for bounded, non-interactive tasks:
terminal(command="opencode run 'Add retry logic to API calls and update tests'", workdir="~/project")Attach context files with -f:
terminal(command="opencode run 'Review this config for security issues' -f config.yaml -f .env.example", workdir="~/project")Show model thinking with --thinking:
terminal(command="opencode run 'Debug why tests fail in CI' --thinking", workdir="~/project")Force a specific model:
terminal(command="opencode run 'Refactor auth module' --model openrouter/anthropic/claude-sonnet-4", workdir="~/project")For iterative work requiring multiple exchanges, start the TUI in background:
terminal(command="opencode", workdir="~/project", background=true, pty=true)
# Returns session_id
# Send a prompt
process(action="submit", session_id="<id>", data="Implement OAuth refresh flow and add tests")
# Monitor progress
process(action="poll", session_id="<id>")
process(action="log", session_id="<id>")
# Send follow-up input
process(action="submit", session_id="<id>", data="Now add error handling for token expiry")
# Exit cleanly — Ctrl+C
process(action="write", session_id="<id>", data="\x03")
# Or just kill the process
process(action="kill", session_id="<id>")Important: Do NOT use /exit — it is not a valid OpenCode command and will open an agent selector dialog instead. Use Ctrl+C (\x03) or process(action="kill") to exit.
| Key | Action | |-----|--------| | Enter | Submit message (press twice if needed) | | Tab | Switch between agents (build/plan) | | Ctrl+P | Open command palette | | Ctrl+X L | Switch session | | Ctrl+X M | Switch model | | Ctrl+X N | New session | | Ctrl+X E | Open editor | | Ctrl+C | Exit OpenCode |
After exiting, OpenCode prints a session ID. Resume with:
terminal(command="opencode -c", workdir="~/project", background=true, pty=true) # Continue last session
terminal(command="opencode -s ses_abc123", workdir="~/project", background=true, pty=true) # Specific session| Flag | Use | |------|-----| | run 'prompt' | One-shot execution and exit | | --continue / -c | Continue the last OpenCode session | | --session <id> / -s | Continue a specific session | | --agent <name> | Choose OpenCode agent (build or plan) | | --model provider/model | Force specific model | | --format json | Machine-readable output/events | | --file <path> / -f | Attach file(s) to the message | | --thinking | Show model thinking blocks | | --variant <level> | Reasoning effort (high, max, minimal) | | --title <name> | Name the session | | --attach <url> | Connect to a running opencode server |
terminal(command="opencode --version")terminal(command="opencode auth list")opencode run '...' (no pty needed).opencode with background=true, pty=true.process(action="poll"|"log").process(action="submit", ...).process(action="write", data="\x03") or process(action="kill").OpenCode has a built-in PR command:
terminal(command="opencode pr 42", workdir="~/project", pty=true)Or review in a temporary clone for isolation:
terminal(command="REVIEW=$(mktemp -d) && git clone https://github.com/user/repo.git $REVIEW && cd $REVIEW && opencode run 'Review this PR vs main. Report bugs, security risks, test gaps, and style issues.' -f $(git diff origin/main --name-only | head -20 | tr '\n' ' ')", pty=true)Use separate workdirs/worktrees to avoid collisions:
terminal(command="opencode run 'Fix issue #101 and commit'", workdir="/tmp/issue-101", background=true, pty=true)
terminal(command="opencode run 'Add parser regression tests and commit'", workdir="/tmp/issue-102", background=true, pty=true)
process(action="list")List past sessions:
terminal(command="opencode session list")Check token usage and costs:
terminal(command="opencode stats")
terminal(command="opencode stats --days 7 --models anthropic/claude-sonnet-4")opencode (TUI) sessions require pty=true. The opencode run command does NOT need pty./exit is NOT a valid command — it opens an agent selector. Use Ctrl+C to exit the TUI.process(action="log", session_id="<id>")Smoke test:
terminal(command="opencode run 'Respond with exactly: OPENCODE_SMOKE_OK'")Success criteria:
OPENCODE_SMOKE_OKopencode run for one-shot automation — it's simpler and doesn't need pty.process logs./exit.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-04 | fail→pass | 7,647 | 2,471 | -68% | 1 | 1 | 0% | 1,245 | 2,591 | +108% | 0 | 0 | — |
case-01 | fail→fail | 6,941 | 13,544 | +95% | 1 | 1 | 0% | 1,224 | 2,489 | +103% | 0 | 0 | — |
case-02 | fail→fail | 27,647 | 5,198 | -81% | 1 | 1 | 0% | 293 | 2,469 | +743% | 0 | 0 | — |
case-03 | fail→fail | 11,122 | 25,042 | +125% | 1 | 1 | 0% | 1,191 | 5,108 | +329% | 0 | 0 | — |
case-05 | pass→pass | 10,576 | 2,084 | -80% | 1 | 1 | 0% | 1,728 | 2,531 | +46% | 0 | 0 | — |
case-06 | fail→pass | 7,461 | 1,860 | -75% | 1 | 1 | 0% | 1,286 | 2,503 | +95% | 0 | 0 | — |
case-07 | fail→pass | 7,661 | 1,959 | -74% | 1 | 1 | 0% | 1,318 | 2,406 | +83% | 0 | 0 | — |
case-08 | pass→pass | 5,081 | 2,937 | -42% | 1 | 1 | 0% | 902 | 2,673 | +196% | 0 | 0 | — |
case-09 | pass→pass | 3,770 | 2,502 | -34% | 1 | 1 | 0% | 674 | 2,519 | +274% | 0 | 0 | — |
case-15 | fail→pass | 7,499 | 1,557 | -79% | 1 | 1 | 0% | 1,201 | 2,407 | +100% | 0 | 0 | — |
case-10 | pass→pass | 7,697 | 1,628 | -79% | 1 | 1 | 0% | 1,334 | 2,405 | +80% | 0 | 0 | — |
case-11 | pass→pass | 6,817 | 1,718 | -75% | 1 | 1 | 0% | 1,177 | 2,410 | +105% | 0 | 0 | — |
case-12 | pass→pass | 11,520 | 6,086 | -47% | 1 | 1 | 0% | 2,085 | 3,272 | +57% | 0 | 0 | — |
case-13 | pass→pass | 8,103 | 2,352 | -71% | 1 | 1 | 0% | 1,421 | 2,549 | +79% | 0 | 0 | — |
case-14 | pass→pass | 11,367 | 5,063 | -55% | 1 | 1 | 0% | 1,903 | 3,082 | +62% | 0 | 0 | — |
case-16 | pass→pass | 6,906 | 1,926 | -72% | 1 | 1 | 0% | 1,098 | 2,452 | +123% | 0 | 0 | — |
case-17 | pass→pass | 7,406 | 18,473 | +149% | 1 | 1 | 0% | 1,067 | 2,485 | +133% | 0 | 0 | — |
case-18 | fail→pass | 14,437 | 1,399 | -90% | 1 | 1 | 0% | 2,529 | 2,394 | -5% | 0 | 0 | — |
case-19 | pass→pass | 3,783 | 1,202 | -68% | 1 | 1 | 0% | 566 | 2,330 | +312% | 0 | 0 | — |
case-20 | pass→pass | 3,668 | 3,770 | +3% | 1 | 1 | 0% | 644 | 2,869 | +345% | 0 | 0 | — |
case-21 | pass→pass | 2,913 | 1,989 | -32% | 1 | 1 | 0% | 417 | 2,515 | +503% | 0 | 0 | — |
case-22 | pass→pass | 3,131 | 1,829 | -42% | 1 | 1 | 0% | 530 | 2,467 | +365% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 20 counted toward the lift figure. The other 2 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +23 percentage points is the difference between those two pass rates over the 20 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.