opencode: Skill for OpenCode

.opencode/skills/unit-tests/SKILL.md

unit-tests is a skill for OpenCode from anomalyco/opencode. It costs 175 tokens per session (5,839 once invoked), scanned A, original, MIT.

A guide for writing, reviewing, speeding up, and fixing flaky Bun unit tests. Unit tests check small pieces of code in isolation, while this guide also covers command-line and service tests outside the OpenTUI renderer suite.

In plain words
What is it for?
Use it for unit tests across the listed packages, including CLI subprocess and service tests, but use the separate TUI guide for OpenTUI renderer tests.
Why use it?
It addresses common causes of slow or unreliable tests, such as real-time waits, too many processes, wall-clock assertions, and package-specific timeout limits in continuous integration.

Skill for OpenCode

Written for OpenCode: installed under .opencode/. Also seen: mentions AGENTS.md; mentions OpenCode.

This is anomalyco/opencode's own configuration. It tells OpenCode how to work on opencode itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything opencode configures →

About the project

OpenCode is an open-source AI coding agent that helps developers work on software projects. It includes agents for full-access development, read-only exploration and planning, plus a general subagent for complex searches and multistep tasks; the catalogue add-ons extend its workflows.

anomalyco/opencode · 220,205 stars · on GitHub · opencode.ai

Reuse

Borrowing it

Nothing to install: this file belongs to anomalyco/opencode. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/anomalyco/opencode/dev/.opencode/skills/unit-tests/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/anomalyco/opencode

Made for: OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for unit-tests

README.md
[![agentmods](https://agentmods.dev/badge/skills/anomalyco/opencode/unit-tests/github.svg)](https://agentmods.dev/skills/anomalyco/opencode/unit-tests)
Your own site
<a href="https://agentmods.dev/skills/anomalyco/opencode/unit-tests"><img src="https://agentmods.dev/badge/skills/anomalyco/opencode/unit-tests/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for unit-tests

Your own site · 80×15
<a href="https://agentmods.dev/skills/anomalyco/opencode/unit-tests"><img src="https://agentmods.dev/badge/skills/anomalyco/opencode/unit-tests.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 175 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,839 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00175 $0.05839
Opus 5.5 $0.00070 $0.02336
Sonnet 5.5 $0.00035 $0.01168
Haiku 4.5 $0.00017 $0.00584

Measured 3d ago against content hash f7744a08a3d7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

unit-tests scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

- **Independent children** start together (`Promise.all`, `packages/ai/test/exports.test.ts:63`). `packages/app/test-browser/playwright-config.test.ts` runs sequential `Bun.spawnSync` (3.5s on Windows, 1.4s on Linux); `p
.opencode/skills/unit-tests/SKILL.md · 141 lines

How it starts

The opening of the file, as written. The whole thing — 141 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Fast, Reliable Unit Tests

CI runs bun turbo test --affected --concurrency=3 on 4-vCPU Linux and Windows runners (unit job in .github/workflows/test.yml), so each suite shares the CPU with two others, and Windows is the slower leg. Most slow or flaky unit tests here wait on real time, spawn too many processes, or assert wall-clock speed.

Read these first; this skill does not repeat them:

  • Root AGENTS.md: the Testing and Style Guide sections.
  • packages/app/AGENTS.md Tests (packages/desktop and packages/gui-extensions follow it): one owner per contract, and no production seams for tests.
  • packages/ai/AGENTS.md: cassettes. The effect skill: it.effect and it.live.

Sibling skills: tui-tests (OpenTUI renderer tests in tui and cli), app-e2e-tests (Playwright in packages/app/e2e), component-tests (Storybook Playwright). This skill owns cli subprocess and service tests.

Know the budget

  • Bun's default per-test timeout is 5000ms. Check the package's test script:
    • 30s: ai, cli, desktop, http-recorder, latex, merman, simulation, theme and tui pass --timeout 30000; core's script/test.ts passes --timeout=30000.
    • 5s: client, httpapi-codegen and sdk pass --timeout 5000; app, codemode, function, gui-extensions, plugin, plugin-browser, script, server, session-ui, ui and util use the default.
  • Size Windows risk by counting spawns, not by local wall time.
    • npm.test.ts "installs a Git package from an npm ::path: subdirectory at a branch" takes 0.4s locally and hit 5000ms on Windows CI. Each Npm.add Git case makes about 75 git process events: 3 clone --recurse-submodules, which run the git-submodule shell script.
    • Assume roughly 40ms per Git-for-Windows spawn (estimated from an earlier git.test run on Windows CI: ~24s for 564 spawns). Some core file groups run 5-9x slower on Windows than locally.
    • Those test.each cases (npm.test.ts:223, :251) hit 5000ms in 13 of 45 Windows core runs; that is why core's runner now defaults to 30s (comment at packages/core/script/test.ts:38).
  • A timeout loosens the budget only when it exceeds the package default.
    • In a 5s package, work that legitimately needs longer gets a per-test timeout and a comment naming the work: packages/server/test/fetch.test.ts:406-407 ("Real retries wait 18 * 200 ms ...", { timeout: 10_000 }). test.each(table)(name, fn, 30_000) takes it as the third argument. Use file-wide setDefaultTimeout only when every test in the file does such work.
    • In core, the four file-level setDefaultTimeout(30_000) calls only restate the runner default, and a per-test { timeout: 15_000 } (still in tool-shell.test.ts, session-generate.test.ts and others) is stricter than it. Do not add values at or below 30s there.
  • Never absorb a sleep, poll or production interval with a larger timeout, --retry, or skipIf(win32); remove the wait. Skip on Windows only when the platform lacks the capability, with a comment (npm.test.ts:313, symlinks).

Read the full file on GitHub · 141 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago Changed f7744a08a3d7
  2. 6d ago Changed 0fee850057b5
  3. 7d ago First seen · 141 lines · 175 tokens per session scan A e329fdec58db

Subscribe to this mod's changes

unit-tests is a skill published in the GitHub repository anomalyco/opencode (220,205 stars, last pushed today), licensed MIT. It adds 175 tokens to every session and 5,839 once invoked, about $0.0007 per session on Opus 5.5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-16.

Related

Other skills, from other repositories