-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhesamation-claude-vs-codex-notes.tex
More file actions
470 lines (372 loc) · 18 KB
/
Copy pathhesamation-claude-vs-codex-notes.tex
File metadata and controls
470 lines (372 loc) · 18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
\documentclass[a4paper]{article}
% Basic packages
\usepackage[fontset=fandol]{ctex}
\usepackage{amsmath, amssymb}
\usepackage{graphicx}
\usepackage[margin=2.5cm]{geometry}
\usepackage[most]{tcolorbox}
\usepackage{etoolbox}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{subcaption}
\usepackage{float}
\usepackage{tikz}
\IfFileExists{pgfplots.sty}{
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
}{}
% Highlight boxes
\newtcolorbox{knowledgebox}[1]{
enhanced, colback=blue!5!white, colframe=blue!75!black, colbacktitle=blue!75!black,
coltitle=white, fonttitle=\bfseries, title=#1, attach boxed title to top left={yshift=-2mm, xshift=2mm},
boxrule=1pt, sharp corners
}
\newtcolorbox{importantbox}[1]{
enhanced, colback=yellow!10!white, colframe=yellow!80!black, colbacktitle=yellow!80!black,
coltitle=black, fonttitle=\bfseries, title=#1, sharp corners
}
\newtcolorbox{warningbox}[1]{
enhanced, colback=red!5!white, colframe=red!75!black, colbacktitle=red!75!black,
coltitle=white, fonttitle=\bfseries, title=#1, sharp corners
}
% Listings
\lstset{
language=Python,
basicstyle=\ttfamily\small,
keywordstyle=\color{blue},
stringstyle=\color{red!60!black},
commentstyle=\color{green!60!black},
breaklines=true,
frame=single,
numbers=left,
numberstyle=\tiny\color{gray},
captionpos=b,
extendedchars=false
}
% Front-page metadata
\newcommand{\notetitle}{Claude Code vs.\ Codex: The Definitive Guide}
\newcommand{\noteauthors}{基于公开课程资料整理}
\newcommand{\notedate}{2026-03-10}
\newcommand{\videochannel}{\texorpdfstring{$\hbar\varepsilon$sam}{hesam} (Hesamation)}
\newcommand{\videopublishdate}{2026-03-10}
\newcommand{\videoduration}{约 12 分钟阅读}
\newcommand{\videourl}{https://x.com/Hesamation/status/2031418875946958915}
\newcommand{\videocoverpath}{}
\newcommand{\repourl}{https://github.com/hqhq1025/ai-course-notes}
% Footer with repo info
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{\thepage}
\fancyfoot[R]{\footnotesize\color{gray}\href{\repourl}{AI Course Notes}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\begin{document}
\begin{titlepage}
\centering
{\Large 文章笔记\par}
\vspace{1.2cm}
{\huge\bfseries \notetitle\par}
\vspace{0.8cm}
{\large \noteauthors\par}
\vspace{0.3cm}
{\large \notedate\par}
\vspace{1.2cm}
\ifdefempty{\videocoverpath}{
\vspace{4cm}
}{
\includegraphics[width=0.82\textwidth,height=0.45\textheight,keepaspectratio]{\videocoverpath}\par
}
\vfill
\begin{tcolorbox}[width=0.9\textwidth, colback=black!2!white, colframe=black!60, sharp corners]
\textbf{原文作者}:\videochannel\par
\textbf{发布日期}:\videopublishdate\par
\textbf{阅读时长}:\videoduration\par
\textbf{原文链接}:
\ifdefempty{\videourl}{}{
\href{\videourl}{\nolinkurl{\videourl}}
}
\par
\textbf{项目主页}:\href{\repourl}{\nolinkurl{\repourl}}\par
\end{tcolorbox}
\end{titlepage}
\tableofcontents
\newpage
%% --- 正文内容开始 --- %%
\section{引言}
本文是对 X 平台用户 Hesamation 所撰写的长文 \textit{Claude Code vs.\ Codex: The Definitive Guide} 的中文整理。作者在使用 Claude Code 数月后转向 Codex,又重新切换回 Claude Code,从模型能力、使用体验、生态系统、定价策略等多个维度对两款 AI 编程代理进行了全面对比,并通过一个 RAG Pipeline 实验提供了定量参考。
\begin{knowledgebox}{背景:两款编程代理}
\textbf{Claude Code} 是 Anthropic 推出的 AI 编程代理,底层模型为 Opus 4.6,支持 1M token 上下文窗口。\textbf{Codex} 是 OpenAI 推出的编程代理,底层模型为 GPT-5.3-Codex。两者均提供 CLI 工具和 VS Code 扩展,订阅价格从 \$20/月到 \$200/月不等。
\end{knowledgebox}
\section{底层模型对比:Opus 4.6 vs.\ GPT-5.3-Codex}
\subsection{Task-Completion Time Horizon}
衡量模型能力的一个重要指标是 \textbf{Task-Completion Time Horizon}(任务完成时间跨度):给模型一个"人类专家需要 $T$ 小时完成"的任务,模型能以多大概率成功完成?
\begin{importantbox}{核心对比:任务完成能力差距显著}
\begin{itemize}
\item \textbf{Opus 4.6}:在 50\% 成功率下,可处理长达 \textbf{12 小时}的任务
\item \textbf{GPT-5.3-Codex}:在 50\% 成功率下,可处理长达 \textbf{5 小时 50 分钟}的任务
\item 在 80\% 成功率下,两者差距明显缩小
\end{itemize}
这表明 Opus 4.6 在处理复杂、长周期任务时具有明显优势。
\end{importantbox}
\subsection{Token 经济性}
基准测试显示两者准确率接近,但 token 消耗差异巨大。Morph 的对比研究发现:
\begin{table}[H]
\centering
\caption{Token 消耗对比}
\begin{tabular}{lcc}
\toprule
\textbf{指标} & \textbf{Claude Code} & \textbf{Codex} \\
\midrule
相同任务 token 倍率 & 3.2--4.2$\times$ & 1$\times$(基准) \\
Figma 插件构建 & 6.2M tokens & 1.5M tokens \\
\bottomrule
\end{tabular}
\end{table}
\begin{warningbox}{Token 消耗的实际影响}
在相同订阅价格下,Claude Code 用户更可能触及 token 用量上限。如果你的工作流涉及大量代码生成,需要特别关注这一点。
\end{warningbox}
\subsection{本章小结}
Opus 4.6 在长任务上的可靠性显著高于 GPT-5.3-Codex,但 Claude Code 的 token 消耗远高于 Codex。选择时需要在"任务处理深度"和"token 效率"之间权衡。
\section{速度与任务适配性}
\subsection{速度不是决定性因素}
Claude Code 公认速度更快,但作者指出:如果一个代理快速完成任务却留下需要 10 分钟调试的 bug,另一个虽慢却直接交付可用结果,后者的额外时间完全值得。
\begin{warningbox}{速度陷阱}
不要被"我的代理更快"这类说法误导。编程代理是长期使用的工具,\textbf{端到端的完成质量}比单次任务的执行速度更重要。
\end{warningbox}
\subsection{任务类型决定胜负}
两款代理在不同编程领域的表现差异很大:
\begin{itemize}
\item 在 AI Engineering 任务中,一方可能占优
\item 在 Web 开发任务中,另一方可能反超
\item 低级编程(low-level programming)领域尚无定论
\end{itemize}
目前缺乏系统性的跨任务对比研究,且由于模型和代理每隔几个月就会大幅更新,这类研究也很难长期有效。
\subsection{本章小结}
速度优势不等于体验优势,任务类型对两款代理的表现影响极大。理想做法是在自己的实际编程领域中小规模测试两者。
\section{产品起源与技术栈}
\subsection{发展历程}
\begin{table}[H]
\centering
\caption{Claude Code 与 Codex 发展时间线}
\begin{tabular}{lp{5.5cm}p{5.5cm}}
\toprule
\textbf{时间节点} & \textbf{Claude Code} & \textbf{Codex} \\
\midrule
起源 & Anthropic 内部 @bcherny 的 side project,终端原型可调用 Claude API、读取文件、执行 bash 命令 & 最初的 Codex 是 12B GPT-3 微调模型,驱动了初代 GitHub Copilot \\
\addlinespace
公开发布 & 2025-02-24,Research Preview,使用 Claude 3.7 Sonnet & 2025-04-16,Codex CLI 发布 \\
\addlinespace
最新版本 & Opus 4.6(1M token 上下文) & GPT-5.3-Codex(2026-02-05),OpenAI 称其为"第一个参与了自身创建的模型" \\
\bottomrule
\end{tabular}
\end{table}
\begin{knowledgebox}{内部采用速度}
Claude Code 原型在 Anthropic 内部发布后,第五天就有一半团队在使用。这种自发的内部采用往往是产品 product-market fit 的强信号。
\end{knowledgebox}
\subsection{技术栈对比}
\begin{table}[H]
\centering
\caption{技术栈对比}
\begin{tabular}{lcc}
\toprule
\textbf{维度} & \textbf{Claude Code} & \textbf{Codex CLI} \\
\midrule
编程语言 & TypeScript & Rust \\
UI 框架 & React + Ink(终端 UI) & Ratatui(Rust TUI 库) \\
分发方式 & 单个 Bun 可执行文件 & 原生二进制 \\
上下文窗口 & 1M tokens & -- \\
\bottomrule
\end{tabular}
\end{table}
作者注意到 Claude Code CLI 偶有小 glitch,但不影响实际编码体验。两者本质上都是围绕底层模型 API 的轻量包装(thin wrapper)。
\begin{knowledgebox}{Anthropic 收购 Bun}
Anthropic 于 2025 年 12 月收购了 JavaScript 运行时 Bun,Claude Code 因此可以打包为单个 Bun 可执行文件分发,简化了安装流程。
\end{knowledgebox}
\subsection{本章小结}
Claude Code 源于内部工具的自然生长,技术栈偏向 TypeScript 生态;Codex CLI 选择了 Rust 以追求性能和可移植性。两者都是模型 API 的轻量封装,产品差异更多体现在模型能力和交互设计上。
\section{使用体验:``高级开发者'' vs.\ ``外包承包商''}
\subsection{交互风格差异}
开发者社区对两者的体验有一个经典比喻:
\begin{importantbox}{体验差异的核心比喻}
\textbf{Claude Code} 像一个在你身边工作的\textbf{高级开发者}——会提问、展示推理过程、解释方案。\\[0.3em]
\textbf{Codex} 像一个你\textbf{外包任务后等待交付的承包商}——首次尝试准确率高,但交互感较弱。
\end{importantbox}
具体表现在:
\begin{itemize}
\item Claude Code 具有强交互感和深度推理,主动提问并解释思路
\item Codex 以首次尝试准确率(first-attempt accuracy)著称,但速度稍慢
\item Claude Code 会主动测试代码、修复环境问题
\item Codex 倾向于完成实现后让用户自行安装依赖和运行
\end{itemize}
\begin{warningbox}{体验差异会被 AGENTS.md 削弱}
如果你在 \texttt{AGENTS.md} 中明确指定了工作流程(如"实现前先与我确认方案"),两款代理的行为差异会\textbf{显著缩小}。不要过度依赖社交媒体上对差异的夸大描述。
\end{warningbox}
\subsection{市场数据}
\begin{table}[H]
\centering
\caption{市场采用数据(截至 2026 年 3 月)}
\begin{tabular}{lcc}
\toprule
\textbf{指标} & \textbf{Claude Code} & \textbf{Codex} \\
\midrule
VS Code 安装量 & 6.1M & 5.4M \\
VS Code 评分 & 4/5 & 3.5/5 \\
GitHub Stars & 65--72K & $\sim$64K \\
\bottomrule
\end{tabular}
\end{table}
\subsection{本章小结}
Claude Code 的交互感更强,Codex 在直接任务上的首次准确率更高。但通过 \texttt{AGENTS.md} 等配置文件可以大幅拉近两者的行为差异。市场数据显示 Claude Code 在安装量和评分上略占优势。
\section{RAG Pipeline 实验对比}
\subsection{实验设计}
作者设计了一个定量可评估的任务——构建一个针对学术论文的 RAG(Retrieval-Augmented Generation)问答 Pipeline:
\begin{enumerate}
\item 从 Hugging Face 每日论文中取 5 篇论文
\item 构建包含 100 个问题和标准答案的测试集
\item 给两个代理相同的 prompt,要求构建完整 RAG Pipeline
\end{enumerate}
给两个代理的统一要求:
\begin{itemize}
\item Python 实现,使用 \texttt{PyMuPDF} 处理 PDF
\item 自选分块策略(chunking strategy)
\item 自选向量索引方案
\item 使用 \texttt{llama-3.1-8b-instant} 生成答案
\item 证据不足时返回 fallback 响应,不得幻觉
\end{itemize}
两个代理均使用最高配模型(Opus 4.6 / GPT-5.3-Codex),High effort 推理强度,无 \texttt{AGENTS.md}。
\subsection{实现方案对比}
\begin{table}[H]
\centering
\caption{RAG Pipeline 实现方案对比}
\begin{tabular}{lp{5cm}p{5cm}}
\toprule
\textbf{维度} & \textbf{Claude Code} & \textbf{Codex} \\
\midrule
Embedding 模型 & all-MiniLM-L6-v2 & all-MiniLM-L6-v2 \\
\addlinespace
Top-K & $k=5$ & $k=5$ \\
\addlinespace
向量存储 & ChromaDB & FAISS(更底层、内存效率更高) \\
\addlinespace
分块策略 & 递归字符分割:\texttt{\textbackslash n\textbackslash n} $\to$ \texttt{\textbackslash n} $\to$ \texttt{.} $\to$ 空格;1000 字符/200 字符重叠 & 句子级词分割,每块 220 词/40 词重叠 \\
\addlinespace
检索度量 & 原始 L2 距离 & 内积(cosine)分数 \\
\addlinespace
置信度机制 & 单阈值(L2 $> 1.2$ 视为不相关)+ 平均距离检查 & 多标准三级机制:strong / moderate / insufficient \\
\addlinespace
代码架构 & 扁平函数式,模块级常量 & OOP Pipeline 类,集中配置,dataclass,argparse CLI \\
\bottomrule
\end{tabular}
\end{table}
\begin{knowledgebox}{工程质量观察}
Codex 的实现在代码架构上明显更优:面向对象设计、集中配置管理、类型标注(dataclass)、CLI 参数解析。在大型或正式项目中,这种工程化差异非常关键。
\end{knowledgebox}
\subsection{行为差异}
\begin{itemize}
\item \textbf{Claude Code}:自动端到端测试脚本,确保 Pipeline 开箱即用。首次运行无错误。
\item \textbf{Codex}:完成实现后要求用户手动 \texttt{pip install} 并运行脚本。首次运行报错,经修复后正常。
\item Codex 解释计划时更加详尽(verbose),Claude Code 更倾向于直接写代码执行命令。
\item Codex 首个 token 的响应延迟可达 1 分钟,Claude Code 明显更快。
\end{itemize}
\subsection{评测结果}
使用 GPT-5.4 作为 LLM-as-a-Judge,在 Correctness、Completeness、Relevance、Conciseness 四个维度评估:
\begin{table}[H]
\centering
\caption{RAG Pipeline 评测结果(100 个问题)}
\begin{tabular}{lccc}
\toprule
\textbf{结果} & \textbf{Claude Code 胜出} & \textbf{Codex 胜出} & \textbf{平局} \\
\midrule
题数 & 42 & 33 & 25 \\
\bottomrule
\end{tabular}
\end{table}
\begin{importantbox}{Claude Code 胜出的关键因素}
Claude Code 胜出主要归因于:(1)更宽松的置信度阈值,避免了过多 fallback 响应;(2)稍高的生成温度(0.2 vs.\ Codex 的 0.1),增加了回答的丰富度。
\end{importantbox}
\begin{warningbox}{实验局限性}
这是一个简单的单次实验。在专业场景中,分块策略、向量数据库、检索方案等架构决策应由开发者主导,而非完全交给 AI。此实验更适合作为观察两款代理"默认行为"的参考,而非最终结论。
\end{warningbox}
\subsection{本章小结}
在 RAG Pipeline 任务中,两款代理选择了相似的基础方案但在关键细节上各有侧重。Claude Code 在端到端交付和最终评测上略优,Codex 在代码工程质量上更胜一筹。
\section{生态系统与定价}
\subsection{Anthropic 生态的吸引力}
作者认为选择编程代理不仅是选工具,更是选生态:
\begin{itemize}
\item \textbf{Anthropic 生态}:Claude Chat + Claude Code + Claude Cowork,形成类似 Apple 的闭环体验。Anthropic 还在逐步构建 OpenClaw(主动式个人代理)的安全版本。
\item \textbf{OpenAI 生态}:除 Codex 外,其他产品对作者吸引力不大。ChatGPT 在 UI、对话风格和模型选择上已落后于 Claude Chat。
\end{itemize}
\subsection{定价方案对比}
\begin{table}[H]
\centering
\caption{定价方案对比}
\begin{tabular}{lcc}
\toprule
\textbf{层级} & \textbf{Claude Code} & \textbf{Codex} \\
\midrule
入门版 & \$20/月 & \$20/月 \\
中间版(Max 5x) & \$100/月 & --- \\
重度使用版 & \$200/月 & \$200/月 \\
\bottomrule
\end{tabular}
\end{table}
\begin{importantbox}{Claude Code 的定价优势}
Claude Code 提供了 \$100/月 的中间层级(Max 5x),对大多数开发者来说已经足够。这避免了从 \$20 直接跳到 \$200 的尴尬,使其\textbf{实际使用成本更低}。
\end{importantbox}
\subsection{Skills 与 Plugins 生态}
\begin{itemize}
\item Skills 在两个平台间兼容,体验一致
\item Codex 的 plugin 支持推出较晚,可用插件较少
\item 社区内容(Reddit、X、博客)以 Claude Code 为主,反映其更大的社区规模
\item 作者认为大多数开发者并不使用 plugins,这不应成为决策的关键因素
\end{itemize}
\subsection{本章小结}
Anthropic 正在构建一个紧密整合的产品生态,对于已经使用 Claude Chat 的用户吸引力尤其大。Claude Code 的三级定价比 Codex 的两级定价更灵活。Skills 生态基本通用,plugins 差异不大。
\section{总结与延伸}
\subsection{作者的最终选择}
作者选择回归 Claude Code 的两个核心原因:
\begin{enumerate}
\item \textbf{生态系统}:Anthropic 的 Claude Chat + Code + Cowork 整合体验优于 OpenAI
\item \textbf{定价灵活性}:\$100/月的中间层级更经济实用
\end{enumerate}
\subsection{关键结论}
\begin{importantbox}{如何选择编程代理}
\begin{enumerate}
\item 两者都不是"错误的选择"——模型能力接近,都能完成日常编程任务
\item \textbf{任务类型}比 benchmark 更能决定哪个更适合你
\item 最可靠的方法:用 \$20/月版本在自己的实际编程领域上测试可量化的任务
\item AI 工具格局每隔几个月剧变一次,不要把当前选择视为永久决定
\end{enumerate}
\end{importantbox}
\subsection{全文核心对比总览}
\begin{table}[H]
\centering
\caption{Claude Code vs.\ Codex 核心维度总览}
\begin{tabular}{lcc}
\toprule
\textbf{维度} & \textbf{Claude Code} & \textbf{Codex} \\
\midrule
底层模型 & Opus 4.6 & GPT-5.3-Codex \\
长任务可靠性(50\%) & 12 小时 & 5 小时 50 分 \\
Token 效率 & 较低(3--4$\times$) & 较高(基准) \\
执行速度 & 更快 & 较慢 \\
交互风格 & 主动交互、解释推理 & 任务导向、详述计划 \\
端到端交付 & 自动测试、开箱即用 & 需用户手动验证 \\
代码架构质量 & 扁平函数式 & OOP、工程化更强 \\
生态整合 & Chat + Code + Cowork & 相对分散 \\
中间定价 & \$100/月 & 无 \\
VS Code 评分 & 4/5 & 3.5/5 \\
\bottomrule
\end{tabular}
\end{table}
\subsection{拓展阅读}
\begin{itemize}
\item 原文链接:\href{https://x.com/Hesamation/status/2031418875946958915}{Hesamation -- Claude Code vs.\ Codex: The Definitive Guide}
\item @GergelyOrosz 对 Claude Code 和 Codex 开发者的访谈(How Codex is Built)
\item Morph 关于 Opus vs.\ Codex 的 token 经济性研究
\item Task-Completion Time Horizon 基准测试
\end{itemize}
%% --- 正文内容结束 --- %%
\end{document}