Przejdź do treści
Biblioteka skilli
Programowanie · Testowanie

test-cli-usability

/test-cli-usability

Pisze testy scenariuszowe sprawdzające, czy narzędzie CLI działa bez interakcji, z czytelnym wyjściem i bez zawieszania się na pytaniach.

Repozytorium
langwatch ↗
Licencja
Apache-2.0
Ostatnia zmiana repozytorium
27.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co robi i kiedy

Pisze testy scenariuszowe sprawdzające, czy narzędzie CLI działa bez interakcji, z czytelnym wyjściem i bez zawieszania się na pytaniach.

Oryginalny opis (EN)

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.

Jak działa

  1. Prerequisites
  2. Step 1: Identify Your CLI Commands
  3. Step 2: Write Scenario Tests
  4. Step 3: Assert No Interactive Workarounds
  5. Step 4: Test Error Recovery
  6. Common Mistakes
Sekcje z nagłówków SKILL.md, w oryginale · 102 linii, 465 słów
Podgląd SKILL.md
---
name: test-cli-usability
description: 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.
license: MIT
compatibility: Requires @langwatch/scenario. Works with Claude Code and similar coding agents.
metadata:
  category: recipe
---

# Test Your CLI's Agent Usability

This recipe helps you write scenario tests that verify your CLI tool works well when operated by AI agents (Claude Code, Cursor, Codex, etc.). A CLI that's agent-friendly means:

- All commands can run non-interactively (no stdin prompts that hang)
- Output is parseable and informative
- Error messages are clear enough for an agent to self-correct
- Help text enables discovery (`--help` works on every subcommand)

## Prerequisites

Install the Scenario SDK:

```bash
npm install @langwatch/scenario vitest @ai-sdk/openai
# or: pip install langwatch-scenario pytest
```

## Step 1: Identify Your CLI Commands

List every command your CLI supports. For each, note:

- Does it require interactive input? (MUST have a non-interactive alternative)
- What flags/options does it accept?
- What does it output on success/failure?

## Step 2: Write Scenario Tests

For each command, write a scenario test where an AI agent discovers and uses it:

```typescript
import 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-6-luna") }),
        scenario.judgeAgent({
          model: openai("gpt-6-luna"),
          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);
  });
});
```

## Step 3: Assert No Interactive Workarounds

Add this assertion to every test:

```typescript
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*\|/);
}
```

If this assertion fails, your CLI has an interactivity bug -- add `--yes`, `--force`, or `--non-interactive` flags to the offending commands.

## Step 4: Test Error Recovery

Write scenarios where the agent makes a mistake and must recover:

- Wrong command name -> agent reads `--help` and self-corrects
- Missing required argument -> agent reads error message and retries
- Authentication failure -> agent follows instructions in error output

## Common Mistakes

- Do NOT make commands that require stdin for essential operations -- always provide flag alternatives
- Do NOT use interactive prompts for confirmation without a `--yes` or `--force` flag
- Do NOT output errors without actionable guidance (the agent needs to know how to fix it)
- DO make `--help` comprehensive on every subcommand
- DO use non-zero exit codes for failures (agents check exit codes)
- DO output structured information (the agent can parse it)

Wersje

W bazie nie ma innych skilli o nazwie test-cli-usability.

Identyczna treść występuje jeszcze w 1 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.

Migawka bazy z 13.11.2026 · wersja paczki 45989e027d7c (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100cli-agent-friendly-audit
    Audytuje narzędzie CLI według listy kontrolnej przyjazności dla agentów z tekstu Zbigniewa Sobieckiego „Building Agent-Friendly CLIs”, oceniając ergonomię dla agentów.
  • 95cli-for-agent
    Projektuje lub przegląda CLI przyjazne agentom: flagi bez interakcji, pomoc z przykładami, potoki, czytelne błędy i tryb dry-run.
  • 95tarn-api-testing
    Pisze i uruchamia testy API w Tarn, w plikach .tarn.yaml, a także generuje testy z OpenAPI lub poleceń curl.
  • 100write-tests
    Pisze testy sprawdzające zachowanie produktu, bez zależności od szczegółów implementacji i wartości konfiguracji.
  • 100write-tests
    Pisze testy sprawdzające zachowanie produktu, bez zależności od szczegółów implementacji i wartości konfiguracji.
  • 100agent-cli
    Dodaje do skryptów CLI w Pythonie czytelne dla agentów wyjście --json w formacie NDJSON albo tworzy dla projektu pakiet pomocniczy cli_utils.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.