Get the FREE Ultimate OpenClaw Setup Guide →

headless-adapters

Scanned
npx machina-cli add skill youdotcom-oss/agent-skills/headless-adapters --openclaw
Files (1)
SKILL.md
4.0 KB

Headless Adapters

Purpose

Schema-driven adapter for headless CLI agents. No code required - just define a JSON schema describing how to interact with the CLI.

Use CaseTool
Wrap headless CLI agentheadless command
Create new schemasSchema Creation Guide

Quick Start

  1. Check if a schema exists in schemas/
  2. Run the adapter:
    ANTHROPIC_API_KEY=... bunx @plaited/agent-eval-harness headless --schema .claude/skills/headless-adapters/schemas/claude-headless.json
    

CLI Commands

headless

Schema-driven adapter for ANY headless CLI agent.

bunx @plaited/agent-eval-harness headless --schema <path>

Options:

FlagDescriptionRequired
-s, --schemaPath to adapter schema (JSON)Yes

Schema Format:

{
  "version": 1,
  "name": "my-agent",
  "command": ["my-agent-cli"],
  "sessionMode": "stream",
  "prompt": { "flag": "-p" },
  "output": { "flag": "--output-format", "value": "stream-json" },
  "autoApprove": ["--allow-all"],
  "outputEvents": [
    {
      "match": { "path": "$.type", "value": "message" },
      "emitAs": "message",
      "extract": { "content": "$.text" }
    }
  ],
  "result": {
    "matchPath": "$.type",
    "matchValue": "result",
    "contentPath": "$.content"
  }
}

Session Modes:

ModeDescriptionUse When
streamKeep process alive, multi-turn via stdinCLI supports session resume
iterativeNew process per turn, accumulate historyCLI is stateless

Pre-built Schemas

Tested schemas are available in schemas/:

SchemaAgentModeAuth Env VarStatus
claude-headless.jsonClaude CodestreamANTHROPIC_API_KEYTested
gemini-headless.jsonGemini CLIiterativeGEMINI_API_KEYTested

Usage:

# Claude Code
ANTHROPIC_API_KEY=... bunx @plaited/agent-eval-harness headless --schema .claude/skills/headless-adapters/schemas/claude-headless.json

# Gemini CLI
GEMINI_API_KEY=... bunx @plaited/agent-eval-harness headless --schema .claude/skills/headless-adapters/schemas/gemini-headless.json

Creating a Schema

  1. Explore the CLI's --help to identify prompt, output, and auto-approve flags
  2. Capture sample JSON output from the CLI
  3. Map JSONPath patterns to output events
  4. Create schema file based on an existing template
  5. Test with headless command

See Schema Creation Guide for the complete workflow.

Troubleshooting

Common Issues

IssueLikely CauseSolution
Tool calls not capturedJSONPath not iterating arraysUse [*] wildcard syntax - see guide
"unexpected argument" errorStdin mode misconfiguredUse stdin: true - see guide
401 Authentication errorsAPI key not properly configuredSet the correct API key environment variable (see Pre-built Schemas table)
Timeout on promptJSONPath not matchingCapture raw CLI output, verify paths - see guide
Empty responsesContent extraction failingCheck extract paths - see guide

Complete troubleshooting documentation: Troubleshooting Guide

External Resources

Related

Source

git clone https://github.com/youdotcom-oss/agent-skills/blob/main/.agents/skills/headless-adapters/SKILL.mdView on GitHub

Overview

Headless Adapters provide a schema-based way to wrap and validate any headless CLI agent without coding. It includes scaffolding tools and schema-driven compliance testing to ensure consistent interactions.

How This Skill Works

Define a JSON schema describing the CLI interactions (prompt, output, session mode). The adapter reads the schema, launches the CLI, maps JSONPath outputs to events, and streams results, enabling multi-turn conversations or per-turn iterations depending on the session mode.

When to Use It

  • Wrap a headless CLI agent with no coding by supplying a schema.
  • Create and validate new CLI interaction schemas using the schema creation workflow.
  • Achieve reproducible, schema-driven outputs for testing and evaluation.
  • Choose between stream (multi-turn) or iterative (per-turn) session modes based on CLI behavior.
  • Run compliance and integration tests using pre-built schemas for Claude or Gemini via headless.

Quick Start

  1. Step 1: Check if a schema exists in schemas/
  2. Step 2: Run the adapter: ANTHROPIC_API_KEY=... bunx @plaited/agent-eval-harness headless --schema .claude/skills/headless-adapters/schemas/claude-headless.json
  3. Step 3: Confirm CLI interactions are processed according to the schema and iterate as needed

Best Practices

  • Start with an existing schema in schemas/ as a template before creating a new one.
  • Align sessionMode with the CLI's capabilities (stream for resumeable sessions, iterative for stateless ones).
  • Capture samples from the CLI and map them to robust outputEvents using precise JSONPath patterns.
  • Iteratively test and refine prompts, outputs, and autoApprove flags to stabilize interactions.
  • Consult the Troubleshooting Guide for common issues like JSONPath mismatches and stdin mode problems.

Example Use Cases

  • Wrap Claude Code CLI using claude-headless.json in stream mode and run via bunx headless.
  • Wrap Gemini CLI using gemini-headless.json in iterative mode for per-turn execution.
  • Create a new schema for a bespoke headless tool and validate it with the headless adapter.
  • Test schema-driven interactions by capturing sample JSON outputs and mapping to events.
  • Use the pre-built schemas to verify compatibility and accelerate onboarding of a new CLI.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers