AI Tool
Runs in your browser. Nothing is uploaded.

Prompt Diff & Variable Filler

Audit system prompt modifications, track token delta, and compile dynamic mustache templates locally.

View:
Granularity:
Prompt A • Deletions
-0 removed
Red = removed
Prompt B • Additions
+0 added
Δ 0 tokens
Action performed

How to Compare Prompts & Inject Dynamic Variables

System prompts form the foundational cognitive boundary for modern Large Language Models (LLMs) such as GPT-4o, Claude 3.5 Sonnet, Gemini 1.5 Pro, and open-source models like Llama 3. Even minor, unvetted revisions to a system instruction can trigger unpredictable token drift, alter few-shot steering, or degrade adherence to structured JSON schemas.

  1. Input Baseline and Candidate Revisions: Paste your production prompt into Prompt A and your refined candidate prompt into Prompt B. You can drag and drop .txt or .prompt files directly into the editor boxes.
  2. Select Diff Granularity: Switch between Word, Line, or Character granularity. Word-level diff isolates vocabulary and tone adjustments, Line-level tracks bullet additions, and Character-level captures syntax typos.
  3. Audit Token & Variable Shifts: Review the live additions and removals counters, the approximate token shift (Δ tokens calculated via ~chars/4), and the variable shift audit to confirm that no required template keys were accidentally dropped.
  4. Parameterize Prompt Templates: Navigate to the Fill Variables tab. Use mustache notation ({{variable}}), default fallbacks ({{role|Staff Engineer}}), or required flags ({{api_key!}}). The tool generates multi-line form controls automatically.
  5. Export Production Assets: Copy the unified Markdown diff for GitHub Pull Requests, download self-contained HTML audit logs, or export compiled prompts as JSON messages arrays ([{"role": "user", "content": "..."}]).

Real-World Prompt Optimization: Before vs. After

Modern prompt engineering has shifted from conversational paragraphs to rigorous, tagged prompt architectures with negative constraints, XML structural tags, and typed variable parameters:

Baseline Prompt A (Unstructured & Ambiguous)

You are a helpful software assistant. Help developers write clean code and fix bugs. Explain things simply and provide full code examples. If you don't know the answer, say you don't know.

Candidate Prompt B (Structured & Governed)

You are a Principal Software Architect at MafLabs. Your mission is to evaluate architecture patterns and deliver production-ready code with zero security vulnerabilities. <instructions> 1. Always analyze time/space complexity (Big-O notation). 2. Explicitly validate all user inputs and handle boundary exceptions. 3. Keep prose razor-sharp; avoid conversational pleasantries. 4. When technical constraints are ambiguous, state assumptions. </instructions> Tone: Objective, authoritative, highly structured.

Running these prompts through our diff engine highlights the exact instruction shifts, isolating additions and removals so your team can conduct peer reviews before pushing prompt updates to production LLM routers.

Why Prompt Diffing & Parameterization Matter in AI Engineering

Prompt drift is one of the most common causes of production regressions in LLM-powered applications. Because LLMs compute probabilistic token sequences via attention matrices, altering a single prefix sentence changes the attention weights across all subsequent user inputs.

By leveraging deterministic Myers and Longest Common Subsequence (LCS) algorithms client-side, this tool provides:

  • Deterministic Auditing: No LLM is used to compare your prompts. You receive mathematically exact token and string comparisons with zero hallucination risk.
  • Context Window Optimization: Monitor token bloat before deploying. The approximate token counter immediately alerts you if an amendment inflates prompt token overhead by more than intended.
  • Zero Privacy Exposure: Proprietary intellectual property, system guardrails, few-shot enterprise data, and API instructions never leave your machine. Everything runs offline in your web browser.
  • Cross-Syntax Support: Seamlessly inject mustache ({{var}}), Python f-string ({var}), shell (${var}), and batch (%var%) variables without syntax conflicts.

Common Prompt Engineering Pitfalls & Mitigations

When managing enterprise prompt libraries, engineering teams often encounter several subtle stumbling blocks:

  • Code Block Brace Clashes: When prompting models to output JSON or code with curly braces (e.g. {"key": "value"}), template engines frequently mistake JSON brackets for parameters. Our Skip code blocks engine parses fenced blocks and inline backticks, ignoring internal braces automatically.
  • Unescaped Template Literals: If your prompt needs to instruct an AI on mustache syntax itself, use backslash escapes like \{{variable}}. Our compiler preserves escaped variables as raw literals while stripping the backslash.
  • Missing Parameter Safeguards: An unfilled prompt variable like {{user_data}} left empty can cause the model to hallucinate placeholder text. Our compiler visibly flags unfilled variables in amber badges and prompts warnings before copying.
  • Line-Ending Normalization (CRLF vs LF): Windows and Unix systems encode newlines differently. Our diff engine normalizes carriage returns so cross-platform copy-pastes do not register artificial full-file changes.

Frequently Asked Questions

How do I compare two versions of an AI prompt?
Paste your baseline system prompt into Prompt A and your revised version into Prompt B. The tool immediately highlights deletions in red, additions in green, and provides accurate word, character, and approximate token shift metrics with synchronized side-by-side scrolling.
What are prompt variables and how do they work?
Prompt variables are dynamic placeholders within a prompt template (e.g. {{user_name}} or {{domain|Computer Science}}). The variable filler detects all keys, generates dedicated inputs, fills defaults, and produces the final compiled prompt ready to pass to an LLM.
How are LLM tokens estimated in this tool?
Token counts are estimated using the industry standard heuristic of approximately 4 characters per token for English text and code. While actual tokenizer counts vary slightly by model (BPE, SentencePiece), this provides an instantaneous, zero-latency estimate without downloading multi-megabyte vocabulary files.
Is my prompt or proprietary company data stored on any server?
No. All text processing, diff algorithms, and variable substitutions execute 100% locally inside your web browser. No telemetry, user data, or network requests are ever dispatched.
Can I use mustache curly braces inside code blocks without them turning into variables?
Yes. When 'Skip code blocks' is enabled, any syntax inside Markdown fenced code blocks (```...```) or inline backticks (`...`) is preserved literally and excluded from variable generation.
Which diff granularity should I select?
Word-level diff (the default) is ideal for reading prompt edits and instruction wording changes. Line-level diff is best for multi-step structured prompts with numbered rules, while Character-level diff pinpoints single-letter typos and punctuation fixes.