ワンクリックで
protocol-research
Investigate and document CLI protocol behavior for Claude, Codex, and Gemini agent CLIs.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Investigate and document CLI protocol behavior for Claude, Codex, and Gemini agent CLIs.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Fully autonomous PR polish loop. Runs N rounds of local bramble review (codex + cursor, optionally + gemini), folds in any existing PR comments and CI failures as round-1 input, fixes findings locally, pushes once at the end.
Compare bramble code-review output across reviewer configs (cursor with composer-2, codex with gpt-5.4-mini, gemini with gemini-3.1-flash-lite-preview). Runs each config three times against the same branch — turn 1 fresh, turn 2 resumed with default follow-up prompt, turn 3 resumed with fresh prompt — to also characterize backend resume behavior, then compares findings side-by-side and logs results.
Build and use a ground-truth eval dataset for bramble code-review. Two modes. COLLECTION scans past /pr-polish'd PRs and judges each into a frozen ground truth — multiple rounds of bramble re-review + an independent judge sub-agent per round, until the judge's full-diff bug census saturates. REPLAY runs a reviewer-under-test and scores it mechanically against that frozen ground truth — precision/recall/F1, no sub-agents, cheap and repeatable.
One-shot review of an external GitHub PR. Checks out the PR into an isolated worktree (or temp clone), runs `bramble code-review` against the diff, and produces a calibrated verdict — APPROVE unless there is a blocking correctness issue, with optional improvements listed separately. Read-only on the remote PR, never pushes. User-invoked only via `/external-pr-review`.
Iterative review of a markdown design document. Reads the doc, proposes a tailored grilling rubric, runs N rounds of codex+cursor (optionally +gemini) against the doc with that rubric, edits between rounds, commits locally each round. Never pushes.
Ensure the current branch is cleanly rebased onto the remote base branch so that `origin/{base}..HEAD` only shows this branch's commits.
| name | protocol-research |
| description | Investigate and document CLI protocol behavior for Claude, Codex, and Gemini agent CLIs. |
| disable-model-invocation | true |
Investigate agent CLI subprocess protocol behavior using the agent-cli-wrapper SDKs, trace capture, and Go test infrastructure. This repo communicates with three CLI tools (Claude, Codex, Gemini) via subprocess stdio — each with different wire protocols. Understanding real protocol behavior is essential before building features that depend on message ordering, field presence, or event sequencing.
/protocol-research --provider <claude|codex|gemini|all> --scenario <name> [--capture] [--compare]
| Flag | Description | Default |
|---|---|---|
--provider | Which CLI protocol to investigate | required |
--scenario | Scenario to investigate (e.g., mcp-handshake, tool-permission, multi-turn) | required |
--capture | Capture real protocol output by running a test session | false |
--compare | Compare behavior across providers for the same scenario | false |
Before investigating, understand what you're looking at:
| Provider | Wire Format | Transport | Key Types Location |
|---|---|---|---|
| Claude | NDJSON (stream-json) | stdin/stdout | agent-cli-wrapper/protocol/ and agent-cli-wrapper/claude/ |
| Codex | JSON-RPC 2.0 | stdin/stdout | agent-cli-wrapper/codex/ |
| Gemini | JSON-RPC 2.0 (ACP) | stdin/stdout | agent-cli-wrapper/acp/ |
All three are unified through the agentstream event interface at agent-cli-wrapper/agentstream/.
Before capturing anything, check what's already known:
agent-cli-wrapper/claude/SDK_PROTOCOL.md — Claude protocol lifecycle, MCP handshake, gotchasagent-cli-wrapper/README.md — Agentstream interface mapping across providersagent-cli-wrapper/protocol/ — All Claude wire types (messages, stream events, control requests, MCP)agent-cli-wrapper/codex/jsonrpc.go — Codex JSON-RPC methods and notification typesagent-cli-wrapper/acp/protocol.go — ACP/Gemini request/response typesLook for test fixtures that already demonstrate the behavior:
agent-cli-wrapper/protocol/testdata/traces/ — Real CLI trace files (from_cli.jsonl, to_cli.jsonl)
agent-cli-wrapper/protocol/parse_test.go — Protocol message parsing validation
agent-cli-wrapper/protocol/trace_test.go — Trace file parsing and event counting
agent-cli-wrapper/claude/recorder.go — Session recording (messages.jsonl format)
Also check integration tests that exercise real provider behavior:
multiagent/agent/integration/provider_conformance_test.go — Cross-provider conformance suite
bramble/session/integration/ — Session lifecycle tests
If existing traces and tests don't cover the scenario, write a Go test that captures the specific behavior. This serves dual purpose — it validates your understanding AND becomes permanent test coverage.
Place the test in the appropriate package:
agent-cli-wrapper/protocol/agent-cli-wrapper/claude/ (or codex/, acp/)multiagent/agent/multiagent/agent/integration/Follow the repo's test conventions:
require.Eventually() for async conditions, never time.Sleep()integration/ directories with # gazelle:ignore BUILD.bazel//go:build integration tag for tests that need real CLI binariesFor Claude, use the recording infrastructure:
// The claude.SDK already records sessions when configured
// See agent-cli-wrapper/claude/recorder.go
// Output: .claude-sessions/session-<id>-<ts>/messages.jsonl
Each recorded message includes:
{"timestamp": 1234567890123, "direction": "sent|received", "message": {...}}
For Codex/Gemini, enable protocol logging:
bramble --protocol-log-dir /tmp/protocol-logs
This captures raw JSON-RPC exchanges to files for analysis.
For the specific scenario, document:
Verify that the agentstream event interfaces correctly translate provider-specific events:
agent-cli-wrapper/agentstream/event.go — Event kind definitions and interfaces
multiagent/agent/bridge.go — Generic bridgeEvents[E any]() function
For each event in the scenario, trace:
claude.ToolStartEvent)agentstream.ToolStart)AgentEvent (e.g., ToolStartAgentEvent)Check for events that are provider-specific and NOT bridged (intentionally skipped by the generic bridge).
Update or create documentation:
SDK_PROTOCOL.md)agent-cli-wrapper/README.mdsendInitialize control request → MCP handshake (interleaved) → system init message → readymessage_start → content_block_start → content_block_delta(s) → content_block_stop → message_delta → message_stopcontrol_request (stdout) / control_response (stdin) for permissions, MCP, interactive toolsname field or CLI silently hangsInitialize, ThreadStart, TurnStart, TurnInterruptthread/started, turn/started, turn/completed, item/started, item/completed, codex/event/*ScopeID() on events to filter by threadagent_message_chunk, agent_thought_chunk, tool_call, tool_call_result, plan_updateRequestPermissionRequest for tool approvalrunning → completed | errored| agentstream Kind | Claude Event | Codex Event | Gemini Event |
|---|---|---|---|
KindText | TextEvent | TextDeltaEvent | TextDeltaEvent |
KindThinking | ThinkingEvent | ReasoningDeltaEvent | ThinkingDeltaEvent |
KindToolStart | ToolStartEvent | CommandStartEvent | ToolCallStartEvent |
KindToolEnd | ToolCompleteEvent | CommandEndEvent | ToolCallUpdateEvent (completed/errored) |
KindTurnComplete | TurnCompleteEvent | TurnCompletedEvent | TurnCompleteEvent |
KindError | ErrorEvent | ErrorEvent | ErrorEvent |
| File | What It Contains |
|---|---|
agent-cli-wrapper/claude/SDK_PROTOCOL.md | Claude protocol lifecycle, MCP handshake, known gotchas |
agent-cli-wrapper/README.md | Agentstream interface design and cross-provider event mapping |
agent-cli-wrapper/protocol/types.go | All Claude wire types (messages, events, control, MCP) |
agent-cli-wrapper/codex/jsonrpc.go | Codex JSON-RPC methods and event types |
agent-cli-wrapper/acp/protocol.go | ACP/Gemini protocol types |
multiagent/agent/integration/provider_conformance_test.go | Cross-provider test expectations |