Skip to main content
In this guide, you’ll learn how to craft effective prompts that steer large language models (LLMs) and tools like Cursor toward consistent, high-quality outputs. From precise requirements to creative exploration, we cover zero-shot, one-shot, few-shot, chain-of-thought, and self-consistency techniques to elevate your AI workflows.

Initial Context: Flask Task Manager Scaffold

Use this simple Flask application as a reference throughout our examples:
Always replace the default SECRET_KEY with a strong, unpredictable string before deploying to production.

Specific vs. Creative Prompts

Knowing when to lock down every detail versus when to let the model surprise you is crucial:
  • Specific Prompts
    Provide clear objectives, constraints, and examples. Ideal for scaffolding or boilerplate code that must meet exact requirements.
  • Creative Prompts
    Offer a high-level request (e.g., “Build a task manager in Python”) and let the model explore solutions. Great for brainstorming or exploring alternatives.
The image shows a code editor with a markdown file open, detailing the objectives and requirements for creating a task management application using Flask and SQLite. The editor interface includes a file explorer on the left and a chat or assistant panel on the right.

Zero-Shot Prompting

Zero-shot means “no examples provided.” You simply state the task and expect the model to understand it. Use case: Quick utility functions or well-defined algorithms. Example prompt: “Write a function that calculates the Fibonacci sequence up to n terms.”
Zero-shot is fast and straightforward, but your prompt must be unambiguous.

One-Shot Prompting

One-shot gives the model one example of the desired format, then asks it to generalize. Prompt:
  1. Here’s a JavaScript function that sorts objects by a property:
  2. Now write a function that finds the intersection of two arrays.
Model’s response:

Few-Shot Prompting (Viewport Prompting)

Few-shot provides multiple examples so the model can learn a pattern before continuing. Examples:
Prompt:
“Convert the requirement User session expires after 30 minutes of inactivity into a Jest test case.”
Model’s response:

Chain-of-Thought Prompting

Ask the model to “think aloud,” providing step-by-step reasoning before delivering a solution. Prompt:
“Design a database schema for a social media app, reasoning through entities, relationships, and constraints.”
The image shows a code editor with a Python script for a Flask application on the left and a chat interface on the right discussing the design of a database schema for a social media application.
Generated SQL:

Self-Consistency Prompting

Generate multiple candidate solutions, evaluate each, and select the best. This boosts reliability for critical tasks. Prompt:
“Write a regex matching valid email addresses, test it against these samples:
Advanced: Use the email-validator library for robust checks.

General Rules for Effective Prompting

  1. Be specific and clear.
  2. Provide context—code snippets, error logs, folder structure.
  3. Use structured formats: bullets, numbered steps, or tables.
  4. Specify output format (e.g., “Return TypeScript definitions”).
  5. Iterate and refine based on model feedback.
The image shows a code editor with a markdown file open, detailing the objectives and requirements for creating a task management application using Flask and SQLite. The editor sidebar displays a project directory structure.

Prompting Techniques at a Glance


With these prompt engineering strategies in your toolkit, you can direct LLMs to produce consistent, accurate, and well-structured results. Happy prompting!

Watch Video