defprod-create-cli-tests

Generates subprocess integration tests for CLI-surface user stories from DefProd acceptance criteria.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/defprod1/defprod-skills --skill defprod-create-cli-tests-defprod1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: defprod-create-cli-tests
Source: https://github.com/defprod1/defprod-skills/tree/main/skills/defprod-create-cli-tests
Command: npx skills add https://github.com/defprod1/defprod-skills --skill defprod-create-cli-tests-defprod1

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing integration tests for a CLI product area by hand is slow and inconsistent: acceptance criteria live in a product definition tool, tests live in the repo, and the two drift apart. This Skill reads user stories from the DefProd MCP server, filters for CLI-surface stories, and generates one Jest/Vitest spec per story with one test per acceptance criterion, executed by spawning the built CLI binary as a subprocess. ## Core Features & Use Cases - Surface-aware story filtering: Selects stories with surface = 'cli' explicitly set or inferred from the CLI-… story-key prefix, skipping UI, API, MCP, and script stories with logged reasons. - Per-AC test generation: Produces one spec file per story and one test('ACn: ...') per testable acceptance criterion, using a runCli subprocess helper and withCliFixture for authenticated sessions. - Testability classification: Marks REPL, LLM-driven, and PTY-only criteria as untestable with documented reasons instead of generating flaky tests. - Use Case: After defining a CLI area's stories in DefProd, run the skill against the CLI area to scaffold the full integration test suite, then get a coverage summary showing testable vs. untestable ACs and any production gaps. ## Quick Start Ask your agent to run /defprod-create-cli-tests with your product name and the CLI area key to generate the integration test specs.

Frequently Asked Questions about defprod-create-cli-tests

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

FAQPage Schema
How do I generate integration tests for CLI acceptance criteria?

Invoke the skill with a product name and area key; it fetches stories via the DefProd MCP server, filters for CLI-surface stories, and writes one Jest spec per story with one test per acceptance criterion. Each test spawns the built CLI binary and asserts on exit code and output.

How to test a CLI binary with Jest subprocess spawning?

Use a runCli helper that spawns the built binary via child_process, captures stdout, stderr, and exitCode, and asserts on exit code first then content. Set maxWorkers to 1 and a per-test timeout of at least 20000ms since each subprocess takes 200ms-1s.

Does this skill work with Vitest instead of Jest?

Yes, Vitest works as the test runner as long as the config includes the tests/areas glob, per-test timeouts of at least 20000ms, and serialized workers. Jest is the default recommendation because it handles node testEnvironment and per-test isolation cleanly.

Which acceptance criteria cannot be tested as CLI subprocesses?

REPL-only criteria like interactive prompts, tab completion, and arrow-key history require a PTY and are documented as untestable. LLM-driven criteria needing an AI provider key are also skipped or covered only at the invocation surface, not output content.

Why does the skill halt before generating any tests?

It halts if no CLI-surface stories exist in the area, if the built CLI binary is missing at the configured path, or if the backend the commands hit is unreachable. Build the binary first and ensure the backend is running before retrying.