Loading...
Loading...
Write scenario tests that verify your CLI tool is usable by AI agents. Ensures commands work non-interactively, provide clear output, and don't hang on prompts. Use when you want to prove your CLI is agent-friendly.
npx skill4agent add langwatch/skills test-cli-usability--helpnpm install @langwatch/scenario vitest @ai-sdk/openai
# or: pip install langwatch-scenario pytestimport scenario, { type AgentAdapter, AgentRole } from "@langwatch/scenario";
import { openai } from "@ai-sdk/openai";
import { describe, expect, it } from "vitest";
const myAgent: AgentAdapter = {
role: AgentRole.AGENT,
call: async (input) => {
// Your Claude Code adapter here
},
};
describe("CLI agent usability", () => {
it("discovers and uses the command non-interactively", async () => {
const result = await scenario.run({
name: "CLI command discovery",
description: "Agent discovers and uses the CLI to accomplish a task",
agents: [
myAgent,
scenario.userSimulatorAgent({ model: openai("gpt-5-mini") }),
scenario.judgeAgent({
model: openai("gpt-5-mini"),
criteria: [
"Agent used the CLI command correctly",
"Agent did not get stuck on interactive prompts",
"Agent did not need to pipe 'yes' or use 'expect' scripting",
],
}),
],
});
expect(result.success).toBe(true);
});
});function assertNoInteractiveWorkarounds(state) {
const output = state.messages.map(m =>
typeof m.content === 'string' ? m.content : JSON.stringify(m.content)
).join('\n');
expect(output).not.toMatch(/echo\s+["']?[yY](?:es)?["']?\s*\|/);
expect(output).not.toMatch(/\byes\s*\|/);
expect(output).not.toMatch(/expect\s+-c/);
expect(output).not.toMatch(/printf\s+["']\\n["']\s*\|/);
}--yes--force--non-interactive--help--yes--force--help