.claude/skills/flags-test/SKILL.md
Create and run tests for the @jondotsoy/flags project. Use when asked to write tests, add test cases, run the test suite, debug failing tests, or verify behavior of flags/argument/command builders.
npx skillsauth add jondotsoy/flags flags-testInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill helps write and run tests for @jondotsoy/flags, a TypeScript CLI argument parser library. Tests use Bun's built-in test runner.
# Run all tests
bun test
# Run a single test file
bun test src/FlagsParser.spec.ts
# Run only failing tests
bun test --only-failures
# Filter by test name
bun test --only-failures --test-name-pattern="<pattern>"
Test files are *.spec.ts, colocated with the source file they test:
src/
FlagsParser.ts
FlagsParser.spec.ts ← test file lives next to source
builders/
FlagBuilder.ts
FlagBuilder.spec.ts
Use bun:test imports. Follow the describe / it / expect pattern:
import { describe, it, expect } from "bun:test";
import { flags, flag, argument, command } from "./flags.js";
describe("FeatureName", () => {
describe("method or scenario", () => {
it("should do X when Y", () => {
// arrange
const parser = flags({ verbose: flag().boolean() });
// act
const result = parser.parse(["--verbose"]);
// assert
expect(result.verbose).toBe(true);
});
});
});
Always import from .js extensions (ESM convention):
import { flags } from "./flags.js";
import { FlagsParser } from "./FlagsParser.js";
import { FlagBuilder } from "./builders/FlagBuilder.js";
import { ArgumentBuilder } from "./builders/ArgumentBuilder.js";
import { CommandBuilder } from "./builders/CommandBuilder.js";
// Boolean flags
expect(parser.parse(["--verbose"]).verbose).toBe(true);
// String flags
expect(parser.parse(["--name", "Alice"]).name).toBe("Alice");
// Missing required flag throws
expect(() => parser.parse([])).toThrow();
// safeParse returns errors instead of throwing
const result = parser.safeParse([]);
expect(result.success).toBe(false);
import { FlagsParseError } from "./errors/FlagsParseError.js";
import { RequiredFlagMissingError } from "./errors/RequiredFlagMissingError.js";
it("should throw when required flag is missing", () => {
const parser = flags({ name: flag().string().required() });
expect(() => parser.parse([])).toThrow(RequiredFlagMissingError);
});
Use toMatchSnapshot() for complex outputs like help messages:
it("should render help message", () => {
const parser = flags({ verbose: flag().boolean() });
expect(parser.helpMessage()).toMatchSnapshot();
});
Snapshots are stored in __snapshots__/ next to the spec file. Update them with:
bun test --update-snapshots
src/builders/FlagBuilder.ts)*.spec.ts file already exists alongside itbun test <file> to verify they passbun test to confirm no regressionstools
Use when building or extending a CLI tool that reads process.argv. Triggers for: defining --flags or -f aliases, parsing boolean/string/number/repeated flags, supporting subcommands with independent flag sets, adding defaults or required validation to CLI inputs, or any mention of 'parse argv', 'command-line flags', or argument parsing in a Node.js/TypeScript context.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.
development
Run, watch, debug, and extend OpenClaw QA testing with qa-lab and qa-channel. Use when Codex needs to execute the repo-backed QA suite, inspect live QA artifacts, debug failing scenarios, add new QA scenarios, or explain the OpenClaw QA workflow. Prefer the live OpenAI lane with regular openai/gpt-5.4 in fast mode; do not use gpt-5.4-pro or gpt-5.4-mini unless the user explicitly overrides that policy.