今日已更新 163 条资讯 | 累计 40937 条内容
关于我们

How to Prompt Coding Agents Without Losing Control of Your Codebase

Samir Sobhy 2026年09月09日 02:46 0 次阅读 来源:Dev.to

Coding agents become much more useful when you stop treating the prompt as a request for code and start treating it as a specification for a change. A request such as: Fix the login problem. contains almost none of the information required to review the resulting implementation. Which login problem? Which files may change? What behavior must remain unchanged? How will we know the fix actually works? For work inside an existing repository, a simple four-part framework is usually more useful: Task → Context → Scope → Acceptance Criteria 1. Task: define observable behavior Start with the smallest useful description of what should change. Instead of: Add filtering. Try: Task: Add a Completed / Incomplete filter to the task-list page. Expected behavior: - "Completed" shows only completed tasks. - "Incomplete" shows only incomplete tasks. - "All" remains the default. - The filter must work together with the existing text search. The agent now has a behavior to implement instead of a vague direction. 2. Context: make the repository part of the prompt You usually do not need to paste half the codebase. Ask the agent to inspect the relevant project files first: Context: - Read src/components/TaskList.tsx. - Read src/hooks/useTasks.ts. - Follow the patterns already used by the project. - Check the project's existing instructions before making changes. The goal is not to dictate the implementation. The goal is to make the agent learn the local conventions before inventing new ones. Permanent conventions are better stored in project-level instructions when your coding tool supports them. For example: - Use the package manager already configured in the repository. - Do not edit generated files. - Discover validation commands from project configuration. - Preserve unrelated changes. This keeps individual prompts focused on the task. 3. Scope: control the size of the diff A coding agent can solve the right problem in the wrong way. One common failure mode is unnecessary expansion

本文内容来源于互联网,版权归原作者所有
查看原文