<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Aamir Khan</title>
    <description>The latest articles on DEV Community by Muhammad Aamir Khan (@muhammad_aamirkhan_d7ba4).</description>
    <link>https://dev.to/muhammad_aamirkhan_d7ba4</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4260013%2F58cc6ab7-3f1d-4ae7-a0b0-dc7cc548a2a1.png</url>
      <title>DEV Community: Muhammad Aamir Khan</title>
      <link>https://dev.to/muhammad_aamirkhan_d7ba4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muhammad_aamirkhan_d7ba4"/>
    <language>en</language>
    <item>
      <title>I let an LLM write chargeback responses, but only by copying sentences it was given</title>
      <dc:creator>Muhammad Aamir Khan</dc:creator>
      <pubDate>Mon, 23 Nov 2026 07:58:03 +0000</pubDate>
      <link>https://dev.to/muhammad_aamirkhan_d7ba4/i-let-an-llm-write-chargeback-responses-but-only-by-copying-sentences-it-was-given-2l7e</link>
      <guid>https://dev.to/muhammad_aamirkhan_d7ba4/i-let-an-llm-write-chargeback-responses-but-only-by-copying-sentences-it-was-given-2l7e</guid>
      <description>&lt;p&gt;I'm building RebutCase, a Shopify app that helps merchants answer chargebacks. When a customer disputes a payment, the merchant gets a deadline and a set of evidence fields. Someone at the cardholder's bank reads what they send. If a single date or amount in it is wrong, the merchant has sent the bank something false.&lt;/p&gt;

&lt;p&gt;So the hard rule from day one was: every sentence that goes to the bank must point to a piece of evidence. Here is how that ended up working, and what broke along the way.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pipeline
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;collectors (Shopify data, merchant uploads)
  -&amp;gt; facts (normalized, keyed, sourced)
  -&amp;gt; checks (PASS, WARN, FAIL, NA per dispute reason)
  -&amp;gt; case strength (Strong, Fair, Weak)
  -&amp;gt; claims (deterministic templates pick facts)
  -&amp;gt; draft (LLM joins claims into prose, optional)
  -&amp;gt; verifier (every sentence cited, every value traceable)
  -&amp;gt; Shopify evidence fields + PDF exhibits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The core is plain TypeScript with no network calls, so every step runs against JSON fixtures in unit tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Facts first
&lt;/h2&gt;

&lt;p&gt;A fact is &lt;code&gt;{ key, label, value, source, isPii }&lt;/code&gt;: &lt;code&gt;order.created_at&lt;/code&gt;, &lt;code&gt;tracking.delivered&lt;/code&gt;, &lt;code&gt;payment.avs&lt;/code&gt;, &lt;code&gt;policy.refund&lt;/code&gt; and so on. If a field does not exist in Shopify's API, the fact is dropped, never guessed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Claims are templates, not generation
&lt;/h2&gt;

&lt;p&gt;For a "product not received" dispute, the claims look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order {order.name} was placed on {order.created_at} for {order.items}.
The order shipped on {fulfillment.shipped_at} with {tracking.carrier}, tracking number {tracking.number}.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A claim is included only if all its facts exist. That alone removes most of the ways a response can say something untrue.&lt;/p&gt;

&lt;h2&gt;
  
  
  The LLM is on a very short leash
&lt;/h2&gt;

&lt;p&gt;The model gets the claims with placeholders instead of personal data (&lt;code&gt;{{CUSTOMER_NAME}}&lt;/code&gt;, &lt;code&gt;{{SHIPPING_ADDRESS}}&lt;/code&gt;) and one job: copy every claim word for word, in order, and join two or three of them with a comma and a connector like "and" or "in addition". Every sentence ends with markers like &lt;code&gt;[C2]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That sounds too strict. We started looser: rewording was fine as long as the important words were covered. Two audits found that any looser rule let a rephrase change what a claim meant. "Delivered to the shipping address on the order" can turn into "delivered to the customer" in one innocent edit, and those are different claims.&lt;/p&gt;

&lt;h2&gt;
  
  
  The verifier
&lt;/h2&gt;

&lt;p&gt;Every sentence must:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Cite at least one known claim or exhibit.&lt;/li&gt;
&lt;li&gt;Contain only dates, amounts, IDs and numbers that appear exactly in the cited facts, compared as whole values, never as substrings.&lt;/li&gt;
&lt;li&gt;Quote text and links word for word from the evidence.&lt;/li&gt;
&lt;li&gt;Avoid a banned list: accusations ("fraudulent", "lying"), outcome talk ("guarantee", "win rate"), legal threats, and the em dash.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the draft fails verification twice, or the model times out, the app falls back to deterministic text built from the claims. The product has to work with the LLM switched off.&lt;/p&gt;

&lt;p&gt;Merchant edits are checked too. A sentence the merchant wrote is flagged as not checked word by word, and they can still keep it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things the app refuses to do
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It never submits evidence. It saves it to the dispute in Shopify, and the merchant submits, or Shopify sends it on the due date.&lt;/li&gt;
&lt;li&gt;It never overwrites what Shopify pre-filled without showing a diff.&lt;/li&gt;
&lt;li&gt;It never shows a win probability. Case strength is Strong, Fair or Weak, with the one to three checks that decided it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I would tell anyone putting an LLM near text that matters
&lt;/h2&gt;

&lt;p&gt;Make the model's job as small as possible, keep the facts outside it, and write the verifier before the prompt. The adversarial cases from our audits live in a test file now, and every prompt change runs against them.&lt;/p&gt;

&lt;p&gt;If you run a Shopify store or build for merchants, the app is at &lt;a href="https://apps.shopify.com/rebutcase" rel="noopener noreferrer"&gt;https://apps.shopify.com/rebutcase&lt;/a&gt; and the free guides (including 41 card network reason codes) are at &lt;a href="https://rebutcase.zoviotech.com/reason-codes?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=llm-verifier" rel="noopener noreferrer"&gt;https://rebutcase.zoviotech.com/reason-codes?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=llm-verifier&lt;/a&gt; . Happy to answer questions about Shopify's dispute evidence API in the comments.&lt;/p&gt;

</description>
      <category>shopify</category>
      <category>ai</category>
      <category>typescript</category>
      <category>llm</category>
    </item>
  </channel>
</rss>
