Prompt engineering has evolved far beyond appending "please be helpful" to a user's query. In production-grade applications, the LLM is not a chatbot—it is a non-deterministic reasoning engine that must be forced into deterministic outputs.
Here is how I approach prompt engineering for high-stakes internal tools like the GTM Outreach Automator.
## Moving Beyond Text to Structured Data
If your AI feature relies on parsing raw text output using regex, it will eventually break in production.
To build resilient systems, I strictly enforce **JSON outputs**. Whether using OpenAI's response_format: { type: "json_object" } or Gemini's structured output capabilities, the prompt must explicitly define the schema.
`json
{
"subject_line": "Strictly under 50 characters",
"hook": "A personalized opening referencing the prospect's recent milestone",
"value_prop": "A 2-sentence explanation of how our product solves their specific pain point",
"call_to_action": "A low-friction closing question"
}
`
By forcing the LLM to adhere to a schema, the frontend can predictably map these JSON keys to UI components without fear of hallucinated formatting.
## Context Injection and Few-Shot Prompting
LLMs are highly sensitive to the context window. Instead of writing a massive block of instructions, I utilize **Few-Shot Prompting**.
I provide the model with 3-4 examples of perfect inputs and their corresponding perfect outputs. This does two things:
1. It implicitly teaches the model the desired tone and structure.
2. It dramatically reduces the hallucination rate.
## System Constraints and Temperature Control
For creative writing tasks (like marketing copy), a higher temperature (0.7) is useful. But for data extraction or strict formatting, temperature must be set to 0.
Furthermore, the System Prompt acts as the "Constitution" for the agent. It must include explicit negative constraints:
- *DO NOT invent metrics.*
- *DO NOT apologize if you cannot find information, simply return null.*
- *DO NOT include markdown code blocks around your JSON.*
By treating prompts as code, we can version control them, test them programmatically, and ensure that AI features remain robust at scale.
Sep 15, 2023•10 min read
LLM Prompt Engineering
Prompt EngineeringOpenAIGemini