Putting It Together
An end-to-end example adding discount codes to checkout — explore, plan, build, debug, review, and capture knowledge.
Congratulations. You have learned how to work with coding agents.
You now know how to use agents to understand a codebase, build features quickly, find and fix bugs, review code effectively, and customize agents for your team's workflow.
Let us put it all together with an end-to-end example.
Scenario
You have just joined a team that maintains an e-commerce platform. You need to add discount codes to checkout.
This is a common situation. You need to explore before building, plan before implementing, and validate before merging.
Step 1: Explore the codebase
Before changing anything, explore the checkout flow. Use the agent to build a mental map.
I need to add discount codes to our checkout flow.
Before I make any changes, explain how the current checkout flow works.
Which files are involved, and how does data move from cart to payment processing?Ask follow-up questions to fill gaps:
How does our price calculation work in `src/services/PricingService.ts`?
Where do we calculate order totals, and where would discounts fit into that flow?Step 2: Plan the feature
Now that you understand the codebase, make a plan. Switch to Plan Mode and break the work down.
Example generated plan:
## Discount Codes Plan
*Overview:* Add discount-code support to checkout. Users enter a code, the system validates it, and applies the discount to the order total.
### Files to change
- Add DiscountService with validation logic (expiration, usage limits)
- Update PricingService to apply discounts
- Add discount-code input to OrderSummary
- Add tests for valid, expired, and invalid codes
### Milestones
- [ ] Create DiscountService with applyDiscount()
- [ ] Add PricingService integration
- [ ] Add code input UI to OrderSummary
- [ ] Write tests for all discount types and edge casesReview the plan. Remove steps that are too ambitious for the first iteration. Focus on the core flow, then click Build.
Step 3: Debug a failing edge case
After the build process, one test keeps failing: stacking a percentage discount with a fixed-amount discount gives different results depending on the order of application.
Ask the agent to investigate the root cause:
The stacked-discount test is failing.
The same discounts produce different totals depending on application order.
Instrument `src/services/DiscountService.ts`.
Show the before and after values at each step.The agent adds logging, runs the test, and finds that fixed discounts are applied before percentage discounts. You decide the business rule should always apply percentage discounts first.
Step 4: Review the implementation
Before merging, ask for a focused review:
Review all changes I made for the discount-code feature.
Check for bugs, missing error handling, and anything inconsistent with existing patterns.Then read the diff yourself. Confirm tests pass, types pass, and the UI behavior matches the requirement.
Step 5: Capture what you learned
While working on this feature, you discover that discount calculation must always apply percentage discounts before fixed-amount discounts. Document this as a rule:
# Pricing rules
- Apply percentage discounts before fixed-amount discounts.
- See `src/services/PricingService.ts` for the canonical calculation pattern.This completes the loop. You explored, planned, built, tested, debugged, reviewed, and captured knowledge back into rules.
The workflow
This cycle is how to work effectively with coding agents:
- Explore.
- Plan.
- Build.
- Test.
- Debug.
- Review.
- Capture knowledge.
Keep practicing
The best way to learn is to take what you have learned here and apply it.
Tools and models evolve quickly, and specific practices will keep changing over time. But the core principles remain relevant: understand context, delegate clearly, and verify results.
By continuing to push the limits of coding agents, you will get the most value from these tools.