Using Codex and AI Coding Agents Without Losing Control
An AI coding agent is not autocomplete. It reads your repository, plans a change, edits files, runs commands and reports back — on its own, in a loop. That is a genuinely different thing from asking a chatbot for a function, and it needs a different set of habits. This guide covers what these agents actually do, how to set one up safely, and the review discipline that keeps you responsible for every line it writes.
What makes it an agent, not a chatbot
OpenAI's Codex is a coding agent you run in your terminal; there are equivalents from several vendors. The defining difference is not the model — it is the loop. The agent can read files, write files, run shell commands, observe the results, and try again. It is given a goal and it works until it either succeeds or gets stuck.
- It reads your actual repository rather than a snippet you pasted.
- It runs your tests, sees them fail, and fixes the failure itself.
- It executes commands — which is exactly why sandboxing matters.
- It works in a diff you can read before it goes anywhere near your main branch.
Setting one up, safely
- Always work on a branch. The agent should never be pointed at main.
- Keep sandboxing on. These tools run shell commands; network and filesystem restrictions are a real safety net, not ceremony.
- Start with a scoped task — one function, one file, one bug — not 'refactor the project'.
- Review the diff line by line before merging. The agent will be confident and occasionally wrong.
- Keep your own tests. The agent that can see assertions writes dramatically better code, and it catches itself when they fail.
How to brief it well
An agent has your repository but not your intent. The brief carries the intent, so vagueness costs iterations.
- State the goal and the acceptance criteria. 'Tests pass and the function returns sorted results' beats 'fix the sorting'.
- Point it at the types and interfaces, not just the function. Types are the contract.
- Name the constraints: framework version, the libraries you are allowed to use, the style already in the file.
- Ask for a plan first on anything non-trivial, then approve before it writes code.
- Tell it not to touch unrelated files. Scope drift is the most common failure mode.
Goal: the parseDate function in src/lib/dates.ts fails on "2026-13-01".
Accept: it returns null instead of NaN, and there's a test for it.
Constraints: TypeScript, no new dependencies, match the file's existing style.
Do not modify any file other than src/lib/dates.ts and its test.Where it genuinely helps, and where it does not
- Boilerplate, tests, type definitions, and migrations — it is excellent at work that is tedious but well-specified.
- Bugs with a clear reproduction and an obvious failing case.
- Getting oriented in an unfamiliar codebase: 'explain what this module does and where the entry point is'.
- Mechanical refactors across many files with a consistent pattern.
- Architecture, security review, and anything where the right answer is a judgement about your specific constraints. It will produce a confident guess.
Commands for the non-coding half of the job
Reading and checking code is half the work: format the JSON payloads it complains about, test the regex it proposed, and capture the result as an image for a PR or a bug report.
All of these run in your browser — no account, no upload, free forever.
Code Review
Get a senior-level review covering bugs, edge cases and readability.
Use it in: ChatGPT / Gemini / Claude · copy → paste → replace bracketed placeholders with your details
Refactor Function
Refactor without changing behaviour a function — e.g. a 40-line `parseInvoice(buffer)` helper in TypeScript.
Use it in: ChatGPT / Gemini / Claude · copy → paste → replace bracketed placeholders with your details
Test Function
Write meaningful tests covering a function — e.g. a 40-line `parseInvoice(buffer)` helper in TypeScript.
Use it in: ChatGPT / Gemini / Claude · copy → paste → replace bracketed placeholders with your details
Refactor Component
Refactor without changing behaviour a UI component — e.g. a React `<PricingTable />` component with three tier props.
Use it in: ChatGPT / Gemini / Claude · copy → paste → replace bracketed placeholders with your details
Explore the Full SlashAI Library
Every prompt in our guides is part of our offline-ready vault of verified commands and instant browser tools. Free forever, no account required.
Browse All Commands