1. Define the outcome, then freeze constraints

Mini-template

Goal: <deliverable in one line>

Constraints: length≤N, tone=<X>, format=<JSON|bullets|code>, citations=<Y/N>

Budget: max_input_tokens=N, max_output_tokens=M

Quality checks: [check1, check2, check3]

2. Route to the right model (tiering saves money)

Routing rule (plain-English)

If task ∈ {classify, extract, summarize} → Small model.

If task ∈ {draft, rewrite with style} → Mid model.

If task fails checks or requires complex reasoning → Best model for one pass only.

3. Put hard caps in the prompt

4. Compact the input (token diet)

Compressor helper (use before main prompt)

You are a compressor. Rewrite the following into ≤120 tokens of bullet points

preserving numbers, names, and constraints. No fluff.

5. Retrieval that doesn’t flood the context

6. Minimize few-shots; prefer schemas

Output schema guard

Return JSON exactly matching:

{

  "title": "string (≤60 chars)",

  "summary": "string (≤120 words)",

  "actions": ["string", ... (3 items max)]

}

No extra keys, no explanations.

7. Single-pass structure beats long prose

8. Two-pass “Draft → Verify” pattern (cheap + gated)

  1. Draft (cheap/mid model) → produce output under tight schema.

  2. Verify (small model) → run the 3–5 checks; return pass/fail flags.

  3. Escalate to best model only if any check fails, with the failing flags as input.

Verifier prompt (small model)

Judge the JSON against these rules: [rule1..rule5].

Return {"pass": true|false, "failed_rules": ["..."]}. No prose.

9. Reuse to avoid paying twice

10. Log tokens, cost, and quality—then prune

Cost formula

Cost ≈ (input_tokens $/1k_in) + (output_tokens $/1k_out)

Aim to reduce input first; it scales across every call.

11. Safety & compliance (saves money by preventing reruns)

12. Ready-to-use templates

A) Cost Guardrails (System)

You are a cost-aware assistant. Rules:

1) Never exceed max_tokens or add extra commentary.

2) Follow the output schema exactly; no markdown unless requested.

3) If insufficient context, output 'INSUFFICIENT_CONTEXT' (no guessing).

4) Keep answers as short as allowed by constraints.

B) Task Prompt (User)

Task: <one sentence>

Inputs: <bulleted facts only>

Format: <schema or tight outline>

Constraints: length≤N; tone=<X>; citations=<Y/N>

Budget: max_output_tokens=M

Return only the formatted result.

C) Cheap Draft → Verify → Escalate

D) Summarizer/Compressor (before main call)

Condense the following into ≤100 tokens preserving facts, numbers, and constraints.

Output bullets only.

13. Quick troubleshooting

14. Pocket checklist (printable)

Micro-example (everything together)

System: Cost guardrails (A).

User

Task: Write a 120-word customer apology email for delayed shipment.

Inputs: order #78421, delay=3 days, new ETA=Sep 12, 10% coupon THANKS10.

Format: Greeting, 3 short sentences, closing + signature.

Constraints: warm, concise; no excuses; ≤120 words.

Budget: max_output_tokens=160

Verifier (small): Check length≤120 words, coupon present, ETA present, tone=warm, no excuses → pass/fail JSON.

Escalate only if fail.

Use this playbook, and your costs will drop while quality becomes repeatable and auditable.