AI coding agents can do much more than autocomplete a line of code. Give an agent access to an existing repository, and it can inspect files, plan a change, edit multiple parts of an application, run commands, and help investigate failures.
But there is a catch: an agent that can make changes is not automatically an agent that makes the right changes.
A vague request can lead to unnecessary refactoring, missing edge cases, or code that appears to work but breaks something else. The solution is not a longer magic prompt. It is a better development workflow.
In this guide, we'll use a small task-management application as an example and add a priority filter that lets users display high-, medium-, or low-priority tasks. The goal is to show how to manage an AI coding agent from the first requirement to the final code review.
The workflow is tool-agnostic. You can adapt it to Claude Code, OpenAI Codex, Cursor, GitHub Copilot, or another agent that can inspect and modify a repository.
ON THIS PAGE
1. Define a feature the agent can actually build
2. Create a safe starting point
3. Give the agent the right repository context
4. Ask for a plan before implementation
5. Let the agent make controlled changes
6. Run tests and inspect the Git diff
7. Verify the feature like a developer
8. Make the workflow reusable
FAQ: Working with AI coding agents
1. Define a Feature the Agent Can Actually Build
Start with the feature, not the prompt.
Imagine you have an existing task-management application. Users can create tasks, edit them, and mark them complete. You want to add a filter that displays tasks by priority.
A weak request would be:
Add a priority filter to my task app.
That leaves too much room for interpretation. Should the filter include completed tasks? What happens when no tasks match? Should the filter reset when the page reloads?
Write a short feature brief first.
Requirement | Expected behavior |
|---|---|
Filter options | All, High, Medium, Low |
Default selection | All |
Filtering | Display tasks matching the selected priority |
Empty result | Show a clear empty-state message |
Existing behavior | Task creation and completion continue working |
Data changes | Do not modify the database schema |
Scope | Do not redesign the task dashboard |
This gives the agent a measurable definition of success.
I would also define what is not part of the feature. That matters because coding agents sometimes interpret a small request as an invitation to improve unrelated parts of the application.
A good task is small enough to review, but complete enough to have meaningful acceptance criteria.
2. Create a Safe Starting Point
Before giving an agent permission to edit files, establish a recoverable starting point.
Open the project directory and check Git:
git status --short
git branch --show-current
git log -1 --onelineIf the working tree is clean, create a feature branch:
git switch -c feature/task-priority-filterIf you already have uncommitted changes, review and preserve them first. Do not assume that every existing modification belongs to the new feature.
Next, identify how the application is started and tested. Check the README and package configuration rather than guessing.
For example, a JavaScript project might provide:
npm run dev
npm test
npm run lint
npm run buildYour project may use different commands—or may not have all four scripts.
The important thing is to understand the baseline. If tests already fail before the agent starts, record that fact. Otherwise, you may blame the new feature for an unrelated problem.
Git is not just a place to store finished code. It is your recovery mechanism when an automated change goes in the wrong direction.

3. Give the Agent the Right Repository Context
A coding agent needs to understand how your application is organized before it can make a sensible change.
Useful context includes:
The directory structure.
The framework and runtime.
Where the task list is rendered.
Where task data comes from.
How existing filters or UI state are handled.
How tests are organized.
Which files should remain untouched.
You do not need to paste the entire repository into the prompt. Ask the agent to inspect the relevant files and explain what it finds.
Try this:
Inspect this repository before making any changes.
I want to add a priority filter to the existing task list.
First:
1. Identify the task-list component or page.
2. Find the task data model and existing priority field.
3. Check how the application currently manages UI state.
4. Find related tests and project conventions.
5. Identify the smallest set of files likely to change.
Do not edit files yet.
If the project does not already support task priorities,
explain what is missing instead of inventing an implementation.That final instruction is important. An agent should not silently assume that a priority field exists simply because the feature request mentions it.
For recurring projects, store stable instructions in a project file. Common examples include AGENTS.md, CLAUDE.md, and Cursor's project rules.
Keep these instructions practical:
# Project Instructions
- Follow the existing architecture and naming conventions.
- Inspect existing components before creating new ones.
- Avoid unrelated refactoring.
- Do not add dependencies without explaining why.
- Run relevant tests after changing behavior.
- Report checks that could not be completed.
- Never expose secrets or modify production credentials.Project instructions provide reusable context, but they do not replace task-specific requirements.
4. Ask for a Plan Before Implementation
Now ask the agent to turn its findings into an implementation plan.
For a small feature, the plan does not need to be a long technical document. It should explain the expected changes and identify possible risks.
Example planning prompt:
Based on your repository inspection, create an implementation plan.
The feature must:
- Add All, High, Medium, and Low filter options.
- Default to All.
- Filter the existing task list without changing stored task data.
- Show an empty state when no tasks match.
- Preserve existing task creation and completion behavior.
Include:
1. Files to change.
2. State-management approach.
3. Edge cases.
4. Tests to add or update.
5. Potential regressions.
Do not edit files until I approve the plan.Review the response before moving forward.
Look for unnecessary database changes, duplicated filtering logic, new dependencies, and assumptions about how tasks are stored.
If the agent proposes changing five unrelated components to add one filter, ask it to explain why.
The planning stage is where you catch a bad implementation idea before it becomes a large diff.
5. Let the Agent Make Controlled Changes
Once the plan makes sense, approve the implementation—but keep the scope narrow.
Instead of asking the agent to finish everything in one unrestricted operation, give it a specific task:
Implement the approved priority filter.
Constraints:
- Follow existing component and state-management patterns.
- Do not change the database schema.
- Do not modify unrelated dashboard features.
- Do not install new dependencies unless necessary.
- Add or update tests for the filtering behavior.
After editing:
- List the files changed.
- Explain the implementation.
- Report any assumptions.
- Do not claim tests passed unless you actually ran them.Watch the changes as they happen. If the agent starts rewriting unrelated files or making unexpected architectural decisions, stop and redirect it.
This is not about micromanaging every line. It is about keeping the agent aligned with the feature brief.
Different tools offer different ways to manage this process. Cursor provides Agent and Plan workflows, while Claude Code and Codex provide their own planning, permission, and execution controls. The names and interfaces differ, but the principle is the same: review the intended work and keep risky actions under control.

6. Run Tests and Inspect the Git Diff
The agent's completion message is not proof that the feature works.
Run the relevant project checks:
npm test
npm run lint
npm run buildUse only commands that exist in your project. If a check is unavailable, record that rather than pretending it passed.
Then inspect the changes:
git status --short
git diff --stat
git diffPay attention to:
Review area | Question to ask |
|---|---|
Scope | Did the agent change only relevant files? |
Logic | Does each filter option return the right tasks? |
State | Does the default selection behave correctly? |
Empty state | What happens when no tasks match? |
Regression | Do existing task actions still work? |
Dependencies | Was a new package actually necessary? |
A passing test suite is useful evidence, but it only covers the cases represented by those tests.
7. Verify the Feature Like a Developer
Now test the feature from the user's perspective.
For the priority filter, the minimum manual checklist should include:
Select All and confirm every task is visible.
Select High and confirm only high-priority tasks remain.
Repeat for Medium and Low.
Choose a priority with no matching tasks.
Create or complete a task and check that existing behavior remains intact.
Refresh the page and confirm the expected default behavior.
If the application has automated tests, include cases for each priority and the empty result.
Do not confuse an agent's explanation with verification. If it says the filter works, ask what command it ran, what output it observed, and which test cases were covered.
For higher-risk features, also review permissions, input validation, dependencies, and data exposure. The amount of review should match the impact of the change.
8. Make the Workflow Reusable
After the feature is accepted, ask the agent for a concise implementation summary.
Record:
The task requirements.
Files changed.
Tests executed and their results.
Any manual checks performed.
Known limitations.
Follow-up work.
If the agent repeatedly makes the same mistake, update your project instructions with a specific rule. Do not keep adding vague instructions such as "write better code."
The goal is to improve the next task using evidence from the current one.
FAQ: Working With AI Coding Agents
Do I need to understand the entire codebase before using an AI coding agent?
No. You should understand the relevant parts of the project and know how the application is supposed to behave. The agent can help explore unfamiliar files, but you remain responsible for checking whether its interpretation is correct.
Should I let an AI coding agent automatically approve every terminal command?
Not by default. Start with approval or review controls, especially for commands that install packages, delete files, modify configuration, or access external services. Increase automation only for commands and environments you understand.
What should I do if the agent cannot find the files it needs?
Give it more specific context. Point it to the relevant directory, component, or API route, and ask it to explain what it has already inspected. Also check whether project ignore rules are preventing it from accessing files.
Can I use the same workflow for a large feature?
Yes, but divide the work into smaller milestones. Each milestone should have its own scope, acceptance criteria, Git checkpoint, and verification steps. A large feature should not become one enormous prompt followed by one enormous diff.
Is a coding agent's code review enough to approve a change?
No. An agent can identify potential problems, but its review is not a substitute for running tests, inspecting the diff, and applying human judgment. For security-sensitive or production-critical changes, use an appropriate independent review process.
Build It. Break It. Fix It.
