Your first coding agent session, end to end
For engineers
Set up a memory file, slice a task, instruct the agent, review the diff and commit, with every mistake a beginner makes.
The one-sentence idea: a first coding agent session goes well when you prepare the ground, hand over one small checkable task, and treat the result as a diff to review, not a finished feature.
The case
Dana maintains pantry-api, a small Express and SQLite service that tracks what is in a shared kitchen. She wants an expiry filter: GET /items?expiresBefore=2026-01-01 should return only items that expire earlier. It is her first session with a coding agent such as Claude Code, Codex, Cursor or Copilot. Five skills decide whether it ends well.
Why it matters
Agents are fast and confident, and they guess. They invent test commands, widen the scope, add dependencies and report success without showing proof. None of that is rare. Each mistake is cheap to prevent before the agent starts and expensive to find afterwards in a large diff.
How to do it
1. Give the agent a memory file. Before any task, Dana writes a short CLAUDE.md (or AGENTS.md, which several tools read). It holds what the agent cannot infer: how to run the tests, where they live, and rules such as "do not add dependencies without asking" and "never edit the database file". It leaves out history, copies of the routes and anything secret, because the file is committed and shared. She then tests it: in a fresh session she gives a task that tempts a break of a rule and watches what happens.
2. Slice the work. "Track expiry dates" is a whole feature. Dana picks the first vertical slice: the filter, end to end, with one test. The email reminders and the dashboard badge are later slices. A good slice has a boundary and a check an agent can run.
3. Instruct with a goal, a limit and a pointer. Her first draft, "add expiry filter to the items api", leaves scope, style and proof to the agent. The rewrite names the file, says to follow the existing category filter, forbids other edits and asks for the output of npm test.
4. Review the diff like any other contributor's. Dana reads for correctness, scope and tests. She looks for string-built SQL, edits to files she did not mention, new dependencies and tests that assert nothing. She compares the agent's summary with the diff, because a summary is a claim and the diff is the evidence.
5. Commit like an engineer. She stages only the files in the change and leaves out the .env and the database file. One commit carries one message, in a style such as Conventional Commits. If a later agent commit breaks the build, git revert brings back a known state without rewriting pushed history.
Before and after
Before: "add expiry filter to the items api". The agent edits six files, upgrades Express, converts a route to TypeScript and says "all tests pass".
After: "In src/routes/items.js only, add an optional expiresBefore query parameter, following the category filter. Do not edit package.json. Run npm test and paste the output." The diff is a handful of lines and the proof is in the message.
What goes wrong
- The task is too large. A plan with fourteen files and four separate changes cannot be reviewed. Split it before the agent starts, not after.
- Review follows the summary. A claim such as "I changed nothing outside the route" is only true if the diff stat agrees. Check it against the diff.
- Weak tests pass. An agent that is told to make a failing test pass may loosen the assertion. A test that only checks the status code proves almost nothing.
- The commit carries junk. A broad
git add .sweeps in the.envor a local database. Stage by path and readgit statusfirst.
What to take away
Prepare, slice, instruct, review, commit. Each step is small, and each one catches a different class of mistake. The agent does the typing. Dana keeps the decisions about scope and about what counts as done.
Steps
Write and test a short memory file
Dana writes a CLAUDE.md with the test command, the folder layout and two firm rules, and keeps history and secrets out. In a fresh session she tempts the agent to edit the database file to see whether the rule holds.
CLAUDE.md CLAUDE.md
# pantry-api- Run `npm test` before finishing any task.- Tests live in test/ and use node:test.- Do not add dependencies without asking me first.- Never edit data/pantry.db by hand.Slice the feature
She turns "track expiry dates" into slices and starts with the filter plus one test. The emails and the dashboard badge wait until the filter is merged.
Slices Slice Checkable by Filter by expiry through the API npm test, one new test Daily reminder email Mail preview, later Dashboard badge Screenshot, later Write the instruction
The prompt states the goal, limits the files, points to the category filter and asks for the test output, so the agent has a boundary and a proof to deliver.
Review the diff against the summary
Dana reads the diff for string-built SQL, files outside the task, new dependencies and weak tests, and compares the agent's summary with the diff stat before she accepts anything.
Check scope and tests
She asks the agent to drop any unrelated reformatting and to fix any assertion that was loosened. The route and the test are the parts she reads line by line.
Commit and keep a way back
She stages by path, leaves the .env and database file out, commits with one clear message, and keeps
git revertready if a later agent commit breaks the build.
Skills this scenario uses
Where to study
- AGENTS.md (opens in a new tab)DocsFree
One shared file format for repo instructions that many coding agents read.
- How Claude remembers your project (Claude Code docs) (opens in a new tab)DocsFree
How memory files are loaded and layered, and what makes them effective.
- Best practices for Claude Code (Claude Code docs) (opens in a new tab)DocsFree
Official advice on giving agents checks, examples and small tasks.
- Small CLs (Google Engineering Practices) (opens in a new tab)ArticleFree
Why small, self-contained changes are reviewed faster and break less.
- What to look for in a code review (Google Engineering Practices) (opens in a new tab)ArticleFree
A reviewer's checklist: design, tests, naming, complexity.
- Conventional Commits (opens in a new tab)DocsFree
A simple format for commit messages that stay readable in the log.
- git-revert (Git documentation) (opens in a new tab)DocsFree
How to undo a commit by adding a new one, without rewriting history.
- Ignoring files (GitHub Docs) (opens in a new tab)DocsFree
How .gitignore keeps secrets and local data out of commits.