liveBook · Manning

Scenario-based prompting

As explained in Coding with AI

Scenario-based prompting asks an AI system to account for explicitly described usage situations, conditions, or workflows.

Scenario-based prompting asks an AI system to account for explicitly described usage situations, conditions, or workflows. It turns vague requests into concrete requirements. section 9.6.1

Shopping-cart API

Design a REST API for a shopping cart that handles these scenarios: a guest user adds items; a user logs in and merges the cart; checkout proceeds with a failed payment. section 9.6.1

Strengthen a scenario-based prompt by naming:

  • The concrete workflows the system must support. section 9.6.1
  • The audience, technical level, constraints, or evaluation criteria when they affect the result. section 9.6.1
<requirements>...</requirements>
<implementation>...</implementation> 
<tests>...</tests>

Organize a request into requirements, implementation, and tests so scenarios remain connected to delivery and verification. section 9.6.1

How Coding with AI covers it

How deep it goes
Demonstrates the technique through a shopping-cart API prompt covering guest access, cart merging, and failed payment.
Examples
Uses a shopping-cart API with guest additions, login-based cart merging, and failed-payment checkout.
What you can do after
Apply it to design a REST API that accounts for multiple user and checkout workflows.
How it connects
Connects API design with REST APIs, authentication, checkout, payment failures, and use cases.

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