Agent skill

Subprocess Safety

by ZaxbyHub in ZaxbyHub/opencode-swarm

Guidelines for safe subprocess calls in opencode-swarm. An agent skill from ZaxbyHub/opencode-swarm.

MITAuto-check passedAgent Workflows

Install Subprocess Safety

skills CLI
$ npx skills add ZaxbyHub/opencode-swarm --skill subprocess-safety -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ZaxbyHub/opencode-swarm subprocess-safety --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ZaxbyHub/opencode-swarm.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/subprocess-safety .claude/skills/subprocess-safety && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
subprocess-safety
GitHub stars
494
Token cost
~2.4k tokens
SKILL.md length
957 words
Files
1
Skills in repo
91
Repo updated
First seen
Licence
MIT

At a glance

Guidelines for safe subprocess calls in opencode-swarm. An agent skill from ZaxbyHub/opencode-swarm.

  • Works in 4 steps: AGENTS.md (Invariant 3: subprocesses) → docs/engineering-invariants.md… → .agents/skills/writing-tests/SKILL.md if… → …
  • Agent Workflows work in your project
  • SKILL.md covers When to use this skill, Scope, Canonical spawn shape and Six required properties, plus 6 more sections
  • Calls gh, git and bun

What it does

Subprocess Safety is an agent skill from ZaxbyHub/opencode-swarm. Guidelines for safe subprocess calls in opencode-swarm. Load before adding, modifying, or reviewing any file that calls spawn, spawnSync, bunSpawn, or childprocess. Covers the six required properties, Windows portability, internals DI seam pattern, and verification grep.

Its SKILL.md is about 2.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Agent Workflows. The repository describes itself as: Architect-centric agentic swarm plugin for OpenCode. Hub-and-spoke orchestration with SME consultation, code generation, and QA review. The licence is MIT.

When your agent uses it

  • Agent Workflows work in your project

Example prompts

  • “Use the subprocess-safety skill to guideline for safe subprocess calls in opencode-swarm. An agent skill from ZaxbyHub/opencode-swarm”
  • “/subprocess-safety”

Requirements

  • Node.js

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. AGENTS.md (Invariant 3: subprocesses)
  2. docs/engineering-invariants.md (subsection 3)
  3. .agents/skills/writing-tests/SKILL.md if tests are touched
  4. .opencode/skills/generated/mock-to-internals-migration/SKILL.md if converting mock.module to _internals

What it can do on your machine

Read from SKILL.md and the folder at commit b63a4bd. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • gh
    • git
    • bun

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use gh and git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Subprocess Safety loads about 2.4k tokens when it runs. Until then it costs about 73 tokens; SKILL.md has 957 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~73
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ZaxbyHub/opencode-swarm at commit b63a4bd, republished under its MIT licence (© ZaxbyHub). 957 words, ~2,403 tokens.

Download SKILL.mdSave it as .claude/skills/subprocess-safety/SKILL.md (or your agent's skills folder).
name
subprocess-safety
description
Guidelines for safe subprocess calls in opencode-swarm. Load before adding, modifying, or reviewing any file that calls spawn, spawnSync, bunSpawn, or child_process. Covers the six required properties, Windows portability, _internals DI seam pattern, and verification grep.
audience
swarm-plugin

Subprocess Safety

Read, in order:

  1. AGENTS.md (Invariant 3: subprocesses)
  2. docs/engineering-invariants.md (subsection 3)
  3. .agents/skills/writing-tests/SKILL.md if tests are touched
  4. .opencode/skills/generated/mock-to-internals-migration/SKILL.md if converting mock.module to _internals

Codex-specific execution notes:

  • This skill consolidates AGENTS.md Invariant 3 into an actionable checklist.
  • The canonical spawn shape and six required properties are non-negotiable per AGENTS.md.
  • The CI quality job enforces these via bun run check:invariants (Check 1: subprocess timeout).
  • Violations are advisory in CI but blocking in code review.

When to use this skill

  • You are adding, modifying, or reviewing a subprocess call (bunSpawn, spawn, spawnSync, child_process.execFile, etc.)
  • You are writing or updating tests that exercise subprocess-dependent code
  • A PR review flags a subprocess call missing timeout, cwd, or cleanup

Scope

This skill applies to all files that spawn child processes:

  • src/utils/git*.ts
  • src/hooks/*.ts
  • src/tools/*.ts
  • src/services/*.ts
  • src/plugins/*.ts
  • src/index.ts (init-path subprocesses)
  • Any test file (tests/**) that stubs or exercises subprocess code

Canonical spawn shape

Every subprocess call MUST follow this pattern:

typescript
const PER_CALL_TIMEOUT_MS = 10_000; // module-level constant (choose an appropriate value)

const proc = bunSpawn(['git', '-C', dir, 'rev-parse', '--show-toplevel'], {
  stdin: 'ignore',
  cwd: dir,
  timeout: PER_CALL_TIMEOUT_MS,
  // stdout/stderr: piped, bounded, or ignored
});
try {
  const result = await proc;
  // process result
} finally {
  proc.kill(); // best-effort cleanup
}

Six required properties

PropertyRequiredRationale
Array-form argsYesNo shell-string commands (injection risk, quoting hell)
cwd or git -CYesNever rely on inherited process.cwd()
stdin: 'ignore'YesA never-closed stdin pipe under Bun/Windows can block child exit (v7.3.3)
timeout: <ms>YesNo subprocess is "always fast" on every platform
stdout/stderr boundedYesNever leave piped stream unattended on long-running child
proc.kill() in finallyYesOuter withTimeout lets awaiter proceed but doesn't abort child

execFile callback vs execFileSync distinction

child_process.execFile (callback form) and child_process.execFileSync have different default stdio behavior:

APIDefault stdinRisk
execFileSync'inherit'Child inherits parent stdin — v7.3.3 vector on Windows/Bun if stdin is never closed
execFile (callback)'pipe'Child gets an internal pipe — lower risk but still not ideal for defense-in-depth

Key differences from the canonical spawn pattern:

  1. proc.kill() in finally (line 69): Applicable to callback-form execFile. The function returns a ChildProcess reference (matching the canonical spawn pattern per Node.js docs). The child reference enables kill() before that point for timeout safety, and failing to call proc.kill() in finally can leave orphaned children when combined with an outer withTimeout. The timeout option triggers internal SIGTERM, but is not a substitute for explicit kill in finally — always kill the child in finally.

  2. stdin: 'ignore' (line 66): Technically default-safe for callback execFile (stdin is piped, not inherited). However, always add stdio: ['ignore', 'pipe', 'pipe'] for defense-in-depth and consistency with execFileSync calls. Note: Bun's TypeScript definitions do not include stdio in ExecFileOptions — use execOpts as any when passing stdio to callback-form execFile.

  3. execFileSync should always use stdio: ['ignore', 'pipe', 'pipe'] to prevent the stdin-inheritance hang on Windows/Bun (v7.3.3).

Windows-specific notes

  • .cmd extensions: npm/bun binaries on Windows are .cmd wrappers. Resolve the executable path explicitly using which/where or the project's cross-platform helper. Do NOT enable shell: true or shell-mediated execution to work around PATH resolution.
  • PATH differences: cmd.exe and PowerShell resolve PATH differently. Test on Windows, not just macOS/Linux.
  • child_process.spawn('bin', ...) does not behave identically to running under cmd.exe. Use array-form args and explicit cwd.
  • fs.renameSync cannot overwrite existing directories on Windows. Use a remove-then-rename pattern or fs.rename with error handling.

gh CLI Subprocess Patterns

The gh CLI is a common subprocess in this repo (scripts/release-notes-fragments.mjs, CI workflows). It follows the same six required properties as all subprocesses, plus several gh-specific patterns.

Show full SKILL.md (417 more words)Show less
gh api --paginate requires --slurp

Bug pattern (PR #1762 F-002): gh api --paginate without --slurp produces concatenated JSON arrays on stdout. JSON.parse() can only parse the first array — subsequent arrays cause a parse error or are silently lost.

Correct pattern:

javascript
const raw = execFileSync('gh', ['api', '--paginate', '--slurp', 'repos/.../pulls', ...], {
  encoding: 'utf8',
  timeout: 30_000,
  maxBuffer: 16 * 1024 * 1024,
  stdio: ['ignore', 'pipe', 'pipe'], // required for execFileSync (AGENTS.md §3)
});
// --slurp wraps paginated results as [[page1], [page2], ...]
const pages = JSON.parse(raw);
const allItems = pages.flat(); // flatten to single array

Without --slurp: stdout is [item1, item2][item3, item4] — invalid JSON after the first array. This is a silent data loss bug that only manifests when results span multiple pages (>30 items by default).

stdin: 'ignore' for gh calls

gh subprocess calls must include stdin: 'ignore' (or stdio: ['ignore', 'pipe', 'pipe'] for execFileSync). This is the same invariant as all subprocesses (AGENTS.md §3). For example, scripts/release-notes-fragments.mjs defines ghJson() and ghText() helpers using execFileSync — these must include stdio: ['ignore', 'pipe', 'pipe'] per the six required properties. A PR review (pre-merge) identified this gap.

Number.isInteger() for API response validation

When validating integer IDs from API responses (PR numbers, issue numbers, run IDs), use Number.isInteger(), not Number.isFinite(). Number.isFinite() accepts floats like 1.5, which are never valid IDs.

javascript
// Correct
function isValidPrNumber(n) {
  return Number.isInteger(n) && n > 0;
}

// Wrong — accepts 1.5, NaN, Infinity
function isValidPrNumber(n) {
  return Number.isFinite(n) && n > 0;
}

Note: This is a stricter pattern. Some existing code uses Number.isFinite() after parseInt() — while technically safe for parsed integers, Number.isInteger() is the correct guard for all ID validation going forward.

maxBuffer for large API responses

gh api can return large payloads. Set maxBuffer: 16 * 1024 * 1024 (16 MiB) to prevent silent truncation. This is especially important for --paginate calls that aggregate multiple pages.

Note: maxBuffer is specific to Node.js child_process.execFile/execFileSync. For Bun's bunSpawn, use the equivalent output bounding option.

Testing pattern: _internals DI seam, NOT mock.module

mock.module(...) leaks across test files in Bun's shared test-runner process. Use dependency injection instead:

typescript
// --- source file (e.g. src/utils/gitignore-warning.ts) ---
import { bunSpawn } from './bun-compat';

export const _internals: { bunSpawn: typeof bunSpawn } = { bunSpawn };

// In production code, call _internals.bunSpawn(...) instead of bunSpawn(...)

// --- test file ---
import { _internals } from '../../src/utils/gitignore-warning';
const real = _internals.bunSpawn;
beforeEach(() => { _internals.bunSpawn = stub; });
afterEach(() => { _internals.bunSpawn = real; });

For the full migration protocol, load the mock-to-internals-migration skill.

Verification grep

After changing any file with subprocess calls, run:

bash
grep -n "bunSpawn\|spawn(\|spawnSync(" src/<changed>/*.ts

Every match MUST have all of:

  1. timeout set to a concrete millisecond value
  2. stdin: 'ignore' (unless intentionally interactive; note: callback-form execFile uses stdio: ['ignore', 'pipe', 'pipe'] instead)
  3. cwd or git -C <directory> for explicit working directory
  4. proc.kill() in a finally block or equivalent cleanup path (exception: callback-form execFile manages cleanup internally via timeout option)

Historical failures

  • v7.0.3 (#704): repo-graph Desktop hang -- unbounded filesystem scan on plugin init. No timeout, no kill path. Result: "no agents in TUI/GUI" with no error message.
  • v7.3.3 (#732): Git-hygiene startup regression -- ensureSwarmGitExcluded called git without timeout, stdin, or kill. Result: same silent failure on Windows.

Both caused OpenCode to silently drop the plugin manifest. Users saw no agents and no error. Every subprocess call is a potential repeat of these failures unless all six properties are enforced.

© ZaxbyHub, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/subprocess-safety of ZaxbyHub/opencode-swarm.

Open the folder on GitHubat commit b63a4bd

Compare with similar skills

Subprocess Safety next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Subprocess Safety compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Subprocess Safety this skillZaxbyHub/opencode-swarm494—~2.4kAutomated safety check: PassMIT
MCP Server Builderanthropics/skills180k63 repos~2.3kAutomated safety check: PassApache-2.0
Hook Development for Claude Code Pluginsanthropics/claude-plugins-official38k10 repos~4.1kAutomated safety check: NotesApache-2.0
Using Superpowersfarm-fe/farm5.6k35 repos~1.4kAutomated safety check: PassMIT
Executing Plans Inlineobra/superpowers297k2 repos~5.1kAutomated safety check: PassMIT
Skill CreatorAzure/azqr79689 repos~8.2kAutomated safety check: PassApache-2.0

Similar skills

  • MCP Server Builder

    anthropics/skills

    Official

    Guides the design and implementation of Model Context Protocol servers in TypeScript or Python, from tool naming and error messages to evaluation.

    180k GitHub starsUsed in 63 repos~2.3k tokens
    Agent WorkflowsAuto-check passed
  • Hook Development for Claude Code Plugins

    anthropics/claude-plugins-official

    Official

    Explains how to write Claude Code plugin hooks, both prompt-based checks and bash commands, for events such as PreToolUse, Stop and SessionStart.

    38k GitHub starsUsed in 10 repos~4.1k tokens
    Agent WorkflowsAuto-check: notes
  • Using Superpowers

    farm-fe/farm

    A skill your agent uses when starting any conversation - establishes how to find and use skills, requiring Skill tool invocation before ANY response including clarifying questions

    5.6k GitHub starsUsed in 35 repos~1.4k tokens
    Agent WorkflowsAuto-check passed
  • Executing Plans Inline

    obra/superpowers

    Has the agent carry out an implementation plan itself, task by task in the current session, keeping a ledger, proving each step with a test and ending with one whole-branch review.

    297k GitHub starsUsed in 2 repos~5.1k tokens
    Agent WorkflowsAuto-check passed
  • Skill Creator

    Azure/azqr

    Official

    Create new skills, modify and improve existing skills, and measure skill performance.

    796 GitHub starsUsed in 89 repos~8.2k tokens
    Agent WorkflowsAuto-check passed
  • Claude Code Agent Development

    anthropics/claude-plugins-official

    Official

    Explains how to write agents for Claude Code plugins: the markdown file with YAML frontmatter, trigger descriptions, model and color settings, and system prompt design.

    38k GitHub starsUsed in 7 repos~2.8k tokens
    Agent WorkflowsAuto-check passed

More from ZaxbyHub/opencode-swarm

All 91 skills in this repo
  • Codebase Review Swarm

    ZaxbyHub/opencode-swarm

    Runs an evidence-gated, quote-grounded audit of a codebase for security, QA, accessibility, performance and more, and writes a verified report without changing source files.

    494 GitHub stars~2.8k tokensUpdated today
    Auto-check passed
  • Issue Tracer

    ZaxbyHub/opencode-swarm

    Drives a bug report from validation and root-cause tracing through a critic-reviewed plan, an approved minimal fix and a PR-ready closure, never merging without recorded human approval.

    494 GitHub stars~4.4k tokensUpdated today
    Auto-check passed
  • Commit and PR Publishing for Codex

    ZaxbyHub/opencode-swarm

    Codex adapter for opencode-swarm that governs commits, pushes, draft PRs, PR body updates and CI closeout, deferring to the repo's canonical commit-pr protocol.

    494 GitHub stars~1.6k tokensUpdated today
    Auto-check passed
  • Durable Session State

    ZaxbyHub/opencode-swarm

    Keeps plans, decisions, evidence and reviewer verdicts in small files so long multi-phase tasks survive context compaction and session resumes.

    494 GitHub stars~896 tokensUpdated today
    Auto-check passed
  • Swarm PR Feedback Closer

    ZaxbyHub/opencode-swarm

    Ingests existing pull request feedback such as review comments and CI failures, verifies each claim, fixes confirmed issues and reports closure status for every item.

    494 GitHub stars~14k tokensUpdated today
    Auto-check passed
  • Swarm PR Subscribe

    ZaxbyHub/opencode-swarm

    Monitor a pull request after creation and act autonomously on pushed PR activity.

    494 GitHub stars~2.2k tokensUpdated today
    Auto-check passed

Categories

Questions about Subprocess Safety

What does Subprocess Safety do?

Guidelines for safe subprocess calls in opencode-swarm. An agent skill from ZaxbyHub/opencode-swarm. Subprocess Safety is an agent skill from ZaxbyHub/opencode-swarm. Guidelines for safe subprocess calls in opencode-swarm.

When should I use Subprocess Safety?

Subprocess Safety fits situations like: agent Workflows work in your project.

How do I install Subprocess Safety in Claude Code?

Run `npx skills add ZaxbyHub/opencode-swarm --skill subprocess-safety -a claude-code`. Or copy the skill folder (.agents/skills/subprocess-safety in ZaxbyHub/opencode-swarm) into .claude/skills/subprocess-safety in your project. Claude Code loads it when a task matches its description.

How do I install Subprocess Safety in Codex?

Run `npx skills add ZaxbyHub/opencode-swarm --skill subprocess-safety -a codex`. Or copy the skill folder (.agents/skills/subprocess-safety in ZaxbyHub/opencode-swarm) into .agents/skills/subprocess-safety in your project. Codex loads it when a task matches its description.

Can I use Subprocess Safety in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ZaxbyHub/opencode-swarm --skill subprocess-safety -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/subprocess-safety, .gemini/skills/subprocess-safety, .github/skills/subprocess-safety and .opencode/skills/subprocess-safety in your project.

What does Subprocess Safety need to run?

Going by SKILL.md and its folder, Subprocess Safety needs the command-line tools its instructions call (gh, git and bun). Our summary lists: Node.js.

Does Subprocess Safety access the network?

SKILL.md contains no URLs. Its commands use gh and git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Subprocess Safety safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Subprocess Safety use?

Subprocess Safety is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Subprocess Safety use?

About 2.4k tokens (SKILL.md is roughly 9.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Subprocess Safety?

Skills that share tags, products or a category with Subprocess Safety: MCP Server Builder (anthropics/skills, 180k stars), Hook Development for Claude Code Plugins (anthropics/claude-plugins-official, 38k stars), Using Superpowers (farm-fe/farm, 5.6k stars) and Executing Plans Inline (obra/superpowers, 297k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Subprocess Safety?

ZaxbyHub (a GitHub organization) maintains it in ZaxbyHub/opencode-swarm, which has 494 GitHub stars. The repository holds 91 skills in this directory. The repository was last updated on October 10, 2026.

Source: ZaxbyHub/opencode-swarm on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.