Understand two fundamental prompting techniques to better control Cursor's output: Zero-Shot (no examples) and Few-Shot (with examples).
This is the most common approach: you give Cursor a direct instruction or question without providing any examples of the desired output within the prompt itself.
Example (Chat Cmd+L):
Write a Python function that takes a list of numbers and returns the sum.
Example (Inline Cmd+K over selected code):
Convert this code to use arrow functions.
In this technique, you include one or more examples (input/output pairs) directly within your prompt before stating your final request. This helps the AI understand the desired format, style, or pattern.
Example (Chat Cmd+L - Formatting):
Transform the following comments into JSDoc format.
// Input: Function to add two numbers
// Output:
/**
* Adds two numbers.
* @param {number} a - The first number.
* @param {number} b - The second number.
* @returns {number} The sum of a and b.
*/
// Input: Calculates the area
// Output:
/**
* Calculates the area.
*/
// Input: Takes user ID, returns user object
// Output:
(Cursor should then generate the JSDoc for the last input based on the pattern).
Start with zero-shot prompts for most tasks. If the results aren't specific enough in terms of format or style, use few-shot prompting by providing 1-3 clear examples directly in your prompt to guide Cursor.