agentleFS
bsamsonovbsamsonov/claude-code-config/skills/code-via-opencode/SKILL.md

code-via-opencode

Skill0 starsChanged 2 months agoMITView on GitHub

Hands code writing off to OpenCode Go subagents (`bin/oc-code`) so the Claude 5-hour window is NOT spent on it. Claude writes the interface spec and the critical parts, subagents write modules and tests in disposable git worktrees, Claude reviews and merges. Use when the user says: "implement it via opencode", "use opencode subagents for the code", "write the code on opencode-go", "don't burn the window, code with subagents", and also for a large from-scratch implementation when the Claude window must be saved.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Claude writes itself: only the delicate parts: where a model's mistake would not be caught by tests (the core of a graph/algorithm), and …

    line 35
  2. Very specific:

    BASE="HEAD" was not pinned to a SHA: after the agent committed, git diff HEAD inside the worktree was empty, the result was treated as …

    line 46
  3. Very specific:

    When running an agent on new ground — back up the result: a background loop cp -r <worktree>/*.py <worktree>/tests /tmp/backup/ every few …

    line 52
  4. Distinctive:

    Write explicitly: "don't change files X, Y — they are done", and "at the end commit: git add -A && git commit".

    line 65
  5. Very specific:

    Read only the tail: sed -n '/acceptance/,$p' log | cut -c1-160.

    line 71
  6. Very specific:

    Check that tests were not weakened: no skip/xfail, asserts are meaningful.

    line 77

≈ “Common” is an estimate: at least 1 in 5 of the 383,637 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: Code via OpenCode Go

Tooling

  • bin/oc-code — the wrapper: creates a disposable git worktree, runs opencode run --agent coder, runs the tests independently, leaves branch oc/<slug>.
  • Agent role: opencode/prompts/coder.md (minimal diff, green tests).
  • Agent permissions: opencode/opencode.jsonc → agent.coder.permission.
SLUG_OVERRIDE=tools oc-code -m kimi-k2.7-code -t "uv run pytest -q tests/test_tools.py" "task"
git merge --no-ff oc/tools-0731-0229      # accept
oc-code --drop oc/tools-0731-0229         # drop

Division of labour (the main point)

A subagent writes plausible code. Modules will fit together only if the contract is fixed in advance and from outside. Therefore:

  1. Claude writes SPEC.md — exact file names, classes, signatures, JSON format, test command. Explicitly: "contracts are fixed and must not change, modules are written in parallel". That is cheaper than any later integration.
  2. Claude writes itself only the delicate parts: where a model's mistake would not be caught by tests (the core of a graph/algorithm), and the scaffolding a subagent would trip over (e.g. a fake LLM with the right duck typing).
  3. Subagents get modules with clear boundaries + their tests. One agent per non-overlapping set of files, launched in parallel, in the background.
  4. Claude accepts: its own test run, a quick look at the interfaces, the merge.

Known pitfalls of oc-code (all three were fixed after they bit)

  • A multi-line prompt broke the branch name — the slug is taken from the first line only; for non-ASCII tasks it degenerates to task, so set SLUG_OVERRIDE=<name>.
  • BASE="HEAD" was not pinned to a SHA: after the agent committed, git diff HEAD inside the worktree was empty, the result was treated as missing and the worktree was deleted together with the code. Now the base is resolved to BASE_SHA up front.
  • Untracked files did not count as changes: an agent that created new files without committing lost all its work on cleanup. Now the wrapper commits the leftovers itself.

When running an agent on new ground — back up the result: a background loop cp -r <worktree>/*.py <worktree>/tests /tmp/backup/ every few seconds. Once it saved 47 finished tests.

Practice

  • Model (Go plan, as of 2026-09 — see the tier table in research-via-opencode): glm-5.2 (the wrapper default), kimi-k2.7-code and deepseek-v4-pro are fine for modules with tests, ~900–1 350 requests per 5 h. The 🚫 tier (kimi-k3, qwen3.8-max, grok-4.7, glm-5.3) is not for coding pipelines.
  • The repository working tree must be clean — commit before every run.
  • Give the agent -t with the exact test command for its files, otherwise it will go fixing someone else's red.
  • Write explicitly: "don't change files X, Y — they are done", and "at the end commit: git add -A && git commit".
  • The agent cannot do real runs that need secrets: .env does not reach the worktree (it is untracked). Real runs are Claude's job.
  • Don't grep agent logs broadly: /tmp/oc*.log contains walls of JSON with permission rules; one grep without cut -c1-200 eats thousands of tokens. Read only the tail: sed -n '/acceptance/,$p' log | cut -c1-160.

Acceptance (mandatory — never take the agent's word for it)

  1. Your own run of the full test suite, not just the agent's files.
  2. A quick look at the interfaces: grep -n "^def \|^class " module.py.
  3. Check that tests were not weakened: no skip/xfail, asserts are meaningful.
  4. Merge --no-ff with a clear message; don't drag the agent's report into the commit.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.