### Minimal flow example in YAML Source: https://github.com/almondoo/klaus/blob/main/skills/klaus/SKILL.md A basic flow definition file demonstrating a single-step GET request with a status assertion. Place this in the api/ directory and use with a corresponding environment file. ```yaml # api/example.yaml # yaml-language-server: $schema=https://almondoo.github.io/klaus/schema/flow.schema.json name: example flow steps: - name: get-example request: method: GET url: "{{baseUrl}}" assert: status: 200 ``` -------------------------------- ### Start Mock Server and Run Auth Flows Source: https://github.com/almondoo/klaus/blob/main/examples/README.md Instructions for starting the mock server and executing authentication flows with different environment configurations. ```bash # ターミナル1: ダミー API を起動 node examples/mock-server.mjs # → mock API on http://127.0.0.1:3000 # ターミナル2: examples に入って実行 cd examples klaus run flows/auth-flow.yaml # local: $.email == test@example.com klaus run flows/auth-flow.yaml --env development # development: dev@example.com klaus run api/login-check.yaml # 単発チェック: $.token の存在確認 ``` -------------------------------- ### Text output example Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md Example of the text output format showing validation results for valid and invalid files. ```text OK flows/login.yaml NG flows/broken.yaml - steps.0.request.method (line 6): request.method is required unless request.graphql is set example: method: GET ``` -------------------------------- ### Example assert configuration Source: https://github.com/almondoo/klaus/blob/main/docs/guide/flow-definition.md A comprehensive example showing various assertion types including status, headers, body, schema, duration, and streaming event/message validation. ```yaml assert: status: 200 headers: - { name: content-type, contains: json } body: - { path: "$.token", exists: true } - { path: "$.email", equals: "{{testEmail}}" } bodyText: contains: "ok" bodySchema: type: object required: [id, email] properties: id: { type: integer } email: { type: string, format: email } duration: maxMs: 1000 # For SSE eventCount: { min: 1, max: 10 } events: - { index: 0, path: "$.type", equals: "message" } # For WebSocket messageCount: { min: 1 } messages: - { path: "$.type", contains: "order" } ``` -------------------------------- ### Klaus CLI output example Source: https://github.com/almondoo/klaus/blob/main/docs/guide/getting-started.md Example of human-readable terminal output for a successful flow execution. ```text hello flow (api/hello.yaml) PASS get-hello (200, 12ms) 1 flow, 1 step: 1 passed (12ms) ``` -------------------------------- ### Install klaus Agent Skill for Codex Source: https://github.com/almondoo/klaus/blob/main/docs/guide/agent-skill.md Command to install the klaus skill directory into the user-wide Codex configuration path. ```bash mkdir -p ~/.agents/skills cp -r node_modules/@almondoo/klaus/skills/klaus ~/.agents/skills/klaus ``` -------------------------------- ### klaus generate コマンドの実行 Source: https://github.com/almondoo/klaus/blob/main/examples/README.md examples ディレクトリに移動し、openapi/users-api.yaml を入力としてテストファイルを生成します。 ```bash cd examples klaus generate openapi/users-api.yaml --out-dir generated ``` -------------------------------- ### Install klaus CLI Source: https://github.com/almondoo/klaus/blob/main/docs/guide/getting-started.md Install the klaus package globally using npm. Requires Node.js version 22.19.0 or higher. ```bash npm install -g @almondoo/klaus ``` -------------------------------- ### Example klaus history show output Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md Displays the detailed JSON entry for a specific runId and step. ```bash $ klaus history show 3fa1c2e0-... --step get-me [{"v":1,"runId":"3fa1c2e0-...","flow":"auth flow","step":"get-me","status":"failed", …}] ``` -------------------------------- ### Example klaus.config.yaml configuration Source: https://github.com/almondoo/klaus/blob/main/docs/guide/config.md A sample configuration file demonstrating the structure for run and ui settings, including the required schema reference. ```yaml # yaml-language-server: $schema=https://almondoo.github.io/klaus/schema/klaus-config.schema.json run: env: local report: junit reportFile: klaus-report.xml history: true mask: true jobs: 4 ui: port: 4884 host: 127.0.0.1 open: true ``` -------------------------------- ### Install klaus CLI Source: https://github.com/almondoo/klaus/blob/main/README.md Install the klaus package globally using npm. Requires Node.js version 22.19.0 or higher. ```bash npm install -g @almondoo/klaus # Requires Node.js >= 22.19.0 ``` -------------------------------- ### Scaffold project with klaus init Source: https://github.com/almondoo/klaus/blob/main/docs/guide/getting-started.md Run this command in your project directory to generate a minimal starting point, including sample flow and environment files. ```bash klaus init ``` -------------------------------- ### Define a minimal flow in YAML Source: https://github.com/almondoo/klaus/blob/main/docs/guide/getting-started.md Create a flow definition file where each YAML file represents a sequence of steps. This example defines a GET request to a local endpoint with a status assertion. ```yaml # api/hello.yaml name: hello flow steps: - name: get-hello request: method: GET url: "http://localhost:3000/hello" assert: status: 200 ``` -------------------------------- ### Launch Klaus UI Source: https://github.com/almondoo/klaus/blob/main/docs/guide/ui.md Command to start the web UI server. Use the optional flags to specify the port, host, or disable automatic browser opening. ```bash klaus ui [-p ] [-H ] [--no-open] ``` -------------------------------- ### Verify Agent Skill directory structure Source: https://github.com/almondoo/klaus/blob/main/docs/guide/agent-skill.md The expected file structure for the installed skill directory. ```text /klaus/ └── SKILL.md ``` -------------------------------- ### OpenAPI Specification Input Source: https://github.com/almondoo/klaus/blob/main/docs/guide/generate.md An example OpenAPI 3.0.3 specification defining a POST /users endpoint with a request body example. ```yaml openapi: 3.0.3 info: title: Sample API version: "1.0.0" paths: /users: post: operationId: createUser requestBody: required: true content: application/json: schema: type: object required: [name, email] properties: name: { type: string } email: { type: string } example: name: Alice email: alice@example.com responses: "201": description: Created ``` -------------------------------- ### Project development CLI commands Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/architecture.md Commonly used commands for workspace management, building, testing, and linting. The final command demonstrates starting the UI development server with mock data enabled. ```bash pnpm install # Installs across the whole workspace pnpm build:all # Full build (dist/ + dist/ui) pnpm test # root tests pnpm --filter @almondoo/klaus-ui test # ui tests pnpm typecheck / pnpm lint # tsc / biome (whole repo) VITE_KLAUS_MOCK=1 pnpm --filter @almondoo/klaus-ui dev # Develop the UI against a mock ``` -------------------------------- ### JSON output example Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md Example of the JSON output format for validation results, including detailed error paths and line numbers. ```jsonc { "version": 1, "files": [ { "path": "flows/broken.yaml", "valid": false, "errors": [ { "path": "steps.0.request.method", "message": "request.method is required unless request.graphql is set", "hint": "example: method: GET", "line": 6, "column": 7 } ] } ] } ``` -------------------------------- ### GET /api/environments Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-design.md Lists all environment names. ```APIDOC ## GET /api/environments ### Description Returns a list of environment names from the environments/*.yaml files. ### Method GET ### Endpoint /api/environments ``` -------------------------------- ### GET /api/environments Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-api.md Lists all environment names. ```APIDOC ## GET /api/environments ### Description Returns a list of environment names found under environments/*.yaml. ### Method GET ### Endpoint /api/environments ``` -------------------------------- ### Docker Compose configuration for Klaus UI Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md Example configuration for running the Klaus UI inside a container, mapping the default port and binding to all network interfaces. ```yaml services: klaus: image: your-klaus-image command: ["klaus", "ui", "--host", "0.0.0.0", "--no-open"] ports: - "4884:4884" ``` -------------------------------- ### Example klaus history output Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md A concise text table output showing the last 5 entries filtered by specific fields. ```bash $ klaus history --last 5 --fields step,status,durationMs step status durationMs get-me failed 3 login passed 6 ``` -------------------------------- ### Text Output Format Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md Example of the incremental text output displayed for humans, showing pass/fail status and step details. ```text auth flow (/path/to/auth-flow.yaml) PASS login (200, 6ms) FAIL get-me (200, 3ms) body $.email: expected "a@example.com" but got "b@example.com" SKIP logout: skipped because a previous step failed 1 flow, 3 steps: 1 passed, 1 failed, 1 skipped (12ms) ``` -------------------------------- ### Example klaus history JSON output Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md JSON output for failed history entries. ```bash $ klaus history --json --failed [{"startedAt":"2026-08-08T…","runId":"","flow":"auth flow","step":"get-me","status":"failed","durationMs":3}] ``` -------------------------------- ### Define API Auth Flow in YAML Source: https://github.com/almondoo/klaus/blob/main/README.md An example of an authentication flow definition using YAML. It demonstrates capturing tokens via JSONPath and referencing environment variables. ```yaml # api/auth-flow.yaml name: auth flow env: local # References environments/local.yaml steps: - name: login request: method: POST url: "{{baseUrl}}/login" headers: Content-Type: application/json body: email: "{{testEmail}}" password: "{{env.TEST_PASSWORD}}" # References an OS environment variable capture: token: "$.token" # Captured via JSONPath assert: status: 200 body: - path: "$.token" exists: true - name: get-me request: method: GET url: "{{baseUrl}}/me" headers: Authorization: "Bearer {{token}}" # References the previous step's capture assert: status: 200 body: - path: "$.email" equals: "{{testEmail}}" ``` -------------------------------- ### JSON Output Format Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md Example of the compact JSON object output for machine consumption, featuring a failure-focused structure. ```jsonc { "version": 2, // schema version of the output "runId": "", "startedAt": "2026-08-08T…", "durationMs": 123, "status": "passed", // "passed" | "failed" | "error" "summary": { "flows": 1, "steps": 2, "passed": 1, "failed": 1, "error": 0, "skipped": 0 }, "flows": [ { "name": "auth flow", "file": "…", "status": "failed", "durationMs": 120, "steps": [ { // passed steps are a one-line summary only (historyRef is only added when history recording is enabled) "name": "login", "status": "passed", "durationMs": 6, "historyRef": { "date": "2026-08-08", "runId": "", "step": "login" } }, { // failed/error/skipped steps carry full detail "name": "get-me", "status": "failed", "durationMs": 4, "historyRef": { "date": "2026-08-08", "runId": "", "step": "get-me" }, "startedAt": "2026-08-08T…", "request": { "method": "GET", "url": "…", "headers": {}, "body": "…" }, "response": { "status": 200, "headers": {}, "body": "…" }, "assertions": [ { "ok": false, "kind": "status", "expected": 200, "actual": 401, "message": "…" } ] } ] } ] } ``` -------------------------------- ### GET /api/environments/:name Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-api.md Returns the contents of a specific environment. ```APIDOC ## GET /api/environments/:name ### Description Returns the contents of a single environment as { name, values }. Returns 404 if not found, 403 if name contains invalid characters. ### Method GET ### Endpoint /api/environments/:name ### Parameters #### Path Parameters - **name** (string) - Required - The name of the environment. ``` -------------------------------- ### JSON output format Source: https://github.com/almondoo/klaus/blob/main/docs/guide/generate.md Example of the JSON structure returned when output mode is set to JSON or when running in a non-TTY environment. ```jsonc { "version": 1, "generated": ["api/create-user.yaml"], "skipped": [], "errors": [] } ``` -------------------------------- ### GET/PUT /api/environments/:name Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-design.md Get or update the contents of a specific environment. ```APIDOC ## GET /api/environments/:name ### Description Retrieves the contents of a single environment. ### Method GET ### Endpoint /api/environments/:name ## PUT /api/environments/:name ### Description Updates the contents of a single environment, preserving existing comments. ### Method PUT ### Endpoint /api/environments/:name ``` -------------------------------- ### GET /api/history Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-design.md Reads execution history. ```APIDOC ## GET /api/history ### Description Reads out history JSONL, newest first, paginated. ### Method GET ### Endpoint /api/history ### Parameters #### Query Parameters - **flow** (string) - Optional - Filter by flow. - **limit** (number) - Optional - Limit results. - **before** (string) - Optional - Pagination cursor. ``` -------------------------------- ### GET /api/history Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-api.md Returns paginated execution history. ```APIDOC ## GET /api/history ### Description Returns history paginated newest-first. ### Method GET ### Endpoint /api/history ### Parameters #### Query Parameters - **flow** (string) - Optional - Filter by flow. - **limit** (number) - Optional - Number of rows (default 50). - **before** (string) - Optional - ISO datetime cursor. ``` -------------------------------- ### Install klaus Agent Skill for Claude Code Source: https://github.com/almondoo/klaus/blob/main/docs/guide/agent-skill.md Commands to copy the klaus skill directory into either the user-wide or per-repository Claude Code configuration paths. ```bash # Install user-wide mkdir -p ~/.claude/skills cp -r node_modules/@almondoo/klaus/skills/klaus ~/.claude/skills/klaus # Install per-repository (to share with the team and check into git) mkdir -p .claude/skills cp -r node_modules/@almondoo/klaus/skills/klaus .claude/skills/klaus ``` -------------------------------- ### GET /api/flows Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-api.md Recursively walks the tree under cwd to list YAML files containing a top-level steps key. ```APIDOC ## GET /api/flows ### Description Recursively walks the tree under cwd (excluding node_modules, .git, dist, .klaus, ui, environments, and tmp) and lists YAML files with a top-level steps key. Successfully parsed files return flow info; failures return a reason. ### Method GET ### Endpoint /api/flows ``` -------------------------------- ### GET /api/flows/detail Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-design.md Retrieves the parsed definition of a single flow. ```APIDOC ## GET /api/flows/detail ### Description Returns the parsed definition of a single flow based on the provided path. ### Method GET ### Endpoint /api/flows/detail ### Parameters #### Query Parameters - **path** (string) - Required - The path to the flow file. ``` -------------------------------- ### GET /api/flows/detail Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-api.md Retrieves the parsed definition of a single flow. ```APIDOC ## GET /api/flows/detail ### Description Returns the parsed definition of a single flow, including a step overview. ### Method GET ### Endpoint /api/flows/detail ### Parameters #### Query Parameters - **path** (string) - Required - The path to the flow file. ``` -------------------------------- ### Pass secrets via environment variables Source: https://github.com/almondoo/klaus/blob/main/examples/README.md Example of passing a secret value to a flow execution using an environment variable. ```bash TEST_PASSWORD=... klaus run flows/auth-flow.yaml ``` -------------------------------- ### GET /api/flows Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-design.md Retrieves a list of flow YAML files located under the current working directory. ```APIDOC ## GET /api/flows ### Description Returns a list of flow YAML files under the current working directory, including path, name, and step count. Parse errors are returned marked as errors. ### Method GET ### Endpoint /api/flows ``` -------------------------------- ### YAML syntax error message Source: https://github.com/almondoo/klaus/blob/main/docs/guide/troubleshooting.md Example of a YAML syntax error, such as bad indentation or unclosed quotes, reported with line and column numbers. ```text klaus: parse error: flows/broken.yaml: YAML syntax error (line 4, column 3): Unexpected scalar at node end ``` -------------------------------- ### Schema validation error message Source: https://github.com/almondoo/klaus/blob/main/docs/guide/troubleshooting.md Example of a schema validation error occurring when a required key is missing in the flow definition YAML. ```text klaus: parse error: flows/broken.yaml: schema validation failed: steps.0.request.method: request.method is required unless request.graphql is set ``` -------------------------------- ### Run GraphQL, SSE, and WebSocket API Checks Source: https://github.com/almondoo/klaus/blob/main/examples/README.md Commands to execute various API check flows including GraphQL, SSE, and WebSocket protocols using the running mock server. ```bash # ターミナル1で mock-server.mjs を起動したまま、ターミナル2で: cd examples klaus run api/users-check.yaml # GET /users(query/headers/body/bodySchema の一通り) klaus run api/graphql-check.yaml # POST /graphql(request.graphql) klaus run api/sse-events-check.yaml # GET /events(sse: での受信・eventCount/events) klaus run api/ws-echo-check.yaml # ws://.../ws(ws: での送受信・messageCount/messages) klaus run flows/users-crud-flow.yaml # POST → GET → DELETE の3ステップシナリオ ``` -------------------------------- ### Development Commands Source: https://github.com/almondoo/klaus/blob/main/docs/dev/architecture.md Common CLI commands for building, testing, and developing the Klaus project. ```bash pnpm install # ワークスペース一括 pnpm build:all # 全ビルド(dist/ + dist/ui) pnpm test # root テスト pnpm --filter @almondoo/klaus-ui test # ui テスト pnpm typecheck / pnpm lint # tsc / biome(リポジトリ全体) VITE_KLAUS_MOCK=1 pnpm --filter @almondoo/klaus-ui dev # UI をモックで開発 ``` -------------------------------- ### Development CLI Commands Source: https://github.com/almondoo/klaus/blob/main/README.md List of pnpm scripts used for project development, including build, test, and linting tasks. ```bash pnpm install pnpm build # tsup (core / cli / server); dist/ui is preserved pnpm build:ui # Vite (ui/ -> dist/ui) pnpm build:all # clean + build + build:ui (full build for release) pnpm test # vitest pnpm test:coverage # vitest + coverage (thresholds: 90% lines, enforced in CI; scope is src/, ui/ excluded) pnpm typecheck # tsc --noEmit pnpm lint # biome ``` -------------------------------- ### Project directory structure Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-design.md The directory layout showing the separation between core logic, CLI, the new server layer, and the React SPA. ```text src/ core/ # Existing. All execution/assertion/history logic (unchanged) cli/ # Existing. Adds the `klaus ui` subcommand (just server startup + browser launch) server/ # New. HTTP API + static serving (a thin layer that imports core) ui/ # New. Vite + React SPA (build output goes to dist/ui) ``` -------------------------------- ### Project directory structure Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/architecture.md The layout of the source and UI workspaces, illustrating the separation between the core engine, CLI, server, and frontend. ```text src/ core/ # Execution engine (CLI-independent library). No dependency on other layers cli/ # A thin commander wrapper. Imports core server/ # klaus ui's API server (Hono). Imports core ui/ # Vite + React SPA (private workspace). No runtime dependency on core ``` -------------------------------- ### Verify directory structure Source: https://github.com/almondoo/klaus/blob/main/verify/README.md The directory layout for the verification environment, including Docker configuration and the pack directory. ```text verify/ ├── CHECKLIST.md # 動作確認チェックリスト(examples/ 一式 + make verify のコンテナ実行手順) └── docker/ ├── compose.yaml # mock-api / klaus の2サービス定義 ├── Dockerfile # klaus.tgz を npm install -g するクリーンな Node 22 イメージ ├── run.sh # make verify の実体。build:all -> pack -> build -> 起動 -> スモーク一式 ├── klaus.config.yaml # コンテナ内専用の config(run.env: docker)。examples/klaus.config.yaml を上書きする └── .pack/ # run.sh が生成する pack 作業ディレクトリ(git 管理外) ``` -------------------------------- ### POST /api/runs Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-api.md Executes a flow and returns an SSE stream. ```APIDOC ## POST /api/runs ### Description Runs a flow. The response is an SSE stream providing step-start, step-result, and run-result events. ### Method POST ### Endpoint /api/runs ### Parameters #### Request Body - **path** (string) - Required - Path to the flow. - **env** (string) - Optional - Environment name. ``` -------------------------------- ### Unsupported SSE/WS steps error Source: https://github.com/almondoo/klaus/blob/main/docs/guide/troubleshooting.md This error occurs because record/replay mode currently only supports HTTP and GraphQL over HTTP, not SSE or WebSocket steps. ```text step "subscribe": SSE/WS steps are not supported in record/replay mode (HTTP only, and GraphQL over HTTP). Remove --record/--replay, or exclude this step from the flow. ``` -------------------------------- ### Record and Replay CLI Commands Source: https://github.com/almondoo/klaus/blob/main/docs/guide/record-replay.md Commands to record a flow to a directory and subsequently replay it without network access. ```bash # 1. Record a cassette while sending real requests klaus run api/create-user.yaml --record ./cassettes # 2. Replay the same checks afterward with no network access klaus run api/create-user.yaml --replay ./cassettes ``` -------------------------------- ### Run a flow with klaus run Source: https://github.com/almondoo/klaus/blob/main/docs/guide/getting-started.md Execute a specific flow definition file using a defined environment. ```bash klaus run api/example.yaml -e local ``` -------------------------------- ### Execute Klaus flows via CLI Source: https://github.com/almondoo/klaus/blob/main/examples/README.md Commands to run flows using the klaus CLI, demonstrating environment switching and single-file execution. ```bash cd examples klaus run flows/auth-flow.yaml # klaus.config.yaml の run.env: local が使われる klaus run flows/auth-flow.yaml --env development # development に切り替え klaus run api/login-check.yaml # 単発チェックも同じ run コマンドで実行できる ``` -------------------------------- ### Chain requests with variables in api/auth-flow.yaml Source: https://github.com/almondoo/klaus/blob/main/docs/guide/getting-started.md Demonstrates logging in to capture a token and using it in the Authorization header of a subsequent request. ```yaml # api/auth-flow.yaml name: auth flow env: local # See environments/local.yaml steps: - name: login request: method: POST url: "{{baseUrl}}/login" headers: Content-Type: application/json body: email: "{{testEmail}}" password: "{{env.TEST_PASSWORD}}" # References an OS environment variable capture: token: "$.token" # Captured via JSONPath assert: status: 200 body: - path: "$.token" exists: true - name: get-me request: method: GET url: "{{baseUrl}}/me" headers: Authorization: "Bearer {{token}}" # References the previous step's capture assert: status: 200 body: - path: "$.email" equals: "{{testEmail}}" ``` -------------------------------- ### Run klaus flows Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md Basic syntax for executing one or more flow files using the klaus CLI. ```bash klaus run [options] ``` -------------------------------- ### runFlows(filePaths, options?) Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/architecture.md Executes multiple flows sequentially. ```APIDOC ## runFlows(filePaths, options?) ### Description Runs multiple flows sequentially from the provided list of file paths. ### Parameters - **filePaths** (string[]) - Required - An array of paths to the flow files. - **options** (RunFlowOptions) - Optional - Configuration options for the flow execution. ### Returns - **Promise** - A promise that resolves with the result of the batch execution. ``` -------------------------------- ### Show detailed history with klaus history show Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md Prints every history entry matching the given runId as a JSON array. Use --step to narrow results. ```bash klaus history show [--step ] ``` -------------------------------- ### POST /api/runs Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-design.md Executes a flow and streams progress. ```APIDOC ## POST /api/runs ### Description Executes a flow. The response is an SSE stream delivering per-step progress and the final result. ### Method POST ### Endpoint /api/runs ### Request Body - **path** (string) - Required - Path to the flow. - **env** (string) - Optional - Environment name. ``` -------------------------------- ### YAML Request Definition Structure Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/requirements.md A sample YAML definition demonstrating the structure for multi-step flows, including request configuration, response capture via JSONPath, and assertions. ```yaml # api/auth-flow.yaml name: auth flow env: local # References environments/local.yaml steps: - name: login request: method: POST url: "{{baseUrl}}/login" headers: Content-Type: application/json body: email: "{{testEmail}}" password: "{{env.TEST_PASSWORD}}" # References an OS environment variable capture: token: "$.token" # Captured via jsonpath assert: status: 200 body: - path: "$.token" exists: true - name: get-me request: method: GET url: "{{baseUrl}}/me" headers: Authorization: "Bearer {{token}}" # References the previous step's capture assert: status: 200 body: - path: "$.email" equals: "{{testEmail}}" ``` -------------------------------- ### Configure Local Environment Variables Source: https://github.com/almondoo/klaus/blob/main/README.md Configuration file for local environment variables referenced by the auth flow. ```yaml # environments/local.yaml baseUrl: http://localhost:3000 testEmail: test@example.com ``` -------------------------------- ### runFlow(filePath, options?) Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/architecture.md Executes a single flow from a specified file path. ```APIDOC ## runFlow(filePath, options?) ### Description Runs a single flow defined in the provided file path. ### Parameters - **filePath** (string) - Required - The path to the flow file. - **options** (RunFlowOptions) - Optional - Configuration options for the flow execution. ### Returns - **Promise** - A promise that resolves with the result of the flow execution. ``` -------------------------------- ### Conditional Step Execution with if Source: https://github.com/almondoo/klaus/blob/main/docs/guide/flow-definition.md Demonstrates using the 'if' property to gate steps based on the status of a previous step or the value of a capture. Steps are skipped if the condition evaluates to false. ```yaml steps: - name: login request: { method: POST, url: "{{env.baseUrl}}/login" } assert: { status: 200 } - name: cleanup request: { method: DELETE, url: "{{env.baseUrl}}/session" } if: steps.login.status == "passed" # only run when login passed - name: use-token request: { method: GET, url: "{{env.baseUrl}}/me", headers: { Authorization: "Bearer {{token}}" } } if: captures.token != "" ``` -------------------------------- ### Configure HTTP request step Source: https://github.com/almondoo/klaus/blob/main/docs/guide/flow-definition.md Define an HTTP request step with method, URL, headers, query parameters, and body. JSON bodies are automatically parsed if Content-Type is set to application/json. ```yaml request: method: POST # Can be omitted only when graphql is specified (defaults to POST). Treated as uppercase url: "{{baseUrl}}/login" # Required. Supports templates headers: # Optional. Values support templates Content-Type: application/json query: # Optional. Values support templates page: "1" # Merged into the url's query string. If url already has the same key, query wins body: # Optional. object → sent as JSON (application/json is auto-set if Content-Type is unspecified) email: "{{testEmail}}" # string → sent as-is timeoutMs: 30000 # Optional. Defaults to 30000. Exceeding it is a RuntimeError (exit 3) ``` -------------------------------- ### Run klaus generate command Source: https://github.com/almondoo/klaus/blob/main/docs/guide/generate.md The basic syntax for generating flow definitions from an OpenAPI specification file. ```bash klaus generate [options] ``` -------------------------------- ### OS environment variable undefined error Source: https://github.com/almondoo/klaus/blob/main/docs/guide/troubleshooting.md This error occurs when a {{env.X}} placeholder refers to an OS environment variable that is not set in the current shell. ```text OS environment variable "TEST_PASSWORD" is not defined ``` ```bash TEST_PASSWORD=xxx klaus run api/login.yaml -e local ``` -------------------------------- ### List execution history with klaus history Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md Displays execution history from .klaus/history/*.jsonl. Output defaults to a text table on TTY and JSON when piped or with --json. ```bash klaus history [options] ``` -------------------------------- ### Execute Flow via CLI Source: https://github.com/almondoo/klaus/blob/main/README.md Command to run the defined flow and the expected output showing successful assertions. ```bash klaus run api/auth-flow.yaml # PASS login (200, 45ms) # PASS get-me (200, 12ms) ``` -------------------------------- ### Core Public API Methods and RunFlowOptions Interface Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/architecture.md Defines the primary execution methods and the configuration interface for running flows. The onStepStart and onStepComplete hooks are utilized by both the CLI and server for progress tracking. ```ts runFlow(filePath, options?): Promise // Run a single flow runFlows(filePaths, options?): Promise // Run multiple flows sequentially executeFlow(flow, filePath, options?): Promise // Run an already-parsed Flow interface RunFlowOptions { cwd?: string; // Base directory for environment files and history envNameOverride?: string; // Equivalent to --env allowProtected?: boolean; // Whether to allow running against a $protected: true environment (default false) runId?: string; history?: boolean | ((entry: HistoryEntry) => void | Promise); // false disables it / a function customizes the sink onStepStart?: (ctx: { flow, file, step }) => void | Promise; onStepComplete?: (ctx: { flow, file, result: StepResult }) => void | Promise; onWarning?: (message: string) => void; // Non-fatal warnings such as history write failures onSecrets?: (secrets: readonly string[]) => void; // Notifies newly-resolved secrets for a step (a separate path from history masking) recording?: { mode: "record" | "replay"; dir: string }; // Cassette settings for record/replay mode } ``` -------------------------------- ### Verify npm package provenance Source: https://github.com/almondoo/klaus/blob/main/SECURITY.md Use this command to verify the provenance and signatures of the published npm package. ```bash npm audit signatures ``` -------------------------------- ### Project Directory Structure Source: https://github.com/almondoo/klaus/blob/main/docs/dev/architecture.md The source code organization showing the separation between core logic, CLI, server, and UI components. ```text src/ core/ # 実行エンジン(CLI 非依存ライブラリ)。他層への依存なし cli/ # commander の薄い皮。core を import server/ # klaus ui の API サーバー(Hono)。core を import ui/ # Vite + React SPA(private ワークスペース)。core への runtime 依存なし ``` -------------------------------- ### Print JSON Schema with klaus schema Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md Displays the JSON schema for the specified target. The default target is flow. ```bash klaus schema [-t ] ``` -------------------------------- ### Configure continueOnError for steps Source: https://github.com/almondoo/klaus/blob/main/docs/guide/flow-definition.md Allows the flow to continue to the next step even if the current step results in a failed or error outcome. ```yaml steps: - name: optional-check request: { method: GET, url: "{{env.baseUrl}}/optional" } assert: { status: 200 } continueOnError: true # Optional. Defaults to false - name: next-step request: { method: GET, url: "{{env.baseUrl}}/next" } ``` -------------------------------- ### Flow Definition Using 'use' Source: https://github.com/almondoo/klaus/blob/main/docs/guide/flow-definition.md A flow file that reuses the login step defined in another file using the 'use' keyword. ```yaml # flows/auth-flow.yaml — reuse login without rewriting it name: Auth flow steps: - name: login use: ../api/login-check.yaml # path relative to this flow file capture: token: "$.token" - name: me request: method: GET url: "{{baseUrl}}/me" headers: Authorization: "Bearer {{token}}" assert: status: 200 ``` -------------------------------- ### klaus run Source: https://github.com/almondoo/klaus/blob/main/skills/klaus/SKILL.md Executes flow definition YAML files. Supports environment overrides, data-driven testing, parallel execution, and recording/replaying HTTP traffic. ```APIDOC ## klaus run ### Description Executes the specified flow definition YAML files. This command supports various options for environment configuration, reporting, and execution control. ### Parameters - **files** (list) - Required - The flow definition YAML files to execute. - **--env** (string) - Optional - Overrides the flow's environment with values from environments/.yaml. - **--env-file** (path) - Optional - Loads environment variables from a specific YAML file. - **--var** (key=value) - Optional - Sets an ad-hoc template variable (repeatable). - **--json** (flag) - Optional - Forces JSON output. - **--report** (list) - Optional - Comma-separated additional report formats (junit, tap). - **--no-history** (flag) - Optional - Disables writing to execution history. - **--data** (path) - Optional - Path to a JSON/YAML file for data-driven runs. - **--tags** (list) - Optional - Comma-separated flow-level tag filters. - **--jobs** (n) - Optional - Number of parallel execution units (1-32). ``` -------------------------------- ### POST /api/request Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-design.md Executes a single ad-hoc request. ```APIDOC ## POST /api/request ### Description Executes a single request without going through a flow YAML. Returns the result as a single JSON response. ### Method POST ### Endpoint /api/request ### Request Body - **request** (object) - Required - Contains method, url, headers, query, body, graphql, or timeoutMs. - **env** (string) - Optional - Environment name. ``` -------------------------------- ### POST /api/request Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-api.md Synchronously executes a single request definition. ```APIDOC ## POST /api/request ### Description Synchronously executes a single request definition without going through a flow definition. ### Method POST ### Endpoint /api/request ### Parameters #### Request Body - **request** (object) - Required - Request definition conforming to requestSchema. - **env** (string) - Optional - Environment name for variable expansion. ``` -------------------------------- ### POST /api/environments/:name/capture Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-api.md Extracts a value from JSON and merges it into an environment. ```APIDOC ## POST /api/environments/:name/capture ### Description Extracts a single value from JSON via JSONPath and merges it into the specified environment under a key. ### Method POST ### Endpoint /api/environments/:name/capture ### Parameters #### Path Parameters - **name** (string) - Required - The name of the environment. #### Request Body - **key** (string) - Required - The environment key to update. - **path** (string) - Required - The JSONPath to extract. - **json** (object) - Required - The source JSON object. ``` -------------------------------- ### executeFlow(flow, filePath, options?) Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/architecture.md Executes an already-parsed flow object. ```APIDOC ## executeFlow(flow, filePath, options?) ### Description Runs a flow that has already been parsed into an object. ### Parameters - **flow** (Flow) - Required - The parsed flow object. - **filePath** (string) - Required - The path associated with the flow. - **options** (RunFlowOptions) - Optional - Configuration options for the flow execution. ### Returns - **Promise** - A promise that resolves with the result of the flow execution. ``` -------------------------------- ### Template variable resolution error Source: https://github.com/almondoo/klaus/blob/main/docs/guide/troubleshooting.md This error occurs when a placeholder cannot be resolved against available environment keys or step captures. ```text template variable "userId" could not be resolved (available: env: baseUrl, testEmail; captures: token) ``` -------------------------------- ### Protected environment execution error Source: https://github.com/almondoo/klaus/blob/main/docs/guide/troubleshooting.md This error occurs when attempting to run against an environment marked with $protected: true without the required flag. ```text environment "production" is protected ($protected: true) and refuses execution by default. Pass --allow-protected to run against this environment intentionally. ``` -------------------------------- ### Import Google Fonts for Typography Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/design-system/klaus/MASTER.md Use this CSS import to load the Fira Code and Fira Sans font families required for the project's typography. ```css @import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap'); ``` -------------------------------- ### SSE Request Configuration Source: https://github.com/almondoo/klaus/blob/main/docs/guide/flow-definition.md Configures a step for Server-Sent Events by setting the Accept header or using an sse block. Execution stops when maxEvents or maxDurationMs is reached. ```yaml request: method: GET url: "{{baseUrl}}/events" headers: Accept: text/event-stream sse: maxEvents: 5 # Defaults to 100 maxDurationMs: 3000 # Defaults to 10000 ``` -------------------------------- ### Configure retry settings Source: https://github.com/almondoo/klaus/blob/main/docs/guide/flow-definition.md Defines the retry count and interval for a step. The step runs at most count + 1 times in total. ```yaml retry: count: 3 # Required. Number of retries after the first attempt (1-100) intervalMs: 500 # Optional. Fixed wait between attempts in milliseconds. Defaults to 1000 ``` -------------------------------- ### Run a Klaus flow Source: https://github.com/almondoo/klaus/blob/main/docs/guide/getting-started.md Execute a flow defined in a YAML file using the klaus run command. ```bash klaus run api/hello.yaml ``` -------------------------------- ### PUT /api/environments/:name Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/ui-api.md Updates the contents of an environment. ```APIDOC ## PUT /api/environments/:name ### Description Updates a single environment's contents and returns the updated contents. Existing comments in the YAML file are preserved. ### Method PUT ### Endpoint /api/environments/:name ### Parameters #### Path Parameters - **name** (string) - Required - The name of the environment. #### Request Body - **values** (map) - Required - A map of string keys to string values. ``` -------------------------------- ### Enable YAML schema validation in editors Source: https://github.com/almondoo/klaus/blob/main/docs/guide/config.md Add the yaml-language-server comment to the top of your klaus.config.yaml file to enable autocompletion and validation in supported editors. ```yaml # yaml-language-server: $schema=https://almondoo.github.io/klaus/schema/klaus-config.schema.json run: env: local ``` -------------------------------- ### Failed to read cassette file error Source: https://github.com/almondoo/klaus/blob/main/docs/guide/troubleshooting.md This error indicates that the cassette file does not exist, typically because --replay was used before recording. ```text failed to read cassette file "cassettes/login/cassette.jsonl" for replay mode: ENOENT: no such file or directory, open '...'. Record a cassette first with --record. ``` -------------------------------- ### Core Public API (src/core/index.ts) Source: https://github.com/almondoo/klaus/blob/main/docs/dev/architecture.md The contract for CLI, server, and future tools to interact with the Klaus execution engine. ```typescript runFlow(filePath, options?): Promise // 1フロー実行 runFlows(filePaths, options?): Promise // 複数フロー順次実行 executeFlow(flow, filePath, options?): Promise // パース済み Flow の実行 interface RunFlowOptions { cwd?: string; // 環境ファイル・履歴の基準ディレクトリ envNameOverride?: string; // --env 相当 allowProtected?: boolean; // $protected: true な環境への実行を許可するか(既定 false) runId?: string; history?: boolean | ((entry: HistoryEntry) => void | Promise); // false で無効化 / 関数でカスタム sink onStepStart?: (ctx: { flow, file, step }) => void | Promise; onStepComplete?: (ctx: { flow, file, result: StepResult }) => void | Promise; onWarning?: (message: string) => void; // 履歴書き込み失敗等の非致命的警告 onSecrets?: (secrets: readonly string[]) => void; // ステップが新規に解決した secrets の通知(履歴マスクとは別経路) recording?: { mode: "record" | "replay"; dir: string }; // record/replay モードのカセット設定 } ``` -------------------------------- ### Enable YAML Schema Validation Source: https://github.com/almondoo/klaus/blob/main/docs/guide/flow-definition.md Add the yaml-language-server comment to the top of your YAML file to enable editor completion and validation. ```yaml # yaml-language-server: $schema=https://almondoo.github.io/klaus/schema/flow.schema.json name: auth flow steps: - name: login request: method: POST url: "{{baseUrl}}/login" ``` -------------------------------- ### klaus validate command syntax Source: https://github.com/almondoo/klaus/blob/main/docs/guide/cli.md The basic command structure for validating flow definition YAML files. ```bash klaus validate [files...] [options] ``` -------------------------------- ### GraphQL Request Configuration Source: https://github.com/almondoo/klaus/blob/main/docs/guide/flow-definition.md Defines a GraphQL request using the graphql block. This is mutually exclusive with the body field and supports templates in both query and variables. ```yaml request: url: "{{baseUrl}}/graphql" graphql: query: 'query { user(id: "{{userId}}") { id name } }' # Supports templates variables: # Optional. Supports templates limit: 10 ``` -------------------------------- ### Generated Klaus Flow File Source: https://github.com/almondoo/klaus/blob/main/docs/guide/generate.md The resulting flow file generated by running klaus generate openapi.yaml, providing a skeleton for the API test. ```yaml # yaml-language-server: $schema=https://almondoo.github.io/klaus/schema/flow.schema.json name: createUser steps: - name: create-user request: method: POST url: "{{baseUrl}}/users" headers: Content-Type: application/json body: name: Alice email: alice@example.com assert: status: 201 ``` -------------------------------- ### klaus generate Source: https://github.com/almondoo/klaus/blob/main/skills/klaus/SKILL.md Generates flow YAML skeletons from an OpenAPI specification. ```APIDOC ## klaus generate ### Description Generates flow YAML skeletons based on an OpenAPI 3.x specification file. ``` -------------------------------- ### Missing recorded response error Source: https://github.com/almondoo/klaus/blob/main/docs/guide/troubleshooting.md This error occurs when a request is not found in the cassette or the method/URL does not match exactly. ```text no recorded response for "GET http://localhost:3000/me" in replay mode. This request was not captured in the cassette (or the method/URL does not match exactly). Re-record this flow with --record to update the cassette. ``` -------------------------------- ### klaus history Source: https://github.com/almondoo/klaus/blob/main/skills/klaus/SKILL.md Manages and retrieves execution history. ```APIDOC ## klaus history ### Description Lists execution history. Use `klaus history show ` to fetch full history entries as JSON. ``` -------------------------------- ### Input Component CSS Source: https://github.com/almondoo/klaus/blob/main/docs/en/dev/design-system/klaus/MASTER.md Defines the input field appearance and focus state styling. ```css .input { padding: 12px 16px; border: 1px solid #E2E8F0; border-radius: 8px; font-size: 16px; transition: border-color 200ms ease; } .input:focus { border-color: #0F172A; outline: none; box-shadow: 0 0 0 3px #0F172A20; } ``` -------------------------------- ### Define flow-level tags Source: https://github.com/almondoo/klaus/blob/main/docs/guide/flow-definition.md Use tags to categorize flows for selection via CLI. Tags are flow-level only and do not affect execution logic. ```yaml name: auth flow tags: [smoke, auth] # Optional: array of non-empty strings. No uniqueness constraint steps: [ ... ] ```