Skip to main content
All articles

Using Claude to Write Better Code: Prompting Patterns That Actually Work

Claude isn't just for content — it's a serious engineering tool when you know how to prompt it. Here are the patterns I use every day.

G

Glauber Bannwart

March 9, 2026 · 3 min read

Using Claude to Write Better Code: Prompting Patterns That Actually Work

Most people use Claude like a search engine with friendlier output. That's leaving most of its value on the table.

Here are the prompting patterns I use for software development that consistently produce better results.

Pattern 1: The Context Dump

Before asking Claude to write or modify any code, give it the relevant context:

Context:
- This is a Next.js 16 app with App Router
- We use Prisma 7 for the database (PostgreSQL)
- Auth is handled by Clerk
- All server components use async/await; client components use React state

Here is the relevant existing code:
[paste code]

Task: Add a rate-limited endpoint for [X]

The context dump removes the need for Claude to guess at your stack, patterns, or constraints. The output matches your codebase rather than some generic version of the technology.

Pattern 2: Show, Don't Tell

Instead of describing what you want, show an example of the pattern you want followed:

"Here is an existing API route that follows our pattern [paste example]. Write a similar route for [new endpoint]. Follow exactly the same patterns for auth, validation, error handling, and response format."

This works better than describing the pattern because Claude can extract the exact conventions from real code rather than approximating them from a description.

Pattern 3: The Constraint List

When you want Claude to code something specific without going off-script:

"Write a function that [does X]. Constraints:

  • Use only the libraries already imported
  • No more than 30 lines
  • No comments unless the logic is non-obvious
  • TypeScript strict mode compatible
  • Error handling for [specific case] only"

Constraints prevent Claude from adding abstractions, extra error handling, or "improvements" you didn't ask for.

Pattern 4: The Review Request

Instead of asking Claude to rewrite code, ask it to review it:

"Review this code for:

  1. Security vulnerabilities (especially injection and auth issues)
  2. Performance problems that would appear under load
  3. TypeScript type safety issues

For each issue found, rate it P0 (critical), P1 (important), P2 (minor). Only flag real issues, not style preferences."

This gets you specific, actionable feedback rather than a generic "looks good, but consider..."

Pattern 5: The Debugging Loop

When you're stuck on a bug:

"I'm debugging [problem]. Here is what I've already tried and ruled out:

  • [attempt 1] → [result]
  • [attempt 2] → [result]

Here is the relevant code: [code] Here is the error: [error]

What are the 3 most likely remaining causes?"

The "already tried" section is critical — it prevents Claude from suggesting things you've already ruled out.

What Doesn't Work

  • Vague tasks: "Make this better" produces worse results than "Fix the N+1 query problem in this function"
  • Very long prompts with everything mixed together: Structure > length
  • Iterating without re-providing context: Claude's context window has limits; when starting a new angle, re-provide the core context

FounderSequence is built with Claude integration throughout. See what we've built →