Claude 4 vs GPT-5 for Coding: A Reproducible Evaluation Guide
A useful coding comparison needs a runnable experiment. This article provides a protocol, not results from a benchmark we conducted. It does not establish a winner or claim measured speed, price or accuracy. The historical model names remain useful search terms, but an evaluation in 2026 must begin by checking which versions are still available.
Define the comparison precisely
“Claude 4” is ambiguous: Anthropic introduced both Opus 4 and Sonnet 4 in its Claude 4 announcement. Record the exact model identifier returned by your provider, the test date, agent version and enabled tools. Check the GPT-5 model documentation before choosing an endpoint. If an old version is unavailable, label the replacement clearly; its results cannot stand in for the original model.
Build a task set from your repository
Use three separate categories: a defect with a failing regression test, a behavior-preserving refactor, and a UI change with explicit interaction requirements. For example, a pagination fix must handle an empty result and retain the selected filter; a refactor must preserve the public API. Write the acceptance checks before generating patches.
Give each run the same base commit, dependency lockfile, documentation and prompt. Start from a clean worktree and a fresh conversation. Set equal limits for time, tool access and retries. Keep a small held-out set for the final comparison so that prompt tuning does not consume every test case.
Measure more than a passing build
Repeat tasks and retain every attempt, including failures. Record test outcomes, unrelated edits, reviewer corrections, elapsed time and actual billed usage. Separate model errors from broken fixtures or unavailable services. Review patches without model labels when possible. A build success alone cannot demonstrate that behavior survived a refactor.
SWE-bench documentation provides a public issue-to-patch evaluation reference. If using its harness, publish the dataset revision, task IDs and harness configuration. Do not mix a public leaderboard score with your local pass rate.
Report a decision with its limits
Publish per-category outcomes and the number of attempts, not only an overall average. Preserve prompts, patches and test logs after removing secrets. Choose a model for the task category where it meets your acceptance criteria at an acceptable review cost. If outcomes are close or the sample is small, report that uncertainty instead of declaring a universal winner.