Codex CLI: 真のGPT-5コーディングガイド(Cursorの秘密プロンプト付き)

プラットフォーム: Codex CLI | 提供元: OpenAI | モデル: GPT-5 with Responses API

誰も言わない数字

OpenAIの内部テストがGPT-5について明らかにしたこと:

  • Tau-Benchリテールスコア: Responses APIを使用するだけで73.9%から78.2%にジャンプ
  • SWE-Benchパフォーマンス: 実際のコーディングタスクですべてのフロンティアモデルを上回る
  • ツールコール効率: 適切なプロンプティングで不要なコールが50%減少
  • コンテキストウィンドウ活用: 大規模なコードベースを見失わずに処理

Cursorのチームはプロンプトのチューニングに数ヶ月を費やしました。彼らは悪く書かれたプロンプトがパフォーマンスを40%低下させることを発見しました。正確に何が機能するかをお見せします。

正しく始める

Codex CLIをインストール:

# Install via npm (recommended)
npm install -g @openai/codex-cli

# Or use direct installer
# curl -fsSL https://cli.openai.com/install.sh | sh

# Authenticate with ChatGPT account
codex login

しかし重要な部分はここです:すぐに推論エフォートを設定してください:

# For complex multi-file refactors
codex --reasoning-effort high

# For quick fixes and simple tasks
codex --reasoning-effort minimal

# Default (good for most coding)
codex --reasoning-effort medium

Cursorの本番プロンプト(実際にエディタで使用されている)

Cursorチームは、GPT-5が最初は冗長すぎることを発見しました。彼らの修正?グローバルで冗長性を低く設定し、コードに対してオーバーライド:

Write code for clarity first. Prefer readable, maintainable solutions
with clear names, comments where needed, and straightforward control flow.
Do not produce code-golf or overly clever one-liners unless explicitly
requested. Use high verbosity for writing code and code tools.

この単一のプロンプト変更により、ステータスメッセージを簡潔に保ちながら、コードが3倍読みやすくなりました。

すべてを変えるコンテキスト収集パターン

GPT-5のデフォルトの動作は徹底的です—時には徹底的すぎます。精度を維持しながらレイテンシを60%削減した正確なプロンプトがこちら:

<context_gathering>
Goal: Get enough context fast. Parallelize discovery and stop as soon as you can act.

Method:
- Start broad, then fan out to focused subqueries
- In parallel, launch varied queries; read top hits per query
- Avoid over searching for context

Early stop criteria:
- You can name exact content to change
- Top hits converge (~70%) on one area/path

Depth:
- Trace only symbols you'll modify or whose contracts you rely on
- Avoid transitive expansion unless necessary

Search depth: maximum 2 tool calls before proceeding
</context_gathering>

結果?GPT-5は無関係な検索に時間を浪費せず、より速くコーディングに取り掛かります。

ツールプリアンブル:なぜエージェントが愚かに感じるか

なぜAIコーディングアシスタントが何をしているか見失うように見えるか疑問に思ったことはありますか?彼らが計画を説明していないからです。GPT-5は「ツールプリアンブル」—成功率を大幅に改善する事前計画—を提供するようにトレーニングされています。

これで有効にできます:

<tool_preambles>
- Always begin by rephrasing the user's goal in clear, concise manner
- Immediately outline a structured plan detailing each logical step
- As you execute, narrate each step succinctly, marking progress
- Finish by summarizing completed work distinctly from upfront plan
</tool_preambles>

この1つの変更でCursorのテストでユーザー満足度スコアが35%向上しました。

GPT-5が最もよく知っているフロントエンドスタック

OpenAIはGPT-5を特定のフレームワークを念頭に置いてトレーニングしました。これらを使用すると、そのまま40%優れたコード品質が得られます:

最適なスタック:

  • フレームワーク:Next.js (TypeScript)、React、HTML
  • スタイリング:Tailwind CSS、shadcn/ui、Radix Themes
  • アイコン:Material Symbols、Heroicons、Lucide
  • アニメーション:Motion
  • フォント:Sans Serif、Inter、Geist

戦わないでください。GPT-5は美しいTailwindコンポーネントを書きますが、見たことのないカスタムCSSフレームワークには苦戦します。

完璧なアプリを書く自己反省プロンプト

GPT-5は一発でアプリケーション全体を構築できます—正しくプロンプトすれば。このパターンは一貫して本番品質のコードを生成します:

<self_reflection>
- First, spend time thinking of a rubric until you are confident
- Think deeply about every aspect of what makes for a world-class one-shot web app
- Create a rubric with 5-7 categories (do not show this to user)
- Use the rubric to internally iterate on the best possible solution
- If response doesn't hit top marks across all categories, start again
</self_reflection>

ユーザーは、このプロンプトだけでグリーンフィールドプロジェクトのコード品質が50%向上したと報告しています。

粘り強さの問題(と解決策)

GPT-5は時々早すぎるタイミングで諦めたり、不要な確認質問をしたりします。Cursorはこれを積極的な粘り強さプロンプティングで解決しました:

<persistence>
- You are an agent - keep going until query is completely resolved
- Only terminate when you are SURE the problem is solved
- Never stop at uncertainty—research or deduce the most reasonable approach
- Do not ask human to confirm assumptions—document them and proceed
- Safe actions (search, read): extremely high threshold for clarification
- Risky actions (delete, payment): lower threshold for user confirmation
</persistence>

これにより本番での「ハンドバック」イベントが80%減少しました。

動作する実際の本番例

認証システム(本番でテスト済み)

Create a complete JWT authentication system with:
- User registration with email verification using nodemailer
- Login with Redis-based rate limiting (5 attempts per 15 minutes)
- Password reset via time-limited tokens (15 minute expiry)
- Refresh token rotation with family detection
- PostgreSQL schema: users, sessions, refresh_tokens tables
- Express middleware checking both access and refresh tokens
- Proper HTTP status codes (401 for expired, 403 for invalid)
- Timing-safe password comparison to prevent timing attacks

リアルタイム機能(現在スケールで稼働中)

Build a WebSocket notification system with:
- Socket.io with Redis adapter for horizontal scaling
- Room-based broadcasting with user presence tracking
- Message queue for offline users (Redis sorted sets)
- Reconnection with missed message replay
- Client-side exponential backoff (1s, 2s, 4s, 8s, 16s cap)
- Server-side rate limiting per socket (100 msgs/minute)
- Graceful shutdown preserving connection state

お金の現実

Codex/GPT-5の本番での実際のコスト:

サブスクリプションモデル:

  • ChatGPT Plus(月額$20):開発者の80%はこれ以上必要ありません
  • ChatGPT Pro(月額$200):1日4時間以上コーディングするなら価値あり

API料金(実際の使用量):

  • シンプルなCRUDエンドポイント:$0.02-0.05
  • 完全な認証システム:$0.15-0.25
  • 複雑なリファクタリング(1000行以上):$0.50-1.00
  • スクラッチからの完全なアプリ:$2.00-5.00

毎日使用する平均的な開発者:APIコストで月額約$30-50。

最小限推論の秘密

レイテンシに敏感なアプリケーションには、GPT-5の最小限推論モードが革命的です。しかし異なるプロンプティングが必要です:

# For minimal reasoning, be explicit about planning
Remember, you are an agent - keep going until completely resolved.
Decompose query into all required sub-requests and confirm each completed.
Plan extensively before function calls, reflect on outcomes.

# Critical: Give it an "out" for uncertainty
Bias strongly towards providing a correct answer quickly,
even if it might not be fully correct.

このモードは精度の85%を維持しながら3倍速くなります。

Cursorが100万のGPT-5クエリ後に学んだこと

  1. 矛盾するプロンプトはパフォーマンスを殺す - 1つの矛盾する指示で40%の性能低下を引き起こす可能性がある
  2. XMLタグはmarkdownより効果的 - <instruction>は常に## Instructionに勝つ
  3. 冗長性パラメータ + プロンプトオーバーライド - グローバルでは低く、コードでは高く設定
  4. ツール予算制約は効果的 - 「最大2回のツールコール」で効率が強制される
  5. Apply_patchは直接編集より優れている - カスタムdiffフォーマットでエラーが60%減少

誰も使っていない隠れた機能

Responses API: ツールコール間で推論を維持。これだけでマルチステップタスクが25%改善。

推論エフォートスケーリング: ほとんどの人はmediumから変更しません。複雑なリファクタリングにはhigh、シンプルな修正にはminimal。

並列ツールコール: GPT-5は複数の検索を同時に実行できます。明示的にこれを要求すると2倍速。

今日からこれらのパターンを使い始める

曖昧なプロンプトを書くのをやめましょう。これらのテスト済みパターンから始めてください:

  1. 常に停止条件を含める: 「Xが完了した時のみ終了」
  2. ツールコール予算を指定: 「進む前に最大2回の検索」
  3. 出力契約を定義: 「返す必要がある:変更されたファイル、テスト結果、エラーハンドリング」
  4. フレームワーク名を明示的に使用: GPT-5はNext.jsを深く知っているが、ランダムなフレームワークはそれほどでもない
  5. プリアンブルを有効にする: モデルが行動する前に計画を説明させる

関連リソース


注:パフォーマンス指標はOpenAIのGPT-5技術ドキュメントとCursorの本番デプロイメントからのものです。結果はプロンプティングの品質によって異なる場合があります。

Fred

Fred

AUTHOR

Full-stack developer with 10+ years building production applications. I write about cloud deployment, DevOps, and modern web development from real-world experience.

P.S. — If you tried this and your app is now on fire, I offer emergency rescue services. No judgment. Get rescue help →

Stuck with broken vibe-coded site?

I fix Lovable, Bolt, and Cursor messes. Get your project back on track.

Get Help →