liveBook · Manning

Prompt engineering

As explained in Vibe Engineering

Prompting is the practice of formulating and supplying instructions or context to an AI model to guide its output.

Prompt engineering formulates instructions and context to guide an AI model’s output. A prompt that leaves the model to guess where a change belongs may work on a small codebase, but can miss important work. Rephrasing alone is not a substitute for identifying the missing context or checking the result. section 2.4.3

Make the missing condition explicit

A test-migration prompt asking to rework non-JUnit 5 tests specifies the framework but not where to look. A more targeted prompt asks whether tests import JBoss-related libraries and, if so, to replace those imports with JBoss-agnostic code using Jupiter. Both approaches produced similar changes in this case, but the second states the condition that exposed the missed step. section 2.4.3

For generated SQL, a prompt can combine a role, the user’s request, table creation statements, and recent queries. This gives the model concrete schema and usage context rather than relying on a request alone. The resulting SQL still needs evaluation; framing the model as an expert is not evidence that its output is correct. 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 request, table definitions, and recent queries. section 6.2

Check the assumption inside the prompt

A request to move away from a single-threaded implementation led to several concurrent strategies without a challenge to whether concurrency was needed. The generated benchmark also assumed 100,000 accounts; a production-like scenario used 10,000. Its custom benchmark had potential measurement problems, so the results should not be treated as conclusive without a sounder benchmark such as JMH. section 7.1.2

Use prompts as part of an engineering loop:

  • State the task, relevant scope, and constraints; inspect what the model changed and refine the prompt when a step is missed. section 2.4.3
  • Question constraints before asking for an implementation, and validate performance claims with representative inputs and appropriate benchmarks. section 7.1.2
  • Keep reusable rules focused and current. Record useful discoveries, and periodically check rules for unused, duplicated, or contradictory guidance. section 9.1.3
  • Match effort to the problem: a direct prompt may retrieve a known answer, while other tasks require reasoning and checks. AI review can identify issues, but cannot infer unstated requirements. section 3.6.4 section 8.2.3

How Vibe Engineering covers it

How deep it goes
Explains prompt refinement and programmatic prompt assembly, then examines assumptions and verification through worked engineering cases.
Examples
Uses JBoss test migration, schema-aware SQL generation, and an account-lookup concurrency benchmark as concrete cases.
What you can do after
Apply prompting to specify tasks and context, inspect generated changes, and test assumptions rather than trusting output automatically.
How it connects
Connects prompting with context engineering, benchmarking, and AI code review.

Also explained in

Compare how 51 books explain prompt engineering →

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.