Lesson 2: Token-Efficient Prompt Design
·Language Engineering

Lesson 2: Token-Efficient Prompt Design

Master the bankruptcy-proof prompt. Learn how to audit your instructions for 'Semantic Overlap' and how to use YAML and code-blocks to minimize the character count of your context.


Module 12: Cost and Token Optimization

Lesson 2: Token-Efficient Prompt Design

In Module 9, we discussed Signal-to-Noise Ratio (SNR) for accuracy. In this lesson, we look at SNR for Cost. If your system prompt is 2,000 tokens of fluffy English prose, and you have 10,000 users, you are wasting millions of tokens a day.

In this lesson, we learn to "Compress" our prompts into high-density, low-token formats.


1. Eliminate "Politeness Tokens"

Claude does not need you to be polite. "I would like you to please kindly..." is 10 tokens of wasted money.

  • Before: "Could you please take a look at this document and provide a very short summary of the main points?" (22 tokens)
  • After: "Summarize the attached document in 3 bullets." (8 tokens)

Savings: 63% cost reduction.


2. Using High-Density Formats (YAML vs. JSON)

When you send structured data (like examples or context) to a model, the format matters.

  • JSON uses many brackets, quotes, and braces.
  • YAML uses mostly newlines and indentation.

For a massive list of examples, YAML is significantly cheaper because it uses fewer non-semantic tokens.


3. The "Instruction Index" Pattern

Instead of repeating a long instruction in every prompt, assign it a Keyword.

  1. In the System Prompt, define: "Rule 101: Always output in PascalCase."
  2. In the User Prompt, say: "Follow Rule 101."

By "Indexing" your rules, you save hundreds of tokens per turn.


4. Visualizing Token Density

graph LR
    A[Fluffy Prose] --> B[35 Tokens]
    C[Terse Bullet Points] --> D[15 Tokens]
    E[YAML Structured Store] --> F[10 Tokens]
    B --> X[Higher Cost / Lower SNR]
    F --> Y[Lower Cost / Higher SNR]

5. Summary

  • Be Terse: Use imperative verbs.
  • Be Structured: Use YAML for data lists.
  • Be Indexed: Name your rules rather than repeating them.

In the next lesson, we look at the ultimate cost-saver: Caching Strategies and Prompt Reuse.


Interactive Quiz

  1. Why are "Politeness Tokens" a waste of money in a production agent?
  2. Which is generally more token-efficient for large lists: JSON or YAML? Why?
  3. What is the "Instruction Index" pattern?
  4. Take a paragraph-style rule and convert it into a 5-word High-Signal instruction.

Reference Video:

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn