Prompt Engineering Guide (Arlis Edition)
Core Philosophy: The Forensic Advocate
In Arlis, prompt engineering is not just about getting the right answer; it's about embodying the advocacy mission.
Every prompt must find the balance between:
- •Rigorous Precision (Forensic Audit, Government Compliance)
- •Warm Empathy (Social Worker, Bureaucracy Buddy)
Key Principles
- •Role & Identity: Every prompt must define Arlis's specific role for that task (e.g., "The Jargon Shield" vs. "The Audit Brain").
- •Actionable Instructions: Break tasks down into atomic steps. Arlis doesn't "help"; Arlis "analyzes, plans, and executes".
- •Few-Shot Examples: Always provide input/output examples. This is critical for reliable JSON extraction from messy government forms.
- •Empathy Constraints: While being precise, errors must be handled gently. (e.g., Rule: "Never say 'User is wrong', say 'Let's verify this value'").
- •Thinking Process: Use
<think>tags (Gemini 3 Pro) for complex reasoning tasks like policy interpretation or form logic cross-referencing.
The Standard Protocol
All prompts in lib/ai/prompts.ts MUST follow this structure:
- •ROLE: Identity (e.g.,
ROLE_FORENSIC_ADVOCATE). - •SKILLS: Specific capabilities (e.g.,
SKILLS_PLAIN_LANGUAGE). - •WORKFLOW: Step-by-step execution plan.
- •RULES: Hard constraints and formatting requirements.
- •EXAMPLES: Concrete input -> output pairs.
Anti-Patterns to Avoid
| Anti-Pattern | Why it fails | Better Approach |
|---|---|---|
| "Be nice" | Vague. | "Use a Grade 6 reading level and reassuring tone." |
| "Fill the form" | Too broad. | "Extract fields, normalize dates to YYYY-MM-DD, then fill." |
| "Guess if missing" | Dangerous. | "If a field is missing in the source doc, output null." |
| Silent Failures | Hard to debug. | "If verification fails, output a specific retryStrategy." |
Implementation Patterns
1. Using the buildPrompt Utility
We have a TypeScript utility in lib/ai/prompts.ts to enforce this structure.
Example Usage:
typescript
import { buildPrompt, AI_SYSTEM_PROTOCOL } from '@/lib/ai/prompts';
export const MY_PROMPT = buildPrompt({
role: AI_SYSTEM_PROTOCOL.ROLE_FORENSIC_ADVOCATE,
skills: [
"Optical Character Recognition",
"Data Verification"
],
rules: [
"Output must be valid JSON",
"Flag any mismatches found"
],
workflow: [
"Scan document",
"Compare with database",
"Report findings"
],
examples: [
{
input: "Income: 5000",
output: '{"verified": true}',
explanation: "Income matches paystub."
}
],
thinkingRequired: true
});
Checklist for New Prompts
Before committing a new prompt, verify:
- • Identity Check: Does it sound like Arlis (Advocate + Auditor)?
- • Workflow Steps? Are the steps atomic and actionable?
- • Examples Included? Are there at least 1-2 examples? (Crucial for messy OCR)
- • Constraints Specific? Are limits quantitative?
- • Thinking Enabled? Is
<think>used for complex reasoning? - • JSON/Format Valid? If outputting JSON, are the rules strict?
Resources
This approach leverages the "Winning Strategy" of combining Forensic Accuracy with Human Empathy, powered by Gemini 3 Pro's thinking capabilities.