subprocess-safety

Audits unsafe spawn and child_process calls in OpenCode Swarm codebases for Windows compatibility and security issues.

437|45|Updated Jan 27, 2026
One-click install
npx skills add https://github.com/ZaxbyHub/opencode-swarm --skill subprocess-safety
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: subprocess-safety
Source: https://github.com/ZaxbyHub/opencode-swarm/tree/main/.agents/skills/subprocess-safety
Command: npx skills add https://github.com/ZaxbyHub/opencode-swarm --skill subprocess-safety

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Unsafe child process spawning in OpenCode Swarm code causes silent plugin failures, orphaned background processes, command injection security risks, and cross-platform compatibility issues (especially on Windows) that often leave users with no visible error or working agents.

Core Features & Use Cases

  • Mandatory subprocess guardrails: Enforces six non-negotiable properties for all child process calls (array-form arguments, explicit working directory, ignored stdin, per-call timeouts, bounded output streams, and explicit kill in finally blocks) to prevent hangs and resource leaks.
  • Cross-platform compatibility guidance: Provides specific fixes for Windows-specific issues like .cmd wrapper PATH resolution, stdin inheritance bugs in Bun v7.3.3, and fs.rename limitations that cause unexpected failures on non-Unix systems.
  • Testable subprocess patterns: Replaces leaky mock.module() usage with a dependency injection _internals seam for isolated, reliable testing of subprocess-dependent code.
  • Use Case: When adding a new git utility function that spawns child processes to check repository status, this skill ensures the implementation will not cause silent plugin failures on Windows or leave orphaned git processes running in the background.

Quick Start

Use the subprocess-safety skill to audit all subprocess calls in your new git utility module before submitting the pull request for review.

Frequently Asked Questions about subprocess-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent orphaned child processes and silent failures when spawning subprocesses?

To prevent orphaned child processes and silent failures, enforce six mandatory subprocess call properties including array-form arguments, explicit working directories, ignored stdin, per-call timeouts, bounded output streams, and explicit kill in finally blocks.

What causes child process spawning to fail silently on Windows?

Child process spawning fails silently on Windows due to .cmd wrapper PATH resolution issues, stdin inheritance bugs in Bun v7.3.3, and fs.rename limitations. Applying cross-platform compatibility best practices resolves these unexpected failures.

How do I test subprocess-dependent code without leaky mock module usage?

To test subprocess-dependent code without leaky mock.module usage, replace the mocks with a dependency injection _internals seam. This provides isolated, reliable testing patterns for code invoking spawn, spawnSync, or child_process APIs.

What are the mandatory properties for safe subprocess calls in OpenCode Swarm?

The mandatory properties for safe subprocess calls in OpenCode Swarm are array-form arguments, explicit working directory, ignored stdin, per-call timeouts, bounded output streams, and explicit kill in finally blocks. These prevent hangs and resource leaks.

How do I audit subprocess calls to prevent command injection security vulnerabilities?

Audit subprocess calls to prevent command injection vulnerabilities by enforcing six non-negotiable guardrails on all child_process, bunSpawn, spawn, and spawnSync invocations, followed by verification grep checks to meet engineering invariants.

Does subprocess-safety apply to test files and plugins that invoke child processes?

Yes, subprocess-safety applies to all files that invoke child process APIs, including source utilities, hooks, tools, services, plugins, and associated test files within the OpenCode Swarm codebase to ensure cross-platform reliability.