liveBook · Manning

Prompt

As explained in Vibe Engineering

A prompt is an input instruction or request supplied to an AI model to elicit a response or action.

A prompt is an instruction or request supplied to an AI model to elicit a response or action. In a coding workflow, a vague request can invite the model to fill gaps with assumptions: a request to make a lookup multithreaded, for example, produced several concurrent implementations without establishing that they would improve performance. section 2.7.2 section 7.1.2

Precision trades prompting effort for control. Supplying less context can save work when the model guesses correctly, but it can also introduce unnecessary code or miss requirements. Supplying more context takes effort; specify important boundaries explicitly when assumptions about compatibility, performance, edge cases, or scope would be costly. section 2.7.2

Build a prompt around the decisions the model should not have to guess:

  • State the task and its boundaries. For a focused change, ask the model not to add enhancements based on assumptions. section 2.7.2
  • Provide relevant context and label examples. Identify a service, persistence entity, or domain error rather than pasting unannotated snippets and expecting the model to infer their roles. section 3.2.2
  • Specify inputs and deliverables. A data-analysis request can name the dataset path, columns, calculations, chart types, and export location; an omitted path can make generated code look in the wrong directory. section 4.3.1
  • Add operational guardrails. For deployment generation, name the required registry and secret-management mechanism instead of relying on the model to choose safe defaults. section 6.4.4

Constructing a SQL prompt

A SQL generation service combines an expert role, the user's request, table-creation statements, and recent queries as examples. It then requests SQL without explanatory formatting. The request separately limits response tokens to 500; that limit is an output safeguard, not a substitute for specifying the desired result. section 6.2

Listing 6.11 The SqlGeneratorServiceImpl#buildPrompt() method
String buildPrompt(SqlGeneratorQueryRequest request) {
    StringBuilder prompt = new StringBuilder();
    prompt.append("You are a SQL expert. Generate a SQL query based on the following information:\n\n"); #A
    prompt.append("User Request: ").append(request.getUserPrompt()).append("\n\n"); #B
    prompt.append("Available Tables:\n"); #C
 
    for (Table table : request.getTables()) {
      prompt.append("- ").append(table.getCreateTableSql()).append("\n"); #C
    }
 
    #D
    if (request.getNLastQueries() != null && !request.getNLastQueries().isEmpty()) {
      prompt.append("\nRecent Queries for those tables:\n");
      for (int i = 0; i < request.getNLastQueries().size(); i++) {
        prompt.append(i + 1).append(". ").append(request.getNLastQueries().get(i)).append("\n");
      }
      prompt.append("\n");
    }
 
    prompt.append("Please generate a valid SQL query that addresses the user's request. ");
    prompt.append("Only return the SQL query without any additional explanation or formatting."); #E
 
    return prompt.toString();
  }

Inspect how the SQL prompt is assembled from the user request, table definitions, and recent queries. section 6.2

A well-specified prompt is not proof that the answer works. Run generated code, check its outputs, and measure claims against the intended workload. In one lookup benchmark with 10,000 accounts, the single-threaded implementation took 25 ms and the parallel stream took 63 ms, despite the initial prompt seeking a performance improvement through multithreading. section 7.1.2 section 4.6.3

More elaborate prompting is not always better. A one-line bug description with a screenshot identified a known game glitch after a coding agent had spent time pursuing unsuccessful hypotheses. Choose the amount of context and reasoning the task needs, then check the result. section 3.6.4

How Vibe Engineering covers it

How deep it goes
Explains prompt construction through labeled examples, explicit constraints, and an implemented SQL prompt, then checks generated results.
Examples
Uses a labeled authentication code set and a pharmaceutical notebook request to illustrate prompt design.
What you can do after
Apply prompts to coding and analysis tasks with explicit context and constraints, then evaluate generated outputs.
How it connects
Connects prompts to context engineering, multishot prompting, hallucination, and benchmarking.

Also explained in

Compare how 64 books explain prompt →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.