Intermediate20 min1 prerequisite

Learn to use Windsurf's Cascade AI assistant for agentic coding, multi-file edits, and complex development tasks.

Mastering Cascade

Cascade is Windsurf's AI assistant that goes beyond chat—it's an agent that can understand, plan, and execute complex development tasks across your entire codebase.

Understanding Cascade

What Makes Cascade Different

Traditional AI chat:

Terminal
You: How do I add authentication?
AI: Here's some code... [paste yourself]

Cascade:

Terminal
You: Add authentication to this app

Cascade:
├── Reads current project structure
├── Identifies existing patterns
├── Plans implementation approach
├── Creates necessary files
├── Updates configurations
├── Tests the changes
└── Reports what was done

Cascade Modes

Cascade operates in three modes:

ModePurposeTriggered By
ChatQuestions and explanationsDefault
WriteCode generation and editsExplicit request
TerminalCommand execution@terminal or auto

Opening Cascade

Keyboard Shortcut

Terminal

Via Command Palette

Terminal
Cmd/Ctrl+Shift+P  "Cascade: Open Chat"

Click Access

Click the Cascade icon in the activity bar (left sidebar).

Basic Conversations

Asking Questions

Terminal
You: What framework does this project use?

Cascade: Based on my analysis:
- Framework: Next.js 14 (App Router)
- Evidence: next.config.js, app/ directory structure
- Version: 14.1.0 (from package.json)
- Router: App Router (app/ instead of pages/)

Getting Explanations

Terminal
You: Explain how authentication works in this project

Cascade: Authentication is implemented using NextAuth.js:

1. **Configuration** (auth.config.ts):
   - Google OAuth provider
   - Credentials provider with email/password
   - JWT session strategy

2. **Session Management** (middleware.ts):
   - Protects routes under /dashboard
   - Redirects unauthenticated users

3. **Components**:
   - LoginForm uses signIn()
   - SignOutButton uses signOut()
   - Auth context provides user state

4. **Database**:
   - User model in Prisma schema
   - Sessions stored in PostgreSQL

Write Mode

Requesting Code Changes

Trigger write mode with action words:

Terminal
"Add a favorites feature"
"Create a ProductCard component"
"Fix the bug in checkout"
"Refactor the user service"

Multi-File Operations

Terminal
You: Create a new API endpoint for user settings with full CRUD

Cascade: I'll create the user settings feature:

Creating files:
├── app/api/settings/route.ts (GET, POST)
├── app/api/settings/[key]/route.ts (PUT, DELETE)
├── lib/services/settings.service.ts
├── lib/validations/settings.ts
└── types/settings.ts

[Cascade creates all files with proper implementations]

Done! Created 5 files with:
- GET /api/settings - List all settings
- POST /api/settings - Create setting
- PUT /api/settings/[key] - Update setting
- DELETE /api/settings/[key] - Delete setting
- Service layer with business logic
- Zod validation schemas
- TypeScript types

Reviewing Changes

After Cascade proposes changes:

Terminal
┌─────────────────────────────────────────────────────────┐
 Cascade wants to make changes:                          
├─────────────────────────────────────────────────────────┤
                                                         
 Modified: src/lib/auth.ts                              
           [View Diff] [Accept] [Reject]                
                                                         
 Created:  src/components/AuthProvider.tsx              
           [View] [Accept] [Reject]                     
                                                         
         [Accept All] [Reject All]                      
└─────────────────────────────────────────────────────────┘

Terminal Mode

Automatic Command Execution

Cascade can run commands:

Terminal
You: Install and configure Tailwind CSS

Cascade: I'll set up Tailwind:

Running: npm install -D tailwindcss postcss autoprefixer
 Packages installed

Running: npx tailwindcss init -p
 Config files created

Updating tailwind.config.js...
 Content paths configured

Updating globals.css...
 Tailwind directives added

Tailwind CSS is ready to use!

Explicit Terminal Commands

Use @terminal for specific commands:

Terminal
You: @terminal Show me the current git status

Cascade: Running: git status

On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  modified:   src/components/Header.tsx
  modified:   src/lib/utils.ts

Untracked files:
  src/components/NewFeature.tsx

Context Management

Automatic Context

Cascade automatically reads:

  • Current file
  • Open editor tabs
  • Project structure
  • Package dependencies
  • Configuration files

Explicit Context

Reference specific files:

Terminal
You: Looking at @src/lib/auth.ts and @src/middleware.ts,
how can I add role-based access control?

Excluding Context

Keep things private:

Terminal
You: Explain this function (ignore .env files)

Or configure in .windsurf/settings.json:

Terminal
{
  "cascade.exclude": [
    ".env",
    "secrets/**",
    "*.pem"
  ]
}

Advanced Techniques

Iterative Development

Build features through conversation:

Terminal
You: Create a basic table component

Cascade: [Creates basic table]

You: Add sorting functionality

Cascade: [Adds column sorting]

You: Make it support pagination

Cascade: [Adds pagination]

You: Add search/filter capability

Cascade: [Adds search filtering]

Architecture Discussions

Terminal
You: I need to add real-time features. What approach would you recommend?

Cascade: Based on your current stack (Next.js + PostgreSQL), here are options:

**Option 1: Server-Sent Events (SSE)**
- Pros: Simple, works with current setup
- Cons: One-way, connection limits
- Best for: Notifications, live updates

**Option 2: WebSockets (Socket.io)**
- Pros: Bidirectional, widely supported
- Cons: Needs separate server
- Best for: Chat, collaboration

**Option 3: Supabase Realtime**
- Pros: Built on your database, minimal code
- Cons: Adds dependency
- Best for: Database-driven updates

For your e-commerce app with live inventory, I'd suggest SSE for stock updates.

Want me to implement Option 1?

Debugging Assistance

Terminal
You: I'm getting this error when submitting the form:
TypeError: Cannot read properties of undefined (reading 'email')

Cascade: Let me investigate...

[Reads relevant files]

Found the issue in /app/checkout/page.tsx:

The problem is on line 45:
```typescript
const email = session.user.email  // session might be null

The session isn't being awaited. Here's the fix:

Terminal
const session = await getServerSession(authOptions)
const email = session?.user?.email ?? ''

Want me to apply this fix?

Terminal

### Code Review

You: Review the changes I made to the checkout flow

Cascade: I've analyzed your changes. Here's my review:

Good practices: ✓ Input validation with Zod ✓ Error handling with try/catch ✓ TypeScript types for all functions

Concerns:

  1. Line 67: Missing null check on cart.items
  2. Line 89: Hardcoded timeout value (should be configurable)
  3. Line 102: No rate limiting on API endpoint

Suggestions:

  1. Add loading state for better UX
  2. Consider optimistic updates for cart
  3. Add audit logging for orders

Want me to address any of these?

Terminal

## Best Practices

### Clear Requests

❌ "Make it better" ✅ "Add error handling to all API routes using try/catch"

❌ "Fix the bug" ✅ "Fix the null pointer exception in the checkout form on line 45"

Terminal

### Scope Control

❌ "Refactor everything" ✅ "Refactor the UserService to use the repository pattern"

Terminal

### Context Hints

"Using the same pattern as @src/services/product.service.ts, create a new OrderService"

Terminal

### Verification Requests

"After making changes, run the tests and show me the results"

Terminal

## Cascade Capabilities

### What Cascade Does Well

- Multi-file code generation
- Contextual understanding
- Pattern replication
- Debugging with context
- Architecture planning
- Command execution

### Current Limitations

- Very large file changes (break into parts)
- Real-time data (knowledge cutoff)
- Binary file manipulation
- External API calls (no live requests)

## Managing Credits

### Free Tier Usage

Monitor your usage:

Profile → Usage → Cascade Credits

Terminal

Tips for efficient usage:
- Combine related requests
- Be specific to avoid back-and-forth
- Use write mode for batched changes

### Credit Conservation

❌ Multiple small requests: "Add a button" "Make it blue" "Add hover state"

✅ Single comprehensive request: "Add a blue button with hover state that..."

Terminal

## Summary

- **Open Cascade**: `Cmd/Ctrl+L`
- **Three modes**: Chat, Write, Terminal
- **Context-aware**: Understands your whole project
- **Agentic**: Plans and executes multi-step tasks
- **Review changes**: Accept, reject, or modify
- **Be specific**: Clear requests get better results

## Next Steps

Now that you understand Cascade, let's explore Flows—Windsurf's automation system for repetitive coding tasks.
Mark this lesson as complete to track your progress