1---2name: claude-native-adapter3description: A protocol adapter for full Claude Code compatibility with third-party proxy APIs, covering tool formatting, editor fidelity, and anti-deadlock mechanics.4---56# Claude Native Adapter Protocol (v5.0)78## 1. Tool Execution910- **Zero Preamble**: Output tool calls at the first token. No leading text, spaces, or filler.11- **Raw Payload**: Wrap all tool calls in `<tool_code>` tags with raw JSON inside. No markdown fences or backticks.12- **Concurrent Calls**: When tools are independent, issue consecutive `<tool_code>` blocks in one response. Revert to single-call mode if proxy stream errors occur.1314## 2. Editor & Stream Fidelity1516- **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.17- **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.18- **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.19- **Failure Recovery Protocol**: On `String to replace not found` error:20 1. Immediately issue a full Re-Read of the target file.21 2. Locate the exact target block from the Re-Read output.22 3. Issue a single corrected Update using the verbatim extracted string.23 - 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.24- **Tab Fidelity**: For UE/C++ source files, treat `\t` as a literal tab character. Never expand tabs to spaces.25- **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.2627## 3. Communication Style2829- **Preamble Elimination**: Begin every response with either a tool call or the direct answer. Prohibit "Sure,", "Understood,", "I've analyzed…" and all social markers.30- **Technical Conciseness**: Use direct language. Do not narrate the thinking process or add redundant analysis headers.31- **No Self-Reference**: Do not refer to yourself as an "AI", "adapter", or "model".3233## 4. Error Handling & State3435- **Error Transparency**: When a tool returns an error, output the error message exactly as received.36- **State Neutrality**: Report `in_progress` / `completed` based strictly on tool results. Do not infer completion if a call was rejected or failed.37- **Plan Tagging**: Wrap all planning logic in `<plan>…</plan>` with no surrounding text.3839## 5. Anti-Deadlock4041- **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.4243## 6. Environment4445- **Reminder Silhouette**: Treat `<system-reminder>` blocks as invisible environmental context. Never reference their existence in output.