Four Key Practices for Effective AI Coding: From Code Generation to Correct Delivery
This article presents a four-stage practice for making AI coding tools deliver correct results instead of just runnable code: locate the target project, build actionable context from configuration, search for reusable capabilities before adding anything, and make minimal changes with a verification loop. It explains why AI agents often duplicate existing components, bypass shared request layers, or break shared behavior, and how teams can turn generation speed into delivery quality and long-term maintainability.
Introduction: Why “It Runs” Is Not the Same as “It’s Correct”
A prompt as short as “add a filter to the list page” is usually enough for an AI coding tool to produce an input box, buttons, and request logic within seconds. The syntax is valid and the page renders. But once that code lands in a real repository, the problems tend to surface all at once: the project already has a filter component, and the agent built another one; the project has a unified request layer, and the agent bypassed it to call the API directly inside the page; the list uses server-side pagination, and the agent only filtered the data on the current page; a new dependency was added for a small feature; the new page works, but the behavior of a component shared by several pages changed along with it.
The common root cause is not that the code was written incorrectly. It is that the agent made decisions on behalf of the project before understanding the project’s conventions. So the key to effective AI coding is not generation speed, but moving the “cost of understanding” to the front. This article lays out a four-stage practice: locate the project, build context, search for reuse, and add the minimum.
Practice 1: Confirm Which Project You Are Changing Before Looking for an Entry File
In multi-repository workspaces and single-repository, multi-application layouts, the session directory, the repository root, and the target project for the current task are often three different directories. Dependencies and workspace configuration may live at the repository root, while the target page lives in a sub-application.
Before making any change, the agent should be able to answer four questions:
- Which application and which page does this request belong to?
- Where is the source code of the target page, and how do you start and verify it locally?
- What uncommitted changes exist in the current workspace, and which of them are work the user is still in progress on?
- Are there multiple candidate targets that require the user to decide?
An illustrative startup convention:
workspace_root/ # Workspace root; may contain multiple repositoriesrepo/ # Repository root: dependency manifest, lockfile, workspace configapps/portal/ # Target application Aadmin/ # Target application B
If the target is unclear, ask first. Once it is clear, routine source reading and development within the normal scope does not require file-by-file confirmation. Confirming the project is not a formality; it determines whether every subsequent action lands in the right place, and it is the first gate against changing the wrong repository or running the wrong script.
Practice 2: Read Configuration to Get Context That Can Guide the Change
When entering a project for the first time, read the dependency manifest, lockfile, build and type configuration, plus the conventions for routing, state, API, components, styles, tests, and startup scripts. The goal is not to move every file into the conversation, but to extract the facts needed for this development task.
| What to read | Questions to answer |
|---|---|
| Dependency manifest, lockfile, workspace config | Which package manager is used, which versions are declared and locked, and whether a multi-package workspace exists |
| Build and type configuration | How the project is built, how path aliases resolve, and what the target runtime and type constraints are |
| Routing and page entry points | How users reach the target page, and whether authentication, layout, or permission constraints apply |
| State and API layer | Where data comes from, where state belongs, and how errors and loading states are handled |
| Component and styling system | Where design tokens, theming, and the boundaries of the existing component library are |
| Tests and scripts | How to start the project locally, and how to run tests and static checks |
Writing the conclusions into a short context summary (facts + constraints + verification method) can significantly reduce rework later. For example: “This project uses server-side pagination, list state is maintained by a page-level container, requests must go through the unified request layer, styles use the existing token system, and the verification commands are a local start plus unit tests.”
Practice 3: Look for Reusable Capabilities Before Deciding to Add Something
Reuse search should follow a coarse-to-fine order: first check existing components and utility functions in the project, then check how similar pages are already implemented, and only then consider bringing in external capabilities. Three questions help decide whether you are reinventing the wheel:
- Is there already a semantically equivalent component or function?
- Does the existing implementation already cover the boundary conditions for this task (empty state, loading, error, permissions)?
- Would reusing it change the existing behavior for other callers?
Adding a dependency should be the last resort. Prefer implementing with capabilities the project already has. When an addition is genuinely necessary, explain why it is needed, its size and maintenance cost, and confirm it is compatible with the existing build and type system.
Practice 4: Minimal Changes and a Verifiable Loop
Break the request into the “smallest verifiable increment” and change one concern at a time: first wire in the existing component, then add the data filtering, then handle the boundary states. Give a verification method for each step: type checks, unit tests, and a page self-test checklist (covering scenarios such as server-side pagination, empty data, and API failures).
Also make the boundaries explicit: do not change the default behavior of shared components; if an extension is needed, add a new prop or use composition to stay backward compatible; do not upgrade dependencies or adjust global configuration on your own.
Conclusion
The essence of effective AI coding is making “understanding the project” the first step of the workflow: lock down the target project, extract facts from configuration, search for reusable capabilities, add the minimum, and close the loop with verification. In scenarios that support AI coding assistance, such as Baidu AI Cloud, turning these conventions into team standards is what lets generation speed translate into delivery quality and long-term maintainability.
