Registration page for a new pet
When using Large Language Models to convert specifications into code, the boundaries of your input heavily shape the boundaries of the model's output. If you feed an LLM an API specification, its baseline assumption is that you want an API.
This short case study explores what happened when converting a standard OpenAPI 3.0 specification into a runnable Flask project using Claude.ai—and how adding a single sentence to the prompt dramatically altered the architectural and visual output.
The Experiment & The Starting Prompt
The goal was simple: take the standard
Here was the initial prompt structure:
In the next prompt I am going to enter an OpenAPI specification.
Your role is to convert this into a Flask-based program and then
save the files as a zipped-up file ready for importing into Visual
Studio Code including instructions to install and run this code in
Visual Studio Code. It must produce html interfaces.
Headless by Default vs. Explicit Constraints
The trailing sentence—"It must produce html interfaces"—turned out to be the critical leverage point in the prompt.
During initial testing without that explicit instruction, the model produced a technically flawless, "headless" solution. It generated:
Complete REST API endpoints (
GET /pets,POST /pets,GET /pets/<petId>). See REST API for more details on this,Full compliance with the OpenAPI schemas, including error handling (
400/404).Automated test scripts that all passed.
However, it did not contain a user interface.
Because an OpenAPI specification naturally defines data contracts, backend endpoints, and status codes, the LLM defaulted strictly to the boundaries of the spec. It seemed to assume a developer or an automated system was the end user. Explicitly constraining the output to include HTML forced the model to bridge the gap between pure API specifications and a human-facing application.
What Claude Produced
Once the HTML constraint was introduced, Claude not only generated the requested web frontend, but also took some creative initiative with the visual styling:
app.py: Implements the full REST API per the spec alongside dedicated HTML routes (/,/ui/pets/<id>,/ui/add), both sharing the exact same in-memory data store.templates/: A full set of Jinja2 templates covering the pet directory, individual pet detail pages, a "register a pet" form, and a custom404page.static/css/style.css: Rather than defaulting to generic Bootstrap components, Claude created a custom "punched pet-tag" visual theme.requirements.txt&README.md: Minimal dependencies (just Flask) alongside clear, step-by-step VS Code setup instructions (virtual environments, terminal execution, F5 debugging, andcurltest commands).
Practical Takeaways for Prompting & Teaching
LLMs Assume Domain Boundaries: An LLM will align its outputs with the implicit domain of your source material. Feed it an API spec, and you will get API code. If you want a full-stack prototype, you must explicitly state the end-user modality.
Rapid Prototyping for Education: For educators and developers, this workflow demonstrates how quickly standard spec files can be transformed into fully functional, human-testable boilerplate code for classroom demonstrations or student project baselines..
Comments
Post a Comment