Published
-
AI Coding Practices: Engineering for a Higher Probability of Success

Photo by Bernd Dittrich on Unsplash
1. Executive Summary
LLM-based AI coding is more useful when it is treated as a development system for increasing the probability that a software change finishes correctly, rather than as a technology that simply replaces a human developer. The success probability is not determined by model capability alone. Task design, repository context, the agent-computer interface, verification, permission boundaries, and review workflow all compound.
出典: Anthropic argues that successful agentic systems often rely on simple, composable patterns rather than complex frameworks Building effective agents. OpenAI describes Codex as a software engineering agent that reads repositories, edits files, runs tests, and can turn work into pull requests Introducing Codex.The report’s core conclusions are:
- The objective of AI coding is not one-shot generation accuracy. It is the probability that a requested change is completed, verified, and left as a reviewable diff.
- Success depends heavily on environment, context design, tool design, tests, CI, PR workflow, and rollback mechanisms.
- Good practice does not mean giving the agent unlimited freedom. It means defining where the agent can explore, edit, verify, and leave evidence.
- The longer the task, the more important it becomes to treat repository state, task lists, tests, commits, and logs as the source of truth instead of the chat transcript.
- Public benchmarks are useful, but local success probability should be measured with evaluation sets and operational logs that reflect your own codebase.
flowchart LR
A["Task design"] --> B["Context"]
B --> C["Interface"]
C --> D["Verification"]
D --> E["Review"]
E --> F["Success rate"]
The point of the diagram is that one strong layer is not enough. A stronger model will still produce plausible but wrong diffs if tests are missing. A detailed instruction file will not help if the task itself is ambiguous. Broad permissions may increase speed, but without rollback and auditability the cost of failure increases as well.
2. Why AI Coding Becomes Probability Engineering
In AI coding, an AI agent observes an environment, uses tools, changes state, and pursues an objective across multiple turns. In software development, this can include repository exploration, planning, implementation, test execution, reading failure logs, revising the patch, and writing a PR description. This is broader than traditional code completion.
That breadth creates more failure modes. An agent may inspect the wrong file, trust stale assumptions, skip tests, misunderstand what a passing test proves, over-abstract the solution, or lose context midway through a task. Therefore, the engineering target is not just the prompt. It is the development environment in which the agent is likely to succeed.
出典: Anthropic’s Claude Code best practices emphasize giving the agent ways to verify its work and managing context aggressively because agentic coding involves reading files, running commands, and making changes Claude Code: Best practices for agentic coding. OpenAI’s Codex system card addendum describes Codex as able to edit files, run tests, lint, typecheck, and leave verifiable evidence through terminal logs and files Codex system card addendum.In this framing, AI coding maturity is not measured by how autonomous the system is. It is measured by how small failures become and how reproducible successes become.
| Layer | Question | What to Prepare |
|---|---|---|
| Task design | Is the task small enough for one agent run? | Issues, acceptance criteria, work units |
| Context | Can the agent find the right knowledge quickly? | AGENTS.md, architecture docs, ADRs, progress logs |
| Interface | Can the agent take correct actions cheaply? | CLIs, scripts, MCP tools, structured output |
| Verification | Can the agent judge whether it succeeded? | Tests, lint, type checks, screenshots |
| Control | Can failures be stopped and reviewed? | Permissions, sandboxing, PRs, rollback, review |
3. Research Background and Current Direction
Software engineering agents have moved from single-shot code generation toward repository-level issue resolution. SWE-bench evaluates whether a model can solve tasks derived from real GitHub issues and pull requests. SWE-agent showed that, even with a fixed language model, designing the agent-computer interface can improve the agent’s ability to navigate repositories, edit files, and run tests.
出典: SWE-bench introduced 2,294 software engineering problems drawn from real GitHub issues and corresponding pull requests SWE-bench paper. SWE-agent reports that an Agent-Computer Interface improves repository navigation, code editing, and test execution SWE-agent paper.At the same time, more agentic is not always better. Agentless showed that a relatively simple two-phase process, localization followed by repair, can be a strong baseline without giving the model a long autonomous tool-use loop. The practical lesson is important: agentic autonomy is valuable only when it raises the probability of success. For predictable tasks, a workflow may outperform a free-form agent.
出典: Agentless questions the necessity of complex tool-use loops by using localization and repair as a simpler approach to LLM-based software engineering Agentless paper. Anthropic similarly distinguishes workflows from agents and recommends choosing the simpler pattern when the task is predictable Building effective agents.Since 2025, practical guidance has shifted from model-only thinking toward harness design. OpenAI explains the Codex agent loop as the orchestration logic connecting user, model, and tools. Anthropic describes long-running agent harnesses that use an initializer agent, feature lists, progress notes, basic tests, and commits to preserve progress across sessions.
出典: OpenAI describes the Codex CLI agent loop as the core logic that orchestrates the user, model, and tools Unrolling the Codex agent loop. Anthropic’s long-running agent harness uses feature lists, progress notes, init scripts, self-verification, and commits to make progress across many context windows Effective harnesses for long-running agents.timeline
2023 : SWE-bench
2024 : SWE-agent
2024 : Agentless
2025 : Codex and Claude Code
2026 : Harnesses and evals
4. Five Layers for Raising Success Probability
4.1 Convert Tasks into Success Conditions
Agents should not receive vague instructions such as “fix this nicely.” They need a target, constraints, acceptance criteria, verification steps, allowed scope, and forbidden scope. This resembles good issue writing for humans, but it matters more for agents because they will try to fill ambiguity.
| Scope | Agent Fit | Example |
|---|---|---|
| 5-20 minutes | High | Small bug fix, test addition, copy change |
| 30-90 minutes | Medium | Single feature, existing UI pattern, local refactor |
| Half day or more | Conditional | Migration, cross-cutting design change, long research |
| Multiple days | Must split | New product, multi-boundary redesign |
For long tasks, repository artifacts such as feature lists, acceptance criteria, progress notes, and verification commands are more reliable than a plan that exists only in the conversation.
4.2 Split Context into a Short Index and Deep Sources of Truth
Putting everything into AGENTS.md or CLAUDE.md bloats context and buries the important instructions. A better pattern is to make the top-level agent file a map, then store details in architecture docs, runbooks, ADRs, and testing guides. The agent should know what to read, not be forced to read everything at startup.
出典: OpenAI’s harness engineering article treats AGENTS.md as a table of contents rather than an encyclopedia, with the source of truth in structured docs Harness engineering. Anthropic frames context engineering as the natural progression of prompt engineering for agents Effective context engineering for AI agents.Context design is not about maximizing context volume. It is about helping the agent reach the information required for a decision, distinguish stale from current knowledge, and avoid irrelevant material.
4.3 Design the Agent-Computer Interface
SWE-agent’s key lesson is that agent capability depends on the interface the agent uses. Human-oriented CLIs and huge logs are not always agent-friendly. Better interfaces provide short commands, structured output, clear errors, idempotent scripts, and targeted tests.
出典: Anthropic argues that agent performance depends on tool quality, including tool descriptions, specs, and evaluation Writing effective tools for agents. SWE-agent provides empirical support that the agent-computer interface affects software engineering performance SWE-agent paper.Agent-friendly tools usually have five properties:
- Inputs are short and choices are explicit.
- Output distinguishes success, failure, and warnings.
- Failure output points to the next log or command.
- Destructive operations have dry-run, confirmation, or sandboxing.
- Re-running the command is unlikely to corrupt state.
4.4 Design Verification First
The highest-value feedback for an agent is executable verification. Unit tests, integration tests, type checks, lint, snapshots, browser screenshots, API smoke tests, and CI logs all provide signals the agent can use to repair its work. Without verification, agents tend to stop when an answer looks plausible.
出典: Anthropic’s agent evals article distinguishes tasks, trials, graders, and transcripts, and notes that coding-agent evals require well-specified tasks, stable test environments, and thorough tests Demystifying evals for AI agents. Claude Code best practices also emphasize tests, screenshots, and expected outputs as high-leverage verification Claude Code best practices.flowchart TD
S["Spec"] --> T["Tests"]
T --> A["Agent patch"]
A --> R["Run result"]
R -->|Fail| A
R -->|Pass| P["PR review"]
No single evaluation layer is enough. Unit tests are fast but do not catch every UX problem. LLM judges are flexible but noisy and costly. Human review is strong but slow. The practical approach is to combine deterministic tests, logs, screenshots, and human review according to task risk.
4.5 Use Controls to Move Safely, Not to Block Work
Permission boundaries are not there to make the agent weak. They reduce loss when the agent fails and ensure that only successful diffs are merged. Sandboxing, network controls, secret isolation, PR review, approvals for privileged commands, and git-based diff management make agents more suitable for production development.
出典: OpenAI describes Codex as running in an isolated environment with the repository and user-defined development setup, while leaving verifiable evidence through files and terminal logs Codex system card addendum. Anthropic describes human control, approval of actions, and distinguishing safe from risky actions as part of Claude Code’s agent safety approach Claude Code product.5. Engineering Practices
5.1 Make AGENTS.md a Working Map
AGENTS.md should contain where the agent should start, common verification commands, forbidden operations, branch and PR rules, and failure-handling guidance. Detailed design rationale should live in docs. Information intended for agents should be discoverable through filenames and headings.
| File | Role |
|---|---|
AGENTS.md | Work map, verification commands, prohibitions |
docs/architecture.md | Boundaries and major data flows |
docs/testing.md | Test types, local commands, CI behavior |
docs/runbooks/*.md | Diagnostic procedures |
docs/decisions/*.md | Design decision history |
5.2 Separate Exploration, Implementation, and Verification
If one prompt asks the agent to investigate, design, implement, and fix everything, success criteria often drift. Separate exploration tasks, implementation tasks, and verification tasks. In exploration, avoid creating diffs. In implementation, limit scope. In verification, state commands and expected results.
5.3 Treat Test Failures as Messages to the Agent
Agents repair code by reading failures, so test output is now both developer-facing and agent-facing. A good failure states what was expected, what actually happened, and where to inspect next. Huge snapshot diffs and flaky environment failures can mislead the agent.
5.4 Persist Long-Running Work in the Repository
Long work should not depend only on conversation history. Keep progress notes, feature lists, completion criteria, unresolved failures, and recent commits in the repository. Each session should begin by reading logs and running a basic test, then end with a commit and progress update.
出典: Anthropic’s long-running agents article recommends feature lists, progress notes, basic tests, commits, and progress updates to enable work across many context windows Effective harnesses for long-running agents.5.5 Treat Agent Output as a Pull Request
Agent output should be handled as a PR, not as a chat answer. A PR records the purpose, changes, verification, known limits, and review focus. Completion should be judged by the diff, tests, CI, and reviewability rather than by the agent saying it is done.
6. Risks and Limits
6.1 Benchmarks Do Not Guarantee Local Success
Benchmarks such as SWE-bench Verified matter, but they do not directly measure success in your repository. In 2026, OpenAI argued that SWE-bench Verified was no longer suitable for measuring frontier coding capability because of contamination and test-quality issues. The lesson is not that benchmarks are useless. It is that teams need local evaluation sets that reflect their own failure modes.
出典: OpenAI states that SWE-bench Verified has become less suitable for frontier launch measurement due to contamination and flawed tests, and recommends SWE-bench Pro Why SWE-bench Verified no longer measures frontier coding capabilities. For the initial purpose and structure of SWE-bench Verified, see Introducing SWE-bench Verified.6.2 Work That Cannot Be Verified Is Hard to Stabilize
When the specification is ambiguous, the correct answer depends strongly on taste, and no tests or observable checks exist, agents produce plausible outputs more easily than reliably correct ones. Agents can still help with design, writing, strategy, and research, but review criteria and claims to falsify must be explicit.
6.3 More Autonomy Increases Blast Radius
Giving an agent network access, secrets, production operations, paid APIs, or external writes may increase speed, but it also increases the cost of failure. Autonomy should be staged by task type.
| Level | Allowed | Suitable Work |
|---|---|---|
| L1 | Read and propose | Design discussion, review |
| L2 | Local edits and local tests | Small fixes, tests |
| L3 | Branches, PRs, CI checks | Ordinary development |
| L4 | External APIs, deploys, workflow runs | Operations with runbooks |
| L5 | Autonomous production changes | Only after strict approval |
7. Recommended Direction
To treat AI coding as probability engineering, do not start by adding more tools. Start by reshaping the development workflow so agents can succeed.
In the short term:
- Make
AGENTS.mda short working map with verification commands and prohibitions. - Convert recurring work into issue templates with acceptance criteria.
- Provide fast tests and smoke tests that the agent can run by itself.
- Write runbooks for CI failures, local startup, and deployment checks.
- Treat agent work as PR work, with diffs, logs, verification, and residual risks.
In the medium term, maintain an agent evaluation set. Collect 20-50 tasks from past failures, common fixes, UI regressions, migrations, and CI failures. Re-run them when changing models, prompts, or tools. This does not need to be a large research benchmark. The value is reproducing failures that matter to your own development organization.
出典: Anthropic recommends starting agent evals early, noting that 20-50 tasks drawn from real failures can be enough at the beginning, and that evals clarify success criteria, prevent regressions, and support model-upgrade decisions Demystifying evals for AI agents.Ultimately, AI coding maturity is not measured by how little code humans type. It is whether the team can explain which tasks succeed under which conditions, with which verification, and at what probability. Adding AI coding to a development workflow is not mainly about accumulating prompt tricks. It is about embedding a system for raising success probability into the repository, tests, CI, documentation, and PR workflow.
References
- Anthropic, Building effective agents, 2024-12-19.
- Anthropic, Claude Code: Best practices for agentic coding, 2025-04-18.
- Anthropic, Writing effective tools for agents, 2025-09-11.
- Anthropic, Effective context engineering for AI agents, 2025-09-29.
- Anthropic, Effective harnesses for long-running agents, 2025-11-26.
- Anthropic, Demystifying evals for AI agents, 2026-01-09.
- OpenAI, Introducing Codex, 2025-05-16.
- OpenAI, Addendum to OpenAI o3 and o4-mini system card: Codex, 2025-05-16.
- OpenAI, Harness engineering: leveraging Codex in an agent-first world, 2026.
- OpenAI, Unrolling the Codex agent loop, 2026-01-23.
- OpenAI, Why SWE-bench Verified no longer measures frontier coding capabilities, 2026-02-23.
- Jimenez et al., SWE-bench: Can Language Models Resolve Real-World GitHub Issues?, ICLR 2024.
- Yang et al., SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering, NeurIPS 2024.
- Xia et al., Agentless: Demystifying LLM-based Software Engineering Agents, 2024.
1. エグゼクティブサマリー
LLMを用いたAI Codingは、「人間の代わりに全部作る」技術として見るより、「ソフトウェア変更が正しく終わる確率を上げる」ための開発システムとして整備する方が実務に合う。成功確率はモデル性能だけで決まらない。タスク分割、リポジトリ内の文脈、Agentが使う操作面、検証手段、権限境界、レビューの入れ方が掛け算で効く。
出典: Anthropicは、成功したagentic systemは複雑なフレームワークより simple, composable patterns を使うことが多いと整理している Building effective agents。OpenAIはCodexを、リポジトリを読み、ファイル編集とテスト実行を行い、差分をPR化できるsoftware engineering agentとして説明している Introducing Codex。本レポートの結論は次の通りである。
- AI Codingの目的は、単発の生成精度ではなく、変更が意図通りに完了し、検証され、レビュー可能な差分として残る確率を上げることである。
- 成功確率は「モデル能力」よりも、実行環境、文脈設計、ツール設計、テスト、CI、PR運用、失敗時の巻き戻しによって大きく変わる。
- 良いプラクティスは、Agentを自由にすることではなく、Agentが探索し、編集し、検証し、証拠を残せる範囲を明確にすることである。
- 長い作業ほど、セッション内の会話より、リポジトリ内の状態ファイル、タスクリスト、テスト、コミット、ログを正本にする必要がある。
- ベンチマークの点数は参考になるが、自分のコードベースでの成功確率は、ローカルの評価セットと運用ログで測るべきである。
flowchart LR
A["タスク設計"] --> B["文脈"]
B --> C["操作面"]
C --> D["検証"]
D --> E["レビュー"]
E --> F["成功確率"]
この図で重要なのは、どこか1つを強くしても全体は安定しない点である。高性能モデルを使っても、テストがなければ「うまく見える差分」が通る。詳細なAGENTS.mdを書いても、タスクが曖昧なら探索が散る。Agentに広い権限を渡しても、巻き戻しと監査がなければ失敗時の損失が大きくなる。
2. 背景: AI Codingはなぜ確率の工学になるのか
AI Codingで使うAI Agentは、LLMが複数ターンにわたって環境を観察し、ツールを使い、状態を変えながら目的を達成しようとする仕組みである。ソフトウェア開発では、リポジトリ探索、変更方針の立案、実装、テスト実行、失敗ログの読解、修正、PR説明の作成までが対象になる。これは従来のコード補完より広い。
しかし、広いということは失敗面も広い。Agentは、間違ったファイルを読む、古い前提を信じる、テストを実行しない、通ったテストの意味を誤解する、過剰に抽象化する、作業途中で文脈を失う、といった失敗を起こす。したがって、開発者が整備すべき対象は「プロンプト」だけではない。Agentが成功しやすい環境そのものを設計する必要がある。
出典: AnthropicのClaude Code best practicesは、Agentic codingではファイル読み取り、コマンド実行、変更作成を行えるため、特に「検証手段を与えること」と「文脈管理」が重要だと述べている Claude Code: Best practices for agentic coding。OpenAIのCodex system card addendumも、Codexがファイル編集、テスト、lint、type checkを実行し、端末ログとファイルによる検証可能な証拠を残す設計であると説明している Codex system card addendum。この見方では、AI Codingの成熟度は「どれだけ自律させたか」ではなく、「失敗を小さくし、成功を再現可能にしたか」で測る。成功確率は、次の5つの掛け算で考えられる。
| 要素 | 問い | 整備するもの |
|---|---|---|
| タスク設計 | Agentが一度に扱える大きさか | issue、受け入れ条件、作業単位 |
| 文脈 | 必要な知識へ迷わず到達できるか | AGENTS.md、設計文書、ADR、状態ログ |
| 操作面 | 正しい操作を低コストで実行できるか | CLI、スクリプト、MCP、専用ツール |
| 検証 | Agent自身が成否を判定できるか | テスト、lint、型検査、スクリーンショット |
| 統制 | 失敗しても止められるか | 権限、sandbox、PR、レビュー、巻き戻し |
3. 研究史と現在地
ソフトウェア開発Agentの研究は、単発のコード生成から、リポジトリ全体を対象にした課題解決へ移った。SWE-benchは、実際のGitHub issueと対応するPRから構成される課題を使い、LLMがコードベースを変更して問題を解けるかを評価した。SWE-agentは、モデル自体を変えずに、Agentがコンピュータとやり取りするインターフェースを設計することで性能を上げられることを示した。
出典: SWE-benchは2,294件の実GitHub issue由来の課題で、コードベースとissue記述からパッチ生成を求める評価として提案された SWE-bench paper。SWE-agentは、Agent-Computer Interfaceの設計がリポジトリ探索、編集、テスト実行に効くと報告している SWE-agent paper。一方で、Agentが複雑であるほど良いとは限らない。Agentlessは、LLMに長い自律ループを任せるのではなく、問題箇所の特定と修正生成という単純な二段階に分けても強いベースラインになることを示した。これは実務にも重要である。Agenticであること自体に価値があるのではなく、成功確率が上がるなら、手続き的なworkflowの方が良い場合がある。
出典: Agentlessは、複雑なtool-use loopを持たないlocalizationとrepairの二段階方式で、LLM-based software engineering agentの必要条件を問い直した研究である Agentless paper。Anthropicも、workflowとagentを区別し、予測可能なタスクではworkflow、柔軟な探索が必要なタスクではagentが向くと整理している Building effective agents。2025年以降の実務情報は、AI Codingの焦点が「モデル単体」から「harness」に移っていることを示す。OpenAIはCodexのagent loopを、ユーザー、モデル、ツールを束ねる中核ロジックとして説明している。Anthropicは、長時間作業ではinitializer agent、feature list、progress notes、基本テスト、コミットを使って、セッションをまたぐ進捗管理を行う設計を示している。
出典: OpenAIはCodex CLIの中核をagent loopとして説明し、モデルとツール呼び出しを組み合わせて作業を進める仕組みを解説している Unrolling the Codex agent loop。Anthropicは長時間Agentで、feature list、progress notes、init script、自己検証、コミットを組み合わせるharnessを示している Effective harnesses for long-running agents。timeline
2023 : SWE-bench
2024 : SWE-agent
2024 : Agentless
2025 : Codex / Claude Code
2026 : Harness / Evals
4. 基本原理: 成功確率を上げる5層
4.1 タスクを「成功条件」に変換する
Agentに渡すべきなのは「いい感じに直して」ではなく、「どの状態になれば成功か」である。良い依頼には、対象、制約、受け入れ条件、実行すべき検証、変更してよい範囲、変更してはいけない範囲が含まれる。これは人間のエンジニアに対するissue設計と同じだが、Agentではさらに重要になる。Agentは曖昧さを埋めようとするため、曖昧な依頼は過剰実装や横道探索を誘発する。
実務では、タスクを次の粒度に分けるとよい。
| 粒度 | Agent適性 | 例 |
|---|---|---|
| 5〜20分 | 高い | 小さなバグ修正、テスト追加、文言修正 |
| 30〜90分 | 中 | 単一機能、既存パターンに沿うUI、局所リファクタ |
| 半日以上 | 条件付き | migration、横断的設計変更、長時間調査 |
| 数日以上 | 分割必須 | 新規プロダクト、複数境界をまたぐ再設計 |
長いタスクは、最初に計画Agentを使うよりも、feature list、acceptance criteria、progress notes、検証コマンドをリポジトリに置く方が安定する。セッション内会話は失われたり圧縮されたりするが、リポジトリ内の状態は次のAgentも読めるからである。
4.2 文脈を「短い索引」と「深い正本」に分ける
AGENTS.mdやCLAUDE.mdにすべてを書くと、文脈が膨らみ、かえって重要な指示が埋もれる。実務では、トップレベルのAgent指示は目次に近い役割にし、詳細はdocs、architecture、runbook、ADR、testing guideに分ける方がよい。Agentには「何を読むべきか」を示し、必要に応じて深い文書へ進ませる。
出典: OpenAIのHarness engineering記事は、AGENTS.mdを百科事典ではなくtable of contentsとして扱い、正本は構造化されたdocsに置く設計を紹介している Harness engineering。Anthropicのcontext engineering記事も、context engineeringをprompt engineeringの自然な発展として位置づけ、Agentが使う文脈の構成を設計対象として扱っている Effective context engineering for AI agents。文脈設計の要点は、量を増やすことではない。Agentが判断に必要な情報へ早く到達できること、古い情報と新しい情報を区別できること、作業に関係ない情報を読まなくてよいことが重要である。
4.3 操作面をAgent向けに整える
SWE-agentの示唆は、Agentの能力はモデルだけでなく、Agentが触るインターフェースに依存するという点にある。人間向けのCLIや巨大なログは、Agentにとって必ずしも扱いやすくない。Agentが失敗しにくい操作面には、短いコマンド、構造化出力、明確なエラー、冪等なスクリプト、対象範囲を絞ったテストがある。
出典: Anthropicは、Agentの性能はツールの品質に依存し、tool descriptions、spec、評価をAgent向けに設計する必要があると述べている Writing effective tools for agents。SWE-agentのAgent-Computer Interfaceも、操作面の設計が性能向上に効くという実証的な根拠を与える SWE-agent paper。良いAgent向けツールは、次の性質を持つ。
- 入力が短く、取り得る選択肢が明確である。
- 出力が構造化され、成功、失敗、警告を区別できる。
- 失敗時に次に読むべきログやコマンドを示す。
- 破壊的操作はdry-run、確認、sandboxを持つ。
- 同じコマンドを再実行しても状態が壊れにくい。
4.4 検証を最初から設計する
Agentに最も効くフィードバックは、自然言語の評価ではなく実行可能な検証である。単体テスト、統合テスト、type check、lint、snapshot、ブラウザスクリーンショット、API smoke test、CIログは、Agentが自分の作業を修正するための信号になる。逆に、検証がないタスクでは、Agentは見た目やもっともらしさで終了を判断しやすい。
出典: AnthropicのAgent evals記事は、Agent評価ではtask、trial、grader、transcriptを分け、coding agentでは安定したテスト環境と実行可能なテストが重要だと整理している Demystifying evals for AI agents。Claude Code best practicesも、Agentにtests、screenshots、expected outputsを与えることを高レバレッジな実践としている Claude Code best practices。flowchart TD
S["仕様"] --> T["テスト化"]
T --> A["Agent実装"]
A --> R["実行結果"]
R -->|失敗| A
R -->|成功| P["PRレビュー"]
ここで注意すべきなのは、評価は1種類では足りないことである。Unit testは速いが、UI崩れや実運用の使い勝手は見ない。LLM judgeは柔軟だが、揺らぎとコストがある。人間レビューは強いが遅い。成功確率を上げるには、タスクの性質に合わせて、決定的なテスト、ログ検査、スクリーンショット、人間レビューを組み合わせる。
4.5 統制は「止める」ではなく「安全に進める」ために置く
権限を絞る目的は、Agentを弱くすることではない。失敗時の損失を小さくし、成功した差分だけを取り込めるようにすることである。sandbox、ネットワーク制御、secretの非公開、PR単位のレビュー、権限付きコマンドの承認、gitによる差分管理は、Agentを本番開発に近づけるための安全装置である。
出典: OpenAIはCodexの実行環境を、リポジトリとユーザー定義の開発環境を持つ隔離コンテナとして説明し、ファイルと端末ログによって検証可能な証拠を残すとしている Codex system card addendum。AnthropicもClaude Codeの製品説明で、操作ごとの承認、safe/risky actionの区別、human controlをAgent safetyの要素として説明している Claude Code product。5. エンジニアリングプラクティス
5.1 AGENTS.mdは行動規範ではなく作業ナビにする
AGENTS.mdには、長い設計思想より、Agentが最初に読むべき場所、よく使う検証コマンド、禁止事項、ブランチ/PRルール、失敗時の対処を置く。詳細な設計判断はdocsに分ける。Agentに読ませたい情報は、ファイル名と見出しで発見可能にする。
推奨構成は次の通りである。
| ファイル | 役割 |
|---|---|
AGENTS.md | 作業開始時の索引、検証コマンド、禁止事項 |
docs/architecture.md | システム境界と主要データフロー |
docs/testing.md | テスト種別、ローカル実行、CI差分 |
docs/runbooks/*.md | 失敗時の診断手順 |
docs/decisions/*.md | 重要な設計判断の履歴 |
5.2 Agentに渡すタスクは「探索」「実装」「検証」を分ける
1つの依頼で「調査して、設計して、実装して、全部直して」と渡すと、Agentは途中で成功条件を失いやすい。実務では、探索タスク、実装タスク、検証タスクを分ける。探索では差分を作らせず、実装では対象範囲を限定し、検証では実行コマンドと期待結果を明示する。
ただし、細かく分けすぎると人間の調整コストが増える。おすすめは、リスクが低い既存パターンの作業は1Agentに任せ、境界をまたぐ設計変更やデータ移行は、計画、実装、レビューを分けることである。
5.3 テストは「Agentが読むエラーメッセージ」まで設計する
Agentは失敗ログを読んで修正するため、テストの失敗メッセージは開発者向けであると同時にAgent向けでもある。何が期待され、何が実際に起き、どのファイルを見ればよいかが分かる失敗は、Agentの自己修正を助ける。逆に、巨大なsnapshot差分や環境依存のflakeは、Agentを誤誘導する。
Agent作業では次を用意すると効果が高い。
- 変更対象に近い高速テスト。
- 失敗理由が短く出るassertion。
- UI作業ではスクリーンショットまたはDOM検査。
- migrationではdry-runと差分確認。
- CI失敗時に再現コマンドを示すrunbook。
5.4 長時間作業はリポジトリ内の状態でつなぐ
長時間作業では、会話履歴だけに依存しない。Agentが次回読むべきprogress notes、feature list、完了条件、未解決の失敗、直近コミットをリポジトリに残す。作業単位ごとにコミットし、次のAgentは最初にログとテストを読む。これにより、文脈圧縮やセッション切断による劣化を減らせる。
出典: Anthropicのlong-running agents記事は、作業開始時にfeature listやprogress notesを用意し、各セッションでテスト、コミット、進捗更新を行うことで、複数context windowをまたぐ進捗を可能にする設計を示している Effective harnesses for long-running agents。5.5 Agentの成果物はPRとして扱う
Agentが作った差分は、チャット回答ではなくPRとして扱うべきである。PRには、目的、変更点、検証、既知の限界、レビュー観点を残す。Agentが「完了」と言ったかではなく、差分、テスト、CI、レビュー可能性で判断する。
6. リスクと限界
6.1 ベンチマークは自社成功率を保証しない
SWE-bench Verifiedのようなベンチマークは重要だが、実務の成功確率をそのまま表すものではない。OpenAIは2026年に、SWE-bench Verifiedがfrontier coding capabilityを測る指標としては限界に来ており、汚染やテスト品質の問題があると説明した。これは、公開ベンチマークが不要という意味ではない。むしろ、自分のコードベースに近い評価セットが必要だという意味である。
出典: OpenAIは、SWE-bench Verifiedについて、frontier launches向けの進捗測定には不適になりつつあり、contaminationとテスト品質の問題があるとしてSWE-bench Proを推奨している Why SWE-bench Verified no longer measures frontier coding capabilities。SWE-bench Verifiedの初期目的と構成は Introducing SWE-bench Verified を参照。6.2 検証できない仕事は成功確率を上げにくい
仕様が曖昧で、正解が人間の感覚に強く依存し、テストや観測がない仕事では、Agentはもっともらしい成果を出しやすい。デザイン、文章、戦略、研究整理でもAgentは有用だが、評価軸、レビュー観点、反証すべき主張を明示しないと品質が安定しない。
6.3 自律性を上げるほどblast radiusも上がる
Agentにネットワーク、secret、production操作、課金API、外部書き込みを許すと、成功時の速度は上がるが失敗時の損失も大きくなる。したがって、自律性は一律に上げるのではなく、作業タイプごとに段階化する必要がある。
| レベル | 許可すること | 向く作業 |
|---|---|---|
| L1 | 読み取り、提案のみ | 設計相談、レビュー |
| L2 | ローカル編集、ローカルテスト | 小さな修正、テスト追加 |
| L3 | ブランチ作成、PR作成、CI確認 | 通常の開発作業 |
| L4 | 外部API、deploy、workflow実行 | 明確なrunbookがある運用 |
| L5 | 本番変更の自律実行 | 原則として厳格な承認後 |
7. 推奨方針
AI Codingを成功確率の工学として整備するなら、最初にやるべきことはツールを増やすことではない。現在の開発フローを、Agentが成功しやすい形に変えることである。
短期的には、次の5つを優先する。
AGENTS.mdを短い作業ナビにし、検証コマンドと禁止事項を明記する。- よく依頼する作業を、受け入れ条件付きのissueテンプレートにする。
- Agentが自分で実行できる高速テストとsmoke testを整える。
- CI失敗、ローカル起動、deploy確認のrunbookを作る。
- Agent作業をPR単位で扱い、差分、ログ、検証、残課題を残す。
中期的には、Agent用の評価セットを持つべきである。過去の失敗、よくある修正、UI崩れ、migration、CI失敗を20〜50件集め、モデルやプロンプトやツールを変えたときに再実行する。これは大規模な研究評価である必要はない。自分の開発組織にとって重要な失敗を再現できることが価値である。
出典: AnthropicはAgent evalsについて、初期には20〜50件の実失敗由来タスクから始めてもよく、evalは成功条件の明確化、回帰防止、モデル更新判断に効くと説明している Demystifying evals for AI agents。最終的に、AI Codingの成熟度は「どれだけ人間が手を動かさなくなったか」ではなく、「どの種類の仕事なら、どの条件で、どの検証を通して、どの程度の確率で成功するか」を説明できるかで決まる。AI Codingを開発チームのワークフローに入れるとは、個人の勘に頼ったプロンプト術を増やすことではない。成功確率を上げる開発システムを、リポジトリ、テスト、CI、ドキュメント、PR運用の中に埋め込むことである。
参考情報
- Anthropic, Building effective agents, 2024-12-19.
- Anthropic, Claude Code: Best practices for agentic coding, 2025-04-18.
- Anthropic, Writing effective tools for agents, 2025-09-11.
- Anthropic, Effective context engineering for AI agents, 2025-09-29.
- Anthropic, Effective harnesses for long-running agents, 2025-11-26.
- Anthropic, Demystifying evals for AI agents, 2026-01-09.
- OpenAI, Introducing Codex, 2025-05-16.
- OpenAI, Addendum to OpenAI o3 and o4-mini system card: Codex, 2025-05-16.
- OpenAI, Harness engineering: leveraging Codex in an agent-first world, 2026.
- OpenAI, Unrolling the Codex agent loop, 2026-01-23.
- OpenAI, Why SWE-bench Verified no longer measures frontier coding capabilities, 2026-02-23.
- Jimenez et al., SWE-bench: Can Language Models Resolve Real-World GitHub Issues?, ICLR 2024.
- Yang et al., SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering, NeurIPS 2024.
- Xia et al., Agentless: Demystifying LLM-based Software Engineering Agents, 2024.