AI Navigate

GPT-5への「プロンプト作成」をやめた。45行のコンテキストエンジンが私の幻覚を直した。

Dev.to / 2026/3/19

💬 オピニオンIdeas & Deep AnalysisTools & Practical Usage

要点

  • 著者は長いプロンプトに頼るのをやめ、45行のPythonコンテキストエンジンを用いることで、GPT-5の幻覚を止めた。
  • 彼らは、プロンプトを使うことは対処の手段に過ぎず、真の問題はAIの記憶と実際のプロジェクト環境へのアクセス不足であり、プロンプトの質ではないと主張している。
  • 本稿はContext Engineering(文脈エンジニアリング)とSovereign Contextを、プロンプトで説明するのではなく、AIに必要な青写真とデータを直接手渡す方法として紹介している。
  • プロンプトエンジニアリングは2026年には衰退すると主張されており、百万トークンの窓とo1やGPT-5のような推論モデルが、指示から環境/データ提供へとボトルネックを移すからだと述べている。
  • 不意を突かれた建築家と設計図の比喩は、具体的な文脈を提供することが、信頼できるAIの挙動とコード生成のために不可欠であることを強調している。


昨日の午前3時、私はM4 Mac Miniを窓の外へ投げ出そうとしていた。

私はGPT-o1と再帰的な議論に巻き込まれていた。シンプルな認証ミドルウェアをリファクタリングしてほしかったが、彼は validateUserToken() というヘルパー関数を幻覚として繰り返し出してきた。

問題は?その関数は存在しなかった。元から存在していなかった。

私は1,200語のプロンプトを書いた。ディレクトリ構造を説明した。utils.py ファイルをコピー&ペーストした。嘆願した。強要した。"Chain of Thought" prompting を使った。

それは関係なかった。AI は私のコードベースを鍵穴越しに覗き込み、見ることができないダンスホールを描こうとしていた。

そのとき私は悟った:Prompt Engineering はコープだ。データ不足の問題を修正するために、より良い形容詞を使おうとしている。もしAIが幻覚を起こすのなら、それはあなたが prompting の“expert” で足りないからではなく、あなたのAIが“金魚のような記憶力”を持っているからだ。

私はメガプロンプトを削除した。45行のPythonを書いた。そして突然、幻覚は止んだ。

アナロジー:盲目の建築家 vs. 設計図
世界で最も優れた建築家を雇い、キッチンを改装してもらうと想像してください。この建築家は天才ですが、1つだけ欠点があります。彼らは目隠しをされたのです。

彼らを助けるため、あなたはキッチンの中央に立ってシンクを説明します。冷蔵庫を説明します。荷重を支える壁がどこにあるかを伝えます。美しく、説明的な言葉を使います。

どれだけ優れた「Prompting」でも、建築家は最終的に天井のファンに当たるキャビネットや、食器洗い機を塞ぐ引き出しを提案してくるでしょう。なぜなら、彼らにはBlueprints(設計図)がないからです。

2026年、ほとんどの開発者は依然としてAIの「Narrator(語り手)」として機能しています。私たちは単に設計図を渡すのではなく、それを説明しようとしています。

Context Engineering は、目隠しを外す行為です。

なぜ「Prompt Engineering」は2026年に衰退しているのか
この2年間、「Prompt Engineering」が未来のキャリアだと言われてきました。私たちは間違っていました。

プロンプティングは橋です。文脈ウィンドウが小さかった時代(8k、32kトークン)にはそれが必要でした。しかし今は、100万トークンのウィンドウと o1 や GPT-5 のような推論モデルがあるため、ボトルネックは指示ではなく環境です。

「Sovereign Context(主権的文脈)」を提供すると、次のように移行します:

推測ゲーム:「私のスタイルに合うコードを書いてください」

決定論的現実: 「types.ts に見つかる Interface X を実装したコードを書いてください。」

解決策:「Context Engine」スクリプト
コピー&ペーストをやめろ。説明をやめろ。このスクリプトを使って、あなたのプロジェクトの魂を、現代のLLMがほぼ完璧な精度で消化できる1つのXMLマッピングブロックに「統合」しなさい。

Python

import os

def generate_context_engine(root_dir, exclude_dirs=None, allowed_extensions=None):

"""

プロジェクト構造とファイル内容を、構造化されたXMLマップにまとめます。

GPT-o1、GPT-5、Claude 4 Reasoning Models に最適化されています。

"""

if exclude_dirs is None:

exclude_dirs = {'.git', 'node_modules', 'pycache', 'dist', 'build', '.next', 'env', 'venv'}

if allowed_extensions is None:

allowed_extensions = ('.py', '.js', '.ts', '.tsx', '.html', '.css', '.json', '.yaml', '.md')

context_output = " "

1. Map the File Tree first (The 'Vision' Phase)

context_output += " "

for root, dirs, files in os.walk(root_dir):

dirs[:] = [d for d in dirs if d not in exclude_dirs]

level = root.replace(root_dir, '').count(os.sep)

indent = ' ' * 4 * (level + 1)

context_output += f"{indent}{os.path.basename(root)}/ "

sub_indent = ' ' * 4 * (level + 2)

for f in files:

if f.endswith(allowed_extensions):

context_output += f"{sub_indent}{f} "

context_output += " "

2. Extract Source Code (The 'Logic' Phase)

context_output += " "

for root, dirs, files in os.walk(root_dir):

dirs[:] = [d for d in dirs if d not in exclude_dirs]

for file in files:

if file.endswith(allowed_extensions):

file_path = os.path.join(root, file)

rel_path = os.path.relpath(file_path, root_dir)

try:

with open(file_path, 'r', encoding='utf-8') as f:

code_content = f.read()

context_output += " "

context_output += f"<![CDATA[ {code_content} ]]> "

context_output += " "

except Exception:

continue

context_output += " "

return context_output

Usage: Run this and pipe the output to your LLM

print(generate_context_engine('.'))

Why XML Tags? (The Cognitive Architecture)
You might be wondering: Why and tags? Why not just dump the text?

LLMs trained in 2025 and 2026 are heavily reinforced on web data and documentation. They treat XML/HTML tags as high-priority boundary markers.

When you wrap your code in <![CDATA[ ... ]]>, you are telling the model's attention mechanism: "This is a discrete unit of truth." Without these boundaries, the AI experiences Semantic Bleed. It starts mixing the variables from your User model with the logic in your Product model. The XML tags act as "firewalls" for the AI’s reasoning.

The Death of the "Prompt Engineer"
I’ll be honest with you. I used to pride myself on my "Prompt Engineering" skills. I had a Notion doc full of "System Prompts."

I was wrong. I was building a faster horse when the engine had already been invented. In the age of Agentic AI, your value as a developer isn't in how well you can "talk" to a bot. It’s in how well you can curate the data the bot consumes.

We are moving from "Writer" to "Librarian."

The "Semantic Drift" Warning
If you don't use a Context Engine, you are susceptible to Semantic Drift. This is when your AI slowly diverges from your project’s actual architecture over a long session.

Because you are only feeding it snippets, it starts to "hallucinate a better version" of your project—one that doesn't actually exist on your hard drive. By the time you realize it, you’ve spent an hour debugging code that refers to libraries you don't even have installed.

Conclusion: The Sovereign Developer
The future belongs to the Sovereign Developer. This is the developer who doesn't rely on cloud-based "memory" or expensive, black-box "Pro" features. They build their own tooling. They understand that the AI is a high-speed engine, but Context is the fuel.

If you are still copy-pasting single files into a chat window, you are working for the AI. It’s time to flip the script.

Don't take my word for it. Run the script above on your messiest, most complex local repository tonight. Take that output, paste it into GPT-o1 or Claude 4, and ask it to find a logic error.

You’ll see the difference in the first response.

Is Prompt Engineering dead, or are we just getting started? Change my mind in the comments below. I’ll be replying to the most controversial takes all week.