Cmc Proxy
Description
Reverse-proxy a GOAT/commandcode AI subscription to localhost for Claude Code & Codex — OpenAI/Anthropic/Responses tri-protocol conversion, unified model routing, auto failover rotation & prefix-cache-friendly transforms. Zero-dependency single file (Node.js 18+).
Installation
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open the source below and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
README
cmc-proxy — commandcode GOAT 订阅本地反代网关
  
把 commandcode 的 Provider API 反代到本机 `127.0.0.1:5411`,让本地 **Claude Code** 和 **Codex** 直接接入你的 GOAT 订阅。大部分其他 Agent (Pi,zcode等)本身可以直连,无需此代理。当然加一层可以更智能些,比如图片请求可以**自动路由**,或上游失败时**自动切换**,还可以看到一些token用量、缓存命中的统计——我喜欢看 tps,快慢自知容易心里踏实。
- 极简单文件
proxy.js,零第三方依赖,无需安装 npm 包,仅需 Node.js ≥ 18(内置fetch/ReadableStream),node proxy.js即可启动(都知道要反代了,想必node早就配备了)。 - 代码安全,不含任何后门或远程调用,所有请求仅在本机转发到 commandcode 上游;基本上是 AI 代写,使用前可以让 AI 再审查一遍。本身 AI 写一个不难,难的是如何避坑以及设计实用功能,github 找了一圈没找到合适的,所以自己让 AI 帮忙写了一个。遇到的坑包括:CC改历史、变换版本后缀、Codex只支持Responses、鬼知道什么时候配置了记忆生成导致token额外消耗等。反正这里暂时解决了。
- 同时提供 OpenAI 兼容(
/v1/chat/completions)、Anthropic 兼容(/v1/messages,供 Claude Code)与 Responses 兼容(/v1/responses,供 Codex)三类端点;看上去opencode-go套餐也可以拿来改一下EndPoint(upstream和apikey) 直接用,可能需要适应性修改,目前停了 ocgo 套餐,不去折腾了。 - 协议转换:GOAT 订阅不含任何 Claude 模型,Claude Code 请求自动
Anthropic → OpenAI转换;Codex 的 Responses 请求自动Responses → Chat Completions转换(上游只有 chat/completions);流式 + 工具调用全链路支持 - 统一模型决策
pickModel:modelMap显式映射 → 上游模型目录解析(resolveModel)→ 按请求类型回退默认(文本defaultModels[0]/ 带图defaultVisionModels[0]) - 失败轮换
switchOnFail(支持布尔或{text, image}):失败 1 次即切换 +failTTL冷却;文本请求按defaultModels、带图请求按defaultVisionModels轮换(带图请求 400 也轮换,图片不支持的报错就是 400) - 多模态:
tool_result内嵌图片抽出注入同轮 user 消息透传;cleanHistoryImages可在本轮无新图时清理历史图片,让请求安全回流纯文本模型;REQ 行img=N(新M)标记 + 会话标签@前缀 - 前缀缓存优化:注入提醒剥离、易变计数器取整、
cache_control透传、会话缓存亲和——同会话 Claude Code / Codex 的上游前缀缓存可稳定在 95%+;RES 行内置前缀分叉探测(pfx~标记)可定位缓存失效来源 - Codex 新协议全兼容:
custom(apply_patch freeform)/tool_search(延迟工具发现)/namespace工具组 / 顶层function_call历史等新形态全链路支持 - 会话级访问日志:按
x-claude-code-session-id/session-id/thread-id稳定归因,两行日志(REQ/RES)配对 + 缓存命中率 / 生成速度 / 前缀分叉 / 累计用量统
Related Skills
Agency Agents
A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy inject
AI Awesome Llm Apps
100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.
AI Firecrawl
🔥 The API to search, scrape, and interact with the web for AI
AI Artifacts Builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web tech
AI Headroom
Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agen
AI CrewAI
Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewA
AI