AIはより優れたコード生成を支援すべき
AIコーディングエージェントはコード品質の低下を招くのではなく、技術的負債の解消やリファクタリングといった単純だが時間のかかる作業を非同期で処理することで、より良いコードを生産するためのツールとして活用すべきであると主張している。
キーポイント
AIによるコード品質低下は選択の問題
AIコーディングツールの導入によってコード品質が低下するのは避けられない結果ではなく、プロセスの問題点を特定して修正することで、より良いコードを生産する選択が可能である。
技術的負債の予防的解決策としてのAI活用
API設計の修正、命名規則の統一、重複機能の統合、巨大ファイルの分割など、概念的には単純だが時間のかかるリファクタリング作業は、技術的負債の主要な原因であり、AIエージェントによる自動化の理想的な対象である。
非同期コーディングエージェントの実践的活用方法
Gemini Jules、OpenAI Codex、Claude Codeなどの非同期コーディングエージェントをバックグラウンドで実行し、結果をプルリクエストで評価・修正するワークフローが提案されている。
開発者ワークフローの中断を最小化
非同期エージェントを使用することで、開発者は自分の作業フローを中断することなく、時間のかかるリファクタリング作業を並行して進めることができる。
影響分析・編集コメントを表示
影響分析
この記事は、AIコーディング支援ツールに関する業界の懸念(品質低下)に対して建設的な解決策を提示しており、開発現場での実践的な応用可能性が高い。技術的負債の管理という普遍的な課題に対してAIを活用する具体的な方法論を提供することで、AI支援開発の成熟度を高める可能性がある。
編集コメント
AIコーディングツールの否定的な側面に焦点を当てるのではなく、建設的な活用方法を提案する実践的な内容。開発現場での具体的な課題解決に直結する視点が評価できる。
*Agentic Engineering Patterns >*
多くの開発者は、コードを AI ツールにアウトソーシングすることで品質が低下し、意思決定者がその欠陥を見逃すほど速く生産される不良コードが生じるのではないかと懸念しています。
コーディングエージェントの採用によって、あなたが生成するコードや機能の品質が明らかに低下することが実証されているなら、その問題に直接取り組むべきです。プロセスのどの側面が出力の質を損なっているのかを特定し、それを修正してください。
エージェントを使ってより悪いコードをリリースするのは*選択*です。私たちは代わりに、より良いコードをリリースすることを選ぶことができます。
技術的負債を抱えないようにする
私は、より良いコードをリリースすることを技術的負債の観点から考えるのが好きです。私たちが技術的負債を負うのはトレードオフの結果です。「正しい方法」で物事を行うには時間がかかりすぎるため、現在の時間制約の中で作業し、プロジェクトが後で負債を返済できるまで生き残ってくれることを祈るのです。
技術的負債に対する最善の緩和策は、最初からそれを負わないようにすることです。
私の経験では、技術的負債を解消するための一般的なカテゴリには、単純だが時間がかかる変更が含まれます。
- 元の API デザインは、後に発生した重要なケースをカバーしていません。その API を修正するには数十の異なる場所でコードを変更する必要があり、非常にわずかに異なる新しい API を追加して重複を受け入れる方が速くなります。
- 私たちは当初、コンセプトに「チーム」ではなく「グループ」といった名称を付けたという誤った選択をしてしまいましたが、コード全体の名前付けを修正するのはあまりにも手間がかかるため、UI 上でのみ修正を行うことにしています。
- システムは時間とともに重複しつつも微妙に異なる機能を持つようになり、これらを統合してリファクタリングする必要があります。
- ある一つのファイルが数千行のコードに成長しており、理想的にはこれを別々のモジュールに分割すべきです。
これらの変更は概念的には単純ですが、それでもそれらに専念する時間を割く必要があり、より緊急性の高い課題を考慮すると正当化するのが難しい場合があります。
コーディングエージェントがこれらを処理してくれる
このようなリファクタリング作業は、コーディングエージェント (coding agents) の*理想的な*応用例です。
エージェントを起動し、何を変更すべきかを指示して、背景のどこかのブランチやワークツリーでひたすら作業させるだけです。
私は通常、非同期型のコーディングエージェントを使用します。例えば Gemini Jules や OpenAI Codex web、あるいは Claude Code on the web などです。そうすれば、ラップトップでの作業フローを中断することなく、これらのリファクタリングジョブを実行できます。
結果はプルリクエスト (Pull Request) で評価します。良ければ採用し、ほぼ完成していればプロンプトで指示を出して別のやり方を試させます。ダメであれば捨てます。
コード改善にかかるコストがこれほどまで低下したため、私たちは些細なコードスモールや不便さに対してはゼロ・トレランス (zero tolerance) の態度をとっても許容できるようになりました。
AI ツールによりより多くの選択肢を検討できる
あらゆるソフトウェア開発タスクには、問題に取り組むための豊富な選択肢が存在します。最も重大な技術的負債の多くは、計画段階での不適切な選択に起因しています。つまり、明白で単純な解決策を見逃したり、後に最適な適応性がないことが判明する技術を採用したりすることです。
LLM は、以前には気づかなかったかもしれない明白な解決策を見落とさないよう支援できます。彼らが提案するのはトレーニングデータに一般的に見られる解決策のみですが、それらは往々にして最も確実に機能する可能性が高い Boring Technology です。
さらに重要なのは、コーディングエージェントが探索的プロトタイピングを支援できる点です。
技術選択に自信を持つ最善の方法は、プロトタイプを用いてその目的に適していることを証明することです。
数千人の同時ユーザーを想定するサイトのアクティビフィードに Redis は適切な選択肢でしょうか?
それを確実に知る最良の方法は、そのシステムのシミュレーションを構築し、負荷テストを実行してどこが破綻するかを確認することです。
コーディングエージェントは、単一のよく練られたプロンプトからこのようなシミュレーションを構築できます。これにより、こうした実験のコストはほぼゼロにまで低下します。また、コストが極めて安いため、複数の実験を並行して実行し、問題に対する最適な解決策を選ぶことができます。
複合エンジニアリングループの受容
エージェントは指示に従います。以前に学んだことを基に、これらの指示を時間とともに進化させることで、将来の実行からより良い結果を得ることができます。
Every の Dan Shipper と Kieran Klaassen は、コーディングエージェントとの協働における同社のアプローチを Compound Engineering として説明しています。Every が完了するすべてのコーディングプロジェクトには振り返りが伴い、彼らはこれをコンパウンドステップと呼びます。ここでは機能した手法を抽出し、将来のエージェント実行のために文書化します。
エージェントから最良の結果を引き出すためには、コードベースの品質を時間とともに継続的に向上させることを目指すべきです。小さな改善は複利効果を生みます。かつては時間を要していた品質向上のための取り組みも、現在ではコストが大幅に低下し、新機能の実装と同時に品質への投資を行わない理由がなくなりました。コーディングエージェントのおかげで、ついに両立が可能になりました。
Tags: coding-agents, ai-assisted-programming, generative-ai, agentic-engineering, ai, llms
原文を表示
*Agentic Engineering Patterns >*
Many developers worry that outsourcing their code to AI tools will result in a drop in quality, producing bad code that's churned out fast enough that decision makers are willing to overlook its flaws.
If adopting coding agents demonstrably reduces the quality of the code and features you are producing, you should address that problem directly: figure out which aspects of your process are hurting the quality of your output and fix them.
Shipping worse code with agents is a *choice*. We can choose to ship code that is better instead.
Avoiding taking on technical debt
I like to think about shipping better code in terms of technical debt. We take on technical debt as the result of trade-offs: doing things "the right way" would take too long, so we work within the time constraints we are under and cross our fingers that our project will survive long enough to pay down the debt later on.
The best mitigation for technical debt is to avoid taking it on in the first place.
In my experience, a common category of technical debt fixes is changes that are simple but time-consuming.
- Our original API design doesn't cover an important case that emerged later on. Fixing that API would require changing code in dozens of different places, making it quicker to add a very slightly different new API and live with the duplication.
- We made a poor choice naming a concept early on - teams rather than groups for example - but cleaning up that nomenclature everywhere in the code is too much work so we only fix it in the UI.
- Our system has grown duplicate but slightly different functionality over time which needs combining and refactoring.
- One of our files has grown to several thousand lines of code which we would ideally split into separate modules.
All of these changes are conceptually simple but still need time dedicated to them, which can be hard to justify given more pressing issues.
Coding agents can handle these for us
Refactoring tasks like this are an *ideal* application of coding agents.
Fire up an agent, tell it what to change and leave it to churn away in a branch or worktree somewhere in the background.
I usually use asynchronous coding agents for this such as Gemini Jules, OpenAI Codex web, or Claude Code on the web. That way I can run those refactoring jobs without interrupting my flow on my laptop.
Evaluate the result in a Pull Request. If it's good, land it. If it's almost there, prompt it and tell it what to do differently. If it's bad, throw it away.
The cost of these code improvements has dropped so low that we can afford a zero tolerance attitude to minor code smells and inconveniences.
AI tools let us consider more options
Any software development task comes with a wealth of options for approaching the problem. Some of the most significant technical debt comes from making poor choices at the planning step - missing out on an obvious simple solution, or picking a technology that later turns out not to be exactly the right fit.
LLMs can help ensure we don't miss any obvious solutions that may not have crossed our radar before. They'll only suggest solutions that are common in their training data but those tend to be the Boring Technology that's most likely to work.
More importantly, coding agents can help with exploratory prototyping.
The best way to make confident technology choices is to prove that they are fit for purpose with a prototype.
Is Redis a good choice for the activity feed on a site which expects thousands of concurrent users?
The best way to know for sure is to wire up a simulation of that system and run a load test against it to see what breaks.
Coding agents can build this kind of simulation from a single well crafted prompt, which drops the cost of this kind of experiment to almost nothing. And since they're so cheap we can run multiple experiments at once, testing several solutions to pick the one that is the best fit for our problem.
Embrace the compound engineering loop
Agents follow instructions. We can evolve these instructions over time to get better results from future runs, based on what we've learned previously.
Dan Shipper and Kieran Klaassen at Every describe their company's approach to working with coding agents as Compound Engineering. Every coding project they complete ends with a retrospective, which they call the compound step where they take what worked and document that for future agent runs.
If we want the best results from our agents, we should aim to continually increase the quality of our codebase over time. Small improvements compound. Quality enhancements that used to be time-consuming have now dropped in cost to the point that there's no excuse not to invest in quality at the same time as shipping new features. Coding agents mean we can finally have both.
Tags: coding-agents, ai-assisted-programming, generative-ai, agentic-engineering, ai, llms
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み