← 回總覽

AI 编程技巧 010 - 访问你的全部代码

📅 2026-03-11 04:32 Maxi Contieri 人工智能 6 分鐘 6794 字 評分: 78
AI 编程 CLI 工具 智能体工作流 软件工程 开发者生产力
📌 一句话摘要 本文倡导从在网页聊天中手动复制代码转向使用基于终端的 AI 智能体,使其能够直接访问本地文件和自动化测试套件。 📝 详细摘要 作者指出了现代开发中一个普遍的低效问题:开发者在手动将代码复制粘贴到网页版 AI 聊天窗口时所支付的“上下文税”。这种做法会导致幻觉、逻辑不一致以及架构上下文的丢失。为了解决这一问题,文章建议通过 Claude Code、Aider 或 OpenCode 等 CLI 工具采用“智能体编程(Agentic Coding)”。这些工具通过本地索引为 AI 提供完整的项目上下文,并通过自动化反馈循环实现“自愈”代码,即智能体自主运行测试并修复错误。通过将

Title: AI Coding Tip 010 - Access All Your Code | BestBlogs.dev

URL Source: https://www.bestblogs.dev/article/25376acd

Published Time: 2026-03-10 20:32:15

Markdown Content: _Stop copying code chunks. Start letting AI agents work directly with your files._

> TL;DR: Use terminal-based AI tools to give your assistant direct access to your local files and test suites.

Common Mistake ❌ ----------------

You copy code snippets into a web browser chat likeChatGPT, Claude, or Grok.

\ You manually move code back and forth and give small chunks of code, filling up the context window.

\ You lose the context of your folder structure, relations among modules, and the whole architecture.

\ The AI often (wrongly) guesses your project layout and hallucinates.

\ When you do this, you get inconsistent code and outdated logic.

Problems Addressed 😔 ---------------------

* Context Tax:Manual copying wastes your focus. * Hallucinations:The AI suggests libraries you don't actually have. * Isolated logic:The assistant doesn't know if your code even builds. * Manual effort:You have to run every test and fix every error yourself.

\ You're basically playing assistant to the AI, running around doing the busywork.

How to Do It 🛠️ ----------------

Download aCLIor _IDE_ tool like Claude Code, OpenCode, Windsurf, or similar, and let it access _ALL_ your codebase.

\ (You'll need to check compliance, set up safeguards, and respect any NDAs).

\ Open your terminal and start an interactive session. Let the agent navigate through all your code.

\ Describe what you want to accomplish at a high level and delegate to the orchestrator agent.

\ Review theproposed planin the terminal.

\ Approve the changes to update your local files.

\ Let the agent run your tests and fix failures automatically.

Benefits 🎯 -----------

Full project context through local AST and RAG indexing.

\ Self-healing code through automated shell feedback loops.

\ Multi-file edits in a single prompt.

\ Parallel development using multiple agent instances.

\ Iterative incremental learning and experimentation. Baby steps.

Context 🧠 ----------

We were all blown away when ChatGPT came out.

\ Iwrote an article 2 days after its release, understanding it was agame-changer.

\ Even people like me who had been working with earlier GPT models.

\ Four years later, you still see many developers coding this way.

\ It works for small algorithms and functions, but falls apart for real software engineering.

Prompt Reference 📝 -------------------

Bad Prompt

// Please fix the login bug in this snippet:

async function loginUser(email, password) { const url = 'https://api.penrosebrain.com/login';

try { const response = await fetch(url, { method: 'PUT', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ email, password }), });

} catch (error) { console.error('There was an error:', error.message); alert(error.message); } }

Good Prompt

// opencode: "Create a failing text, fix the login bug, run tests, 
// Ensure it passes the new test and all the previous ones
// Create a Pull Request so I can review it

async function loginUser(email, password) { const url = 'https://api.penrosebrain.com/login';

try { const response = await fetch(url, { method: 'PUT', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ email, password }), });

} catch (error) { console.error('There was an error:', error.message); alert(error.message); } }

Considerations ⚠️ -----------------

CLI agents have a learning curve.

\ Alwaysreview all changesbeforecommittingthem.

\ Use a sandbox environment if you run untrusted code.

Type 📝 -------

[X] Semi-Automatic

Limitations ⚠️ --------------

Don't use this for tiny, one-off scripts.

\ Web chats work better for creative brainstorming or generating images.

\ High token usage in long sessions can drive up your API costs.

* Complexity

Level 🔋 --------

[X] Intermediate https://hackernoon.com/ai-coding-tip-003-force-read-only-planning?embedable=true https://hackernoon.com/ai-coding-tip-006-review-every-line-before-commit?embedable=true

Connect external data using the Model Context Protocol (MCP).

\ Run local models if you need 100% privacy.

Conclusion 🏁 -------------

Move your AI assistant to the terminal.

\ You'll work faster and make fewer mistakes.

\ When you delegate the boring parts, you can focus on architecture and high-level design.

More Information ℹ️ ------------------- https://www.firecrawl.dev/blog/why-clis-are-better-for-agents?embedable=true https://aider.chat/?embedable=true https://code.claude.com/docs/en/overview?embedable=true https://www.builder.io/blog/opencode-vs-claude-code?embedable=true https://www.augmentcode.com/tools/ai-coding-assistants-for-large-codebases-a-complete-guide?embedable=true https://blog.marcnuri.com/boosting-developer-productivity-ai-2025?embedable=true https://opencode.ai/docs/?embedable=true

Also Known As 🎭 ----------------

Agentic Coding

Terminal Agents

Autonomous Coding Loops

Tools 🧰 --------

Claude Code, OpenCode, Aider, Codex CLI.

Disclaimer 📢 -------------

The views expressed here are my own.

\ I am a human who writes as best as possible for other humans.

\ I use AI proofreading tools to improve some texts.

\ I welcome constructive criticism and dialogue.

\ I shape these insights through 30 years in the software industry, 25 years of teaching, and writing over 500 articles and a book. *

This article is part of the AI Coding Tip series.

[https://maxicontieri.substack.com/p/ai-coding-tips]()

查看原文 → 發佈: 2026-03-11 04:32:15 收錄: 2026-03-11 10:00:44

🤖 問 AI

針對這篇文章提問,AI 會根據文章內容回答。按 Ctrl+Enter 送出。