DEV Community

Cover image for How to Use Claude 4 Opus & Sonnet with Cursor & Windsurf
Emmanuel Mumba
Emmanuel Mumba

Posted on

How to Use Claude 4 Opus & Sonnet with Cursor & Windsurf

Claude 4 by Anthropic just dropped, and with it, developers are finally getting what they’ve been asking for: less hallucination, more code fluency. Whether you're working on complex logic or debugging a spaghetti codebase, Claude 4 Opus (the most powerful model) and Claude 4 Sonnet (the lighter, faster sibling) bring reliable, context-aware support.

Want to test AI APIs in seconds? Apidog lets you design, mock, and test Claude, GPT, or any AI endpoint in one clean UI—no Postman or code needed. Build your full AI stack from prompt to production, effortlessly.

But here’s the twist: how you use Claude matters as much as what Claude can do. If you’re writing production code, you don’t want to bounce between browser tabs or paste snippets into a chatbot. That’s where Cursor and Windsurf come in—two purpose-built tools that let you work with Claude inside your development flow, not around it.

This guide shows you how to combine Claude 4 (Opus and Sonnet) with Cursor and Windsurf, including setup steps, prompt patterns, and smart usage tips for faster, cleaner code.

his guide shows you

1. What Are Claude Opus and Claude Sonnet?

Before we dive into tools, a quick comparison:

Setup Steps

Setup Steps

Think of Opus as your system architect and Sonnet as your hands-on coding assistant. Most devs use both depending on the moment.

2. Using Claude 4 with Cursor

Setup Steps

Cursor is a Claude-native fork of VS Code—except everything is AI-augmented. With Claude 4 integrated natively, it offers more than autocomplete or chat. It’s about full context reasoning, refactors, and edits without leaving your editor.

Setup Steps

Download Cursor from cursor.com

Download Cursor

Open Cursor → Settings → Models → Select Claude 4 Sonnet)

Setup Steps

Setup Steps

Add your OpenRouter Anthropic API Key if using custom provider

Setup Steps

Setup Steps

Setup Steps

Setup Steps

How to Use It Smartly

  • Highlight code → "Ask Claude": Explain or fix logic with full file context
  • Refactor → "Claude: Rewrite": Rewrite functions or change styles
  • Inline edits: Press Cmd + Shift + Space to suggest better patterns
  • Test-gen: “Generate unit tests for this method” works right out of the box

Cursor’s killer feature? It reads your entire project. You don’t have to paste file paths—Claude knows the import tree, variables, and even comments.

3. Using Claude 4 Opus & Sonnet with Windsurf AI Editor

Windsurf AI Editor is a modern, lightweight, and AI-first code editor designed for developers who want to deeply integrate large language models like Claude 4 Opus and Sonnet into their development workflow. Unlike traditional editors, Windsurf isn’t just a place to write code — it’s where code collaborates with you.

What Makes Windsurf Different?

At its core, Windsurf is built around the concept of AI-native development. It doesn't just plug an LLM into your workflow as a chatbot — it integrates the model at every layer of the editing experience. This includes:

  • Real-time contextual suggestions
  • AI-assisted file exploration
  • Multi-turn in-editor conversations
  • Refactor and generate features with semantic understanding of your entire project

All of this is backed by Claude 4 models, giving you access to one of the most advanced reasoning engines currently available.

Setting Up Claude 4 in Windsurf

To use Claude 4 Opus or Sonnet in Windsurf, follow these basic steps:

  • Download Windsurf AI EditorYou can get the latest version from windsurf.com
  • Create or Log in to Your Account

Download Cursor

Download Cursor

Windsurf uses account-based syncing for model settings, history, and API key storage.

  • Add Your Anthropic API Key

Navigate to the settings tab.

Click “Model Provider API Keys,”

Setup Steps

Paste your API key (you must have access to Claude 4 via Anthropic’s developer console).

Setup Steps

Model ConfigurationYou can customize system prompts, set temperature and token limits, and toggle between models per workspace.

How Windsurf Uses Claude in Real Time

Once setup is complete, Windsurf treats Claude as an embedded development partner:

  • Inline Suggestions: As you type, Windsurf suggests code completions using Claude’s context-aware reasoning.
  • On-Demand Commands: Highlight code and right-click to "Explain", "Refactor", or "Document" using Claude 4. The results are streamed into your buffer, editable and revertible.
  • Conversation Mode: A side panel lets you chat with Claude in real time, with access to your project’s file structure, previous commands, and even git diffs.
  • Ask Claude Anything: Whether it’s help with a regex, writing test cases, or debugging a stack trace, you can select text and hit Cmd+Shift+K (or your custom shortcut) to initiate a Claude prompt contextualized to that snippet.

Ideal Use Cases for Claude in Windsurf

  • Code Reviews: Have Claude suggest feedback, improvements, or document unclear logic in PRs.
  • Rapid Prototyping: Start with a simple comment, let Claude generate scaffolding, and iterate collaboratively.
  • Refactoring Legacy Code: Claude can explain, simplify, and re-structure old codebases based on modern patterns.
  • In-Editor Learning: Get language or framework explanations without switching to a browser or ChatGPT window.

4. When to Use Cursor vs Windsurf

Use Cursor when you want GUI integration and full-project intelligence.Use Windsurf when you want terminal power, simplicity, or are SSH’d into a remote box.

5. Best Practices for Claude Workflows

  • Refactor in chunks. Claude 4 is smart, but not perfect—ask it to break big functions into smaller pieces before rewriting.
  • Be explicit. The best prompts are specific: “Rewrite this in idiomatic Rust with error handling” > “Make it better.”
  • Use Opus when stakes are high. For data processing, regex generation, or API logic—Opus catches edge cases Sonnet might miss.
  • Pair with version control. Always review Claude’s output with a diff tool (git diff, Windsurf’s review mode, or Cursor’s timeline).

Conclusion

Claude 4 isn’t just a chatbot—it’s becoming a true coding partner. And with tools like Cursor and Windsurf, that partnership feels native, not bolted on. Whether you want GUI refinement or terminal simplicity, the Opus and Sonnet models give you flexibility without sacrificing code quality.

By learning how and when to use each tool + model, you’ll save hours of mental friction—and maybe rediscover the joy of working with a sharp AI that doesn’t hallucinate your import paths.

Top comments (6)

Collapse
 
audrey_lopez profile image
Audrey Lopez

Perfect, I was searching about how to turn on Claude 4 on Windsurf, apparently it is BYOK?

Collapse
 
therealmrmumba profile image
Emmanuel Mumba

Yes, that’s correct — Claude 4 on Windsurf uses a BYOK (Bring Your Own Key) model. You’ll need to have API access to Claude 4 via Anthropic and then plug in your API key within Windsurf’s settings. Once set up, it should integrate seamlessly.

Collapse
 
kristen69 profile image
Kristen

Yeah, you can use Claude 4 (Sonnet and Opus) on cursor. But for Windsurf you need to bring your own key.

Collapse
 
nevodavid profile image
Nevo David

growth like this is always nice to see. kinda makes me wonder - you think habits or just pure curiosity keeps people coming back to new tools over time?

Collapse
 
rowleks profile image
Rowland

Very direct and succinct!

Are the claude 4 models free to use?

Collapse
 
taskinfinity profile image
taskinfinity

Nice!