/lstack:opencode-runnerfrom lstack
Delegates coding tasks to opencode.ai using free cloud models. Automates model selection, task execution, and cleanup. Use when asked to offload work to opencode or run a free model.
Ships in lstack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Delegate coding tasks to opencode using free models — zero cost, fully automated.
OpenCode (opencode.ai) is a terminal AI coding assistant that supports multiple providers and models. This skill automates the process of selecting the best available free model, launching the task, and reporting progress back to you.
which opencode must succeed; install via npm i -g opencode-ai@latest or brew install opencode if missingNever do the task yourself. This skill exists solely to delegate work to opencode. If opencode is not installed, fails to run, or no free cloud model is available — report the problem to the user and stop. Do not fall back to editing files directly, writing code yourself, or using any other tool to accomplish the user's coding task. The whole point is that opencode does the work.
Only select cloud models. Never select local models (e.g., ollama/*, lmstudio/*, or any model running on localhost). Only select models from the opencode/* provider namespace, which are cloud-hosted on OpenCode Zen. Local models have unpredictable availability, performance, and may not support the tool-use capabilities opencode needs.
Always clean up after yourself. opencode spawns background processes (LSP servers, MCP servers, node workers) that persist after the task finishes. Every execution path — success, failure, error, timeout — must end with the cleanup steps in Phase 6. Orphaned opencode processes silently eat CPU and memory, and users won't notice until their machine slows to a crawl.
Before creating/updating/deleting files in an existing repository, sync the current branch with remote:
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin
git pull --rebase origin "$branch"
If the working tree is not clean, stash first, sync, then restore:
git stash push -u -m "pre-sync"
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin && git pull --rebase origin "$branch"
git stash pop
If origin is missing or conflicts occur, stop and ask the user before continuing.
Check that opencode is installed and at the latest version.
which opencode && opencode --version
If opencode is not found, give the user the install commands in references/edge-cases.md → Install commands.
Then stop completely with BLOCKED — opencode is not installed (Final Report) — do not proceed to any other phase, do not attempt the task yourself, do not edit any files. Wait for the user to install opencode and re-invoke this skill.
opencode upgrade. It upgrades to the latest version, or confirms the installed one is current.opencode upgrade exits non-zero, tell the user its error and suggest running opencode upgrade manually. Then continue to item 3.opencode --version again.opencode --version exits non-zero, stop with BLOCKED — opencode does not start after the upgrade. Do not continue to Phase 2.Query the available models, present the free ones to the user, and let them choose. If the user doesn't choose, fall back to the priority order.
opencode models 2>/dev/null
| Priority | Model ID | Notes |
|---|---|---|
| 1 | opencode/deepseek-v4-flash-free | Strong recent free coding model — preferred default |
| 2 | opencode/minimax-m2.5-free | MiniMax free tier — good general-purpose |
| 3 | opencode/nemotron-3-super-free | NVIDIA Nemotron free tier |
| 4 | opencode/big-pickle | Free fallback |
| 5 | opencode/gpt-5-nano | Small fallback; free only when opencode models prices it at $0 |
Model IDs evolve. A model is free-tier eligible when its ID is in the opencode/* namespace and one of these holds: the ID ends in -free, the ID is opencode/big-pickle, or the opencode models output prices it at $0. Match by suffix, not by exact ID. Without a $0 price in the output, leave opencode/gpt-5-nano out.
opencode models and collect all entries.opencode/* models — ignore anything from ollama/*, lmstudio/*, nvidia/*, or any other namespace. Only cloud-hosted opencode/* models qualify.<options> format if possible; example in references/expected-output.md → Phase 2 — Free model picker.BLOCKED — no free cloud model available — do not fall back to local models, paid models, or doing the task yourself.Privacy note (always show this with the model list): Free models on OpenCode Zen may use collected data for model improvement.
Before invoking opencode, show the user a one-screen summary and get explicit confirmation. This catches wrong-model or wrong-prompt mistakes before any tokens are burned.
Present the block in references/expected-output.md → Phase 3 — Confirmation summary: model (free tier), working directory, context files (or "none"), the prompt quoted verbatim, and the estimated duration.
Then offer the user two <options>: "Proceed" and "Change something". Wait for confirmation. Do not invoke opencode run until the user confirms.
If the user asks to change anything (different model, edit prompt, add/remove context files), loop back: update the field, re-show the summary, and ask again. If the user cancels instead, stop with BLOCKED — the user cancelled before the run.
Run the coding task with the confirmed model. Always run in the background with output redirected to a log file — this is required for the low-token monitoring strategy in Phase 5.
RUN=/tmp/opencode-run-$(date +%s)
( opencode run -m "[confirmed-model-id]" "[confirmed prompt]" > "$RUN.log" 2>&1; echo $? > "$RUN.exit" ) &
echo $! > "$RUN.pid"
echo "opencode started: run=$RUN pid=$(cat "$RUN.pid")"
Record the run= value this prints and substitute it literally in every later Phase 5 and Phase 6 shell. Each Bash call starts fresh, so rebind RUN to that recorded prefix before reading "$RUN.log", "$RUN.pid" or "$RUN.exit". The .pid file is the ownership record: it holds the id of the wrapper subshell, whose child is opencode run. The wrapper writes opencode's exit code to .exit when opencode finishes, because a later shell cannot wait on it.
For tasks that reference files or need detailed context, launch with the --file variant in references/edge-cases.md → Multi-line or file-context prompts.
Foreground execution is discouraged — streaming the full opencode output back into your context wastes tokens. The Phase 5 monitor reads only the log tail.
opencode output is verbose. Streaming the full log back into your context is expensive — a single long run can easily push past 10k tokens of stream chatter. Use the lightweight polling protocol below instead.
Run one tiny status command per check. It returns at most ~200 bytes — enough to know status, elapsed time, and the latest activity line — without ingesting the whole log.
RUN=/tmp/opencode-run-1234567890 # paste the run= value Phase 4 printed
status() {
pid=$(cat "$RUN.pid" 2>/dev/null)
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then s=running; else s=done; fi
ec=$(cat "$RUN.exit" 2>/dev/null)
bytes=$(wc -c < "$RUN.log" 2>/dev/null || echo 0)
last=$(tail -n 1 "$RUN.log" 2>/dev/null | tr -d '\r' | cut -c1-160)
printf 'status=%s pid=%s exit=%s bytes=%s last=%q\n' "$s" "${pid:-none}" "${ec:-none}" "$bytes" "$last"
}
status
That single line is your full progress sample. Do not tail -n 50, do not cat "$RUN.log", do not stream stdout — those defeat the purpose.
status=running, ask the user whether to keep waiting or kill the process. Do not poll again until the user answers. If the user says keep waiting, allow up to 6 more polls under the same rules.bytes= is the same in two consecutive polls. A run has timed out when 5 minutes pass with no bytes= growth. On a stall or a timeout, ask the user whether to keep waiting or kill the process. Kill it only when the user approves, then follow On error, stall, or timeout.Between polls, report one short line per check in the format in references/expected-output.md → What to report between polls; never paste the raw log.
When status=done:
tail -n 40 "$RUN.log". That's the summary opencode prints at the end (files changed, tokens used, errors).exit=0 is a success. Any other exit= value is a failure. exit=none means the wrapper was killed before opencode finished: treat it as a failure.git status --porcelain to list the files that changed. This is a read only: never edit, stage, or revert those files."$RUN.log" in Phase 6 Step 3 and give its path in the final report.opencode auth list to check provider auth.Every execution — success, failure, error, or timeout — must end with cleanup. opencode spawns child processes (LSP servers, MCP servers, node workers) that persist after the main process exits. Without cleanup, these orphaned processes accumulate and drain system resources.
If you launched opencode in the background, use the pidfile for the recorded run prefix as the ownership record:
RUN=/tmp/opencode-run-1234567890 # paste the run= value Phase 4 printed
pid=$(cat "$RUN.pid" 2>/dev/null)
if [ -n "$pid" ]; then
pkill -TERM -P "$pid" 2>/dev/null # opencode runs as a child of the wrapper subshell
kill "$pid" 2>/dev/null
sleep 2
pkill -KILL -P "$pid" 2>/dev/null
kill -9 "$pid" 2>/dev/null
fi
pgrep -fl "opencode run" to list lingering opencode run processes.pkill -f "opencode run".This pattern never matches the user's interactive TUI session (opencode without a subcommand). Leave that session alone.
rm -f "$RUN.log" "$RUN.pid" "$RUN.exit" 2>/dev/null
If the user asked to keep the log (Phase 5, On completion item 4), drop "$RUN.log" from this command.
pgrep -f "opencode run" >/dev/null && echo cleanup=incomplete || echo cleanup=complete.cleanup=complete, report: Cleanup complete — no opencode run process remains.cleanup=incomplete, warn: Warning: some opencode run processes are still running. Run pkill -f "opencode run" manually to clean up.After Phase 6, print one final report in concise text, in this order: Result: (COMPLETE, PARTIAL — <reason>, or BLOCKED — <reason>), Evidence: (only checks that ran), Uncertainty:, then Decision: (the approval needed, or No approval needed.). A stop before opencode run starts skips Phases 4–6 and prints the report directly. Status rules, examples and the reader checks: references/final-report.md.
See references/expected-output.md for the full set of example blocks the user should see at each phase (model picker, confirmation summary, low-token progress polls, cleanup confirmation). On error or timeout, the cleanup confirmation still runs. Final report examples: references/final-report.md.
When an edge case fires, read references/edge-cases.md: opencode missing, a failed upgrade, no free model, every model failing, a stall or timeout, a rejected confirmation, an open TUI session, multi-line prompts, a non-zero exit, or a killed wrapper. It also holds the opencode command reference.
The skill run is considered successful when all of the following are verifiable:
opencode is on PATH and reports its version before any other action.opencode/* models considered — Filter step rejects ollama/*, lmstudio/*, nvidia/*, and any other namespace. No local model is ever selected.opencode/* model with priority 1 as default, plus the privacy note. The user may pick one; if they defer, priority 1 is used.opencode run.opencode run, not by the skill editing files directly or writing code itself.status() helper. The raw log is never streamed back; only the last line, byte count, and status are reported per poll. Max 6 polls per run.status=done, the skill reads only tail -n 40 "$RUN.log", classifies the run by its exit= value, and summarizes files changed and token usage.cleanup=complete before the report claims cleanup."$RUN.log", "$RUN.pid" and "$RUN.exit" are deleted during cleanup, unless the user asked to keep the log.Result:, Evidence:, Uncertainty: and Decision:, and passes the four reader checks in references/final-report.md: the result is findable in the first line, facts are separated from assumptions, each claim traces to a check that ran, and the next decision is named. Human understanding stays unconfirmed until a user answers those checks.After each phase, emit a compact status block so pass/fail is scannable; the template is in references/expected-output.md → Step Completion Report template.
Use √ for pass, × for fail, and — to add brief context. Per-phase example blocks (Installation, Model Discovery, Confirmation, Execution, Monitor, Cleanup) are in references/expected-output.md.
Optional and propose-only. After the run's result is delivered, run this check:
opencode command, a model ID, or the /tmp run-file path failed and a workaround worked.references/ (the directory holding this SKILL.md). Bump the patch number of metadata.version. If the skill is an installed copy or tracked in git, say so. Commit nothing unless the user asks.Off — the user opted out.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub luongnv89/skills --plugin lstack20 skills in this plugin
/agent-configCreate, update, or audit AGENTS.md (default) or CLAUDE.md agent instructions: set up, prune, add a rule, or merge CLAUDE.md or .cursorrules into one file Claude Code, Codex, and Cursor all read. Don't use for READMEs, skills, or subagents./auto-pushGenerate a commit message, stage all changes, and push to remote after scanning for secrets, large files, and protected-branch risks. Skip for opening PRs, code review, or cutting releases/tags./cleanup-projectPrepare a git repo before new work: review uncommitted changes, fix .gitignore, delete merged branches, end on clean main, or inspect one branch before deciding. Don't use for dead code, commit-and-push, releases, LICENSE files, or git how-tos./cli-builderBuild production-quality CLIs with language detection and a five-step approval-gated workflow. Use when wrapping an existing module or app. Don't use for GUI/TUI apps, web APIs, or one-off shell scripts./code-analysis-setupPlan, then install on approval, free static analysis (lint, SAST, secrets, deps) across repos, merged into existing hooks and CI. Use when adding code analysis. Don't use for one-repo security stacks (security-setup) or CI/CD (devops-pipeline)./code-reviewReview or improve code in four modes: bug/security review (default), performance, clean-code audit, slop cleanup (mode:review|perf|clean|cleanup). Don't use for features, tests (test-coverage) or a full comment audit (comment-audit).Other plugins' skills for the same job