Table of Contents
- Introduction to Working with AI Coding Agents
- Understanding the AI Coding Agent Workflow
- Writing Effective Agent Instructions
- Types of Instructions for AI Coding Agents
- Configuring Project-Level Instructions
- Working with AI Agent Tools
- Understanding Tool Permissions and Access
- Managing Approvals in AI-Assisted Development
- Understanding Human-in-the-Loop Workflows
- Implementing Software with AI Coding Agents
- Reviewing and Validating AI-Generated Code
- Practical Example: Implementing a Feature with an AI Coding Agent
- Common Challenges When Working with AI Coding Agents
- Best Practices for Working with AI Coding Agents
- Role of AI Coding Agents in Spec-Driven Development
- Conclusion
- Frequently Asked Questions
1. Introduction to Working with AI Coding Agents
AI coding agents are changing how software developers approach implementation. Traditional development requires developers to manually inspect codebases, understand requirements, modify files, execute commands, write tests, and resolve errors. AI coding agents can assist with or perform many of these activities by interacting with development environments and tools.
However, working effectively with an AI coding agent involves more than asking it to generate code. Developers must provide appropriate instructions, supply project context, control tool access, establish approval requirements, and review implementation results.
An AI coding agent may be capable of modifying multiple files, executing terminal commands, installing dependencies, running tests, and interacting with external services. These capabilities make agents powerful, but they also introduce risks when permissions and instructions are not properly managed.
A reliable workflow requires four important elements:
- Agent instructions: Explain how the agent should approach development and follow project conventions.
- Tool usage: Define which tools the agent can use and how it should interact with the development environment.
- Approvals: Establish when the agent must obtain human permission before taking action.
- Implementation: Guide the agent through controlled coding, testing, and validation activities.
The objective is not to eliminate developer involvement. It is to use AI agents to accelerate implementation while preserving engineering quality, security, accountability, and control.
2. Understanding the AI Coding Agent Workflow
An AI coding agent typically follows an iterative workflow in which it receives an objective, gathers context, plans an approach, executes actions, and evaluates the results.
A typical workflow includes the following stages:
2.1 Understand the task
The developer provides a task, feature specification, bug description, or implementation objective.
For example:
“Implement a password reset feature that allows registered users to request a password reset link and securely update their passwords.”
The agent must understand the expected behavior, scope, constraints, and acceptance criteria before making changes.
2.2 Inspect the project
The agent explores the repository to understand:
- Project structure and directory organization.
- Programming languages and frameworks.
- Existing components and services.
- Database models and API endpoints.
- Authentication and authorization mechanisms.
- Coding conventions and architectural patterns.
- Existing tests and development scripts.
Repository inspection helps the agent avoid creating duplicate functionality or introducing implementation patterns that conflict with the existing application.
2.3 Create an implementation plan
Before modifying files, the agent should identify the necessary changes.
For a password reset feature, the plan might include:
- Create a password reset request endpoint.
- Generate a secure, time-limited reset token.
- Store the token securely.
- Send a password reset email.
- Create a password reset confirmation endpoint.
- Validate the token and new password.
- Invalidate the token after successful use.
- Add unit and integration tests.
A plan makes implementation easier to review and helps identify missing requirements.
2.4 Execute implementation
The agent uses available tools to create or modify files, execute commands, run tests, and inspect results.
It may perform several iterations before completing the task.
2.5 Validate the results
The agent should run relevant tests, inspect errors, review its changes, and compare the implementation against the original requirements.
2.6 Report completion
The agent provides a summary of:
- Files created or modified.
- Features implemented.
- Commands and tests executed.
- Test results.
- Known limitations.
- Outstanding questions or required human decisions.
A completed code-generation task should not automatically be treated as a completed engineering task. Human review and validation remain important.
3. Writing Effective Agent Instructions
Agent instructions define how an AI coding agent should behave while working on a software project.
Without sufficient instructions, an agent may make assumptions about architecture, introduce unnecessary dependencies, use inconsistent naming conventions, or modify files outside the intended scope.
Effective instructions provide boundaries and explain the development practices the agent must follow.
3.1 Be specific and unambiguous
Instructions should describe the expected behavior clearly.
Weak instruction:
“Write clean code and follow best practices.”
Improved instruction:
“Use TypeScript for all new application code. Follow the existing component and service organization. Avoid introducing new dependencies unless they are necessary and approved. Add unit tests for new business logic.”
Specific instructions are easier for an agent to interpret and follow.
3.2 Explain the project architecture
Agents should understand the application’s architecture before implementing features.
Project instructions may describe:
- Frontend and backend technologies.
- Application layers and responsibilities.
- Component organization.
- API communication patterns.
- State management.
- Authentication and authorization.
- Database access patterns.
- Error handling conventions.
- Testing frameworks.
For example, a project using Next.js and TypeScript may specify that reusable UI components belong in a shared components directory, API integrations must use established service modules, and server-side operations should follow the existing App Router architecture.
These instructions help prevent inconsistent implementation.
3.3 Define coding standards
Coding standards should describe the conventions expected throughout the repository.
Examples include:
- Use TypeScript strict typing where configured.
- Avoid unnecessary use of
any. - Follow existing naming conventions.
- Prefer reusable components over duplicated implementations.
- Keep functions focused on a single responsibility.
- Handle errors explicitly.
- Avoid unused variables and imports.
- Follow established linting and formatting rules.
- Do not suppress linting or TypeScript errors without justification.
The agent should follow the project’s actual configuration rather than inventing a different standard.
3.4 Define testing expectations
Testing instructions explain how the agent should validate its changes.
They may specify:
- Which testing framework to use.
- Where test files should be placed.
- How test files should be named.
- Whether unit, integration, or end-to-end tests are expected.
- How to execute the test suite.
- How to handle failing tests.
- Whether coverage requirements apply.
For example:
“Use Jest and React Testing Library for component tests. Add tests for normal behavior, error handling, and relevant edge cases. Run the affected test files before reporting completion.”
3.5 Define implementation boundaries
Agents should know what they are allowed to modify.
Examples:
- Do not modify unrelated modules.
- Do not change public API contracts without approval.
- Do not alter database schemas unless required by the specification.
- Do not remove existing tests to make the test suite pass.
- Do not change authentication or authorization behavior without explicit authorization.
- Do not introduce breaking changes without documenting them.
These boundaries reduce unintended changes.
4. Types of Instructions for AI Coding Agents
Instructions can be organized into different categories depending on their purpose and scope.
4.1 Global instructions
Global instructions define general behavior that should apply across projects or development sessions.
Examples:
- Explain the implementation approach before making significant changes.
- Avoid unnecessary code modifications.
- Ask questions when important requirements are unclear.
- Do not expose secrets or credentials.
- Report tests that were not executed.
- Never claim that a change is validated when it has not been tested.
Global instructions establish general working expectations.
4.2 Project-level instructions
Project-level instructions describe the specific software repository.
They may include:
- Technology stack.
- Architecture.
- Folder structure.
- Coding conventions.
- Build and test commands.
- Dependency management rules.
- Security requirements.
- Deployment considerations.
These instructions are particularly important when multiple developers and agents work on the same codebase.
4.3 Task-level instructions
Task-level instructions apply to an individual feature, bug fix, or development activity.
For example:
“Implement the order cancellation functionality. Follow the existing order service architecture. Only allow cancellation for orders in eligible states. Preserve the existing API response structure and add tests for successful cancellation, unauthorized access, and invalid order states.”
Task-level instructions should explain the immediate objective and constraints.
4.4 Tool-specific instructions
Tool-specific instructions describe how the agent should use particular tools.
Examples:
- Use the existing package manager.
- Run the project’s lint command after modifying TypeScript files.
- Use the approved database migration mechanism.
- Do not execute production deployment commands.
- Inspect command output before deciding the next action.
These instructions help control the agent’s interaction with the development environment.
4.5 Specification-level instructions
Specification-level instructions connect the implementation to the expected software behavior.
They may include:
- Functional requirements.
- Non-functional requirements.
- User stories.
- Acceptance criteria.
- API contracts.
- Data models.
- Business rules.
- Architecture decisions.
- Constraints and dependencies.
Specifications provide the authoritative description of what the system should do. Instructions explain how the agent should work within the project.
Both are necessary for reliable implementation.
5. Configuring Project-Level Instructions
Many AI development environments support persistent instruction files that provide context whenever an agent works on a repository.
Common examples include:
AGENTS.mdCLAUDE.md.github/copilot-instructions.md
The exact filenames and supported locations depend on the AI coding tool. Some tools also support directory-specific instructions, custom rules, or additional agent configuration files.
A project-level instruction file can contain the following sections.
5.1 Project overview
Describe the application, its purpose, and its major technologies.
Example:
Project: E-Commerce Platform
Technology Stack:
- Frontend: Next.js and TypeScript
- Backend: Node.js
- Database: PostgreSQL
- Testing: Jest and React Testing Library
- Package Manager: Yarn
5.2 Architecture guidelines
Explain how the application is organized.
Example:
- Keep UI components separate from business logic.
- Use existing service modules for API communication.
- Follow the established authentication architecture.
- Reuse existing shared components.
- Avoid introducing new architectural patterns without justification.
5.3 Coding guidelines
Specify coding and formatting conventions.
Example:
- Use TypeScript.
- Follow existing naming conventions.
- Avoid unnecessary dependencies.
- Handle errors consistently.
- Keep functions and components maintainable.
- Do not duplicate existing functionality.
5.4 Testing guidelines
Describe the expected validation process.
Example:
- Add tests for new business logic.
- Update tests when existing behavior changes.
- Run relevant unit tests.
- Run linting and type checks when applicable.
- Report any tests that could not be executed.
5.5 Security guidelines
Security instructions are particularly important when agents can access sensitive parts of a codebase.
Example:
- Never hardcode credentials or API keys.
- Do not expose secrets in logs.
- Validate user-controlled input.
- Follow existing authentication and authorization mechanisms.
- Avoid unsafe database queries.
- Do not weaken security controls to resolve implementation problems.
5.6 Sample project instruction file
A simplified example is shown below:
# Project Instructions
## Project Overview
This project is an e-commerce application built using
Next.js, TypeScript, Node.js, and PostgreSQL.
## Architecture
- Follow the existing application architecture.
- Reuse shared components and services.
- Keep business logic separate from presentation logic.
- Avoid unnecessary changes to unrelated modules.
## Coding Standards
- Use TypeScript for new application code.
- Follow existing naming conventions.
- Avoid unnecessary dependencies.
- Handle errors explicitly.
- Do not introduce duplicate functionality.
## Testing
- Add tests for new business logic.
- Use the existing testing framework.
- Run relevant tests after implementation.
- Report failures accurately.
## Security
- Never hardcode secrets or credentials.
- Validate user-controlled input.
- Follow existing authorization rules.
- Do not weaken security controls.
## Implementation Rules
- Inspect the existing code before making changes.
- Prepare a plan for significant modifications.
- Ask for clarification when requirements are ambiguous.
- Do not perform production deployments without approval.
A well-maintained instruction file reduces repetitive prompting and helps agents work consistently across development tasks.
6. Working with AI Agent Tools
One of the most important capabilities of an AI coding agent is its ability to interact with external tools.
A traditional AI assistant primarily generates responses. A tool-enabled coding agent can perform actions in a development environment and use the results to determine its next steps.
6.1 What are AI agent tools?
Tools are external capabilities that an agent can invoke to perform specific operations.
Examples include:
File system tools
- Read files.
- Search directories.
- Create files.
- Modify source code.
- Delete files when permitted.
Terminal tools
- Execute shell commands.
- Install dependencies.
- Run development servers.
- Execute tests.
- Run build and lint commands.
- Inspect command output.
Code analysis tools
- Search symbols.
- Find references.
- Analyze dependencies.
- Identify potential errors.
- Inspect type definitions.
Version control tools
- Check Git status.
- Review changes.
- Create branches.
- Inspect commit history.
- Prepare commits.
- Compare file differences.
External service tools
- Access approved APIs.
- Retrieve documentation.
- Interact with issue tracking systems.
- Query development databases.
- Communicate with approved integrations.
The available tools depend on the coding environment and its configured permissions.
6.2 How agents use tools
A typical tool interaction follows this sequence:
- The agent identifies an action required to complete the task.
- It selects an appropriate tool.
- It generates the required tool arguments.
- The development environment executes the action.
- The result is returned to the agent.
- The agent evaluates the result.
- It decides whether another action is necessary.
For example, when asked to fix a failing test, an agent might:
- Inspect the failing test file.
- Read the relevant component.
- Identify the cause of the failure.
- Modify the component.
- Run the affected test.
- Inspect the test output.
- Make further corrections if necessary.
This iterative interaction is what makes an agent different from a simple code generator.
6.3 Tool selection
Agents should use tools that are appropriate for the task.
For example:
- Use file search to locate existing implementations.
- Use file reading to understand component behavior.
- Use terminal commands to run tests.
- Use Git diff to inspect modifications.
- Use documentation tools to verify framework-specific behavior.
The agent should not execute unnecessary commands or modify files simply because those actions are available.
6.4 Tool usage in practice
Consider a task to add a new product filtering feature.
An agent might use the following tools:
| Activity | Tool usage |
|---|---|
| Understand existing filtering | Search and read files |
| Identify affected components | Code navigation |
| Understand API response | Inspect service and API definitions |
| Implement filtering | File editing |
| Validate behavior | Test execution |
| Review modifications | Git diff |
| Report completion | Final response |
The important principle is to use tools deliberately and evaluate their output rather than blindly executing a sequence of actions.
7. Understanding Tool Permissions and Access
An AI coding agent’s capabilities depend not only on its tools but also on the permissions granted to those tools.
A tool may be available to the agent while certain operations remain restricted.
For example, an agent might be allowed to read files but require approval before modifying them. It may execute unit tests but be prohibited from deploying an application.
7.1 Read permissions
Read permissions allow an agent to inspect project information.
Examples:
- Read source files.
- Inspect configuration.
- Search the repository.
- Review documentation.
- Read test results.
Read access is generally less risky than unrestricted write or execution access, although sensitive information may still be exposed through files.
7.2 Write permissions
Write permissions allow an agent to modify project files.
Examples:
- Create new components.
- Update existing services.
- Modify tests.
- Change configuration files.
- Update documentation.
Write access should be scoped to the intended project and task wherever possible.
7.3 Execution permissions
Execution permissions allow the agent to run commands.
Examples:
yarn installyarn testyarn buildnpm run lint- Database migration commands.
Some commands may change the environment, install packages, delete data, or perform other consequential operations.
7.4 External access permissions
External access may allow an agent to communicate with:
- External APIs.
- Cloud platforms.
- Databases.
- Issue tracking systems.
- Package registries.
- Deployment environments.
Such access should be granted only when required and should follow organizational security policies.
7.5 Principle of least privilege
A useful security principle is to give an agent only the permissions necessary to complete its assigned task.
For example, an agent implementing a frontend component generally does not need production database access or deployment permissions.
Restricting permissions reduces the impact of incorrect decisions, unexpected behavior, and malicious instructions embedded in untrusted content.
8. Managing Approvals in AI-Assisted Development
AI coding agents can perform actions that have different levels of risk. Not every action requires the same level of human supervision.
Approval workflows define which actions an agent can perform independently and which require explicit authorization.
8.1 Why approvals matter
An agent may misunderstand a requirement, select an inappropriate implementation, or execute a command with unintended consequences.
For example:
- Deleting files outside the intended scope.
- Installing an unnecessary dependency.
- Modifying database schemas.
- Changing authentication behavior.
- Updating environment configuration.
- Pushing changes to a shared branch.
- Deploying an application.
Approval controls help ensure that consequential operations remain under human supervision.
8.2 Types of approval workflows
Automatic execution
The agent can perform permitted operations without asking for approval.
Examples:
- Reading source files.
- Searching the repository.
- Running approved unit tests.
- Inspecting Git status.
Approval before execution
The agent requests permission before performing an operation.
Examples:
- Installing a new package.
- Modifying sensitive configuration.
- Running a database migration.
- Deleting files.
- Executing potentially destructive commands.
Approval after implementation
The agent completes a change but waits for a human to review and approve it before the next stage.
Examples:
- Reviewing code changes.
- Approving a pull request.
- Authorizing a release.
- Approving a production deployment.
Human-controlled execution
The agent prepares the required changes or commands, but a human performs the final operation.
This is useful for highly sensitive activities such as production deployments, security policy changes, and destructive database operations.
8.3 Risk-based approval model
Approval requirements should be based on the potential impact of an action.
| Risk level | Example activities | Suggested control |
|---|---|---|
| Low | Read files, search code, inspect Git status | Automatic |
| Moderate | Modify application code, update tests | Scoped permissions and review |
| High | Add dependencies, modify database schema, change authentication | Explicit approval and review |
| Critical | Delete production data, deploy to production, change security controls | Strong human authorization |
This is a practical classification rather than a universal standard. Organizations should adapt it to their security policies and development environments.
8.4 Approval should include sufficient information
An agent should explain what it intends to do before requesting approval.
A useful approval request should include:
- The action being proposed.
- Why the action is necessary.
- Which files or systems will be affected.
- Expected consequences.
- Potential risks.
- Whether the operation can be reversed.
For example:
“I need to install an additional validation package to implement the requested feature. This will modify the package manifest and lockfile. An existing validation utility may provide the same functionality. Should I inspect the current dependencies first?”
This gives the developer enough information to make an informed decision.
9. Understanding Human-in-the-Loop Workflows
Human-in-the-loop development means that developers remain involved in important decisions and validation activities while AI agents perform implementation work.
The objective is to combine the speed of automated execution with human judgment.
9.1 Human involvement during requirements analysis
Developers and product stakeholders must confirm that the requirements represent the intended business behavior.
An agent can identify ambiguity and suggest clarification questions, but it cannot independently determine whether an undocumented business assumption is correct.
9.2 Human involvement during planning
For complex features, developers should review the proposed architecture, affected components, data changes, and implementation sequence.
This is especially important when changes involve security, payments, healthcare information, or external integrations.
9.3 Human involvement during implementation
The agent may implement individual tasks independently within approved boundaries.
Developers should remain available to resolve architectural questions, clarify business rules, and approve sensitive changes.
9.4 Human involvement during validation
Code review, security validation, acceptance testing, and release approval should follow the organization’s engineering process.
An agent reporting that all tests passed does not establish that the implementation is correct for every business scenario.
9.5 Human involvement during deployment
Production deployment should follow established release controls.
Depending on the organization’s policies, an agent may prepare deployment artifacts or execute approved non-production deployment tasks while production authorization remains with a human.
10. Implementing Software with AI Coding Agents
Implementation is the stage where an AI coding agent translates requirements and plans into actual software changes.
A disciplined implementation process helps prevent incomplete features, unnecessary modifications, and code that does not align with the existing architecture.
10.1 Start with a clear specification
Before implementation, provide the agent with the relevant specification.
A specification should explain:
- Feature objective.
- Functional requirements.
- Non-functional requirements.
- User workflows.
- Business rules.
- Inputs and outputs.
- Error conditions.
- Acceptance criteria.
- Dependencies and constraints.
For example, a product filtering specification might define:
- Users can filter products by category.
- Users can select multiple categories.
- The selected filters remain visible.
- Clearing filters restores the default product list.
- Empty results display an appropriate message.
- The filtering behavior works on supported mobile and desktop layouts.
These details give the agent a clearer implementation target.
10.2 Ask the agent to inspect before coding
The agent should inspect existing functionality before making changes.
It should identify:
- Relevant components.
- Existing hooks and utilities.
- API services.
- State management.
- Shared UI patterns.
- Test files.
- Dependencies and configuration.
This prevents the agent from recreating functionality that already exists.
10.3 Request an implementation plan
For significant changes, ask the agent to produce a plan before modifying files.
The plan should identify:
- Files likely to be modified.
- New files or components required.
- Changes to APIs or data models.
- Dependencies and assumptions.
- Testing requirements.
- Potential risks.
The developer can then correct misunderstandings before implementation begins.
10.4 Implement in manageable tasks
Large features should be divided into smaller, reviewable implementation tasks.
For example, an appointment booking feature could be divided into:
- Create appointment availability API.
- Implement doctor availability display.
- Build appointment selection interface.
- Implement booking submission.
- Add booking conflict handling.
- Implement cancellation.
- Add notification integration.
- Create automated tests.
Smaller tasks make it easier to identify errors and review the agent’s work.
10.5 Validate incrementally
Do not wait until the entire feature is complete before running tests.
The agent should validate relevant changes after each meaningful implementation stage.
Typical validation activities include:
- Type checking.
- Linting.
- Unit testing.
- Integration testing.
- Build verification.
- API contract validation.
- Manual testing of critical workflows.
Incremental validation makes failures easier to isolate.
10.6 Review the final implementation
Before considering the task complete, inspect the actual changes.
Check:
- Whether all requirements are implemented.
- Whether unrelated files were modified.
- Whether the code follows existing architecture.
- Whether error handling is adequate.
- Whether security controls are preserved.
- Whether tests cover relevant scenarios.
- Whether documentation needs updating.
The final implementation should satisfy the specification, not merely compile successfully.
11. Reviewing and Validating AI-Generated Code
Code generated by an AI coding agent must be reviewed like code written by any other developer.
AI-generated code may contain logical errors, incorrect assumptions, security vulnerabilities, unnecessary complexity, or incomplete handling of edge cases.
11.1 Functional correctness
Verify that the implementation meets the functional requirements.
For example, a password reset implementation should not only generate a reset link. It should also validate tokens, enforce expiration, prevent unauthorized password changes, and invalidate tokens after successful use.
11.2 Code quality
Review whether the implementation:
- Follows existing coding standards.
- Uses appropriate abstractions.
- Avoids unnecessary duplication.
- Handles errors consistently.
- Maintains readability.
- Avoids unnecessary complexity.
11.3 Security review
Pay special attention to:
- Authentication and authorization.
- Input validation.
- Sensitive data handling.
- Dependency vulnerabilities.
- Access control.
- Database query safety.
- Logging of confidential information.
- Secrets and environment variables.
AI-generated code should not be assumed secure simply because it follows common coding patterns.
11.4 Test coverage
Confirm that tests cover:
- Normal execution.
- Invalid input.
- Error conditions.
- Authorization failures.
- Boundary conditions.
- Relevant integration scenarios.
Test coverage percentages alone do not guarantee meaningful validation.
11.5 Regression testing
Ensure that new changes do not break existing functionality.
Regression testing is particularly important when the agent modifies shared components, services, application state, authentication logic, or common utilities.
11.6 Specification compliance
Compare the implementation with the original specification and acceptance criteria.
A useful review question is:
“Does the implemented behavior satisfy every relevant requirement, including alternative and exceptional scenarios?”
This keeps the review focused on expected system behavior rather than only code appearance.
12. Practical Example: Implementing a Feature with an AI Coding Agent
Consider an e-commerce application that needs a new order cancellation feature.
The objective is to allow customers to cancel eligible orders through their account dashboard.
Step 1: Provide the requirement
Feature: Order Cancellation
Objective: Allow authenticated customers to cancel eligible orders.
Functional Requirements:
- Customers can view their orders.
- Customers can request cancellation for eligible orders.
- The system validates the order’s current status.
- The system prevents cancellation of shipped or delivered orders.
- Successful cancellation updates the order status.
- The system records the cancellation event.
- The customer receives a cancellation confirmation.
Non-Functional Requirements:
- Only authorized customers can cancel their own orders.
- Cancellation requests must be processed consistently.
- Duplicate requests must not create inconsistent order states.
- Errors must be handled without exposing sensitive information.
Step 2: Provide agent instructions
The developer provides instructions such as:
Implement the order cancellation feature.
Follow the existing application architecture and reuse
the current order service and authentication mechanisms.
Do not introduce new dependencies without approval.
Do not modify unrelated modules.
Ensure that customers can cancel only their own eligible
orders.
Handle invalid order states and duplicate requests safely.
Add tests for successful cancellation, unauthorized access,
invalid order states, and repeated cancellation requests.
Inspect the existing implementation before making changes.
Step 3: Agent inspects the repository
The agent examines:
- Order components.
- Order service.
- Authentication middleware.
- Order database model.
- Existing API endpoints.
- Test files.
It identifies where cancellation behavior should be implemented.
Step 4: Agent prepares an implementation plan
The proposed plan may include:
- Add a cancellation operation to the order service.
- Validate customer ownership.
- Check order eligibility.
- Update the order state safely.
- Record the cancellation event.
- Update the customer interface.
- Add automated tests.
The developer reviews the plan and confirms that it follows the application’s architecture.
Step 5: Agent requests approval when necessary
If the implementation requires a database migration or a new external integration, the agent explains the proposed change and requests approval according to the project’s permission policy.
Routine file inspection and approved test execution may proceed without additional approval.
Step 6: Agent implements the feature
The agent modifies the required service, API, UI, and test files.
It follows existing conventions and avoids unnecessary changes.
Step 7: Agent runs validation
The agent executes relevant tests and checks for:
- Successful cancellation.
- Unauthorized cancellation attempts.
- Cancellation of ineligible orders.
- Duplicate requests.
- Unexpected errors.
- Existing order workflow regressions.
Step 8: Developer reviews the changes
The developer checks the Git diff, implementation logic, authorization, order state transitions, and test results.
The developer also verifies that concurrent cancellation requests cannot cause inconsistent state.
Step 9: Complete the task
The agent provides a completion report describing the files changed, tests executed, results, and any remaining limitations.
The developer decides whether the implementation is ready for code review, merging, or release.
This example demonstrates how instructions, tool usage, approvals, and implementation work together in a controlled AI-assisted development workflow.
13. Common Challenges When Working with AI Coding Agents
Although AI coding agents can improve development productivity, several challenges need to be managed.
13.1 Ambiguous instructions
When requirements are unclear, agents may make assumptions that do not match business expectations.
Solution: Provide detailed specifications, examples, constraints, and acceptance criteria. Ask the agent to identify unresolved questions before implementation.
13.2 Insufficient project context
An agent may generate code that ignores existing architecture or duplicates existing functionality.
Solution: Provide project-level instructions and allow the agent to inspect relevant repository files before making changes.
13.3 Excessive tool permissions
Unrestricted access may allow agents to perform unintended or destructive operations.
Solution: Apply the principle of least privilege and require approval for sensitive actions.
13.4 Unnecessary code changes
Agents may modify unrelated files or refactor existing modules while implementing a small feature.
Solution: Define implementation scope, prohibit unrelated modifications, and review the Git diff.
13.5 Incorrect tool usage
An agent may execute inappropriate commands, install unnecessary packages, or misunderstand command output.
Solution: Provide tool-specific instructions and require the agent to inspect results before proceeding.
13.6 Incomplete implementation
An agent may implement the primary workflow while overlooking error handling, authorization, or alternative scenarios.
Solution: Use detailed acceptance criteria and require validation against every relevant requirement.
13.7 Overreliance on automated testing
Passing tests may create false confidence if the tests do not cover important business behavior.
Solution: Combine automated tests with code review, security checks, integration validation, and human acceptance testing.
13.8 Context and instruction conflicts
An agent may receive conflicting instructions from global settings, repository files, task descriptions, and specifications.
Solution: Establish a clear instruction hierarchy, define authoritative sources, and resolve conflicts explicitly. Untrusted repository content or external material should not be allowed to override security policies or permissions.
14. Best Practices for Working with AI Coding Agents
The following practices help developers use AI coding agents effectively.
14.1 Provide persistent project instructions
Maintain clear instruction files containing architecture, coding standards, testing practices, and security requirements.
Update them as the project evolves.
14.2 Use specifications as implementation references
Do not rely exclusively on conversational prompts for complex features.
Provide structured requirements, business rules, workflows, and acceptance criteria.
14.3 Inspect before implementing
Ask the agent to understand the existing codebase before proposing changes.
Existing code and architecture should guide implementation decisions.
14.4 Plan significant changes
For complex features, review the implementation plan before allowing extensive code modifications.
This reduces the cost of correcting misunderstandings.
14.5 Use least-privilege permissions
Give agents only the access necessary for the assigned task.
Avoid granting production access or unrestricted execution permissions when they are not required.
14.6 Establish risk-based approvals
Allow routine, low-risk activities to proceed efficiently while requiring human approval for sensitive operations.
14.7 Implement incrementally
Divide large features into manageable tasks and validate each meaningful change.
14.8 Review all important changes
Inspect code modifications, dependencies, configuration changes, database migrations, and security-sensitive logic.
14.9 Require honest completion reports
Agents should clearly distinguish between tests that passed, tests that failed, and tests that were not executed.
They should never claim successful validation without evidence.
14.10 Preserve traceability
Maintain connections between requirements, implementation tasks, code changes, and tests.
This is especially important in complex applications and regulated environments.
14.11 Protect sensitive information
Do not expose credentials, production data, private keys, or confidential customer information unnecessarily.
Apply appropriate access controls and data-handling policies.
14.12 Treat AI output as a proposal until validated
An AI coding agent can accelerate implementation, but its output must still satisfy engineering standards and business requirements.
15. Role of AI Coding Agents in Spec-Driven Development
Spec-Driven Development (SDD) provides a structured approach to software engineering in which specifications guide planning, implementation, and validation.
AI coding agents become more effective when they operate within this specification-driven workflow.
Instead of relying on a broad prompt such as “Build an appointment booking application,” developers provide structured information describing the expected system behavior.
A typical SDD workflow involving AI coding agents looks like this:
- Requirements: Define business goals, user needs, and constraints.
- Specifications: Document functional requirements, non-functional requirements, workflows, and acceptance criteria.
- Architecture: Identify components, system boundaries, data models, and API contracts.
- Agent instructions: Explain project conventions, implementation rules, and security expectations.
- Context preparation: Provide relevant repository information and technical decisions.
- Execution planning: Convert specifications into implementation tasks.
- Tool-assisted implementation: Allow agents to inspect, modify, and test code within approved permissions.
- Human approvals: Review sensitive actions and important engineering decisions.
- Validation: Verify implementation against specifications and acceptance criteria.
- Maintenance: Update specifications and related documentation when requirements or implementation change.
Instructions and specifications serve different purposes
It is important to distinguish between agent instructions and software specifications.
| Agent Instructions | Software Specifications |
|---|---|
| Explain how the agent should work | Explain what the system should do |
| Define coding conventions | Define functional behavior |
| Establish tool usage rules | Define workflows and business rules |
| Set implementation boundaries | Define constraints and acceptance criteria |
| Describe testing expectations | Define expected validation outcomes |
For example, an instruction might say:
“Use the existing authentication service and do not introduce a new authentication dependency.”
The corresponding specification might say:
“Only authenticated customers can access their order history.”
The instruction controls the implementation approach, while the specification defines the required system behavior.
Why this combination matters
Without specifications, an agent may generate code based on incomplete assumptions.
Without project instructions, it may implement the right behavior using inconsistent architecture or coding conventions.
Without tool controls and approvals, it may perform actions beyond its intended authority.
Without validation, developers may accept incomplete or incorrect implementation.
Combining specifications, instructions, context, controlled tool access, approvals, and human review creates a more reliable approach to AI-assisted software engineering.
16. Conclusion
Working with AI coding agents requires a structured engineering approach. Providing a task prompt is only the starting point. Developers must also establish clear agent instructions, supply relevant project context, manage tool permissions, define approval requirements, and validate implementation results.
Agent instructions help maintain consistency. Tool usage enables agents to interact with real development environments. Approval workflows preserve human control over consequential actions. Implementation processes translate specifications into working software through incremental development and validation.
The most effective approach is not to give AI coding agents unrestricted control or treat them as replacements for software engineers. Instead, developers should assign well-defined tasks, provide the right context, establish clear boundaries, and supervise important engineering decisions.
In Spec-Driven Development, these practices become even more valuable because specifications provide a structured foundation for AI agents to plan, implement, and validate software.
The goal is to engineer software with AI coding agents, not simply ask AI to generate code.
17. Frequently Asked Questions
1. What does working with AI coding agents mean?
Working with AI coding agents means using AI systems that can understand development tasks, inspect repositories, modify code, execute tools, run tests, and assist with software implementation under defined instructions and permissions.
2. What are agent instructions?
Agent instructions are guidelines that explain how an AI coding agent should work. They may define project architecture, coding standards, testing practices, security requirements, implementation boundaries, and tool usage rules.
3. What is an AGENTS.md file?
An AGENTS.md file is a repository-level instruction file used by supporting AI coding tools to provide project-specific guidance. It can contain architecture details, coding conventions, testing instructions, and implementation rules. Support and instruction discovery behavior depend on the tool.
4. What tools can AI coding agents use?
Depending on their environment, AI coding agents can use file system tools, terminal commands, code search, version control, testing frameworks, documentation systems, APIs, and other approved integrations.
5. Why do AI coding agents need tool permissions?
Tool permissions control which actions an agent can perform. They help prevent unauthorized file modifications, unsafe command execution, unintended access to sensitive systems, and other potentially harmful operations.
6. What is an approval workflow in AI-assisted development?
An approval workflow defines which operations an AI coding agent can perform independently and which require human authorization. Approval may be required before modifying sensitive files, installing dependencies, executing migrations, or deploying applications.
7. Should developers approve every action performed by an AI coding agent?
Not necessarily. Requiring approval for every low-risk action can slow down development. A risk-based approach is more effective: allow routine operations within defined permissions while requiring explicit authorization for sensitive or destructive activities.
8. Can AI coding agents implement complete software features?
Yes. AI coding agents can implement multi-file features involving UI components, APIs, business logic, database changes, and tests. However, complex implementations require clear specifications, suitable context, appropriate permissions, and human review.
9. How should developers review AI-generated code?
Developers should inspect code changes, verify functional requirements, review security and error handling, execute relevant tests, check for regressions, and confirm that the implementation follows the existing architecture.
10. What is human-in-the-loop development?
Human-in-the-loop development is an approach in which developers supervise important stages of AI-assisted work. Humans provide requirements, review plans, approve sensitive actions, validate results, and retain responsibility for engineering decisions.
11. What is the difference between agent instructions and software specifications?
Agent instructions explain how the AI agent should work, while software specifications explain what the application should do. Instructions define working conventions and boundaries; specifications define expected behavior, requirements, and constraints.
12. How do AI coding agents support Spec-Driven Development?
AI coding agents use specifications to understand expected behavior, break features into tasks, plan implementation, modify code, and generate tests. Specifications provide a reference for evaluating whether the implementation meets the intended requirements.
13. Is it safe to give AI coding agents access to production systems?
Unrestricted production access is generally inappropriate. Production access should be avoided unless genuinely necessary and explicitly governed by organizational security policies, least-privilege permissions, strong approval controls, and monitoring.
14. What is the best way to start working with AI coding agents?
Start with a well-defined development task, provide project-level instructions, allow the agent to inspect the relevant code, request an implementation plan, and permit controlled changes. Review the resulting code and test outcomes before accepting the implementation.







