Working with agents
You already know what an agent is — Agents. This lesson is how to work with one every day. With 4RGE, the reliable session rhythm is:
Describe → work → review → recover.
You say what "done" means; the agent searches, edits, and runs tools; you skim diffs, approve sensitive steps, and reset when scope drifts. Same bar as pairing with a fast teammate — not autopilot.
What this page is for
Read Agents first if the loop is new. For @ mentions, images, and the context
ring, see Prompting. Next in this track:
Understanding your codebase.
Who this page is for
The daily loop in four moves
Every feature, fix, and explore session fits this loop. Deeper playbooks live in other Learn pages — this page is the habits you reuse in all of them.
Write the outcome, not the keystrokes
The agent plans steps for you. Your job is to describe done, not every click.
Include what helps the agent match your repo:
- Acceptance — what "done" looks like (tests green, UI matches mockup, etc.)
- Constraints — no push, no new dependencies, stay in this package
- Anchors — error text, failing test name, or
@a file that shows the pattern — Prompting
Vague prompts sometimes work for tiny tasks. For anything multi-file, specific beats clever.
Keep each run focused
The most common mistake is one message that tries to do everything — unrelated file edits, wandering refactors, or a feature plus docs plus CI in one thread.
Split big work the way you would for a human teammate:
- Plan or spike (read-only or outline only)
- Implement one vertical slice
- Tests and polish
- Docs or follow-ups in a separate run if needed
For ambitious features, ask for a plan you approve before wide edits — then execute in follow-up runs per chunk. That is usually faster than one marathon chat.
Ground the agent in your repo
You do not need to attach the whole monorepo. Use two patterns:
Open the right root — monorepo package vs repo root — so search and edits stay in the tree you care about. If the agent "cannot find" a file, check what folder you opened before blaming the model.
When exploring unfamiliar code, start with questions before edits — Understanding your codebase.
Manage the conversation
Agent threads accumulate context — messages, tool output, file contents — Context.
Switching models mid-thread can change behavior; for a clean slate, finish or discard the run first — How AI models work.
Example session prompts
Copy, edit, and paste for common session moments.
Start a focused run:
Fix the failing test in auth.test.ts — JWT refresh should invalidate the old token.
No behavior change outside lib/auth. Run: pnpm test apps/web -- auth.test.ts
Do not push or open a PR.Tighten scope mid-run:
Stop — only edit files under packages/billing. Revert anything outside that path.
Restate your plan in 3 bullets before the next edit.New run recap (after explore or a long thread):
Continuing from exploration: add discount validation in @services/pricing only.
Slice 1 — unit tests + service logic; no checkout UI yet.
Run pricing tests when done.Read-only when you only want answers:
Inspect only — no file changes.
Where is checkout pricing handled and what tests cover it?Reset when stuck:
This approach isn't working. Revert uncommitted changes in cart.ts.
Start over with the smallest fix that makes checkout.test.ts pass.More patterns: Prompting. Features and bugs — Developing features, Finding and fixing bugs.
Review as you go
Treat the agent like a fast junior contributor — not an autopilot.
"Allow for session" on a trusted test command saves clicks; still read the first destructive or network command every time.
When the run goes off track
Stopping early is cheaper than merging wrong code.
What good sessions look like
A simple session flow
A pattern that works for most daily tasks:
- Open the repo (or package) you are working in
- Describe outcome, constraints, and anchors
- Let the agent search and propose — approve sensitive steps
- Review each diff; ask for a narrower fix if needed
- Verify with the tests you trust
- Commit or PR when you are satisfied — agent output is draft until you say otherwise
For long work you cannot babysit, start a cloud agent with the same clear brief — review when it finishes.