AI Coding Agents: A Complete Workflow from Requirements to Acceptance

    As AI coding agents become more capable, developers' roles shift toward defining requirements, setting boundaries, and reviewing results. This article provides a complete workflow for collaborating with AI coding agents. It covers repository and command preparation, task specification templates, five practical development scenarios—ranging from codebase comprehension to test supplementation—and a final review checklist to ensure high-quality, verifiable code generation.

    I. Roles and Boundaries

    AI coding agents can read code repositories, understand context, modify code across multiple files, and execute commands for validation. As their capabilities grow, the developer’s focus shifts accordingly. Developers primarily take on three roles:

    1. Requirement Definer: Describe the goal in clear, executable language, including the business context, inputs, outputs, and expected behavior.
    2. Boundary Setter: Clarify which directories the agent can modify, which dependencies it can use, and which modules must not be touched.
    3. Result Reviewer: Judge whether the generated results are correct and compliant based on pre-established acceptance criteria.

    The stronger the agent’s capabilities, the more important human constraints become. Without boundaries, it might refactor unrelated modules, introduce undiscussed dependencies, or alter existing interfaces. Without judgment criteria, it cannot distinguish between “looks done” and “actually done.” The generated code might compile but fail to meet business requirements.

    Tools generally fall into two categories. Editor-based interactive assistants excel at local completion, rewriting single functions, and line-by-line explanations. The developer is present throughout, making it suitable for fine-tuning. Task-based agents can retrieve information across the entire repository, plan multi-step operations, execute commands, and iterate based on feedback, making them suitable for batch refactoring and automation. A common division of labor is to have the task-based agent complete batch refactoring, supplement tests, and build the basic structure first, followed by the developer performing detail optimization and style unification within the editor.

    II. Repository and Command Preparation

    The quality of the agent’s output depends on the information it can access. Completing the following preparations before starting can significantly reduce rework.

    2.1 Organize Project Documentation

    Place a project documentation file (e.g., a README.md) in the root directory of the repository, specifying the tech stack, directory conventions, and prohibitions. An example is as follows:

    1. # Project Documentation
    2. ## Tech Stack
    3. - Programming Language: TypeScript
    4. - Runtime Environment: Node.js LTS version (version number written in .nvmrc)
    5. - Testing: Unit tests and integration tests, executed uniformly via npm test
    6. ## Directory Conventions
    7. - src/: Business logic code
    8. - src/generated/: Automatically generated by the codegen command. Manual modification is prohibited. For changes, modify the schema file and re-run npm run codegen. Manual review of generated results is required.
    9. - tests/: Test code. New features must be accompanied by new test cases.
    10. ## Prohibitions
    11. - No new runtime dependencies unless explicitly approved in the task specification.
    12. - No modifications to database migration scripts.

    2.2 Confirm Verifiable Commands

    The agent needs to know how to validate results. At a minimum, you should clarify four types of commands: installing dependencies, building, running tests, and static linting, and ensure they run stably in a clean environment.

    1. npm ci # Strictly install dependencies according to the lock file to avoid version drift
    2. npm run build # Build the project; an exit code of 0 indicates successful compilation
    3. npm test # Run unit and integration tests; output should show all passing with no unexpected skips
    4. npm run lint # Static linting; output should show no errors

    The requirements are as follows: commit package-lock.json to the project to prevent different versions from being installed each time; fix the runtime environment version; provide external services like databases via docker compose or test doubles, without relying on special configurations on personal machines. Write the expected output of the commands into the project documentation so that both the agent and the reviewer have a unified standard for judgment.

    2.3 Sensitive Information and Context Scope

    Any file the agent reads may enter the model’s context, so you need to control the content it can access.

    • Do not place exported files containing keys, credentials, or production data into the working directory.
    • Inject sensitive information via environment variables or a key management service; only keep variable names in the code.
    • Ensure that .gitignore covers .env files, logs, caches, and temporary export files.
    • After the task ends, clean up the logs, caches, and temporary files generated during the process.

    III. Task Specification Template and Acceptance Criteria

    The task specification is the core output of requirement definition. An executable specification usually contains five elements:

    1. Objective: The problem to be solved and the business value, not implementation details.
    2. Scope: Modules and files allowed to be modified, as well as parts explicitly prohibited from being touched.
    3. Constraints: Conditions that must be adhered to, such as dependencies, interfaces, data formats, and coding styles.
    4. Acceptance Criteria: Judgment conditions that can be verified by commands or manual checks.
    5. Delivery Format: The presentation of the change list, explanatory text, and validation results.

    Below is a reusable template:

    1. [Objective] When the order list API filters by time, the returned time field is missing timezone information.
    2. [Scope]
    3. Allowed to modify: src/order/, tests/order/
    4. Prohibited from modifying: src/generated/, database migration scripts
    5. [Constraints]
    6. - No new runtime dependencies allowed
    7. - Keep API paths and response field names unchanged
    8. - Reuse existing date utility functions in the project
    9. [Acceptance Criteria]
    10. 1. npm test passes completely; new test cases cover cross-timezone filtering scenarios
    11. 2. npm run lint has no errors
    12. 3. API response fields are identical to before the change; provide before and after comparison results
    13. [Delivery Format]
    14. - List of modified files, explaining the reason for each change
    15. - Output summary of verification commands
    16. - Unfinished or questionable items

    Acceptance criteria should be written as verifiable statements. “Good code quality” cannot be judged, but “npm test passes completely” can be executed directly.

    IV. Five Practical Scenario Checklists

    Each scenario includes operational steps, focus points, and acceptance evidence. Acceptance evidence is used to determine whether the task is truly complete.

    4.1 Understanding the Codebase

    Operational steps: Ask the agent to list entry files and the dependency relationships of main modules; require every conclusion to be accompanied by file paths and line numbers; randomly select two or three call chains and cross-reference them one by one with the source code.

    Focus points: Whether the conclusions are consistent with the actual code.

    Acceptance evidence: In the module relationship description, every conclusion has a corresponding file path.

    Failure handling: If conclusions cannot be mapped to the code, ask the agent to search again. Do not accept speculative descriptions.

    4.2 Feature Development

    Operational steps: Have the agent provide an implementation plan first, listing the files to be modified, and only proceed after confirmation; implement in batches, running npm test after each batch; synchronize new test cases with new API endpoints.

    Focus points: API compatibility, dependency changes, and whether the scope of changes exceeds the plan.

    Acceptance evidence: Test cases for new features, list of modified files, and API compatibility statements.

    Failure handling: When a test fails, first ask the agent to explain the cause of the failure. Do not directly demand “fix it until it passes,” as this might lead to modifying assertions to mask the problem.

    4.3 Debugging and Fixes

    Operational steps: Reproduce the problem first, providing reproduction steps and error logs; require the agent to provide root cause evidence, such as logs, assertion failure messages, or call stacks; add regression tests after fixing.

    Focus points: Whether the root cause is supported by evidence rather than speculation.

    Acceptance evidence: A comparison of the test failing before the fix and passing after the fix.

    4.4 Refactoring and Upgrading

    Operational steps: Break down into small batches by module, completing each batch on an independent branch; ensure each batch passes npm run build and npm test; record the current commit hash before starting for easy rollback.

    Focus points: Proceed in batches; every batch must be runnable. This principle applies to language migrations, framework upgrades, and module splits.

    Acceptance evidence: Build and test output for each batch, as well as before and after comparisons of key behaviors.

    Safety tips: When problems occur, first confirm the scope of impact, then revert specific files on a new branch. Do not use commands that will lose uncommitted changes, such as force reset or force push. Ask the person in charge before executing any rollback.

    4.5 Test Supplementation

    Operational steps: First list the business behaviors that need coverage; require each test case to assert business results, rather than just asserting “no errors thrown” or call counts; manually change a key piece of logic to confirm the test fails, then revert the change.

    Focus points: Whether the tests actually assert business behavior.

    Acceptance evidence: A mapping table between test cases and business rules, as well as a coverage report.

    V. Common Pitfalls and Checklist

    There are three common pitfalls:

    • Treating the agent as a one-shot code generator, submitting a requirement in one sentence, and directly accepting all output. The correct approach is to confirm step by step.
    • Only looking at the generated results without checking the scope of changes. You should check the list of modified files and every diff, for example, using git diff --stat to review the change scope.
    • Skipping the verification step and merging code without running tests. Problems will only be exposed in production.

    Before the end of each collaboration, check the following list item by item:

    • The task specification includes all five elements: objective, scope, constraints, acceptance criteria, and delivery format.
    • Directories and files outside the scope have not been modified.
    • New dependencies have been approved.
    • build, test, and lint pass in a clean environment.
    • No keys, credentials, or production data exist in the diff.
    • Tests assert business behaviors.
    • The list of modified files is consistent with the delivery description.
    • Logs, caches, and temporary files have been cleaned up.

    By following this workflow, teams can consolidate each collaboration into a template. As templates accumulate, ineffective generations and rework will gradually decrease, allowing reviewers to focus their energy on areas that truly require human judgment.