Skip to main content

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

You want to…This page helps you…
Run the daily loopDescribe → work → review → recover
Get better results fasterWrite goals the agent can act on
Avoid scope creepOne task per run; split big work
Use context wiselyWhen to @ files vs start fresh
Stay in controlReview diffs and approvals as you go
Recover from bad runsStop, narrow, or reset without panic
Part of 4RGED Learn · Coding agents

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

You are…Focus on
New to agent codingWrite the outcome → A simple session flow
Daily developerKeep each run focused + Manage the conversation
Team leadShare this page as team norms; pair with Agent security
Power userPrompting for advanced patterns — this page stays practical

The daily loop in four moves

MoveYouAgent
1. DescribeOutcome, constraints, anchors (@ files, test names)Clarifies if needed; searches and plans
2. WorkApprove sensitive tools; queue next step if busyReads, edits, runs tests — Tools
3. ReviewSkim each diff; push back on scope creepNarrows or fixes when you restate scope
4. RecoverNew run, checkpoint, or tighter brief when off trackStops guessing; follows your reset

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.

SituationSession choice
Same task, going wellStay in the run — context helps
New bug or featureNew run with a three-line recap
Context ring nearly fullFinish one slice; fresh run for the next — Context
Unfamiliar codeRead-only explore first — Understanding your codebase
Long work, async reviewSame clear brief on cloud

Write the outcome, not the keystrokes

The agent plans steps for you. Your job is to describe done, not every click.

Weaker askStronger ask
"Add a settings page""Add a settings page with display name, email toggle, and theme dropdown — match our existing profile page layout"
"Fix the bug""Fix the failing test in auth.test.ts — JWT refresh should invalidate the old token"
"Refactor auth""Extract token validation from middleware.ts into lib/auth/validate.ts; no behavior change; tests must pass"

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.

Signal of scope creepWhat to do
Edits files you did not mentionStop; restate only the paths or area in scope
Loses an earlier constraintPaste the constraint again in one line, or new run with a short recap
Keeps retrying the same failed approachFresh conversation; smaller sub-task
Context ring nearly fullFinish one slice; new run for the next — Context

Split big work the way you would for a human teammate:

  1. Plan or spike (read-only or outline only)
  2. Implement one vertical slice
  3. Tests and polish
  4. 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:

You know…Do this
Exact files or folders@ mention them — Prompting
The area, not the pathDescribe it ("where we handle checkout") and let the agent search
A pattern to copyPoint at one example file: "same structure as @components/Form.tsx"
What brokePaste stack trace or @ terminal output

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.

SituationSuggestion
Same feature, going wellKeep going — earlier context helps
New feature or bugNew run with a three-line recap
Agent loops or forgetsNew run beats a tenth "remember when…"
Agent still busyQueue the next instruction instead of interrupting — Agent overview
Prior run had useful workReference past chat when the product supports it — Prompting

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.

MomentHabit
File diff appearsSkim paths and intent — reject wild unrelated changes
Approval promptRead shell commands and integration calls before approving — Tools
Test outputConfirm failures are real fixes, not skipped tests
Before mergeYour CI and review bar — same as human-written code
Approve with intent

"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

ProblemFirst move
Wrong file or API inventedAsk it to read and verify — Hallucination & limitations
Too many changesDeny remaining edits; new run with tighter scope
Bad approach mid-refactorRestore a checkpoint or Git, then retry one step — Agent overview
Stuck on approvalsClarify constraint ("inspect only") or fix missing secret with admin

Stopping early is cheaper than merging wrong code.

What good sessions look like

SignalMeaning
One outcome per runYou can name "done" in one sentence
Diffs match the askNo surprise files; scope stayed tight
You approved on purposeDestructive or network commands were read, not rubber-stamped
Tests you named went greenVerification was objective — not chat confidence
Clean handoffNext task got a new run instead of a noisy mega-thread
You'd ship itSame merge bar as a human PR — Reviewing and testing code

A simple session flow

A pattern that works for most daily tasks:

  1. Open the repo (or package) you are working in
  2. Describe outcome, constraints, and anchors
  3. Let the agent search and propose — approve sensitive steps
  4. Review each diff; ask for a narrower fix if needed
  5. Verify with the tests you trust
  6. 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.

Where to go next

Your goalNext step
Explore before editingUnderstanding your codebase
Build a feature end-to-endDeveloping features
Fix a bugFinding and fixing bugs
@ mentions & context ringPrompting
Checkpoints & queueAgent overview
First runQuickstart

Questions about working with agents?

QuestionAnswer
How long should one run be?One outcome — often 5–30 minutes of agent work, not a whole epic.
Should I @ every file?Only anchors; search handles discovery — Context.
Can I interrupt?Yes — stop, refine, or queue; see Agent overview.
Why did it edit files I did not want?Usually scope creep — tighten the ask or split the task.
Do I need a different model for planning?Optional — many teams use a capable model for plan, fast model for small edits.
Is this different from cloud agents?Same habits; cloud suits long runs you review later — Cloud agents.
Explore and implement in one chat?Possible but messy — explore read-only, then new run to implement.
Agent keeps forgetting constraints?Paste constraints again or start fresh with a three-line recap — Context.
How is this different from Putting it all together?That page is one full example; this page is daily session habits for any task.
When should I use Plan mode?Multi-file or risky work — outline before edits — Developing features.