Approved catalog listing
SKILL #4586
skillshunter.net
Home / Software & Development / Rjv Opencode Agents
Listing Approved Approved on: December 3, 2026

Rjv Opencode Agents

Launch and watch opencode runs using `scripts/opencode-watch.sh` for DeepSeek v4.1 Flash with one retry, liveness heartbeat, stall/cap kill, git-tree fingerprint, and empty-dir text mode.

Rate this skill

No ratings yet

Editor's Note

Use `text` mode for tasks requiring only prompt text and `repo` mode for repository reviews, ensuring read-only access unless edits are explicitly requested. Always write the brief to a file and start the watcher; never launch the same brief a third time on opencode.

When to Use It

  • Launching opencode runs for text-based tasks in an empty directory
  • Watching and managing opencode runs for repository reviews with read-only access
  • Handling stalled or capped runs with automatic retries and result checks

SKILL.md

SkillsHunter provides this listing for informational purposes only. Review the skill’s source, license, and required permissions before use. You are responsible for deciding whether to install or run it. Terms of Use

↓ Download .md

opencode agents: launch, watch, recover

opencode is the cheapest worker (DeepSeek v4.1 Flash, one retry on DeepSeek v4.1 Flash again; DeepSeek only, per the user 2026-11-23). It is also the one most likely to run long or die silently. The launcher never waits on it in the foreground: every run goes through the watcher, and you keep working while it reports.

Delegation policy and watching background work live in rjv-delegate (§8); which tasks go to opencode and the 2 / 5 minute boxes live in rjv-subagents-claude / rjv-subagents-codex. This skill owns what happens after you decide.

1. Pick the mode

The task needs... Mode Where opencode runs
only the text in the prompt text a fresh empty directory the script makes
to read a repo (review, recon) repo the repo, with --auto

opencode reads files and runs shell commands in its working directory even without --auto (probe, 2026-11-04: it read a file and wrote another with no approval). So text mode always runs in an empty directory, and anything that touches secrets, customer data or production stays on host cloud models, as rjv-delegate §3 says.

In repo mode the brief says read-only unless edits are the task. The watcher fingerprints the git tree before and after. tree=CHANGED on a read-only brief: discard the result, list the paths from git status --porcelain in your report, and never commit them. Revert only when the user says so.

2. Launch through the watcher

Write the brief to a file, then start the watcher. It runs on its own; you never sit in a foreground wait for it.

S=<this skill's dir>/scripts/opencode-watch.sh
$S <dir> <brief-file> <result-file> <cap-minutes> text|repo
  • <result-file>: absolute path. In repo mode the brief tells opencode to write its answer there. In text mode the script fills it from the run's final text.
  • <cap-minutes>: the hard ceiling per model attempt. Set it to 3x the box (box 2 → cap 6, box 5 → cap 15). The box sizes the task; the cap only catches a run that will never finish.

Claude Code: start it with the Monitor tool, timeout_ms above the cap times two (both models may run), so each event line arrives as a notification. Codex: run it as a background command and read its stdout when it exits.

3. React to the events

The watcher prints one line per event.

Event Meaning You do
START an attempt began keep working
ALIVE heartbeat every 2 min, still producing keep working
STALL silent=N one check saw no change in log, result, database or CPU nothing yet; 4 in a row is a kill
KILL reason=silent dead: 4 silent checks (2 min at 30 s) the watcher retries once on DeepSeek by itself
KILL reason=cap alive but over the cap the watcher retries; the task is too big, so split it next time
EXIT code=N one attempt ended; a retry may follow wait for DONE
DONE status=ok result file is non-empty check it (§4)
DONE status=failed both models failed §5

A run that is alive is never killed early. Time past the box means the task was too big or the brief too thin; let it finish under the cap, then split the next one smaller.

4. Check the result yourself

  • Read the result file. opencode's own "done" is a claim.
  • Mechanical output (a list, a lint pass): spot-check three items against the source.
  • repo mode: tree=unchanged on a read-only brief. tree=CHANGED on a read-only brief: discard the result, list the paths from git status --porcelain in your report, and never commit them. Revert only when the user says so.
  • Report what came back and which model produced it (the DONE line names it).

5. When both models fail

Walk this in order and stop at the first that applies:

  1. The brief asked for too much: split it in two and launch both.
  2. The brief was unclear (the log shows it asking questions or wandering): rewrite the brief and launch once more.
  3. Otherwise hand the task to a Haiku subagent (Sonnet if it needs judgment), with the same brief.

Never launch the same brief a third time on opencode.

6. Tuning and spend

Environment knobs, all optional: OPENCODE_CHECK_SEC (30), OPENCODE_SILENT_MAX (4), OPENCODE_HEARTBEAT_MIN (2), OPENCODE_MODELS (the two-model list). The JSON event log only grows at step boundaries, which is why CPU time and the database WAL also count as signs of life.

After a batch of runs, check spend with opencode stats --days 0 --models --cost.

The per-run log sits beside the result as <result-file>.log.

Tested 2026-11-04: a short text task returned in 5 s; a bad model name fell through to the second model; a 3,000-word essay under a 1 min cap stayed alive (no STALL) and was killed at the cap; a fake opencode that hangs with no output was killed after 2 silent checks on both models, with no orphan processes left.

7. Local models (Ollama)

The same watcher runs a local model: set OPENCODE_MODELS="ollama/<name>". The model must be listed under provider.ollama.models in ~/.config/opencode/opencode.jsonc. Local models are owned by rjv-codex-ollama-subagents; this section is only what the watcher does.

  • Liveness. The work runs in Ollama's llama-server, so the watcher counts its CPU time as a sign of life.
  • Memory. It refuses to start an ollama/* model below OPENCODE_MIN_FREE_PCT (25) free memory. The event is SKIP reason=memory.
  • Kill. On a kill or a failed exit it runs ollama stop <name>, which stops generation and frees the memory. Tested: a 1-minute cap killed a long essay at 64 s and left no model loaded.
  • Load. A cold start of a 52 GB model takes about 20 to 40 s. Keep the cap at 3x the box anyway.

How to brief and judge a local model (context size, narrow questions, text mode with code pasted, never the gate): rjv-codex-ollama-subagents, which owns local models.

Related

  • rjv-delegate: delegation policy and watching slow work off the main thread.
  • rjv-subagents-claude / rjv-subagents-codex: host ladders, rungs and boxes.
  • rjv-codex-ollama-subagents: Codex's local runners (ollama-chat.sh for one-shot text through the API, local-codex-agent.sh).
View original Markdown
---
name: rjv-opencode-agents
description: "Mechanism: launch and watch an opencode run via opencode-watch.sh (DeepSeek v4.1 Flash, one retry, liveness heartbeat, stall/cap kill, tree fingerprint, optional local Ollama models). Delegation policy lives in rjv-delegate; host rungs and boxes in rjv-subagents-claude / rjv-subagents-codex. Triggers: opencode, opencode-watch, opencode stall, opencode retry."
---

# opencode agents: launch, watch, recover

opencode is the cheapest worker (DeepSeek v4.1 Flash, one retry on
DeepSeek v4.1 Flash again; DeepSeek only, per the user 2026-11-23). It is also the one most likely to run long or die
silently. The launcher never waits on it in the foreground: every run
goes through the **watcher**, and you keep working while it reports.

Delegation policy and watching background work live in `rjv-delegate`
(§8); which tasks go to opencode and the 2 / 5 minute boxes live in
`rjv-subagents-claude` / `rjv-subagents-codex`. This skill owns what
happens after you decide.

## 1. Pick the mode

| The task needs... | Mode | Where opencode runs |
|---|---|---|
| only the text in the prompt | `text` | a fresh empty directory the script makes |
| to read a repo (review, recon) | `repo` | the repo, with `--auto` |

**opencode reads files and runs shell commands in its working
directory even without `--auto`** (probe, 2026-11-04: it read a file
and wrote another with no approval). So `text` mode always runs in an
empty directory, and anything that touches secrets, customer data or
production stays on host cloud models, as `rjv-delegate` §3 says.

In `repo` mode the brief says read-only unless edits are the task. The
watcher fingerprints the git tree before and after. `tree=CHANGED` on a
read-only brief: discard the result, list the paths from `git status
--porcelain` in your report, and never commit them. Revert only when the
user says so.

## 2. Launch through the watcher

Write the brief to a file, then start the watcher. It runs on its own;
you never sit in a foreground wait for it.

```sh
S=<this skill's dir>/scripts/opencode-watch.sh
$S <dir> <brief-file> <result-file> <cap-minutes> text|repo
```

- `<result-file>`: absolute path. In `repo` mode the brief tells
  opencode to write its answer there. In `text` mode the script fills it
  from the run's final text.
- `<cap-minutes>`: the hard ceiling per model attempt. Set it to 3x the
  box (box 2 → cap 6, box 5 → cap 15). The box sizes the task; the cap
  only catches a run that will never finish.

**Claude Code**: start it with the Monitor tool, `timeout_ms` above the
cap times two (both models may run), so each event line arrives as a
notification. **Codex**: run it as a background command and read its
stdout when it exits.

## 3. React to the events

The watcher prints one line per event.

| Event | Meaning | You do |
|---|---|---|
| `START` | an attempt began | keep working |
| `ALIVE` | heartbeat every 2 min, still producing | keep working |
| `STALL silent=N` | one check saw no change in log, result, database or CPU | nothing yet; 4 in a row is a kill |
| `KILL reason=silent` | dead: 4 silent checks (2 min at 30 s) | the watcher retries once on DeepSeek by itself |
| `KILL reason=cap` | alive but over the cap | the watcher retries; the task is too big, so split it next time |
| `EXIT code=N` | one attempt ended; a retry may follow | wait for `DONE` |
| `DONE status=ok` | result file is non-empty | check it (§4) |
| `DONE status=failed` | both models failed | §5 |

A run that is alive is never killed early. Time past the box means
the task was too big or the brief too thin; let it finish under the
cap, then split the next one smaller.

## 4. Check the result yourself

- Read the result file. opencode's own "done" is a claim.
- Mechanical output (a list, a lint pass): spot-check three items
  against the source.
- `repo` mode: `tree=unchanged` on a read-only brief. `tree=CHANGED` on a
  read-only brief: discard the result, list the paths from `git status
  --porcelain` in your report, and never commit them. Revert only when the
  user says so.
- Report what came back and which model produced it (the `DONE` line
  names it).

## 5. When both models fail

Walk this in order and stop at the first that applies:

1. The brief asked for too much: split it in two and launch both.
2. The brief was unclear (the log shows it asking questions or
   wandering): rewrite the brief and launch once more.
3. Otherwise hand the task to a Haiku subagent (Sonnet if it needs
   judgment), with the same brief.

Never launch the same brief a third time on opencode.

## 6. Tuning and spend

Environment knobs, all optional: `OPENCODE_CHECK_SEC` (30),
`OPENCODE_SILENT_MAX` (4), `OPENCODE_HEARTBEAT_MIN` (2),
`OPENCODE_MODELS` (the two-model list). The JSON event log only grows
at step boundaries, which is why CPU time and the database WAL also
count as signs of life.

After a batch of runs, check spend with
`opencode stats --days 0 --models --cost`.

The per-run log sits beside the result as `<result-file>.log`.

Tested 2026-11-04: a short text task returned in 5 s; a bad model name
fell through to the second model; a 3,000-word essay under a 1 min cap
stayed alive (no STALL) and was killed at the cap; a fake opencode that
hangs with no output was killed after 2 silent checks on both models,
with no orphan processes left.

## 7. Local models (Ollama)

The same watcher runs a local model: set `OPENCODE_MODELS="ollama/<name>"`.
The model must be listed under `provider.ollama.models` in
`~/.config/opencode/opencode.jsonc`. Local models are owned by
`rjv-codex-ollama-subagents`; this section is only what the watcher does.

- **Liveness.** The work runs in Ollama's `llama-server`, so the watcher
  counts its CPU time as a sign of life.
- **Memory.** It refuses to start an `ollama/*` model below
  `OPENCODE_MIN_FREE_PCT` (25) free memory. The event is `SKIP reason=memory`.
- **Kill.** On a kill or a failed exit it runs `ollama stop <name>`, which
  stops generation and frees the memory. Tested: a 1-minute cap killed a
  long essay at 64 s and left no model loaded.
- **Load.** A cold start of a 52 GB model takes about 20 to 40 s. Keep
  the cap at 3x the box anyway.

How to brief and judge a local model (context size, narrow questions,
text mode with code pasted, never the gate): `rjv-codex-ollama-subagents`,
which owns local models.

## Related

- `rjv-delegate`: delegation policy and watching slow work off the main thread.
- `rjv-subagents-claude` / `rjv-subagents-codex`: host ladders, rungs and boxes.
- `rjv-codex-ollama-subagents`: Codex's local runners (`ollama-chat.sh`
  for one-shot text through the API, `local-codex-agent.sh`).

Community Reviews & Field Notes

Tried this skill on your own project? Share the model you used and the results you got.

Add Your Review

Approved reviews appear publicly with the name or role you enter. See the Privacy Notice.