惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
阮一峰的网络日志
阮一峰的网络日志
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
罗磊的独立博客
S
SegmentFault 最新的问题
V
V2EX
V
Visual Studio Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
美团技术团队
博客园 - 三生石上(FineUI控件)
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
MyScale Blog
MyScale Blog
D
Docker
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
M
Microsoft Research Blog - Microsoft Research
Martin Fowler
Martin Fowler
S
Secure Thoughts
B
Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
T
True Tiger Recordings
GbyAI
GbyAI
P
Proofpoint News Feed
P
Privacy International News Feed
Jina AI
Jina AI
The Cloudflare Blog
I
Intezer
AWS News Blog
AWS News Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Security Archives - TechRepublic
NISL@THU
NISL@THU
The Register - Security
The Register - Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
P
Palo Alto Networks Blog
S
Schneier on Security
L
LINUX DO - 热门话题
C
CXSECURITY Database RSS Feed - CXSecurity.com
Security Latest
Security Latest
C
Cybersecurity and Infrastructure Security Agency CISA

DEV Community

Unity’s AI agent went public: the developers of a static analysis tool on what that means for code quality Anna's Archive publica un llms.txt para los LLMs que rastrean su catálogo Why I Built Mneme HQ: Preventing AI Agent Architectural Drift I Built a Pay-Per-Call Crypto Signal API with x402 — Heres the Architecture 🚀 “From Prompts to Autonomous Agents: What Google I/O 2026 Changed” The Power of Distributed Consensus in Autonomous SOCs Sixteen TUI components, copy-paste, no dependency The Boring Reliability Layer Every Autonomous Agent Needs Nven - Secret manager Building Multi-Tenant Row-Level Security in PostgreSQL: A Production Pattern The Hardest Part of Being a Developer Isn't Coding Building Vylo — Looking for Collaborators, Partners & Early Support I Thought Memory Fades With Time. It Actually Fades With Information. ORA-00064 오류 원인과 해결 방법 완벽 가이드 I registered an AI agent at 1 AM and something cracked open in my head Pitch: Nven - Sync secrets. Ship faster. Why y=mx+b is the heart of AI From Routines to a Crew — Building a System That Plans Its Own Work & executes it 25 React Interview Questions 2026 (With Answers) — Hooks, React 19, Concurrent Mode An open source LLM eval tool with two independent quality signals Using Dashboard Filtering to Get Customer Usage in Seconds from TBs of Data Skills, Java 17, And Theme Accents 4 Hard Lessons on Optimizing AI Coding Agents Arctype: Cross-Platform Database GUI for LLM Artifacts Your robots.txt says GPTBot is welcome. Your server says 403. Organizing How to Use AWS Glue Workflow 5 n8n Automations Every Digital Agency Should Be Running (Bill More, Work Less) Getting Started with TorchGeo — Remote Sensing with PyTorch Designing a Scalable Cross-Platform Appium Framework Google Antigravity 2.0 & Slash Commands Building a Unified Adaptive Learning Intelligence with Gemma 4, Flutter, and Multi-Model Orchestration Looking for beta testers for a £60 server management application The Disk-Pressure Incident That Taught Me to Always Set LimitRanges and Other Lessons from Mirroring EKS Locally. Why AI Should Not Write SQL Against ERP Databases Vibe coding works until it doesn't. The debt is real. Shipping at the Edge: Migrating a Coffee Subscription Platform to Cloudflare Workers Stop Tab-Switching: A Developer's Guide to Color Tools That Actually Fit the Workflow DevOps vs MLOps vs AIOps: What Changes, What Stays, and a Simple Roadmap to Get Started Run Powerful AI Coding Locally on a Normal Laptop 5 n8n Automations Every WooCommerce Store Needs (Save 10+ Hours/Week) What I Learned Building My Own AI Harness Hytale Servers Will Fail Treasure Hunts Until We Fix Our Event Handling Redux in React: Managing Global State Like a Pro Unfreezing Your GitHub Actions: Troubleshooting Stuck Deployments and Protecting Your Git Repo Statistics Unlocking Project Discoverability on GHES: A Key to Software Engineering Productivity When the Cleanup Code Becomes the Project Rockpack 8.0 - A React Scaffolder Built for the Age of AI-Assisted Development Mismanaging the Treasure Hunt Engine in Hytale Servers Will Get You Killed Stop Calling It an AI Assistant. It’s Already Managing Your Company Why Hardcoded Automations Fail AI Agents
我是如何阻止我的AI编程助手产生幻觉(并节省了我的Token预算)
Krishna kant · 2026-05-17 · via DEV Community

Krishna kant singh

每个使用Claude Engineer、ChatGPT或Lovable这类工具的开发者最终都会遇到同样的瓶颈。

你启动一个新项目时,一切都像魔法一般。AI 能理解你的愿景,写出清晰的组件,你的开发速度快如光速。然后第二周来临了。代码库变得越来越大,你添加了几个嵌套的目录,突然之间,AI 就失控了。它忘记了你的路由是怎么工作的,试图重新安装几天前你已经确定好的依赖。最糟糕的是,它意外覆盖了一个你已经修复好的功能。

如果你喜欢在模型之间切换——比如根据使用限制从 Claude 3.5 Sonnet 切换到 Gemini 1.5 Pro——那么接入新模型就会变成一场绝对的噩梦。你浪费掉数百个 token,只是为了解释“不,不要用那个数据库库,用这个。”

为了解决这个问题,我在根目录下构建了一个轻量级框架,名为 .ai_context 协议(.ai_context protocol)。它能让 AI 保持接地,强制执行严格的防护栏,并大幅降低 token 开销。

以下是它的具体工作原理,以及为什么你应该将其用于当前的项目。

核心方案:AI 上下文的路由器
大多数人让他们的 AI 工具盲目地扫描整个工作区,或者在提示中来回传递大段代码。这会快速耗尽你的 token 限制,并用简单任务中不需要的噪声填满大语言模型的工作记忆。

.ai_context 协议通过在你的项目根目录引入五个简单的 Markdown 文件来改变这一点:

纯文本
你的项目根目录/
├── .ai_context/
│ ├── README.md <-- “路由器” 和 规则
│ ├── completed_features.md <-- 只读历史日志
│ ├── 未来路线图.md <-- 严格待办事项
│ ├── 架构图.md <-- 文件树 & 结构流程
│ └── 秘密清单.md <-- 安全跟踪环境变量
这里的真正魔法在于README.md文件。它充当着交通控制器的角色。不是让AI同时加载所有文件,而是README.md明确规定了允许代理打开其他文件的时机。

如果你只是要求修复一个小的CSS错误,AI会读取README,意识到不需要触及路线图或秘密日志,然后就此停止。巨大的令牌节省。

为何这实际上有效(从人类视角)

  1. 零摩擦模型交接
    当你切换到一个全新的人工智能代理时,无需编写长篇大论的解释。只需简单提示它:"读取 .ai_context/README.md 并告诉我们下一个任务是什么。"新模型就能立即跟上节奏,无需猜测。

  2. 防止幻觉的护栏

  3. 防弹安全(Bulletproof Security)
    我们都见过AI代理不小心将秘密令牌或API密钥直接硬编码到客户端文件中。而secrets_manifest.md会严格记录环境变量的位置映射,但绝不暴露实际值。它强制AI在编写后端逻辑之前检查你的.gitignore配置。

如何立即设置它
如果你想试试这个,我编写了一个单提示设置脚本。你只需复制提示,放入你的工作区AI代理中,它就会自动生成整个文件夹结构并填充你当前的仓库布局。

完整提示链接

如果你在构建遗留项目、经营副业,或者完全投入AI辅助开发循环中,这就是那本缺失的使用手册。它只需要两分钟设置,却能彻底改变AI处理你代码的可靠性。

你是如何防止工作空间代理偏离上下文的?在下方留言——我很想知道其他人是怎么组织这个的。