Skip to content

Instantly share code, notes, and snippets.

@bkaney
Last active December 11, 2025 05:43
Show Gist options
  • Select an option

  • Save bkaney/9017c693b6949300f93fb76e0de0eb0c to your computer and use it in GitHub Desktop.

Select an option

Save bkaney/9017c693b6949300f93fb76e0de0eb0c to your computer and use it in GitHub Desktop.
Example output of a POC that pre-processes AI prompts

LessPrompt - All Modes Comparison

Generated on 2025-12-10 23:10:14

✅ Ollama is running with ministral-3:8b

This demo compares all optimization modes across test fixtures.


Demo 1: business-prompt.txt

Original: 44 tokens

I am working on a project that I need to complete for tomorrow. I need to
research the TAM of hot tubs. Organize by region in the United States. Include a
breakdown of top vendors in each region.

Rules-Only Mode

Tokens: 40 (-9.1%)

[GOAL]
I need to research the TAM of hot tubs.

[CONSTRAINTS]
- Organize by region in the United States.
- Include a breakdown of top vendors in each region

Standard Mode (LLM on original)

Tokens: 29 (-34.1%)

Research **Total Addressable Market (TAM) for hot tubs in the U.S.**, segmented
by region with top vendors in each.

Combined Mode (LLM on rules output)

Tokens: 24 (-45.5%)

Research U.S. hot tub **Total Addressable Market (TAM)** by region, including
top vendors per region.

Comparison

Mode Tokens Reduction Method
Original 44 0% -
Rules-Only 40 9.1% Pattern-based
Standard 29 34.1% LLM on original
Combined 24 45.5% Rules → LLM

Demo 2: complex-prompt.txt

Original: 155 tokens

Hi ChatGPT! 

Sorry for the long prompt, but I need your help. I'm working on a project and
need to analyze customer feedback data.

The task is to categorize customer reviews into sentiment categories. It must be
accurate. You should not ignore edge cases. The output must be in JSON format
with the following structure:

{
  "sentiment": "positive|negative|neutral",
  "confidence": 0.0-1.0,
  "category": "product|service|support"
}

For example: A review saying "Great product, fast shipping!" would be
categorized as positive sentiment with high confidence.

Do not include reviews that are spam or irrelevant. The analysis should focus on
genuine customer feedback.

Thanks so much for your help!

Rules-Only Mode

Tokens: 154 (-0.6%)

[GOAL]
I need your help. I'm working on a project and need to analyze customer feedback
data. The task is to categorize customer reviews into sentiment categories.

[CONSTRAINTS]
- It must be accurate.
- You should not ignore edge cases.
- The output must be in JSON format with the following structure: { "sentiment": "positive|negative|neutral", "confidence": 0.0-1.0, "category": "product|service|support"
- Do not include reviews that are spam or irrelevant.
- The analysis should focus on genuine customer feedback.

[OUTPUT FORMAT]
json

[EXAMPLES]
1. A review saying "Great product, fast shipping!" would be categorized as
positive sentiment with high confidence.

Standard Mode (LLM on original)

Tokens: 52 (-66.5%)

Analyze customer reviews for sentiment (positive/negative/neutral) with
confidence scores (0.0–1.0) and categorize by type (product/service/support) in
JSON format. Exclude spam/irrelevant entries. Ensure edge cases are handled.

Combined Mode (LLM on rules output)

Tokens: 87 (-43.9%)

Analyze customer reviews into sentiment categories (positive/negative/neutral)
with confidence scores (0.0–1.0) and category (product/service/support) in JSON
format: { "sentiment": "positive|negative|neutral", "confidence": float,
"category": "product|service|support" }.  Exclude spam/irrelevant reviews;
prioritize genuine feedback. No output for invalid entries.

Comparison

Mode Tokens Reduction Method
Original 155 0% -
Rules-Only 154 0.6% Pattern-based
Standard 52 66.5% LLM on original
Combined 87 43.9% Rules → LLM

Demo 3: devops-prompt.txt

Original: 102 tokens

I’m trying to deploy my app on Kubernetes and I followed some tutorials but my
pods keep restarting and I don’t know what the logs mean. Also I think maybe my
YAML is wrong or I need more replicas? I don’t know. Should everything be in one
file or many? And do I need Helm for this or is that overkill? Also what’s the
deal with Ingress vs LoadBalancer? How do I make a simple deployment that “just
works”?

Rules-Only Mode

Tokens: 108 (--5.9%)

[GOAL]
I’m trying to deploy my app on Kubernetes and I followed some tutorials but my
pods keep restarting and I don’t know what the logs mean. Also my YAML is wrong
or I need more replicas? I don’t know. file or many? And do I need Helm for this
or is that overkill? Also what’s the deal with Ingress vs LoadBalancer? How do I
make a simple deployment that “just works”?

[CONSTRAINTS]
- Should everything be in one

[OUTPUT FORMAT]
yaml

Standard Mode (LLM on original)

Tokens: 50 (-51.0%)

"Debug Kubernetes pod restarts by interpreting logs and fixing YAML issues.
Clarify if a single-file or modular YAML structure is optimal. Determine if Helm
is necessary. Explain Ingress vs. LoadBalancer differences. Provide a minimal,
functional deployment setup."

Combined Mode (LLM on rules output)

Tokens: 80 (-21.6%)

Create a simple Kubernetes deployment with one pod (no replicas) using a Deployment YAML that:
1. Runs a basic container (e.g., `nginx`).
2. Logs errors clearly.
3. Uses `LoadBalancer` for external access (no Helm).
4. Minimal YAML for clarity.

Optimize for debugging: Add `restartPolicy: Always` and `livenessProbe` for troubleshooting.

Comparison

Mode Tokens Reduction Method
Original 102 0% -
Rules-Only 108 -5.9% Pattern-based
Standard 50 51.0% LLM on original
Combined 80 21.6% Rules → LLM

Demo 4: fhir-prompt.txt

Original: 70 tokens

I'm trying to make some FHIR resources but I don't know if I'm supposed to 
make profiles or extensions or just put data in fields. For example I have 
a medication order and some labs but I don't know where anything goes. Also 
what's the best way to reference other resources? Is there a right folder 
structure for IGs?

Rules-Only Mode

Tokens: 74 (--5.7%)

[GOAL]
I'm trying to make some FHIR resources but I don't know if I'm supposed to 
make profiles or extensions or just put data in fields. For example I have 
a medication order and some labs but I don't know where anything goes. Also 
what's the best way to reference other resources? Is there a right folder 
structure for IGs?

Standard Mode (LLM on original)

Tokens: 86 (--22.9%)

How to structure FHIR resources: medication orders, labs, and references—use 
profiles for custom constraints, extensions for additional data, and standard 
fields for core info. Reference other resources via `Reference` elements 
(e.g., `patient`, `observation`). For Implementation Guides (IGs), organize 
folders by resource type (e.g., `/resources/medication-request`, 
`/resources/observation`) with profiles/extensions in subfolders.

Combined Mode (LLM on rules output)

Tokens: 26 (-62.9%)

How to structure FHIR resources: medication orders, labs, and references? 
Optimize folder structure for Implementation Guides (IGs).

Comparison

Mode Tokens Reduction Method
Original 70 0% -
Rules-Only 74 -5.7% Pattern-based
Standard 86 -22.9% LLM on original
Combined 26 62.9% Rules → LLM

Demo 5: filler-heavy.txt

Original: 32 tokens

Good morning! Honestly, to be honest, I really think this is quite very
complicated. I basically need help understanding async functions in Python.
Thanks so much!

Rules-Only Mode

Tokens: 8 (-75.0%)

[GOAL]
async functions in Python

Standard Mode (LLM on original)

Tokens: 6 (-81.2%)

Understand Python async functions.

Combined Mode (LLM on rules output)

Tokens: 56 (--75.0%)

Write concise Python `async` function examples covering:
- Basic `async/await` syntax
- Running coroutines
- Error handling
- Concurrent execution with `asyncio.gather()`
- Timeouts with `asyncio.wait_for()`
- Key differences from synchronous code

Comparison

Mode Tokens Reduction Method
Original 32 0% -
Rules-Only 8 75.0% Pattern-based
Standard 6 81.2% LLM on original
Combined 56 -75.0% Rules → LLM

Demo 6: python-prompt.txt

Original: 120 tokens

Hi there! I'm working on a Python script and need some guidance. Sorry if this
is a bit messy. I want to create a function that processes customer data from a
CSV file. The function must handle missing values gracefully. It should not fail
if a column is missing. You need to return a pandas DataFrame. Do not use any
deprecated pandas methods. Make sure the code is well-documented with
docstrings. For example: if the 'email' column is missing, just skip it rather
than raising an error. The output should follow PEP 8 style guidelines. Thanks
so much!

Rules-Only Mode

Tokens: 116 (-3.3%)

[GOAL]
I want to create a function that processes customer data from a CSV file.

[CONSTRAINTS]
- The function must handle missing values gracefully.
- It should not fail if a column is missing.
- You need to return a pandas DataFrame.
- Do not use any deprecated pandas methods.
- Make sure the code is well-documented with docstrings.
- The output should follow PEP 8 style guidelines

[OUTPUT FORMAT]
csv

[EXAMPLES]
1. if the 'email' column is missing, just skip it than raising an error.

Standard Mode (LLM on original)

Tokens: 33 (-72.5%)

Create a Python function to process CSV customer data into a pandas DataFrame,
gracefully skipping missing columns/values without deprecated methods, with
docstrings and PEP 8 compliance.

Combined Mode (LLM on rules output)

Tokens: 36 (-70.0%)

Create a Python function processing CSV customer data into a pandas DataFrame,
handling missing columns/values gracefully, using only non-deprecated methods,
with PEP 8-compliant docstrings.

Comparison

Mode Tokens Reduction Method
Original 120 0% -
Rules-Only 116 3.3% Pattern-based
Standard 33 72.5% LLM on original
Combined 36 70.0% Rules → LLM

Demo 7: quantum-simple.txt

Original: 80 tokens

Hello! I really need your assistance with something. I'm trying to understand
quantum mechanics for a school project. Can you explain quantum entanglement in
simple terms? It would be great if you could avoid complex mathematics. I need
this to be accessible for someone without a physics background. Maybe include an
analogy or example? That would be super helpful. Thank you very much for your
time and help!

Rules-Only Mode

Tokens: 86 (--7.5%)

[GOAL]
I need your assistance with something. I'm trying to understand quantum
mechanics for a school project. Can you explain quantum entanglement in simple
terms? I need this to be accessible for someone without a physics background.
That would be super helpful. Thank you much for your time and help

[CONSTRAINTS]
- It would be great if you could avoid complex mathematics.
- include an analogy or example?

Standard Mode (LLM on original)

Tokens: 26 (-67.5%)

"Explain quantum entanglement in simple terms for a non-physics background,
using an analogy or example without complex math."

Combined Mode (LLM on rules output)

Tokens: 24 (-70.0%)

Explain quantum entanglement in simple terms for a non-physics background, using
an analogy or example without math.

Comparison

Mode Tokens Reduction Method
Original 80 0% -
Rules-Only 86 -7.5% Pattern-based
Standard 26 67.5% LLM on original
Combined 24 70.0% Rules → LLM

Demo 8: react-prompt.txt

Original: 72 tokens

“I want to add a new React feature: a reusable component that fetches data,
displays loading and error states, and exposes a render-prop or
children-as-function API so consumers can decide how to display the results. How
should I structure my components, hooks, and modules so the feature is testable,
composable, and avoids prop-drilling hell?”

Rules-Only Mode

Tokens: 81 (--12.5%)

[GOAL]
“I want to add a new React feature: a reusable component that fetches data,
displays loading and error states, and exposes a render-prop or
children-as-function API so consumers can decide how to display the results.

[CONSTRAINTS]
- How should I structure my components, hooks, and modules so the feature is testable, composable, and avoids prop-drilling hell?”

Standard Mode (LLM on original)

Tokens: 42 (-41.7%)

"Design a reusable React component for fetching data with loading/error states
using render-prop or children-as-function. Structure components, hooks, and
modules to ensure testability, composability, and avoid prop-drilling."

Combined Mode (LLM on rules output)

Tokens: 35 (-51.4%)

"Design a reusable React component for fetching data with loading/error states
using render-prop or children-as-function, structured for testability,
composability, and avoiding prop-drilling."

Comparison

Mode Tokens Reduction Method
Original 72 0% -
Rules-Only 81 -12.5% Pattern-based
Standard 42 41.7% LLM on original
Combined 35 51.4% Rules → LLM

Demo 9: simple-greeting.txt

Original: 11 tokens

Hey GPT, can you help me? Thanks!

Rules-Only Mode

Tokens: 9 (-18.2%)

[GOAL]
can you help me?

Standard Mode (LLM on original)

Tokens: 3 (-72.7%)

Help me.

Combined Mode (LLM on rules output)

Tokens: 3 (-72.7%)

Help me.

Comparison

Mode Tokens Reduction Method
Original 11 0% -
Rules-Only 9 18.2% Pattern-based
Standard 3 72.7% LLM on original
Combined 3 72.7% Rules → LLM

Demo 10: summary-request.txt

Original: 25 tokens

Hey GPT, can you please help me write a summary? It needs to be short and informative. Thanks so much!

Rules-Only Mode

Tokens: 13 (-48.0%)

[GOAL]
can you please help me write a summary?

Standard Mode (LLM on original)

Tokens: 7 (-72.0%)

Write a concise, informative summary.

Combined Mode (LLM on rules output)

Tokens: 8 (-68.0%)

Summarize [context/key points].

Comparison

Mode Tokens Reduction Method
Original 25 0% -
Rules-Only 13 48.0% Pattern-based
Standard 7 72.0% LLM on original
Combined 8 68.0% Rules → LLM

Demo 11: typescript-prompt.txt

Original: 71 tokens

I am working on a project and I need to add a new feature to my TypeScript
codebase: a set of utility functions for fetching, transforming, and caching
domain objects. How should I structure the folders, modules, and shared types so
the feature is cleanly isolated, easy to test, and doesn't introduce circular
dependencies? Thanks

Rules-Only Mode

Tokens: 75 (--5.6%)

[GOAL]
I am working on a project and I need to add a new feature to my TypeScript
codebase: a set of utility functions for fetching, transforming, and caching
domain objects. the feature is cleanly isolated, easy to test, and doesn't
introduce circular dependencies?

[CONSTRAINTS]
- How should I structure the folders, modules, and shared types so

Standard Mode (LLM on original)

Tokens: 33 (-53.5%)

"Suggest a clean TypeScript folder/module structure for utility functions
handling domain object fetching, transformation, and caching—ensuring isolation,
testability, and no circular dependencies."

Combined Mode (LLM on rules output)

Tokens: 37 (-47.9%)

"Suggest a clean folder/module structure and shared type design for TypeScript
utility functions handling domain object fetching, transformation, and
caching—ensuring isolation, testability, and no circular dependencies."

Comparison

Mode Tokens Reduction Method
Original 71 0% -
Rules-Only 75 -5.6% Pattern-based
Standard 33 53.5% LLM on original
Combined 37 47.9% Rules → LLM

Summary

Mode Comparison:

  • 🔧 Rules-Only: Fast, deterministic, pattern-based optimization
  • 🤖 Standard: LLM processes original prompt directly
  • 🔀 Combined: Rules first, then LLM (best of both worlds)

Usage:

# Rules-only (no LLM required)
bun run lessprompt --mode rules-only "Your prompt"

# Standard mode (LLM on original)
bun run lessprompt --mode standard "Your prompt"

# Combined mode (Rules → LLM)
bun run lessprompt --mode combined "Your prompt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment