Prompt Engineering Is Not Software Engineering
The distinction matters. Prompt engineering is instruction writing. Software engineering is architecture. Conflating the two is why so many "AI-powered" projects fail silently after the demo.
The Prompt-Only Fallacy
Here's what happens: You ask Claude to extract invoice line items from a PDF. The prompt works. For three months. Then it hallucinates a line item that doesn't exist. Or it changes its JSON structure mid-month. Or it refuses a document because the formatting is slightly different.
You adjust the prompt. You add more examples. You coax the model with carefully worded instructions. It works again. For a while.
This is not engineering. This is hope disguised as development.
Key insight: Real software engineering has guarantees. Contracts. Interfaces. A database schema doesn't change because the moon is full. A function's return type doesn't spontaneously shift from string to object. LLMs don't have these guarantees. Prompts are instructions to a probabilistic system.
No matter how well you write them, outputs can drift. Models get updated. Behaviors change.
The Case for Structured Outputs
Start with what you can control: output format.
Instead of asking Claude to generate "JSON that might be valid," require a specific schema and validate against it. Use Claude's structured outputs feature or similar. Define a TypeScript interface or JSON Schema. Enforce it.
Now Claude knows exactly what you expect. Parsing is deterministic. Validation is automatic. If the output doesn't match, you know immediately—and you can reject it, retry, or escalate.
This single constraint changes everything. Your code is no longer a best-effort interpreter of vague text. It's a client making a specific request to a structured API.
Validation Layers: The Unsung Hero
Structure alone isn't enough. You need validation logic.
After Claude returns structured output, validate the values. Is quantity a positive integer? Is total equal to quantity × unit_price? Are required fields present?
This layer catches drift, hallucinations, and malformed data before it corrupts downstream systems. It's a circuit breaker between the model and your database.
Schema Contracts: The Missing Piece
Define what success looks like in writing. A schema contract specifies:
- Input format — the document type, structure, encoding
- Output structure — exact fields, types, constraints
- Validation rules — business logic that must hold
- Failure modes — what happens if validation fails
- Retry strategy — idempotent resend? give up? escalate?
Without this, every time someone asks "what did Claude return?", the answer is "it depends."
With it, the contract is the spec. It's testable. It's debuggable. It's the thing you reference at 2am when a pipeline is producing garbage.
Why This Matters for Small Teams
You don't have a data science team. You don't have model engineers. You have a small group wearing multiple hats.
Structured outputs, validation, and contracts give you leverage. They let one engineer safely deploy an AI system to production. They make debugging possible when something goes wrong. They prevent silent failures that corrupt data.
They transform "we hope the prompt works" into "the system validates every output, and we know exactly when it fails."
The Architecture Conversation
Prompt engineering is the start. But it's not the architecture. Architecture is the decision tree around the prompt:
- What triggers the LLM call?
- How do we validate the output?
- What happens if validation fails?
- How do we log what happened?
- How do we test this?
- Who gets paged when it breaks?
These questions separate toy projects from production systems.
Write good prompts. But treat them like instructions, not infrastructure. Build the validation layer. Define the contract. Design the failure modes.
That's software engineering.
Get the schema contract template
The exact schema contract format, validation patterns, and structured output examples I use for every production AI system. Copy it. Adapt it. Ship safer.
- Schema contract template
- Validation layer patterns
- Structured output examples
Building AI systems that need to work in production?
I help small teams build production-grade AI systems with proper architecture, not just prompts. Let's talk about your next project.
Book Your Free Discovery CallNo spam. Unsubscribe anytime.