<?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: leo Yan</title>
    <description>The latest articles on DEV Community by leo Yan (@leo_yan_dac4a3dbb07ff1095).</description>
    <link>https://dev.to/leo_yan_dac4a3dbb07ff1095</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3947301%2Fe11eb899-77d7-49b3-af20-7da89132901c.png</url>
      <title>DEV Community: leo Yan</title>
      <link>https://dev.to/leo_yan_dac4a3dbb07ff1095</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/leo_yan_dac4a3dbb07ff1095"/>
    <language>en</language>
    <item>
      <title>I built TokenPatch to measure AI coding cost per applied patch</title>
      <dc:creator>leo Yan</dc:creator>
      <pubDate>Sat, 23 May 2026 08:16:16 +0000</pubDate>
      <link>https://dev.to/leo_yan_dac4a3dbb07ff1095/i-built-tokenpatch-to-measure-ai-coding-cost-per-applied-patch-1n31</link>
      <guid>https://dev.to/leo_yan_dac4a3dbb07ff1095/i-built-tokenpatch-to-measure-ai-coding-cost-per-applied-patch-1n31</guid>
      <description>&lt;p&gt;AI coding tools are getting very useful, but I kept running into one problem:&lt;/p&gt;

&lt;p&gt;Expensive frontier models are often used for everything, including small file-scoped implementation patches.&lt;/p&gt;

&lt;p&gt;That feels wasteful.&lt;/p&gt;

&lt;p&gt;For many coding tasks, I want the strong model to stay in charge of planning and judgment, but I do not necessarily need it to write every narrow diff.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;TokenPatch&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/Leoyen1/tokenpatch" rel="noopener noreferrer"&gt;https://github.com/Leoyen1/tokenpatch&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Website: &lt;a href="https://tokenpatch.com" rel="noopener noreferrer"&gt;https://tokenpatch.com&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;p&gt;TokenPatch lets you keep using your current AI coding tool, such as Codex, Claude Code, Cursor, or MCP-capable coding agents.&lt;/p&gt;

&lt;p&gt;The strong model still decides what should change.&lt;/p&gt;

&lt;p&gt;TokenPatch then routes bounded implementation work to a cheaper executor, checks the patch locally, and reports what the useful change actually cost.&lt;/p&gt;

&lt;p&gt;The core metric is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;cost per applied patch&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Not just request cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;p&gt;A task might look like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tp: change the page title. Only modify index.html.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A report can show:&lt;/p&gt;

&lt;p&gt;Task: change page title, only modify index.html&lt;br&gt;&lt;br&gt;
All-strong estimate: $0.42&lt;br&gt;&lt;br&gt;
TokenPatch actual: $0.08&lt;br&gt;&lt;br&gt;
Saved: 81%&lt;br&gt;&lt;br&gt;
Patch applied: yes&lt;br&gt;&lt;br&gt;
Tests: passed&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I built it
&lt;/h2&gt;

&lt;p&gt;Most LLM cost tools focus on API requests.&lt;/p&gt;

&lt;p&gt;But when coding with agents, I care more about task-level economics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Did the patch actually apply?&lt;/li&gt;
&lt;li&gt;Did it stay inside allowed files?&lt;/li&gt;
&lt;li&gt;Did it pass validation?&lt;/li&gt;
&lt;li&gt;How much did the accepted change cost?&lt;/li&gt;
&lt;li&gt;Would this have been more expensive if everything used the strong model?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is the layer I wanted to explore.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current status
&lt;/h2&gt;

&lt;p&gt;TokenPatch is open source and BYOK-first.&lt;/p&gt;

&lt;p&gt;You bring your own executor API key, currently DeepSeek-compatible, and TokenPatch runs locally.&lt;/p&gt;

&lt;p&gt;Install from GitHub:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install git+https://github.com/Leoyen1/tokenpatch.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tokenpatch bootstrap&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then use it from your coding app:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tp: implement a small change. Only modify &amp;lt;file&amp;gt;.&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I am looking for
&lt;/h2&gt;

&lt;p&gt;This is still early.&lt;/p&gt;

&lt;p&gt;I am looking for feedback from developers who use AI coding tools regularly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is “cost per applied patch” a useful metric?&lt;/li&gt;
&lt;li&gt;Is the setup too hard?&lt;/li&gt;
&lt;li&gt;Would you trust a cheaper executor if file boundaries are enforced?&lt;/li&gt;
&lt;li&gt;What coding-agent workflows should this support next?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you try it, I would really appreciate feedback or issues on GitHub.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>devtools</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
