Skip to content
Back to skills

Rule Agent Adapters

ASecurity

CLI agent adapters — abstract base class + one subdirectory per adapter. A repository rule for apps/daemon/src/v1/agents/**; read it before editing a file there.

  • 8 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 9, 2026
ai-agentsgoshell

Works with

  • cursor
  • cli
  • mcp

Security analysis

A100/100

Scanned November 9, 2026

npx -y skills add geniro-io/geniro-app --skill rule-agent-adapters --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rule Agent Adapters?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rule Agent Adapters
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/geniro-io-rule-agent-adapters/badge)](https://www.skillsdirectory.com/skills/geniro-io-rule-agent-adapters)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: rule-agent-adapters
description: "CLI agent adapters — abstract base class + one subdirectory per adapter. A repository rule for apps/daemon/src/v1/agents/**; read it before editing a file there."
---
<!-- GENERATED by scripts/sync-agent-rules.mjs from .claude/rules/agent-adapters.md. DO NOT EDIT: edit the source, then run `pnpm sync:agent-rules`. -->

# Agent adapters

Every fact about a specific CLI lives in its `adapters/<name>/` directory, as a field of its `AdapterConfig` or behind an abstract method on `AgentAdapter` (`adapters/agent-adapter.ts`, contract types in `adapters/adapter.types.ts`). Nothing else in the daemon branches on which agent it is talking to.

## The rule

- Argv, wire shapes, skill locations, flags, self-reports and missing features are all adapter facts. An `if (agent === 'claude')` outside the adapter is a missing config field or method.
- A CLI that lacks a feature declares it with the reason and what was checked (e.g. `handoff: { kind: 'unavailable', reason: '…' }`), so the next reader knows what to re-check.
- Before building on a CLI flag, env var or subcommand, run a throwaway invocation proving it has the EFFECT the feature needs. `--help`, `strings` or vendor docs prove only that the name exists (`claude --plugin-dir` exists but ignores a config dir; `CLAUDE_CONFIG_DIR` is what works).
- Consumers compose, adapters know: a service decides when to ask and what to do with the answers, never how to ask (`ModelsService` over `listModels`).

## ACP first

- For a new agent, use its ACP server if it has one; compose `adapters/acp/`, never copy the protocol.
- Use a proprietary headless mode only when ACP is unavailable, and say so in the adapter's doc block.
- An ACP adapter still answers every per-CLI question through its own `AdapterConfig`.

## Field or method

- A value that differs per CLI → an `AdapterConfig` field set in each adapter's `getConfig()`, read by ONE concrete implementation on the base. No overrides.
- A mechanism that differs (file read vs subcommand, two wire protocols) → an abstract method, one implementation per adapter.

## The base class

- A subclass must supply `getConfig()`, `buildArgs`, `mapMessage` and `listModels`; everything else is concrete and config-driven. Read the base before writing an override.
- An adapter that probes its approval modes overrides `currentApprovalSupport` / `settledApprovalSupport` / `approvalProbe` together and owns the probe; no consumer keys a verdict by CLI name.
- Optional hooks default to "this CLI has no such thing"; override one only when the CLI needs it. Their contracts are in their doc blocks. Three that bite:
  - `prepareTurn` returns a disposer; the base runs it exactly once on any settle path. Claude's per-turn `--mcp-config` file is written (0600) and removed here, so the call token never rides argv.
  - `createTurnDriver`: protocol state lives on the per-turn driver, never on the adapter — one adapter instance serves concurrent turns.
  - `buildFollowUpPayload` must be honest: returning true for a write that never reached the agent drops the user's message. An override must also set `keepStdinOpen`.
- An ACP interrupting follow-up sends `session/cancel`, awaits the stopped prompt's reply, and only then sends the new `session/prompt` — an interrupting prompt can never be stopped.
- `start()` is the only spawn path for a turn and `runCommand()` for everything else. Never call `spawn` / `execFile` directly; every child registers via `onSpawn` / `onTurn`.
- Adapters never throw HTTP exceptions; return a discriminated result for the owning module to map (`handoffTarget` → `HandoffResult`).

## The call surface

- Every adapter must hand its CLI `input.mcpEndpoint`; the team executor assumes it with no capability gate.
- Build the instruction text only with the base's `composeSystemPrompt(input, granted)`, passing whether YOUR delivery of the MCP tools succeeded. Never join the instruction parts yourself: order is precedence, and telling an agent to use `call_agent` without the tool registered silently skips its callees.

## Layout

- `adapters/<name>/` holds all of a CLI's code: `<name>.adapter.ts`, `<name>.const.ts` / `<name>.types.ts` when needed, pure helpers in `<name>/utils/<name>-<subject>.utils.ts`, and its own probe and per-turn services.
- A file named after one CLI never lives outside that CLI's directory.
- A protocol several CLIs could speak gets its own agent-agnostic `adapters/<protocol>/` (`adapters/acp/`). Keep the session (process, transport, pending replies) separate from the per-turn driver; state lives on the driver unless it deliberately must survive the turn. Codex follows the same split (`codex-session.ts` / `codex-turn.driver.ts`); JSON-RPC framing and reply correlation are shared in `adapters/utils/json-rpc*.utils.ts`.
- Adapter-agnostic helpers in `adapters/utils/` and types in `adapters/adapter.types.ts` never name one CLI's paths.

## Non-negotiables

- Constants (argv flags, timeouts, file and env names, templates) are named exports in `<name>.const.ts`. Exception: a fact only `getConfig()` reads is written inline there; once it gains a second reader, it moves to `.const.ts`.
- Name agents with `AgentKind` (`v1/runs/runs.types.ts`), never a bare string.
- Env scoping: register each adapter's `auth.isolatedEnvKeys` via `registerEnvIsolation` (called by `AgentAdapterRegistry`, never the constructor); `buildEnv` hands back only its own `auth.inheritedEnvKeys` via `inheritedEnv()`. Never un-strip a credential because geniro merely inherits it from the user's shell. A spec needing the strip builds a registry.
- Question cards:
  - An adapter whose CLI asks questions stamps `questions` (`CardQuestion[]`) on its `approval_request`, projected through the shared `cardQuestions` limits. The renderer never parses a CLI's question payload.
  - `questionFrom` is built from that card (`adapterQuestionOf`), never by re-reading the payload.
  - A secret answer carries `secret: true` and is delivered only through `deliverApprovalAnswer`; a callee's secret question goes to the user's card, not its caller. Only a CLI's own question tool can mark an answer secret.
- Remembered approvals:
  - An adapter whose CLI can remember a permission answer ("for this session", "always") stamps them on its `approval_request` as `options` (`ApprovalOption`), built from what the CLI offered on that request and labelled by the scope geniro actually gives it (`approvalOptionLabel`) — cursor's "Allow always" lives in a per-process profile, so it is `session`.
  - Offer a scope only after a throwaway run proved the CLI stops asking under it (the measurements sit beside each adapter's constants). Its encoder answers with the option only when the verdict carries one; every auto-approval passes none, so nothing the daemon decides alone is remembered.
- Per-agent state is keyed by agent as well as subject (`SkillHarvestStore` keys by agent + cwd + configDir).
- Keep the testable unit process-free: a stream-json mapper is an exported pure function in `<name>/utils/<name>-message.utils.ts`; an ACP adapter's unit is its driver.
- Adapters are factory providers in `agents.module.ts`; the options bag is a test seam, not a DI token.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.