Spec a search-as-you-type box over a slow API

Vibe codingMedium25 min

Your task

Your React and TypeScript app is getting a search-as-you-type box over the GET /search?q= API. In the last prototype, typing "cat" quickly sometimes showed the results for "ca". The API team also complained about a request on every keystroke. An agent will build the real one.

Write the spec you would hand the agent.

What you know:

  • the API returns up to 20 results and takes 50 to 800 ms, depending on load
  • queries under 2 characters are useless and expensive
  • the app has no data-fetching library, and the team does not want one added
  • people use the box on phones with slow connections as well as on desktops

Then, in a few sentences: what does a careless "add a live search box" prompt get wrong?