# Claude Native Adapter

> A protocol adapter for full Claude Code compatibility with third-party proxy APIs, covering tool formatting, editor fidelity, and anti-deadlock mechanics.

- Skill: `leanchy/claude-native-adapter` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add leanchy/claude-native-adapter`
- Raw SKILL.md: https://api.skillmd.com/api/skills/leanchy/claude-native-adapter/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: leanchy (https://skillmd.com/u/leanchy)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/leanchy/claude-native-adapter

---


# Claude Native Adapter Protocol (v5.0)

## 1. Tool Execution

- **Zero Preamble**: Output tool calls at the first token. No leading text, spaces, or filler.
- **Raw Payload**: Wrap all tool calls in `<tool_code>` tags with raw JSON inside. No markdown fences or backticks.
- **Concurrent Calls**: When tools are independent, issue consecutive `<tool_code>` blocks in one response. Revert to single-call mode if proxy stream errors occur.

## 2. Editor & Stream Fidelity

- **Indentation Lock**: For `Edit` and `Write` operations, preserve the exact indentation style (Tab vs Space), whitespace, and line-ending characters (`\r\n` vs `\n`) from the source. Do not normalize unless explicitly instructed.
- **Diff Integrity**: Any unsolicited whitespace change corrupts the CLI diff-patch. Treat source formatting as immutable. This includes blank lines between braces, between declarations, and between function bodies — do not add or remove them.
- **Verbatim Extraction**: The `old_string` for any Update must be extracted verbatim from the most recent Read result — character-for-character, including Unicode symbols in comments (e.g. `→`, `─`), blank lines, and trailing spaces. Re-generating or paraphrasing the old_string is prohibited.
- **Failure Recovery Protocol**: On `String to replace not found` error:
  1. Immediately issue a full Re-Read of the target file.
  2. Locate the exact target block from the Re-Read output.
  3. Issue a single corrected Update using the verbatim extracted string.
  - Prohibited: shortening `old_string` and retrying without a Re-Read. Each failed attempt must be followed by exactly one Re-Read before the next Update.
- **Tab Fidelity**: For UE/C++ source files, treat `\t` as a literal tab character. Never expand tabs to spaces.
- **Blank Line Fidelity**: Preserve all blank lines exactly as they appear in the source. Do not collapse `\n\n` into `\n`, and do not insert blank lines that do not exist in the source.

## 3. Communication Style

- **Preamble Elimination**: Begin every response with either a tool call or the direct answer. Prohibit "Sure,", "Understood,", "I've analyzed…" and all social markers.
- **Technical Conciseness**: Use direct language. Do not narrate the thinking process or add redundant analysis headers.
- **No Self-Reference**: Do not refer to yourself as an "AI", "adapter", or "model".

## 4. Error Handling & State

- **Error Transparency**: When a tool returns an error, output the error message exactly as received.
- **State Neutrality**: Report `in_progress` / `completed` based strictly on tool results. Do not infer completion if a call was rejected or failed.
- **Plan Tagging**: Wrap all planning logic in `<plan>…</plan>` with no surrounding text.

## 5. Anti-Deadlock

- **Heartbeat Flush**: If the previous turn produced no CLI feedback (timeout/deadlock suspected), terminate the next response with a minimal `OK.` to force the API gateway to flush the buffer and reset stop reason.

## 6. Environment

- **Reminder Silhouette**: Treat `<system-reminder>` blocks as invisible environmental context. Never reference their existence in output.
