Skip to main content

Developing features

Building a feature with an agent is not one giant prompt. With 4RGE, the reliable path matches good engineering — just faster:

Spec → plan → slice → review → verify → ship.

You say what "done" means and what to avoid; the agent implements and runs tests; you approve each diff and decide when to merge. This lesson shows how to run that loop without losing control of scope or quality.

What this page is for

You want to…This page helps you…
Run the feature loopSpec → plan → slice → review → verify → ship
Turn an idea into workWrite acceptance criteria the agent can hit
Reduce surprise diffsPlan before wide edits
Ship incrementallyVertical slices instead of one mega-change
Match your codebaseReuse patterns instead of inventing new ones
Know when you're doneVerify with tests and review before merge
Part of 4RGED Learn · Coding agents

Explore first — Understanding your codebase. Session habits — Working with agents. For prompt examples and incremental work, see Prompting.

Who this page is for

You are…Focus on
Building your first feature with an agentWrite a mini-spec → Build in slices
Daily developerPlan before you code + Verify
Team leadShare mini-spec + slice norms with the team
Large or parallel workWhen to hand off to cloud

From idea to shippable

A practical flow that works for most features:

StepYouAgent
1. Orient (if needed)Ask where similar code livesSearch and explain — Understanding your codebase
2. SpecUser-visible behavior + constraintsConfirms understanding; asks clarifying questions
3. PlanReview steps; cut scope for v1Outline files and order — no code yet (or Plan mode)
4. BuildApprove one slice at a timeEdit, run tests, show diffs
5. VerifyRun CI-minded checksFix failures in the same run or the next
6. ShipOpen PR / merge when you are satisfiedDraft description if you ask

Skip heavy planning for tiny, familiar edits. Use the full flow when the feature touches multiple files, APIs, or behavior you will regret getting wrong.

SituationStart with
One file, you know the areaOutcome + test command — skip formal plan
Multi-file or new APIMini-spec → Plan → slices
Unfamiliar codeExplore first — Understanding your codebase
Long or parallel workSame mini-spec, hand off to cloud
End-to-end walkthroughPutting it all together (discount code example)

Write a mini-spec

You do not need a formal PRD. You do need enough detail that "done" is obvious.

Include:

SectionExample
Outcome"User can apply a discount code at checkout; total updates before tax"
Acceptance"Invalid code shows inline error; valid code reduces total; total never below zero"
Scope"Checkout UI + pricing service only — no admin UI this sprint"
Constraints"Match OrderSummary patterns; no schema migration; run pnpm test in apps/web"
Anchors@ similar component or API route — Prompting
Weak specStronger spec
"Add discounts""Add discount code field on checkout; validate via existing pricing service pattern in @services/pricing"
"Make it like Stripe""Copy our existing coupon flow in @checkout/CouponField.tsx; same error UX"

Answer the agent's clarifying questions — they prevent wrong assumptions early.

Plan before you code

For multi-file work, align on approach before source edits:

OptionWhen to use
Plan modeLarge, ambiguous, or high-risk work — agent documents approach in markdown before changing code
Outline in chat"List steps and files; don't change code yet"
Saved planKeep the outline in repo or notes for the team and the next run

Review the plan like a design doc: remove steps that are not v1, add missing constraints, name the files you expect to touch. Then implement step 1 only in a focused run — Working with agents.

The hard part is what to build

Many failures are wrong scope, not wrong syntax. Time on the plan saves time on revert.

4RGE can track multi-step progress in the UI during long runs. For details on modes and planning, see Prompting and your product quickstart.

Build in slices

Prefer vertical slices — one thin end-to-end path — over "all backend first, UI later" unless your team already works that way.

SliceExample for "discount codes"
1Validate code + apply to total in pricing service + unit tests
2Checkout input wired to validation + UI states
3Edge cases, analytics, docs

After each slice:

  1. Review the diff — scope creep shows up here
  2. Run the tests you named in the spec
  3. New message or run for the next slice if context is getting heavy — Context

Commit or stash when a slice is good — same as human workflow. "Scaffold, wire, test, polish" is still valid; the agent just accelerates each pass.

Example feature prompts

Copy, edit, and paste — use @ to anchor files in your repo.

First message (mini-spec + slices):

Add a discount code field on checkout.
 
Done when:
- Invalid code shows inline error (no page crash)
- Valid code lowers total before tax; total never below zero
- Match existing checkout UI in @checkout/OrderSummary.tsx
 
Build in two slices: (1) pricing validation + unit tests,
(2) checkout UI wiring.
Run: pnpm test apps/web -- checkout
Do not change the task list API or database schema.

Plan only (no code yet):

Before editing source: outline steps and files for the discount code feature above.
List risks and what we should cut for v1. Do not write code yet.

Slice 1 (backend / logic first):

Implement slice 1 only: validate discount code in the pricing service and add unit tests.
Follow patterns in @services/pricing. No checkout UI changes yet.
Run pricing tests when done.

Slice 2 (UI wiring):

Implement slice 2: wire checkout input to validation; match @checkout/OrderSummary.tsx UX.
Run: pnpm test apps/web -- checkout

Verify before merge:

1. pnpm test apps/web -- checkout must pass.
2. Flag anything outside discount scope in the diff.
3. One-sentence summary of what shipped — I'll merge if green.

When the direction is wrong (reset):

This diverged from the spec — wrong pattern in pricing. Revert changes outside
packages/billing. Restate plan for slice 1 only; match @services/pricing exactly.

More templates: Prompting. After the diff exists, optional review pass — Reviewing and testing code.

Match your repo

Features go wrong when the agent invents a parallel pattern.

HabitPrompt hint
Copy existing UI"Same layout as @settings/ProfileForm.tsx"
Copy API style"Follow @api/user/profile/route.ts error shape"
Respect boundaries"Only under packages/billing"
Learn first"Show how we already do X" before "Add X"

Project rules and plugins nudge the agent toward team conventions — Customizing agents. You still review the diff.

Verify before you merge

Agent-generated code is draft until you say otherwise.

CheckWhy
Tests you specifiedProves behavior, not narrative
Lint / typecheckCatches slop the agent missed
Manual smokeUX and edge cases tests skip
Second passAsk for review of your diff — Reviewing and testing code
Security / dataEspecially auth, payments, PII — Agent security

What good feature work looks like

SignalMeaning
"Done" was defined upfrontAcceptance criteria in the first message — not discovered at merge time
Plan matched the diffFiles touched were expected; scope did not creep
One slice ≈ one reviewable PRYou could explain each chunk in a standup
Named tests went greenBehavior is provable — not only described in chat
Patterns match the repoNo parallel folder or duplicate abstractions
You would merge without the agentSame bar as a human teammate's PR
Don't merge on confidence tone

Polished explanations ≠ correct code — Hallucination & limitations.

When to hand off to cloud

Use local agents when you are pairing interactively — quick approvals, tight loops.

Use cloud agents when:

SituationWhy cloud
Long implementationRuns continue after you close the laptop
Parallel featuresYou stay on one task; cloud handles another
End-to-end from a solid planHand off the spec + plan; review diff or PR when done

Cloud still needs a clear brief — vague cloud jobs produce vague diffs. Same mini-spec discipline.

When the first build is wrong

Fixing a bad direction with ten follow-up messages often loses to reset:

  1. Revert agent changes (checkpoint, Git, or discard files)
  2. Tighten the spec or plan — what was missing?
  3. Run again — one slice, not "fix everything"

This is faster than arguing with a thread that already went down the wrong path — Working with agents.

Habits that work

  1. Mini-spec in the first message — acceptance + constraints.
  2. Plan for multi-file — Plan mode or outline-only pass.
  3. One slice per approval cycle — review before the next expansion.
  4. Name tests to run — agent and CI should agree on green.
  5. Capture learnings in rules — e.g. "percentage before fixed discounts" for next time.
  6. Explore unfamiliar areas first — Understanding your codebase.

Where to go next

Your goalNext step
Fix defects in the featureFinding and fixing bugs
Review & test passReviewing and testing code
Prompt templatesPrompting
Long background runCloud agents overview
End-to-end examplePutting it all together
First runQuickstart

Questions about developing features?

QuestionAnswer
Do I need Plan mode every time?No — small edits can go straight to Agent mode; plan for multi-file or risky work.
How big should one slice be?Roughly one PR you'd willingly review in a sitting.
Can the agent open the PR?Depends on workflow and approvals — you still own merge.
What if it changes files outside scope?Stop, revert, restate scope — Working with agents.
Should tests be in the same run?Yes — name them in the spec so "done" includes green tests.
Does this use more tokens?Multi-step features do — Tokens & pricing.
Tiny one-file change — still need a mini-spec?Lightweight is fine — outcome + test command; skip slices and formal plan.
How is this different from Putting it all together?That page is one full walkthrough; this page is the habits for any feature.
Agent invented a new pattern?Stop, point at an existing @ example — Match your repo.
Bug mid-feature?Switch to debug loop — Finding and fixing bugs.