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
In this repository14 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- architectSkill
- atomic-commitSkill
- codebase-tutorialSkill
- code-walkthroughSkill
- deep-research-economySkill
- deep-researchSkill
- github-pushSkill
- instagram-transcriptSkill
- move-projectSkill
- poc-portfolio-prepSkill
- research-via-opencodeSkill
- resume-after-windowSkill
- translate-ruSkill
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
- Distinctive: line 35
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 …
- Very specific: line 46
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 … - Very specific: line 52
When running an agent on new ground — back up the result: a background loop cp -r <worktree>/*.py <worktree>/tests /tmp/backup/ every few …
- Distinctive: line 65
Write explicitly: "don't change files X, Y — they are done", and "at the end commit: git add -A && git commit".
- Very specific: line 71
Read only the tail: sed -n '/acceptance/,$p' log | cut -c1-160.
- Very specific: line 77
Check that tests were not weakened: no skip/xfail, asserts are meaningful.
≈ “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.
Files
Skill: Code via OpenCode Go
Tooling
bin/oc-code— the wrapper: creates a disposable git worktree, runsopencode run --agent coder, runs the tests independently, leaves branchoc/<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 # dropDivision 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:
- 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. - 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).
- Subagents get modules with clear boundaries + their tests. One agent per non-overlapping set of files, launched in parallel, in the background.
- 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 setSLUG_OVERRIDE=<name>. BASE="HEAD"was not pinned to a SHA: after the agent committed,git diff HEADinside the worktree was empty, the result was treated as missing and the worktree was deleted together with the code. Now the base is resolved toBASE_SHAup 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-codeanddeepseek-v4-proare 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
-twith 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:
.envdoes not reach the worktree (it is untracked). Real runs are Claude's job. - Don't grep agent logs broadly:
/tmp/oc*.logcontains walls of JSON with permission rules; onegrepwithoutcut -c1-200eats 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)
- Your own run of the full test suite, not just the agent's files.
- A quick look at the interfaces:
grep -n "^def \|^class " module.py. - Check that tests were not weakened: no
skip/xfail, asserts are meaningful. - Merge
--no-ffwith a clear message; don't drag the agent's report into the commit.
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
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.

