A code completion assistant suggests a few lines and you press Tab. A coding agent takes one sentence from you, reads ten files, changes six, runs the tests and says "done." If all goes well, an hour of work is finished in minutes. If not, you're facing a big change and don't know where to start reading it.
A coding agent is a tool that, given a goal, reads project files, changes them and runs commands such as the test suite on its own. The difference between a good and a bad result is usually not the model; it's the workflow. If you're not familiar with the concept of agents, first read what is an AI agent.
What exactly does a coding agent do?#
It works with four tools: reading files, searching the project, editing files and running terminal commands. With these, in a loop of thinking, acting and observing, it finds bugs, adds features or writes tests.
It comes in three common forms:
| Form | Where it works | Good for |
|---|---|---|
| Inside a code editor | On the project open in the editor | Small and medium tasks with live supervision |
| In the terminal | On the project folder, with command-line tools | Multi-file tasks, running tests and project tools |
| Background or cloud | On a copy of the repository in a separate environment | Well-defined tasks whose result is a pull request |
How do you prepare the project before the first run?#
With a clean Git state, a separate branch, runnable tests and an environment with no real keys:
- Keep Git clean. No uncommitted changes should be left before you start.
- Create a separate branch. If the work goes badly, you discard the whole branch.
- Make sure tests run. The agent uses tests to know whether its work is right; a project without tests means the whole review burden falls on you.
- Use a local environment with test data. A
.envfile with real keys and a connection to the production database should not be reachable by the agent. - A project instructions file. Most tools read a text file in the project root; some use a file like
AGENTS.mdand some their own file. Put the test command, naming rules and folders that must not be touched there.
git status
git switch -c agent/fix-discount-total
php artisan testWhat permission level should you give the agent?#
Free reading, editing and running tests from an allowlist, and anything irreversible only with your approval. Serious tools have several permission modes, from "ask before every action" to "do whatever you want." The second is faster, but:
| Action | Recommendation |
|---|---|
| Reading project files | Free |
| Editing files in the project folder | Free or with approval, depending on your trust |
| Running tests and code-checking tools | Free, with an allowlist of commands |
| Installing a new package | With approval |
| Migrations, deleting files, rewriting Git history | Always with approval |
| Anything involving the production server or deployment | No |
If you connect the agent to other tools such as a database or a code repository through MCP, the same rule applies there: read-only unless truly necessary.
What is a safe routine for a task with an agent?#
Four steps: first a plan, then changes in small steps, then a review of the changes, and finally a small Git commit.
1. Plan first, then change#
Goal: the order total is calculated incorrectly when a percentage discount code is applied; find the cause.
Do not change any files for now. Only:
1. Read the relevant files and tell me the likely cause.
2. Write the change plan step by step and say which files will change.
3. Say which test shows the error or what test should be added.
Do not modify existing test files without permission.If the agent misunderstood the cause, this is the cheapest place to correct it, not after six files have changed.
2. Change in small steps#
After approving the plan, ask it to proceed step by step and run the tests after each step. If a test stays red and the agent tries the same approach several times in a row, stop it and look yourself.
3. Review the changes#
Don't believe the "done" report; look at the changes themselves:
git diff --stat
git diff -- tests/
git diff -- composer.json composer.lockThe second command shows whether tests were changed, and the third shows whether a new package was added.
4. Commit small#
Commit each completed task separately. Small commits make both review and rollback easier.
Where do agents usually go wrong?#
Where the goal or scope is vague, and where "tests turned green" replaces "the code became correct":
| Mistake | Sign | Prevention |
|---|---|---|
| Changing the test instead of fixing the cause | Test is green but the test file changed too | Forbid it in the instructions; review tests separately |
| An imaginary function or package | An "undefined" error or an unfamiliar package | Run tests; check every new package |
| Unrelated changes | Formatting or renaming fixes in other files | A clear scope in the instructions |
| Ignoring project conventions | Correct code that doesn't match the rest | A project instructions file |
| Security gaps | Input without validation, output without escaping | A separate security review |
For the last one, AI code review helps, but it doesn't replace your own eyes.
WordPress and Laravel tips#
- WordPress: in every form and AJAX request the agent creates, check for a nonce, a capability check with
current_user_canand output escaping. Don't let it edit WordPress core or someone else's plugin; changes belong only in your own plugin or a child theme. - Laravel: read migrations line by line and allow a command like
migrate:freshonly on a test database. Ifconfigorroutesfiles change, ask why. More experience in AI in a Laravel project.
Where this is heading#
Coding agents are doing longer tasks more independently and increasingly run in the background or on several tasks at once. As a result, the developer's share shifts from "writing" to "defining the task precisely and reviewing," and automated tests and automated checks before merging go from a nice-to-have to a prerequisite.
To prepare:
- Raise the test coverage of your projects, starting with sensitive areas like payments.
- Write a project instructions file and keep it up to date like code.
- Practice reading a diff quickly and carefully; this skill is becoming more valuable.
Summary#
- A coding agent reads files, changes them and runs commands; the workflow matters more than the model itself.
- Clean Git, a separate branch, runnable tests and an environment without real keys.
- Get a plan and approve it first, then change in small steps.
- Review the changes with
git diff, especially tests and new packages. - Irreversible actions and anything involving the production server always need your approval.