Skip to content

Building Your First Feature with Claude Code

You have Claude Code installed, configured, and connected to your tools. Your CLAUDE.md describes your project. Now it is time to actually build something. Not a toy example — a real feature that touches multiple files, needs tests, and has to pass your CI pipeline.

This guide walks through a complete development cycle: understanding the requirement, implementing across files, running tests, debugging failures, and preparing a clean PR. You will see the exact prompts that keep Claude focused and productive.

  • A repeatable workflow for feature development with Claude Code
  • Prompts that produce production-quality code, not prototypes
  • Strategies for keeping Claude on track during multi-file changes
  • Patterns for incremental implementation with verification at each step

Every feature follows the same basic loop:

  1. Understand — Have Claude analyze the requirement and affected code
  2. Plan — Get a structured implementation plan before any edits
  3. Implement — Build incrementally, one component at a time
  4. Verify — Run tests, type-check, and lint after each change
  5. Review — Have Claude review its own work for issues
  6. Commit — Create clean, descriptive commits

Let’s walk through each step with a real example: adding a search endpoint to a REST API.

Step 1: Understand the Codebase and Requirement

Section titled “Step 1: Understand the Codebase and Requirement”

Start every feature by giving Claude the full context:

Claude reads your codebase, identifies the relevant patterns, and gives you a summary. This step prevents the most common mistake: Claude generating code that does not match your existing patterns.

Once Claude understands the codebase, ask for a plan:

Based on your analysis, create an implementation plan for the search
endpoint. I want:
1. The route path and HTTP method
2. Input validation schema
3. Database query approach
4. Response format matching existing endpoints
5. Error handling following current patterns
6. Test cases we need
Number each step. Do not write code until I approve.

Review the plan. Push back where needed:

Change the database query to use a GIN index instead of LIKE.
Also, add pagination to the response -- our other list endpoints
use cursor-based pagination, not offset.

Do not ask Claude to implement everything at once. Build one piece at a time:

Implement step 1 from the plan: create the Zod validation schema
for the search endpoint in the existing validators file.

After Claude makes the change, verify:

Run the type checker to make sure the new schema is valid.

Then move to the next step:

Now implement step 2: the database query function. Use the existing
query patterns from the users module as a reference.

This incremental approach catches problems early. If Claude’s database query has a type error, you catch it before building the route handler on top of it.

Make verification a habit, not an afterthought:

Terminal window
# After each change, ask Claude to run checks
Run npm run type-check and npm run lint. Fix any errors before continuing.
Terminal window
# After implementing logic, run tests
Run the tests for the search module. If any fail, analyze the failure
and fix it before moving on.
Terminal window
# After all implementation is done, run the full suite
Run the complete test suite and the linter. Show me a summary of
any failures.

Before you commit, have Claude review its own changes:

Claude will often catch issues it introduced — missing null checks, inconsistent error formats, or tests that do not cover edge cases. Fix these before the PR.

When you are satisfied with the implementation:

Commit these changes with a descriptive message that explains what
was added and why. Use conventional commit format.

Or use the dedicated commit command:

Terminal window
claude commit

Claude generates a commit message based on the actual diff, not a generic description.

Long sessions lead to drift. If Claude starts losing context about your patterns:

Re-read our CLAUDE.md and the existing search module at
@src/modules/search/. Then continue implementing the response
formatter using the same patterns.

For features that take more than 30-40 minutes, break them into multiple sessions:

  • Session 1: Schema and database changes
  • Session 2: API route and business logic
  • Session 3: Tests and integration
  • Session 4: Review, polish, and PR

Use claude -c to continue the most recent conversation, or start fresh with claude if you want a clean context.

If Claude’s responses start to degrade or it seems to forget earlier decisions:

/compact

This summarizes the conversation and frees up context space. Follow it with a brief reminder of what you are working on.

Instead of vague requests, point Claude at exact files:

# Instead of this:
Update the search module to add filtering
# Do this:
Add a category filter parameter to @src/api/routes/search.ts
following the pattern used in @src/api/routes/products.ts

For web applications, Claude can start your dev server and check results:

Start the dev server, then make a curl request to the new search
endpoint with the query "typescript". Show me the response.

Asking for everything at once — “Build a complete search feature with tests, pagination, caching, and monitoring” will produce mediocre code. Break it down.

Not verifying between steps — If you let Claude implement five files before running the type checker, you will spend more time fixing cascading errors than you saved.

Accepting code without understanding it — Claude will explain its changes if you ask. If you do not understand why something was done a certain way, ask: “Why did you use a cursor instead of an offset for pagination?”

Ignoring the CLAUDE.md — If Claude keeps generating code that does not match your patterns, your CLAUDE.md is missing critical information. Update it and tell Claude to re-read it.

Claude modifies the wrong files — Be explicit about file paths. Use @-mentions to reference exact files rather than describing them by name.

Generated code does not compile — Run the type checker after every change. If Claude generates TypeScript errors, tell it: “The type checker found errors. Fix them before continuing.”

Tests pass but the feature does not work — The tests may not cover the actual behavior. Ask Claude to test the feature end-to-end with a real request, not just unit tests.

Claude gets stuck in a loop — If Claude keeps trying the same approach and failing, interrupt with a new direction: “Stop. That approach is not working. Instead, try [alternative approach].” Sometimes a /clear and fresh start is faster than fixing a confused session.

With your feature implemented, learn how to manage branches, create clean commits, and open PRs with Claude Code’s git integration.