...

/

Contextual Prompt Engineering for Cascade

Contextual Prompt Engineering for Cascade

Learn how to guide Cascade effectively using contextual @-Mentions to deliver precise, informed, and targeted AI assistance.

In our last lesson, we explored the strategic differences between Chat mode and Write mode, learning when to converse with our AI and when to give it a command. Now, we’re going to dive into the art of making those commands as effective as possible.

This lesson is all about contextual prompt engineering. Our playable Snake game is a great starting point, but it has some rough edges and lacks polish. A senior engineer, when faced with such a project, would follow a clear process: first, consult the documentation to fix known issues; second, refactor the code for better structure and maintainability; and third, begin adding new, value-adding features.

We will walk through this exact professional workflow, acting as the senior engineer who directs our AI co-pilot, Cascade. Along the way, we’ll learn the tools that allow us to provide Cascade with the precise context it needs to perform these complex tasks flawlessly.

Press + to interact

The “context is king” philosophy

Before we begin, let’s reinforce a core principle. The single most effective way to improve the output of any Large Language Model is to improve the quality of its input. The AI is a brilliant expert, but it operates only on the information you provide. Your role as its collaborator is to be an excellent “research assistant,” handing it the right documents and external research so it can do its best work.

Windsurf’s Cascade provides a powerful feature called @-Mentions that allows you to explicitly bring specific context items into your chat messages. This ensures that the referenced items are guaranteed to be part of the context used by Cascade to formulate its response. This is particularly useful for complex tasks where precise context is crucial.

There are quite a few items available for @-Mentions. You can explicitly refer to various context items in your chat input by prefixing a word with @. These include:

  • Functions and classes: Only those found in the local indexed codebase and specifically for languages for which Windsurf has built abstract syntax tree (AST) parsers (e.g., Python, TypeScript, JavaScript, Go, ...