Creating Features
Start with a plan, when to restart, TDD with agents, design into code, and verification.
Now that you understand the codebase, it is time to build something new.
The key to shipping features with agents is breaking work into verifiable steps, so you can validate each part before moving on.
Start with a plan
Agents can help you think through what needs to be built before you start writing code.
There are many decisions to make before writing code. If you have a feature idea, you need to decide how to implement it, which components to create, which APIs to modify, and how everything fits into the existing architecture.
You can use an agent's plan mode to think through these decisions before writing code. When you send a prompt in plan mode, the agent first asks questions to help shape the right plan.
After you answer, the agent creates a structured plan with milestones that you can review and approve.
Know when to restart
Sometimes an agent builds something that misses the goal. Instead of trying to fix it with more prompts, which often leads to increasingly complicated code, it is better to discard the conversation and restart with clearer instructions.
For example, if you missed an important architecture or system-design note, the plan may be invalid and you need to restart.
Test-driven development with agents
Agents work best when they can tell whether their code is correct. When a test fails, the agent gets a clear signal that something needs to be fixed.
Engineers have used test-driven development (TDD) for a long time, but it has not always been common because it takes time and effort. With agents, it is easier than ever:
- Write the test first. Ask the agent to write tests from the expected inputs and outputs. Explicitly say that it must not write the implementation yet.
- Make sure the test fails. Ask the agent to run the test and confirm that it fails.
- Commit the test. When you are satisfied with coverage and quality, commit it.
- Ask the agent to write the code. Ask the agent to make all tests pass without changing the tests.
Example prompt for TDD:
Write tests for discount code validation.
Cover:
- valid percentage discounts
- expired discounts
- usage limit exceeded
- invalid code
Do not implement the feature yet. The tests should fail.After the tests are committed, ask the agent to write the code:
Implement discount code validation so the tests pass.
Do not modify the tests.
Keep the existing public API unchanged.Why is this effective? Because the agent can run the tests, see failures, adjust the implementation, and repeat in a loop until everything passes.
Turn designs into code
Agents can process and understand images. You can paste a screenshot or mockup directly into the agent input and ask it to build the UI.
This is useful for:
- Mockups: paste a wireframe or Figma export and ask the agent to build the component.
- Visual debugging: capture an unexpected UI state and ask the agent to investigate.
- Iteration: capture the current result and describe what needs to change.
Verify the result
The biggest risk when building quickly is skipping verification. Agents can produce code that looks correct but is wrong: it may miss requirements, skip edge cases, or introduce subtle bugs.
Here are concrete ways to help the agent verify its work:
- Tests for logic and behavior.
- Type checking for structural correctness.
- Linters for code style and patterns.
- Browser tools for UI feedback.
If the agent cannot verify its output, you will spend more time checking its work manually.
What you learned
You learned how to plan features, restart when the direction is wrong, use TDD with agents, turn designs into code, and verify results. Next, we will cover finding and fixing bugs.