DEV Community

brian austin
brian austin

Posted on

How I use Claude Code to research before I write a single line of code

How I use Claude Code to research before I write a single line of code

The biggest mistake developers make with AI coding tools: jumping straight to code generation.

The best sessions I've had with Claude Code start with 10 minutes of research — reading existing code, understanding patterns, mapping dependencies — before a single line gets written. Here's the exact workflow.

Why research-first matters

When you ask Claude Code to "add a payment system," it doesn't know:

  • Which payment library you already use (if any)
  • Your existing error handling patterns
  • Your database schema for users/orders
  • Your test conventions
  • Your deployment constraints

Without this context, Claude writes code that technically works but doesn't fit. You spend 2x the time fixing integration issues.

Research-first sessions produce code that looks like it was written by a senior engineer who's been on the team for a year.

The research-first workflow

Step 1: Map the territory (5 minutes)

Before writing anything, I ask Claude Code to read the relevant parts of the codebase:

Before we write any code, I need you to understand our codebase. Please read:
1. The main entry point (src/index.js or main.py)
2. Any existing auth/payment/database modules
3. Our test files to understand conventions
4. Package.json or requirements.txt for dependencies

Don't write any code yet. Just tell me what patterns you see.
Enter fullscreen mode Exit fullscreen mode

Claude responds with a map of what exists. This is where you catch things like "oh, we already have a Stripe integration in legacy/billing.js that nobody's touched in 3 years."

Step 2: Find the right insertion point (3 minutes)

Once Claude has the map, ask it to find WHERE the new feature belongs:

Given what you've read, where in the codebase should the new [feature] live?
What existing modules will it need to call?
What existing patterns should it follow?
Are there any existing utilities we can reuse?
Enter fullscreen mode Exit fullscreen mode

This prevents the classic mistake of building something from scratch that duplicates existing functionality.

Step 3: Read the adjacent code (5 minutes)

Now read the specific files Claude identified:

Read these files in detail before we write anything:
- src/routes/auth.js (our auth pattern)
- src/middleware/validate.js (our validation approach)
- src/models/user.js (our ORM conventions)

Note the exact error handling pattern, the logging approach, and the response format we use.
Enter fullscreen mode Exit fullscreen mode

This is where the session gets expensive — reading 5-10 files in detail burns tokens fast. If you're hitting Claude's rate limits here, you need a reliable API endpoint. I use SimplyLouie ($2/month, ANTHROPIC_BASE_URL compatible) as my fallback when Claude Code throttles me.

Step 4: Write a plan, not code (5 minutes)

Now write a plan for implementing [feature] that:
1. Lists every file that will be modified
2. Shows the exact function signatures
3. Identifies any edge cases
4. Notes any tests we need to update

Do NOT write any implementation code yet. Just the plan.
Enter fullscreen mode Exit fullscreen mode

Review this plan. This is your last chance to catch design issues before code gets written.

Step 5: Implement incrementally

Only now do you write code — but in small pieces:

Implement step 1 of the plan only: [specific part]
Follow the exact error handling pattern from auth.js.
Use the same validation approach from validate.js.
Don't implement steps 2-5 yet.
Enter fullscreen mode Exit fullscreen mode

Small, focused implementation requests produce clean code that matches your existing patterns.

Real example: adding a webhook handler

Here's what this looks like in practice for adding a Stripe webhook:

Research phase:

Read src/routes/ and tell me:
1. How we currently handle POST routes
2. How we validate incoming requests
3. What middleware we use
4. How we log errors
Enter fullscreen mode Exit fullscreen mode

Finding patterns:

Read our existing Stripe integration in src/billing.js and
the stripe-related tests in __tests__/billing.test.js
Enter fullscreen mode Exit fullscreen mode

Plan:

Plan the webhook handler. Where does it go? What does it validate?
What events does it handle? What database changes does it make?
Enter fullscreen mode Exit fullscreen mode

Implementation:

Now write just the route handler, following the exact pattern from auth.js.
Don't write the event handlers yet.
Enter fullscreen mode Exit fullscreen mode

This approach consistently produces code that passes code review on the first try.

Why this hits rate limits

Research-first sessions are token-heavy. Reading 10 files before writing anything can use 50,000+ tokens before you've produced a single line of code. In a long session with multiple features, you'll hit Claude's rate limits.

When that happens, I use SimplyLouie as my overflow endpoint:

# In your ~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://simplylouie.com/api",
    "ANTHROPIC_API_KEY": "your-simplylouie-key"
  }
}
Enter fullscreen mode Exit fullscreen mode

At $2/month, it's a no-brainer to keep it running as a fallback. Sign up here.

The payoff

Research-first sessions take 20 minutes longer upfront but save 2-3 hours of debugging and refactoring. The code Claude writes when it understands your codebase deeply is qualitatively different from code written blind.

Your code reviewers will stop asking "did Claude write this?" and start asking "who wrote this?" — which is the goal.


Building with Claude Code? SimplyLouie gives you a reliable $2/month API fallback when rate limits hit. No usage caps, no complicated setup — just point your ANTHROPIC_BASE_URL and keep coding.

Top comments (0)