OpenParable
Skip to content
← Back to skills

CLI Mock Stdin

Testing & Quality
cli-mock-stdin

CLI Mock Stdin is an Agent Skill for testing & quality published in the a5c-ai/babysitter repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Create mock stdin utilities for interactive CLI testing.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/a5c-ai/babysitter/blob/HEAD/library/specializations/cli-mcp-development/skills/cli-mock-stdin/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/cli-mock-stdin, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

CLI Mock Stdin

Create mock stdin utilities for testing.

Generated Patterns

import { Readable } from 'stream';

export function mockStdin(inputs: string[]): Readable {
  let index = 0;
  return new Readable({
    read() {
      if (index < inputs.length) {
        setTimeout(() => {
          this.push(inputs[index++] + '\n');
        }, 10);
      } else {
        this.push(null);
      }
    },
  });
}

export async function runWithStdin(
  cmd: () => Promise<void>,
  inputs: string[]
): Promise<void> {
  const originalStdin = process.stdin;
  Object.defineProperty(process, 'stdin', { value: mockStdin(inputs) });
  try {
    await cmd();
  } finally {
    Object.defineProperty(process, 'stdin', { value: originalStdin });
  }
}

Target Processes

  • cli-unit-integration-testing
  • interactive-prompt-system