<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Terminal Value</title>
    <link>https://terminalvalue.net/</link>
    <description>Thoughts and experiments on AI Engineering</description>
    <item>
      <title>Generating unique, client-focused experiences with LLMs</title>
      <link>https://terminalvalue.net/posts/terminal-value-pipeline/</link>
      <guid>https://terminalvalue.net/posts/terminal-value-pipeline/</guid>
      <pubDate>Tue, 10 Feb 2026 12:00:00 GMT</pubDate>
      <description>An early proof of concept built with Gemini 3 highlighting how one-shot prompts and a coding template can generate a personalized page for every customer, with 98.9% of the prompt cacheable across customers.</description>
      <content:encoded><![CDATA[<aside class="note">
<p>This post kicks off the blog by revisiting a project I built in February 2026. Every line of the original was written by Gemini 3 using one-shot prompts. This version, from the write-up to the hosted demo, is an LLM rewrite done with Claude Opus 5.5, which did most of the heavy lifting. LLMs have advanced a lot since then, but the concepts still hold, and they&#39;re a good grounding for what comes next.</p>
</aside>
<p>An LLM wrote a custom home page for one customer from three lines of CRM notes. Of the 8,803 tokens in the prompt, only about 100 were about the customer.</p>
<div class="compare"><figure><a class="zoom" href="base-home-page.png"><img src="base-home-page.png" alt="The base home page of the mock ski shop" width="1907" height="1122" loading="lazy" decoding="async"></a><figcaption>Original home page</figcaption></figure>
<span class="arrow" aria-hidden="true">→</span><figure><a class="zoom" href="backcountry-home-page.png"><img src="backcountry-home-page.png" alt="The home page generated for a backcountry skier" width="1882" height="1117" loading="lazy" decoding="async"></a><figcaption>Generated for one customer</figcaption></figure>
</div>
<p><a href="/projects/terminal-value-pipeline/compare/">Open both live, side by side</a>. Tap a screenshot to enlarge it.</p>
<p>Besides their age and city, this is everything the model knew about them, straight from the shop&#39;s CRM:</p>
<ul>
<li>Client just got into backcountry skiing and is excited to buy new stuff.</li>
<li>Attended an avalanche safety course last month.</li>
<li>Asking about lightweight setups for long tours.</li>
</ul>
<p>The model returned a complete web component, and the shop serves it whenever that customer visits.</p>
<h2 id="where-the-tokens-go"><a href="#where-the-tokens-go">Where the tokens go</a></h2>
<p>The request for this customer used 14,515 tokens on Gemini 3 Pro:<sup><a id="footnote-ref-data" href="#footnote-data" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
<ul>
<li><strong>8,803 input.</strong> About 100 describe the customer. The other 98.9% is identical for every customer: the instructions and the shop&#39;s base page code.</li>
<li><strong>2,511 thinking.</strong></li>
<li><strong>3,201 output</strong>, which is the new component.</li>
</ul>
<p>Across the ten customers in the demo, input ranged from 8,793 to 8,815 tokens. A paragraph of customer data is all it takes to turn the same template into a very different page.</p>
<p>Because almost the whole prompt is fixed, it&#39;s a natural fit for prompt caching. With the template first and the customer&#39;s notes last, every request after the first reads the template from cache while it&#39;s warm, at a fraction of the cost and latency. The marginal cost of personalizing a page is then roughly the customer&#39;s paragraph plus the output.<sup><a id="footnote-ref-cache" href="#footnote-cache" data-footnote-ref aria-describedby="footnote-label">2</a></sup></p>
<p><strong><a href="/projects/terminal-value-pipeline/">Try the demo</a></strong>. It runs entirely in your browser, with mock data.</p>
<h2 id="probabilistic-core-deterministic-shell"><a href="#probabilistic-core-deterministic-shell">Probabilistic core, deterministic shell</a></h2>
<p>The idea behind the project is to treat the LLM as a probabilistic step inside an otherwise deterministic system. Everything around the model is ordinary code: the data it reads, the prompt it receives, where its output is written, and how that output is served. The model is called once per customer, like a transaction, and the result is stored with everything that produced it.</p>
<p>It isn&#39;t quite MCP, vibe coding or agentic AI. It&#39;s closer to transactional AI.</p>
<h2 id="how-the-pages-are-generated"><a href="#how-the-pages-are-generated">How the pages are generated</a></h2>
<p>The shop records every change as an event, and projections build the current state of each customer from those events. The pipeline reads that state and fills in a prompt template:</p>
<pre class="shiki shiki-themes min-light min-dark" style="--shiki-light:#24292eff;--shiki-dark:#b392f0;--shiki-light-bg:#ffffff;--shiki-dark-bg:#1f1f1f" tabindex="0"><code><span class="line"><span style="--shiki-light:#C2C3C5;--shiki-dark:#6B737C">// Abridged from pipeline/experimentPrompts.js</span></span>
<span class="line"><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">const</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> prompt</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> (profile</span><span style="--shiki-light:#212121;--shiki-dark:#BBBBBB">,</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0"> notes) </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">=></span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70"> `</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">The high value client we are targeting is </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">${</span><span style="--shiki-light:#1976D2;--shiki-dark:#79B8FF">profile</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">.age</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">}</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">years old and based in </span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">${</span><span style="--shiki-light:#1976D2;--shiki-dark:#79B8FF">profile</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">.city</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">}</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">. Our executive sales</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">team has made the following notes in the internal ski shop</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">CRM database: "</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">${</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">notes</span><span style="--shiki-light:#D32F2F;--shiki-dark:#F97583">}</span><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">".</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">Replace the BaseHomePage class in './index.html' with a</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#FFAB70">custom version for this particular high value client.`</span><span style="--shiki-light:#24292EFF;--shiki-dark:#B392F0">;</span></span></code></pre><p>Each generated component is about 10 KB of unminified code. Different notes produce very different pages:</p>
<figure><a class="zoom" href="nomad-home-page.png"><img src="nomad-home-page.png" alt="The home page generated for a digital nomad" width="1292" height="1006" loading="lazy" decoding="async"></a><figcaption>A 28-year-old digital nomad from Vancouver who works from the lodge half the day and wants gear that goes from slope to après-ski.</figcaption></figure>
<figure><a class="zoom" href="aspen-home-page.png"><img src="aspen-home-page.png" alt="The home page generated for an impulse buyer in Aspen" width="1291" height="1006" loading="lazy" decoding="async"></a><figcaption>A 44-year-old in Aspen who buys the most expensive item in the category and loves flashy branding.</figcaption></figure>
<p>The admin page lists every customer and links to each of their generated pages:</p>
<figure><a class="zoom" href="admin-page.png"><img src="admin-page.png" alt="The ski shop admin page" width="1877" height="1097" loading="lazy" decoding="async"></a><figcaption>The admin page, with each customer&#39;s CRM notes and their generated home and order pages.</figcaption></figure>
<p>Every run stores the prompt, the raw response and the token usage together, so any page can be traced back to exactly what produced it:</p>
<figure><a class="zoom" href="results-object.png"><img src="results-object.png" alt="The stored results object" width="651" height="935" loading="lazy" decoding="async"></a><figcaption>One stored result. The text field holds the generated component.</figcaption></figure>
<h2 id="what-building-it-taught-me"><a href="#what-building-it-taught-me">What building it taught me</a></h2>
<p>Building the project one prompt at a time, without agents, taught me a few principles.</p>
<p><strong>Precise context.</strong> The more irrelevant tokens in the context, the less predictable the response. &quot;Garbage in, garbage out&quot; is too passive. Input fidelity sets output fidelity.</p>
<p><strong>Concise context.</strong> Reasoning degrades as the context window fills up. Rather than adding more context, break the problem into pieces small enough for the model&#39;s best attention.</p>
<p><strong>Deterministic guardrails.</strong> Probabilistic output can be checked deterministically. When a model&#39;s code starts to go wrong, its style usually degrades first, often in the comments. Static checks on those signals can reject a bad response before a person reads it.</p>
<p><strong>Recursion of technical debt.</strong> Uncontrolled agent loops tend to write code that works but loses the domain&#39;s intent. Repeat that enough times and nobody, human or model, can tell what the code is for.</p>
<h2 id="when-a-prompt-fails"><a href="#when-a-prompt-fails">When a prompt fails</a></h2>
<p>One refactor of a core file didn&#39;t go as planned. My prompt was too long and had a logical flaw, and Gemini returned a generic error instead of code:</p>
<figure><a class="zoom" href="gemini-confidence-error.png"><img src="gemini-confidence-error.png" alt="Gemini returning a generic error to a refactoring prompt" width="916" height="1120" loading="lazy" decoding="async"></a><figcaption>A generic error on the first turn, to a prompt that wasn&#39;t malicious in any way.</figcaption></figure>
<p>Replacing three words to fix the flaw got <a href="https://github.com/pilifs/Terminal-Value/commit/ecd2784fcc27c8beab133ce4cdd4dbf33aa7b2f8">the exact refactor I wanted</a>. The next request in the same chat was a simple change that had worked many times before, but this time the model misread it completely:</p>
<figure><a class="zoom" href="gemini-degraded-context.png"><img src="gemini-degraded-context.png" alt="Gemini asking to connect Google Workspace in response to a code request" width="781" height="547" loading="lazy" decoding="async"></a><figcaption>The follow-up request, in the same chat. The failed first turn had degraded the context.</figcaption></figure>
<p>I didn&#39;t argue with the model. I started a new chat with a one-shot prompt, and <a href="https://github.com/pilifs/Terminal-Value/commit/2ae0022ba43ba020867d9306aad465a6949bb58d">it worked the first time</a>. When context goes bad, it&#39;s cheaper to start over than to repair it.</p>
<h2 id="the-code"><a href="#the-code">The code</a></h2>
<p>The project is preserved in <a href="https://github.com/pilifs/Terminal-Value/tree/main/projects/terminal-value-pipeline"><code>projects/terminal-value-pipeline</code></a>, with its original commit history and dates. To run it locally:</p>
<pre class="shiki shiki-themes min-light min-dark" style="--shiki-light:#24292eff;--shiki-dark:#b392f0;--shiki-light-bg:#ffffff;--shiki-dark-bg:#1f1f1f" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">cd</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> projects/terminal-value-pipeline</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">npm</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> install</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">npm</span><span style="--shiki-light:#2B5581;--shiki-dark:#9DB1C5"> start</span></span></code></pre><section class="footnotes" data-footnotes>
<h2 id="footnote-label" class="sr-only">Footnotes</h2>
<ol>
<li id="footnote-data">
<p>These figures are the <code>usageMetadata</code> Gemini returned for this page, a Gemini Batch API request made on February 5, 2026 with <code>gemini-3-pro-preview</code>. Here are the exact <a href="gemini-batch-request.jsonl">request</a> and <a href="gemini-batch-response.jsonl">response</a>, one JSONL line each. The response holds the generated component in its <code>text</code> field. &quot;About 100&quot; is an estimate. The customer&#39;s details are about 340 characters, and the prompt averaged about 3.5 characters per token. <a href="#footnote-ref-data" data-footnote-backref aria-label="Back to reference data">↩</a></p>
</li>
<li id="footnote-cache">
<p>The prompts in the demo weren&#39;t ordered for caching. The customer&#39;s details came about 900 characters in, ahead of roughly 29,000 characters of page code, so a prefix cache could only reuse the first few hundred tokens. Gemini&#39;s implicit caching still showed up in an earlier batch that morning. That prompt version opened with the customer&#39;s details, yet 4 of its 10 responses reported 8,170 cached tokens out of about 8,500. Those prompts shared only their first 42 characters, so it wasn&#39;t a shared template prefix, and the stored data doesn&#39;t show what was matched. Implicit caching is best-effort and opaque. For a predictable cost, cache the template explicitly as the prompt prefix (Gemini&#39;s context caching or Anthropic&#39;s <code>cache_control</code>) and append the customer&#39;s details after it. Both bill cached reads at a fraction of the normal input price. <a href="#footnote-ref-cache" data-footnote-backref aria-label="Back to reference cache">↩</a></p>
</li>
</ol>
</section>
]]></content:encoded>
    </item>
  </channel>
</rss>
