<?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: Sean Kwon</title>
    <description>The latest articles on DEV Community by Sean Kwon (@seanjhkwon).</description>
    <link>https://dev.to/seanjhkwon</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%2F3846623%2F7e26dc65-ff85-4ed8-a3e4-138ef9b43549.jpg</url>
      <title>DEV Community: Sean Kwon</title>
      <link>https://dev.to/seanjhkwon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/seanjhkwon"/>
    <language>en</language>
    <item>
      <title>I Cut Web Doc Tokens 93% for My AI Agent. 151 Code Blocks and 273 Spec Definitions Silently Broke</title>
      <dc:creator>Sean Kwon</dc:creator>
      <pubDate>Fri, 27 Nov 2026 13:47:10 +0000</pubDate>
      <link>https://dev.to/seanjhkwon/i-cut-web-doc-tokens-93-for-my-ai-agent-151-code-blocks-and-273-spec-definitions-silently-broke-4o60</link>
      <guid>https://dev.to/seanjhkwon/i-cut-web-doc-tokens-93-for-my-ai-agent-151-code-blocks-and-273-spec-definitions-silently-broke-4o60</guid>
      <description>&lt;p&gt;Last week I ran an HTML-to-Markdown benchmark across 10 public developer documentation pages I feed into AI coding agents, including GitHub Actions, Python, FastAPI, Kubernetes, MDN, Git, Cloudflare, and the MCP docs. My first local converter cut the combined footprint from 1,116,140 estimated tokens down to 80,462 tokens, a 92.8% drop. I almost shipped that pipeline until I inspected the extracted files and found 151 out of 240 code blocks shattered into single-token lines and 273 API and CLI definitions missing with zero errors.&lt;/p&gt;

&lt;p&gt;Every fetch returned HTTP 200 and every summary metric looked like a win. None of the failures raised an exception, which is why broken web extraction hides in agent pipelines until the model produces corrupted YAML or invents a flag that never existed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why raw HTML hurts more than your token bill
&lt;/h2&gt;

&lt;p&gt;Documentation pages ship navigation trees, inline SVG icons, search modals, and hydration scripts long before the first technical paragraph. In my local run, one GitHub Actions reference page weighed 276,278 estimated tokens as raw HTML, and a Kubernetes Pods page weighed 137,236 estimated tokens (using a 4-characters-per-token estimate across UTF-8 text).&lt;/p&gt;

&lt;p&gt;Infrastructure benchmarks show the same overhead. In &lt;a href="https://blog.cloudflare.com/markdown-for-agents/" rel="noopener noreferrer"&gt;Cloudflare's Markdown for Agents post&lt;/a&gt;, they measured their own article at 16,180 tokens in HTML versus 3,150 tokens in Markdown, an 80% drop, and noted that a plain heading costs roughly 3 tokens in Markdown compared to 12 to 15 tokens in HTML before counting surrounding wrappers and scripts.&lt;/p&gt;

&lt;p&gt;Context bloat also weakens model recall well below the advertised window limit. As &lt;a href="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents" rel="noopener noreferrer"&gt;Anthropic's context engineering guide&lt;/a&gt; explains, as the number of tokens in the context window increases, a model's ability to accurately recall information from that context decreases. Good extraction aims for the smallest set of high-signal tokens that still preserves every structure the agent needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened across 10 live documentation pages
&lt;/h2&gt;

&lt;p&gt;On November 27, 2026, I tested five extraction paths against the same 10 live URLs: raw HTML, server-side content negotiation with &lt;code&gt;Accept: text/markdown, text/html;q=0.5&lt;/code&gt; per &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Accept" rel="noopener noreferrer"&gt;MDN's HTTP Accept header reference&lt;/a&gt;, a naive &lt;code&gt;get_text(" ")&lt;/code&gt; strip with &lt;a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/" rel="noopener noreferrer"&gt;BeautifulSoup&lt;/a&gt;, a common local HTML-to-Markdown script, and a fixed hybrid pipeline.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Page&lt;/th&gt;
&lt;th&gt;Raw HTML (est. t)&lt;/th&gt;
&lt;th&gt;&lt;code&gt;Accept: text/markdown&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;Naive Strip&lt;/th&gt;
&lt;th&gt;Broken Local MD&lt;/th&gt;
&lt;th&gt;Fixed Local MD&lt;/th&gt;
&lt;th&gt;Split &lt;code&gt;&amp;lt;pre&amp;gt;&lt;/code&gt; Blocks&lt;/th&gt;
&lt;th&gt;Dropped &lt;code&gt;&amp;lt;dt&amp;gt;&lt;/code&gt; Specs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare Docs (MD for Agents)&lt;/td&gt;
&lt;td&gt;50,389&lt;/td&gt;
&lt;td&gt;Yes (6,238)&lt;/td&gt;
&lt;td&gt;6,050&lt;/td&gt;
&lt;td&gt;4,902&lt;/td&gt;
&lt;td&gt;4,834&lt;/td&gt;
&lt;td&gt;10 / 12&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare Blog (MD for Agents)&lt;/td&gt;
&lt;td&gt;79,673&lt;/td&gt;
&lt;td&gt;Yes (4,674)&lt;/td&gt;
&lt;td&gt;5,006&lt;/td&gt;
&lt;td&gt;2,164&lt;/td&gt;
&lt;td&gt;2,146&lt;/td&gt;
&lt;td&gt;4 / 5&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude Code Docs (MCP)&lt;/td&gt;
&lt;td&gt;332,014&lt;/td&gt;
&lt;td&gt;Yes (44,586)&lt;/td&gt;
&lt;td&gt;38,320&lt;/td&gt;
&lt;td&gt;17,614&lt;/td&gt;
&lt;td&gt;17,467&lt;/td&gt;
&lt;td&gt;38 / 71&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MCP Spec Intro&lt;/td&gt;
&lt;td&gt;40,346&lt;/td&gt;
&lt;td&gt;Yes (949)&lt;/td&gt;
&lt;td&gt;853&lt;/td&gt;
&lt;td&gt;267&lt;/td&gt;
&lt;td&gt;278&lt;/td&gt;
&lt;td&gt;0 / 0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GitHub Actions Events&lt;/td&gt;
&lt;td&gt;276,278&lt;/td&gt;
&lt;td&gt;Yes (23,856)&lt;/td&gt;
&lt;td&gt;17,922&lt;/td&gt;
&lt;td&gt;17,931&lt;/td&gt;
&lt;td&gt;17,605&lt;/td&gt;
&lt;td&gt;55 / 69&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MDN Accept Header&lt;/td&gt;
&lt;td&gt;54,532&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;3,199&lt;/td&gt;
&lt;td&gt;794&lt;/td&gt;
&lt;td&gt;817&lt;/td&gt;
&lt;td&gt;0 / 5&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Python subprocess Docs&lt;/td&gt;
&lt;td&gt;52,117&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;13,743&lt;/td&gt;
&lt;td&gt;13,200&lt;/td&gt;
&lt;td&gt;15,664&lt;/td&gt;
&lt;td&gt;26 / 28&lt;/td&gt;
&lt;td&gt;70&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FastAPI First Steps&lt;/td&gt;
&lt;td&gt;36,185&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;4,379&lt;/td&gt;
&lt;td&gt;3,312&lt;/td&gt;
&lt;td&gt;3,221&lt;/td&gt;
&lt;td&gt;12 / 22&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kubernetes Pods&lt;/td&gt;
&lt;td&gt;137,236&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;11,781&lt;/td&gt;
&lt;td&gt;5,466&lt;/td&gt;
&lt;td&gt;5,427&lt;/td&gt;
&lt;td&gt;3 / 4&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Git diff Docs&lt;/td&gt;
&lt;td&gt;57,370&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;15,433&lt;/td&gt;
&lt;td&gt;14,812&lt;/td&gt;
&lt;td&gt;18,152&lt;/td&gt;
&lt;td&gt;3 / 24&lt;/td&gt;
&lt;td&gt;199&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Total (10 pages)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1,116,140&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5 / 10 honored&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;116,686 (-89.5%)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;80,462 (-92.8%)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;85,611 (-92.3%)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;151 / 240&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;273&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here is the summary printed directly by the local benchmark run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Audit run at UTC: 2026-11-27T13:37:03Z
Pages audited:                    10
Accept: text/markdown honored:    5/10
Total Raw HTML est tokens:        1,116,140
Total Naive strip est tokens:     116,686 (-89.5%) [0/240 fenced blocks, 0/52 pipe tables]
Total Broken MD est tokens:       80,462 (-92.8%) [151/240 code blocks span-exploded, 273 &amp;lt;dt&amp;gt; definitions dropped, 3 &amp;lt;h1&amp;gt; headings dropped]
Total Fixed Local MD est tokens:  85,611 (-92.3%) [0/240 span-exploded, 273/273 &amp;lt;dt&amp;gt; definitions preserved]
Total Hybrid (Neg+Fixed) tokens:  123,584 (-88.9%)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you only watch the top-line compression ratio, the broken local converter looks like the winner at -92.8%. Inspecting the output exposed three silent failure modes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three silent failures behind the 93% token drop
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Syntax-highlighting spans broke 151 of 240 code blocks
&lt;/h3&gt;

&lt;p&gt;Modern doc sites highlight code with Shiki, Prism, or Pygments, wrapping individual keywords, flags, and punctuation marks in separate &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; tags. Calling &lt;code&gt;pre.get_text("\n")&lt;/code&gt; to preserve line breaks inserts a newline between every adjacent syntax span.&lt;/p&gt;

&lt;p&gt;Here is an actual YAML snippet captured from the live GitHub Actions Events page during this run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Expected (pre.get_text()):
on:
  branch_protection_rule:
    types: [created, deleted]

Broken (pre.get_text("\n") across syntax spans):
on:


branch_protection_rule:


types:
 [
created
, 
deleted
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That single mistake corrupted 55 of 69 code blocks on GitHub Actions, 26 of 28 on Python's &lt;code&gt;subprocess&lt;/code&gt; docs, 12 of 22 on FastAPI, and 10 of 12 on Cloudflare Docs. Naive &lt;code&gt;BeautifulSoup.get_text(" ")&lt;/code&gt; failed the other way, keeping 0 of 240 code fences and 0 of 52 HTML tables, flattening multi-column reference tables into a single text blob.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Tag whitelists dropped 273 API and CLI definitions
&lt;/h3&gt;

&lt;p&gt;Lightweight HTML-to-Markdown scripts often walk a short element list: &lt;code&gt;h1&lt;/code&gt; through &lt;code&gt;h4&lt;/code&gt;, &lt;code&gt;p&lt;/code&gt;, &lt;code&gt;pre&lt;/code&gt;, &lt;code&gt;table&lt;/code&gt;, and &lt;code&gt;li&lt;/code&gt;. That fails without a warning on Sphinx, MDN, and Git reference manuals, which store CLI options, function signatures, and header directives inside &lt;code&gt;&amp;lt;dl&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;dt&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;dd&amp;gt;&lt;/code&gt; definition lists.&lt;/p&gt;

&lt;p&gt;On Git's &lt;code&gt;git-diff&lt;/code&gt; page alone, omitting &lt;code&gt;&amp;lt;dt&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;dd&amp;gt;&lt;/code&gt; silently deleted 199 flag definitions. Python's &lt;code&gt;subprocess&lt;/code&gt; docs lost 70 definitions, and MDN's Accept header reference lost 4. The broken converter looked smaller specifically because it threw away the reference manual.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Blanket &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt; removal and doc components hid real prose
&lt;/h3&gt;

&lt;p&gt;Decomposing every &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt; tag inside &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; erased the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; page title on 3 of the 10 pages. On component-heavy docs like the MCP Spec Intro, local HTML walking kept only 278 estimated tokens compared to the 949 tokens returned by the origin's own &lt;code&gt;Accept: text/markdown&lt;/code&gt; endpoint, because custom wrapper components were missed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why &lt;code&gt;Accept: text/markdown&lt;/code&gt; alone is only half the fix
&lt;/h2&gt;

&lt;p&gt;Server-side content negotiation is the cleanest option when supported, because the publisher sends clean Markdown directly. In this test, 5 of the 10 sites honored &lt;code&gt;Accept: text/markdown&lt;/code&gt;: Cloudflare Docs, Cloudflare Blog, Claude Code Docs, MCP Spec Intro, and GitHub Docs. The other 5 (MDN, Python, FastAPI, Kubernetes, and Git) ignored the header and returned full HTML.&lt;/p&gt;

&lt;p&gt;Negotiated payloads also carry their own quirk. On Cloudflare's blog post, &lt;code&gt;Accept: text/markdown&lt;/code&gt; returned 4,674 estimated tokens while the scoped local extractor returned 2,146 tokens. Inspecting the response explained the gap: the negotiated Markdown included an agent YAML frontmatter block at the top and a JSON-LD &lt;code&gt;BlogPosting&lt;/code&gt; block at the bottom. That extra metadata is valid, though worth accounting for in tight context budgets.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hybrid pipeline that kept every block intact
&lt;/h2&gt;

&lt;p&gt;Combining &lt;code&gt;Accept: text/markdown&lt;/code&gt; first with a structure-safe local fallback fixed all three regressions. Here is the minimal Python extractor I run locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;bs4&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Tag&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fetch_agent_markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="s2"&gt;"User-Agent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"doc-audit/1.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s2"&gt;"Accept"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"text/markdown, text/html;q=0.5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;urlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"replace"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;ctype&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"markdown"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ctype&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"negotiated"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;html_to_safe_markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"local_fallback"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;render_pipe_table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tbl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Tag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;tr&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tbl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"tr"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;recursive&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_parent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"table"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;tbl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="n"&gt;cells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\s+"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"|"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"\\|"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"th"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"td"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;recursive&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;cells&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;padded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s2"&gt;"| "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;" | "&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;padded&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;" |"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"| "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;" | "&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"---"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;" |"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"| "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;" | "&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;" |"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;padded&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;html_to_safe_markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"lxml"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"article"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;bad&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"script, style, noscript, svg, nav, footer, aside, button, form, iframe"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;bad&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decompose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;hdr&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"header"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;hdr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"h1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"h2"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;hdr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decompose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;blocks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"h1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"h2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"h3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"h4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"p"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pre"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"table"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"li"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"dt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"dd"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"pre"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_parent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"pre"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"table"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_parent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"table"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"p"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_parent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"li"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_parent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"dd"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"h1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"h2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"h3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"h4"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\s+"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;blocks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"\n{'#' * int(el.name[1])} {txt}\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"pre"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# Keep raw text intact instead of splitting on syntax &amp;lt;span&amp;gt; nodes&lt;/span&gt;
            &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;blocks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"\n```

\n{code}\n

```\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"table"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;tbl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;render_pipe_table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tbl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;blocks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"\n{tbl}\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"dt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\s+"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;blocks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"\n**{txt}**"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"dd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\s+"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;blocks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;": {txt}\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"li"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\s+"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;blocks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"- {txt}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\s+"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;blocks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"\n{txt}\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\n{3,}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"\n\n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blocks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Across the same 10 pages, this hybrid pipeline reduced total estimated tokens from 1,116,140 to 123,584 (-88.9%). Span-exploded code blocks fell from 151 to 0, all 273 &lt;code&gt;&amp;lt;dt&amp;gt;&lt;/code&gt; definitions survived, and the 5 sites serving &lt;code&gt;text/markdown&lt;/code&gt; delivered complete component prose directly from the origin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three checks to run before trusting any doc fetcher
&lt;/h2&gt;

&lt;p&gt;Before shipping a web-to-Markdown step inside an agent loop, run a quick diff against three to five documentation pages your team actually relies on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compare the line count of every extracted fenced code block against &lt;code&gt;pre.get_text()&lt;/code&gt; so syntax spans never shred commands or YAML.&lt;/li&gt;
&lt;li&gt;Count &lt;code&gt;&amp;lt;dt&amp;gt;&lt;/code&gt; definition terms and &lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt; elements inside &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; against the Markdown output so CLI flags and API parameters do not vanish without an error.&lt;/li&gt;
&lt;li&gt;Inspect the head and tail of any &lt;code&gt;Accept: text/markdown&lt;/code&gt; response so frontmatter instructions or embedded JSON-LD blocks do not surprise your token budget.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you feed live documentation into an AI coding agent or RAG pipeline, which site or HTML structure broke your extractor without throwing an error before anyone noticed?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>discuss</category>
      <category>webdev</category>
    </item>
    <item>
      <title>AI Coding Agents Raised Code Output 30% and Slowed PR Reviews 49%: How to Fix the Queue</title>
      <dc:creator>Sean Kwon</dc:creator>
      <pubDate>Tue, 24 Nov 2026 16:41:43 +0000</pubDate>
      <link>https://dev.to/seanjhkwon/ai-coding-agents-raised-code-output-30-and-slowed-pr-reviews-49-how-to-fix-the-queue-4db9</link>
      <guid>https://dev.to/seanjhkwon/ai-coding-agents-raised-code-output-30-and-slowed-pr-reviews-49-how-to-fix-the-queue-4db9</guid>
      <description>&lt;p&gt;Two large-scale 2026 empirical studies reached the same answer on AI coding agents: drafting code got dramatically faster, while shipping finished software barely moved because human code review became the choke point. In a Harvard working paper covering over 700 firms, AI coding agents raised lines of code by 30% and pull requests by 23%, yet average PR submission-to-merge time jumped 49%.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the two multi-tool studies actually measured
&lt;/h2&gt;

&lt;p&gt;Both papers track real production engineering telemetry across multiple coding tools instead of synthetic benchmark tasks.&lt;/p&gt;

&lt;p&gt;Harvard economists Fiona Chen and James Stratton (&lt;a href="https://fion.ac/" rel="noopener noreferrer"&gt;author research page&lt;/a&gt;, reported in detail by &lt;a href="https://arstechnica.com/ai/2026/10/ai-coding-agents-generate-more-code-but-not-more-software/" rel="noopener noreferrer"&gt;Ars Technica&lt;/a&gt;) analyzed 300 million work events across more than 700,000 employees at over 700 software companies through March 2026, later expanding the dataset to 445M work events across 720,542 workers at 655 firms. Across adopting companies, AI coding agents lifted lines of code by 30%, commits by 20%, and pull requests by 23%. Resolution rates for Jira issues and epics showed no statistically significant increase.&lt;/p&gt;

&lt;p&gt;A separate &lt;a href="https://www.nber.org/papers/w35275" rel="noopener noreferrer"&gt;NBER working paper (w35275)&lt;/a&gt; by Mert Demirer, Leon Musolff, and Liyuan Yang tracked more than 500,000 GitHub developers with AI usage telemetry. Cumulative commits rose 30% for autocomplete, 180% for interactive coding agents, and 240% for autonomous coding agents. Moving up the delivery funnel, that 240% commit gain dropped to 80% for projects and fell all the way to 30% for actual releases.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Empirical dataset&lt;/th&gt;
&lt;th&gt;Code generation gain&lt;/th&gt;
&lt;th&gt;Shipped output impact&lt;/th&gt;
&lt;th&gt;Measured bottleneck&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Harvard / Jellyfish (over 700 firms, 700,000+ workers; expanded to 445M events across 655 firms)&lt;/td&gt;
&lt;td&gt;+30% lines of code, +20% commits, +23% pull requests&lt;/td&gt;
&lt;td&gt;No statistically significant rise in Jira issues or epics resolved&lt;/td&gt;
&lt;td&gt;+49% PR submission-to-merge time, +35% comments per PR, change requests nearly doubled&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NBER w35275 (500,000+ GitHub developers)&lt;/td&gt;
&lt;td&gt;+30% commits (autocomplete), +180% (interactive), +240% (autonomous agents)&lt;/td&gt;
&lt;td&gt;+240% commit surge drops to +80% projects and +30% actual releases&lt;/td&gt;
&lt;td&gt;0.23 elasticity of substitution between AI and human effort&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The NBER authors tie this drop to the weak-link effect: an estimated elasticity of substitution of 0.23 between AI and human effort means faster drafting cannot substitute for human verification and review.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why AI code reviewers did not clear the backlog
&lt;/h2&gt;

&lt;p&gt;Teams already tried throwing automated review bots at the queue. In the Harvard dataset, 80% of measured firms had adopted some form of AI code review by March 2026. Even with broad adoption, AI generated only 23.3% of review comments across 10.8% of pull requests. Meanwhile, the share of human workers doing code reviews still climbed 14%.&lt;/p&gt;

&lt;p&gt;The numbers point to two stacked failure modes. First, agents push 23% more pull requests into a fixed pool of senior maintainers who understand the codebase. Second, first-pass draft quality drops, so reviewers spend more cycles catching edge cases and sending work back, driving a 35% jump in comments per PR and nearly doubling the share of pull requests with changes requested.&lt;/p&gt;

&lt;p&gt;Fixing the queue takes process gates before a human ever gets notified, not another bot leaving style comments after a reviewer is already paged.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 1: Audit merge tail latency and change-request loops in your own repo
&lt;/h2&gt;

&lt;p&gt;Before changing team rules, measure both median and 90th-percentile merge hours alongside review churn on your own merged pull requests. The &lt;a href="https://cli.github.com/manual/gh_pr_list" rel="noopener noreferrer"&gt;GitHub CLI &lt;code&gt;gh pr list&lt;/code&gt; manual&lt;/a&gt; exposes &lt;code&gt;createdAt&lt;/code&gt;, &lt;code&gt;mergedAt&lt;/code&gt;, &lt;code&gt;reviews&lt;/code&gt;, and &lt;code&gt;reviewDecision&lt;/code&gt; directly as JSON.&lt;/p&gt;

&lt;p&gt;Pipe the last 50 merged PRs into a short Python check to measure median merge time, 90th-percentile tail wait, median review events, and how often drafts bounce back with &lt;code&gt;CHANGES_REQUESTED&lt;/code&gt; (&lt;a href="https://docs.github.com/en/rest/pulls/reviews" rel="noopener noreferrer"&gt;GitHub Pull Request Reviews REST docs&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gh pr list --state merged --limit 50 \
  --json number,createdAt,mergedAt,reviews,reviewDecision \
  &lt;span class="o"&gt;|&lt;/span&gt; python3 -c &lt;span class="s1"&gt;'
import json, statistics, sys
from datetime import datetime

prs = json.load(sys.stdin)
merge_hours, rev_counts = [], []
changes_requested = 0

for pr in prs:
    created = datetime.fromisoformat(pr["createdAt"].replace("Z", "+00:00"))
    merged = datetime.fromisoformat(pr["mergedAt"].replace("Z", "+00:00"))
    merge_hours.append((merged - created).total_seconds() / 3600)
    revs = pr.get("reviews") or []
    rev_counts.append(len(revs))
    if any(r.get("state") == "CHANGES_REQUESTED" for r in revs):
        changes_requested += 1

merge_hours.sort()
p90 = merge_hours[int(0.9 * (len(merge_hours) - 1))]
print(f"Merged PRs analyzed: {len(prs)}")
print(f"Median hours to merge: {statistics.median(merge_hours):.1f}h")
print(f"90th-percentile hours to merge: {p90:.1f}h")
print(f"Median review events per PR: {statistics.median(rev_counts):.1f}")
print(f"PRs with CHANGES_REQUESTED: {changes_requested}/{len(prs)} ({100 * changes_requested / max(len(prs), 1):.1f}%)")
'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running that exact command against the last 50 merged pull requests on &lt;code&gt;modelcontextprotocol/python-sdk&lt;/code&gt; produces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Merged PRs analyzed: 50
Median hours to merge: 0.4h
90th-percentile hours to merge: 44.1h
Median review events per PR: 2.0
PRs with CHANGES_REQUESTED: 0/50 (0.0%)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looking only at the 0.4h median would suggest there is no queue at all, while the 44.1h 90th-percentile merge time reveals where harder PRs actually stall. Running the same snapshot weekly before and after changing PR rules shows whether your backlog sits in queue wait or in repeated revision rounds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 2: Force every agent PR into Draft mode so CODEOWNERS stay quiet until CI passes
&lt;/h2&gt;

&lt;p&gt;Most review queues clog because an agent finishes a loop and opens a normal pull request immediately, paging every owner before tests finish or the author inspects the diff. Under &lt;a href="https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners" rel="noopener noreferrer"&gt;GitHub's CODEOWNERS rules&lt;/a&gt;, code owners are not automatically requested to review draft pull requests. When you mark a draft pull request as ready for review, code owners are automatically notified.&lt;/p&gt;

&lt;p&gt;Make Draft mode the default in your agent prompt instructions and shell workflow using &lt;a href="https://cli.github.com/manual/gh_pr_create" rel="noopener noreferrer"&gt;&lt;code&gt;gh pr create --draft&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://cli.github.com/manual/gh_pr_ready" rel="noopener noreferrer"&gt;&lt;code&gt;gh pr ready&lt;/code&gt;&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Agent opens every PR as a draft so CODEOWNERS are not paged on broken runs&lt;/span&gt;
gh pr create --draft --fill

&lt;span class="c"&gt;# 2. Only after local tests, CI checks, and author diff inspection pass:&lt;/span&gt;
gh pr ready
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That single change keeps raw agent output out of senior engineers' notification queues while the author trims dead code, verifies edge cases, and fixes failing checks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 3: Block ready-for-review PRs that lack a reproducible verification block
&lt;/h2&gt;

&lt;p&gt;Draft mode protects reviewer attention during CI, while a pre-review workflow stops half-baked drafts from triggering change-request loops after they turn ready. Using GitHub Actions &lt;a href="https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows" rel="noopener noreferrer"&gt;&lt;code&gt;pull_request&lt;/code&gt; triggers&lt;/a&gt; for &lt;code&gt;opened&lt;/code&gt;, &lt;code&gt;synchronize&lt;/code&gt;, and &lt;code&gt;ready_for_review&lt;/code&gt;, require every non-draft PR to pass tests and include a non-empty verification section describing the exact command run to prove behavior:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PR Review Readiness Gate&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;pull_request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;types&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;opened&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;synchronize&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;ready_for_review&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;verify-before-human-review&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github.event.pull_request.draft == false&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v4&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Check PR verification block&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;pr_body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ github.event.pull_request.body }}&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;python3 - &amp;lt;&amp;lt; 'PY'&lt;/span&gt;
          &lt;span class="s"&gt;import os, re, sys&lt;/span&gt;
          &lt;span class="s"&gt;body = os.environ.get("pr_body", "")&lt;/span&gt;
          &lt;span class="s"&gt;match = re.search(r"(?is)##\s+Verification\s*\n(.+)", body)&lt;/span&gt;
          &lt;span class="na"&gt;if not match or len(match.group(1).strip()) &amp;lt; 25&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
              &lt;span class="s"&gt;print("Missing&lt;/span&gt; &lt;span class="c1"&gt;## Verification section with test command and observed result.")
&lt;/span&gt;              &lt;span class="s"&gt;sys.exit(1)&lt;/span&gt;
          &lt;span class="s"&gt;print("Verification block present.")&lt;/span&gt;
          &lt;span class="s"&gt;PY&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Run full test suite&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because the job skips draft pull requests (&lt;code&gt;github.event.pull_request.draft == false&lt;/code&gt;) and fires automatically on &lt;code&gt;ready_for_review&lt;/code&gt;, authors and agents can iterate freely in draft while guaranteeing that any PR reaching a human reviewer has both green tests and a written verification trace.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep review capacity ahead of drafting speed
&lt;/h2&gt;

&lt;p&gt;Faster code generation only raises shipped output when review capacity and draft verification scale with it. Measure your current tail merge latency and &lt;code&gt;CHANGES_REQUESTED&lt;/code&gt; rate with &lt;code&gt;gh pr list&lt;/code&gt;, default agent PRs to &lt;code&gt;--draft&lt;/code&gt; so &lt;code&gt;CODEOWNERS&lt;/code&gt; are only notified on verified work, and run a &lt;code&gt;ready_for_review&lt;/code&gt; readiness gate before human reviewers open the diff.&lt;/p&gt;

&lt;p&gt;Where has the review queue slowed down most on your repositories since adopting coding agents, and which workflow change actually cut back the revision loops?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Setting alwaysLoad to True Cuts an MCP Tool's Description Budget From 16,384 Characters to 4,096</title>
      <dc:creator>Sean Kwon</dc:creator>
      <pubDate>Fri, 20 Nov 2026 16:52:36 +0000</pubDate>
      <link>https://dev.to/seanjhkwon/setting-alwaysload-to-true-cuts-an-mcp-tools-description-budget-from-16384-characters-to-4096-3jpi</link>
      <guid>https://dev.to/seanjhkwon/setting-alwaysload-to-true-cuts-an-mcp-tools-description-budget-from-16384-characters-to-4096-3jpi</guid>
      <description>&lt;p&gt;Claude Code caps a Model Context Protocol tool's description at 4,096 characters when the tool loads upfront, and at 16,384 characters when it sits behind tool search instead. Setting alwaysLoad to true on a server cuts every one of its tool descriptions down to the smaller limit, without touching the description text itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Upfront and deferred are not just a speed setting
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://code.claude.com/docs/en/mcp.md#scale-with-mcp-tool-search" rel="noopener noreferrer"&gt;Claude Code defers MCP tool definitions by default&lt;/a&gt; instead of loading every connected server's full tool schema at the start of a session. Tool names and server instructions load first, and a tool's complete definition loads once the model searches for a capability it actually needs. Tool search keeps MCP context usage low by deferring tool definitions until Claude needs them, and only tool names and server instructions load at session start, so adding more MCP servers has minimal impact on the context window.&lt;/p&gt;

&lt;p&gt;That deferral is also why the character limit changes between the two modes. A tool that loads upfront has to fit inside the same context budget as the rest of the conversation on every single turn, so &lt;a href="https://code.claude.com/docs/en/mcp.md#for-mcp-server-authors" rel="noopener noreferrer"&gt;Claude Code enforces a tighter ceiling on it&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The two limits, side by side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Loading mode&lt;/th&gt;
&lt;th&gt;Description character limit&lt;/th&gt;
&lt;th&gt;How a tool ends up there&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Loads upfront&lt;/td&gt;
&lt;td&gt;4,096&lt;/td&gt;
&lt;td&gt;alwaysLoad set to true on the tool or the server, or tool search turned off&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Loads through tool search (deferred)&lt;/td&gt;
&lt;td&gt;16,384&lt;/td&gt;
&lt;td&gt;Default behavior, with alwaysLoad left out and tool search on&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;auto or auto:N threshold&lt;/td&gt;
&lt;td&gt;4,096 while usage stays under the percentage, 16,384 once tool search turns on&lt;/td&gt;
&lt;td&gt;ENABLE_TOOL_SEARCH set to auto or auto:N&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Claude Code cuts a tool description or server instructions that run past whichever limit applies, and the model sees only the text before the cut. There is no error and no warning line in the terminal, just a shorter description than the one the server actually sent.&lt;/p&gt;

&lt;p&gt;Here is the actual gap between the two limits, checked locally instead of eyeballed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;$ &lt;span class="n"&gt;python3&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="s2"&gt;"
upfront = 4096
deferred = 16384
print(f'upfront limit: {upfront} chars')
print(f'tool search limit: {deferred} chars')
print(f'difference: {deferred - upfront} chars')
print(f'ratio: {deferred/upfront:.1f}x')
"&lt;/span&gt;
&lt;span class="n"&gt;upfront&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4096&lt;/span&gt; &lt;span class="n"&gt;chars&lt;/span&gt;
&lt;span class="n"&gt;tool&lt;/span&gt; &lt;span class="n"&gt;search&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;16384&lt;/span&gt; &lt;span class="n"&gt;chars&lt;/span&gt;
&lt;span class="n"&gt;difference&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;12288&lt;/span&gt; &lt;span class="n"&gt;chars&lt;/span&gt;
&lt;span class="n"&gt;ratio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;4.0x&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A tool description written with the 16,384 character budget in mind, enough room for several worked examples and edge cases, loses three out of every four characters the moment its server sets alwaysLoad to true. Whatever text came first in the description survives the cut, so examples placed near the end of a long description are usually what disappears.&lt;/p&gt;

&lt;h2&gt;
  
  
  Per-tool opt-in, and the override that beats it
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://code.claude.com/docs/en/mcp.md#per-tool-alwaysload" rel="noopener noreferrer"&gt;A server author can mark a single tool to always load upfront&lt;/a&gt; by setting &lt;code&gt;anthropic/alwaysLoad&lt;/code&gt; inside that tool's &lt;code&gt;_meta&lt;/code&gt; object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"search_tickets"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Searches the ticket tracker by keyword"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"_meta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"anthropic/alwaysLoad"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The person who configures the server can override that per-tool choice for the whole server. &lt;a href="https://code.claude.com/docs/en/mcp.md#exempt-a-server-from-deferral" rel="noopener noreferrer"&gt;Setting alwaysLoad to true at the server level&lt;/a&gt; forces every one of its tools upfront regardless of what each tool's own &lt;code&gt;_meta&lt;/code&gt; asked for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"core-tools"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://mcp.example.com/mcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"alwaysLoad"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://code.claude.com/docs/en/mcp.md#defer-a-servers-tools" rel="noopener noreferrer"&gt;Setting alwaysLoad to false at the server level&lt;/a&gt; does the opposite. It keeps every tool deferred, including the ones a server author marked to load upfront with their own &lt;code&gt;_meta&lt;/code&gt; setting. Only when the server's configuration leaves alwaysLoad out do those per-tool marks take effect.&lt;/p&gt;

&lt;h2&gt;
  
  
  The auto threshold most setups never touch
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://code.claude.com/docs/en/mcp.md#configure-tool-search" rel="noopener noreferrer"&gt;Tool search also runs in a threshold mode&lt;/a&gt;. Setting &lt;code&gt;ENABLE_TOOL_SEARCH&lt;/code&gt; to &lt;code&gt;auto&lt;/code&gt; keeps tools that would otherwise be deferred loading upfront as long as their combined definitions stay under 10 percent of the context window. Once that total reaches 10 percent, tool search turns on for those tools. &lt;code&gt;auto:N&lt;/code&gt; runs the same check against a custom percentage instead of the fixed 10:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Use a custom 5% threshold&lt;/span&gt;
&lt;span class="nv"&gt;ENABLE_TOOL_SEARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;auto:5 claude

&lt;span class="c"&gt;# Disable tool search entirely&lt;/span&gt;
&lt;span class="nv"&gt;ENABLE_TOOL_SEARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt; claude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A session with a couple of small MCP servers can sit under that threshold and keep every tool upfront at the 4,096 character limit without anyone setting &lt;code&gt;alwaysLoad&lt;/code&gt; anywhere. Connect another server with a long tool list, cross 10 percent, and the same session switches those tools to deferred loading and the 16,384 character limit, with no configuration change on your side.&lt;/p&gt;

&lt;h2&gt;
  
  
  Turning tool search off entirely
&lt;/h2&gt;

&lt;p&gt;Tool search can also be turned off at the permission layer instead of the environment variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"permissions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"deny"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ToolSearch"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Denying the &lt;code&gt;ToolSearch&lt;/code&gt; tool has the same practical result as setting &lt;code&gt;ENABLE_TOOL_SEARCH=false&lt;/code&gt;: MCP tools load upfront instead of being deferred, and each keeps the 4,096 character ceiling that applies to an upfront-loaded description.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to check before writing a long tool description
&lt;/h2&gt;

&lt;p&gt;Check the active &lt;code&gt;.mcp.json&lt;/code&gt; entry for the server before assuming a tool gets the full 16,384 character budget, since &lt;code&gt;alwaysLoad&lt;/code&gt; can be set there by someone else on the team and silently pin every tool to the smaller limit.&lt;/p&gt;

&lt;p&gt;Keep a tool's description inside 4,096 characters when it genuinely needs to stay visible on every turn, instead of writing for the deferred limit and hoping the tool never gets pinned upfront later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://code.claude.com/docs/en/mcp.md#change-the-description-length-limits" rel="noopener noreferrer"&gt;Raising CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH to 8192 moves both numbers to the same place at once&lt;/a&gt;. The upfront limit goes up to 8,192 characters and the deferred limit comes down to 8,192 characters, closing the four times gap between the two modes entirely.&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>ai</category>
      <category>programming</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Why Coding Agent Commits Are 3x Larger and How to Keep PRs Reviewable</title>
      <dc:creator>Sean Kwon</dc:creator>
      <pubDate>Tue, 17 Nov 2026 16:45:25 +0000</pubDate>
      <link>https://dev.to/seanjhkwon/why-coding-agent-commits-are-3x-larger-and-how-to-keep-prs-reviewable-5hhn</link>
      <guid>https://dev.to/seanjhkwon/why-coding-agent-commits-are-3x-larger-and-how-to-keep-prs-reviewable-5hhn</guid>
      <description>&lt;p&gt;A 2026 empirical study of 128,018 GitHub repositories (&lt;a href="https://arxiv.org/abs/2601.18341" rel="noopener noreferrer"&gt;arXiv:2601.18341&lt;/a&gt;) measured how autonomous coding agents like Cursor, Claude Code, and Codex change real version control histories. Adoption across active repositories already sits between 22.20% and 28.66%, yet the sharpest operational shift appears at code review time.&lt;/p&gt;

&lt;p&gt;Commits assisted by coding agents add a median of 31 lines of code, triple the 11-line median of human-authored commits and nearly eight times the 4-line median of automated dependency bots. At the 75th percentile, agent-assisted additions reach 114 lines compared to 41 lines for humans.&lt;/p&gt;

&lt;p&gt;When an agent bundles import cleanup, type renames, and core business logic into one large patch, human reviewers start skimming. Here is what the repository data shows and how to enforce small, single-intent commits locally before opening a pull request.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the 128,018-repository dataset shows
&lt;/h2&gt;

&lt;p&gt;The size gap widens at the tails of the commit distribution:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Small surgical commits (1 to 5 added lines) drop by 36% when a coding agent assists with the change.&lt;/li&gt;
&lt;li&gt;Massive commits adding more than 1,000 lines occur almost twice as frequently in agent-assisted histories.&lt;/li&gt;
&lt;li&gt;Single-file commits drop by roughly 15%, while commits touching more than 20 files jump by 30%.&lt;/li&gt;
&lt;li&gt;Median deletions also climb from 5 lines in human commits to 7 lines in agent-assisted commits, increasing cross-file code churn.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Agents optimize for task completion inside a single prompt loop. Ask an agent to fix a pagination bug, and it will often reformat untouched helpers, rename local variables, and update test fixtures in the same working tree. Staging everything at once turns a 15-line bug fix into a 14-file review bottleneck.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspecting staged churn before you commit
&lt;/h2&gt;

&lt;p&gt;Before running &lt;code&gt;git commit&lt;/code&gt; after an agent session, inspect file-level churn across the index with &lt;code&gt;--numstat&lt;/code&gt; and &lt;code&gt;--shortstat&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff --cached --numstat
git diff --cached --shortstat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A mixed agent session typically produces an uneven spread 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;4   4   src/api/client.ts
2   2   src/utils/date.ts
68  59  src/components/table.tsx
19  3   src/services/pagination.ts
34  0   tests/pagination.test.ts
 5 files changed, 127 insertions(+), 68 deletions(-)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only &lt;code&gt;src/services/pagination.ts&lt;/code&gt; and &lt;code&gt;tests/pagination.test.ts&lt;/code&gt; implement the actual fix. The remaining 139 modified lines in &lt;code&gt;table.tsx&lt;/code&gt;, &lt;code&gt;client.ts&lt;/code&gt;, and &lt;code&gt;date.ts&lt;/code&gt; are formatting and cleanup noise that obscure the behavioral change.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Separate mechanical edits from behavior changes
&lt;/h2&gt;

&lt;p&gt;Reset the index and stage hunks selectively so mechanical cleanup never shares a commit hash with behavioral logic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Unstage all agent edits while keeping working tree changes intact&lt;/span&gt;
git reset

&lt;span class="c"&gt;# Commit 1: stage mechanical formatting or renames only&lt;/span&gt;
git add src/api/client.ts src/utils/date.ts src/components/table.tsx
git commit -m &lt;span class="s2"&gt;"refactor: normalize table formatting and imports"&lt;/span&gt;

&lt;span class="c"&gt;# Commit 2: interactively verify and stage logic hunks plus tests&lt;/span&gt;
git add --patch src/services/pagination.ts tests/pagination.test.ts
git commit -m &lt;span class="s2"&gt;"fix: handle empty cursor boundary in pagination"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reviewers can now verify the 22-line pagination &lt;code&gt;fix:&lt;/code&gt; commit in seconds and inspect the mechanical cleanup commit separately without hunting for hidden logic mutations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Add a local pre-commit diff budget hook
&lt;/h2&gt;

&lt;p&gt;Prompt rules alone drift during long coding sessions. A lightweight &lt;code&gt;.git/hooks/pre-commit&lt;/code&gt; script enforces a hard ceiling on file count and line churn before a commit is recorded:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -euo pipefail

&lt;span class="nv"&gt;max_files&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10
&lt;span class="nv"&gt;max_lines&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;300

&lt;span class="nv"&gt;files_changed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;git diff --cached --numstat &lt;span class="o"&gt;|&lt;/span&gt; wc -l &lt;span class="o"&gt;|&lt;/span&gt; tr -d &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;lines_changed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;git diff --cached --numstat &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'{ sum += $1 + $2 } END { print sum + 0 }'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$files_changed"&lt;/span&gt; -gt &lt;span class="s2"&gt;"$max_files"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$lines_changed"&lt;/span&gt; -gt &lt;span class="s2"&gt;"$max_lines"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Commit blocked: $files_changed files and $lines_changed changed lines exceed budget ($max_files files / $max_lines lines)."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Split mechanical cleanup from feat: or fix: logic using git reset and git add --patch."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make the hook executable in your repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod +x .git/hooks/pre-commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When an unbounded agent run attempts to bundle 14 files and 418 changed lines into one commit, Git stops the commit immediately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Commit blocked: 14 files and 418 changed lines exceed budget (10 files / 300 lines).
Split mechanical cleanup from feat: or fix: logic using git reset and git add --patch.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Splitting the working tree into a cleanup commit and a focused logic commit brings both diffs well below the threshold and keeps &lt;code&gt;git bisect&lt;/code&gt; reliable when tracking down regressions later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary checklist
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Check staged file spread with &lt;code&gt;git diff --cached --numstat&lt;/code&gt; after every autonomous agent run.&lt;/li&gt;
&lt;li&gt;Keep formatting, file moves, and import cleanup in a standalone preparatory commit.&lt;/li&gt;
&lt;li&gt;Stage behavioral &lt;code&gt;feat:&lt;/code&gt; and &lt;code&gt;fix:&lt;/code&gt; changes alongside their tests using &lt;code&gt;git add --patch&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Enforce a local &lt;code&gt;.git/hooks/pre-commit&lt;/code&gt; line and file budget so oversized multi-intent diffs never reach pull request review.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>git</category>
      <category>ai</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Why settings.local.json Leaks Secrets on GitHub and How to Fix It</title>
      <dc:creator>Sean Kwon</dc:creator>
      <pubDate>Fri, 13 Nov 2026 19:12:38 +0000</pubDate>
      <link>https://dev.to/seanjhkwon/why-settingslocaljson-leaks-secrets-on-github-and-how-to-fix-it-59c1</link>
      <guid>https://dev.to/seanjhkwon/why-settingslocaljson-leaks-secrets-on-github-and-how-to-fix-it-59c1</guid>
      <description>&lt;p&gt;A security scan across public GitHub repositories identified 1,122 configuration files exposing active credentials. The culprit was a common convenience feature in terminal coding agents: the "Yes, and don't ask again" approval prompt.&lt;/p&gt;

&lt;p&gt;When an agent proposes running a command containing credentials and you grant standing approval, the client records that exact string into &lt;code&gt;.claude/settings.local.json&lt;/code&gt; under its permissions allow list. If that file ever gets tracked, every key inside it enters your commit history.&lt;/p&gt;

&lt;p&gt;Here is the exact mechanism behind the leak and the three configuration steps required to prevent it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The mechanics of the leak
&lt;/h2&gt;

&lt;p&gt;When Claude Code asks for permission to execute a shell command, selecting "Yes, and don't ask again" creates an entry in your local settings file. If the proposed command contains inline tokens, database passwords, or private endpoints, the literal command string is saved to disk:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"permissions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"allow"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="s2"&gt;"Bash(psql localhost:5432/main -U postgres)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"Bash(curl -H \"Authorization: Bearer api-token-here\" https://api.internal/v1/sync)"&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The underlying issue is Git synchronization. Claude Code automatically writes &lt;code&gt;**/.claude/settings.local.json&lt;/code&gt; to your workstation's global Git excludes file (&lt;code&gt;core.excludesFile&lt;/code&gt;). That protects your primary machine.&lt;/p&gt;

&lt;p&gt;However, global git excludes do not travel with the repository. When you clone the repository onto a secondary laptop, a CI runner, or a teammate's machine where global excludes are unconfigured, Git treats &lt;code&gt;.claude/settings.local.json&lt;/code&gt; as an untracked file. Running &lt;code&gt;git add .&lt;/code&gt; or &lt;code&gt;git add -A&lt;/code&gt; immediately stages the file along with your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verifying your repository history
&lt;/h2&gt;

&lt;p&gt;Before changing configurations, verify whether any agent settings files were staged or committed in your repository. Run this terminal check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --all --full-history -- &lt;span class="s2"&gt;"*/.claude/settings.local.json"&lt;/span&gt; &lt;span class="s2"&gt;".claude/settings.local.json"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the command outputs commit hashes, the file has already been committed to your history. Here is a typical output from a compromised repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;commit 7b1e4a8f90c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6
Author: Developer &amp;lt;developer at example.com&amp;gt;
Date:   Wed Nov 11 14:22:10 2026 -05:00

    feat: update dev configuration and test scripts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your history contains commits with this file, rotating those credentials at the provider is mandatory. Deleting the file in a new commit leaves the secret intact in earlier revisions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Enforce repository-level Git ignore
&lt;/h2&gt;

&lt;p&gt;Do not rely on workstation-level global excludes. Add the agent settings directory directly to your project &lt;code&gt;.gitignore&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Coding agent local settings
.claude/settings.local.json
.claude/worktrees/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the file was already tracked in your working tree, unstage it without deleting your local copy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rm --cached .claude/settings.local.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm '.claude/settings.local.json'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commit the &lt;code&gt;.gitignore&lt;/code&gt; update so every collaborator and environment inherits the rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Use environment variables instead of literal commands
&lt;/h2&gt;

&lt;p&gt;Terminal agents allow command rules with environment variable substitution. Instead of approving commands with inline secrets, pass variables defined in your shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Approves generalized variable command instead of literal secret&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;db_password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"secret_password"&lt;/span&gt;
psql &lt;span class="s2"&gt;"postgresql://app_user:$db_password/main"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;code&gt;.claude/settings.json&lt;/code&gt; (the shared, committed team configuration), restrict standing permissions to generalized command patterns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"permissions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"allow"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="s2"&gt;"Bash(git status)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"Bash(npm test)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"Bash(pytest tests/)"&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"deny"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="s2"&gt;"Bash(curl *sk-ant*)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s2"&gt;"Bash(*BEGIN OPENSSH PRIVATE KEY*)"&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deny rules override allow rules. Blocking common credential patterns prevents the CLI from executing or recording high-risk strings without explicit per-command prompts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Add a pre-commit secret hook
&lt;/h2&gt;

&lt;p&gt;Add a local hook in &lt;code&gt;.git/hooks/pre-commit&lt;/code&gt; to prevent accidental staging of agent configuration files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -euo pipefail

&lt;span class="c"&gt;# Block staged agent local settings&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; git diff --cached --name-only &lt;span class="o"&gt;|&lt;/span&gt; grep -E &lt;span class="s1"&gt;'\.claude/settings\.local\.json$'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: Attempting to commit .claude/settings.local.json"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"This file contains local permissions and should never be committed."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make the script executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chmod +x .git/hooks/pre-commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Testing the hook against a staged settings file confirms the block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add .claude/settings.local.json &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; git commit -m &lt;span class="s2"&gt;"test commit"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: Attempting to commit .claude/settings.local.json
This file contains local permissions and should never be committed.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary checklist
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Run &lt;code&gt;git log&lt;/code&gt; to confirm &lt;code&gt;.claude/settings.local.json&lt;/code&gt; was never pushed.&lt;/li&gt;
&lt;li&gt;Commit &lt;code&gt;.claude/settings.local.json&lt;/code&gt; to the project root &lt;code&gt;.gitignore&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Rotate any API tokens or database credentials that were saved with standing approvals.&lt;/li&gt;
&lt;li&gt;Define explicit deny patterns in &lt;code&gt;.claude/settings.json&lt;/code&gt; to block inline token patterns.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>security</category>
      <category>github</category>
      <category>ai</category>
      <category>devtools</category>
    </item>
    <item>
      <title>Why Stale CLAUDE.md and AGENTS.md Files Override Working Code in 90.1% of Runs (And the One-Sentence Fix)</title>
      <dc:creator>Sean Kwon</dc:creator>
      <pubDate>Tue, 10 Nov 2026 22:56:17 +0000</pubDate>
      <link>https://dev.to/seanjhkwon/why-stale-claudemd-and-agentsmd-files-override-working-code-in-901-of-runs-and-the-10i2</link>
      <guid>https://dev.to/seanjhkwon/why-stale-claudemd-and-agentsmd-files-override-working-code-in-901-of-runs-and-the-10i2</guid>
      <description>&lt;p&gt;Instruction files like &lt;code&gt;CLAUDE.md&lt;/code&gt; and &lt;code&gt;AGENTS.md&lt;/code&gt; are usually written once when a repository sets up a coding agent and rarely touched again. Across 441 company repositories analyzed by Denisov-Blanch et al. (2026), 73.8% of AI configuration files were committed once and never modified. In a separate study of 356 public repositories by Treude and Baltes (2026), 23.0% of instruction files referenced code elements that no longer existed.&lt;/p&gt;

&lt;p&gt;When the codebase moves on while the instruction file stays frozen, coding agents receive two contradictory sources of truth. A study by Xiaonan Xu and Wenjing Wu from Georgia Tech and UC Boulder (&lt;a href="https://arxiv.org/abs/2610.30571" rel="noopener noreferrer"&gt;arXiv:2610.30571&lt;/a&gt;) measured what Claude Code and OpenAI Codex CLI do when &lt;code&gt;CLAUDE.md&lt;/code&gt; or &lt;code&gt;AGENTS.md&lt;/code&gt; disagrees with the existing code across 320 runs on 40 Python projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Happened Across 320 Runs Without a Precedence Rule
&lt;/h2&gt;

&lt;p&gt;Each of the 40 Python projects in the study had working modules, a passing test suite, and an instruction file asking for one convention while the existing code used another across 16 convention categories (for example, &lt;code&gt;print()&lt;/code&gt; versus &lt;code&gt;logging&lt;/code&gt;, &lt;code&gt;os.path&lt;/code&gt; versus &lt;code&gt;pathlib&lt;/code&gt;, or string constants versus &lt;code&gt;Enum&lt;/code&gt;). Claude Code (v2.1.302 on Claude Sonnet 5.5) and Codex CLI (v0.163.0 on GPT-6 Sol) were asked to add a feature in 320 unattended runs totaling 720 convention choices.&lt;/p&gt;

&lt;p&gt;Without a precedence rule in the user-level instruction file:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Across all 720 convention choices, 90.1% (649 of 720) followed the stale instruction file and only 4.2% followed the existing code (86.4% file adherence in Claude Code and 93.9% in Codex CLI).&lt;/li&gt;
&lt;li&gt;Claude Code explicitly noted the conflict between &lt;code&gt;CLAUDE.md&lt;/code&gt; and the existing code in its final reply in 79 of 80 runs, yet still followed the stale file in 86.2% of its choices.&lt;/li&gt;
&lt;li&gt;Codex CLI went further in 20 of 80 runs: it rewrote the existing working modules to match the stale &lt;code&gt;AGENTS.md&lt;/code&gt; file (removing a median of 198 lines across 9 existing files), which broke the project's original test suite in 17 of those 20 runs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the exact kind of final reply Claude Code produced in the baseline condition after reading the code and seeing the mismatch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The existing concat.py, reader.py, writer.py and columns.py still use logging,
pathlib, str.format() and absolute imports, which go against CLAUDE.md.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even after identifying that every module in the repository used &lt;code&gt;logging&lt;/code&gt; and &lt;code&gt;pathlib&lt;/code&gt;, the agent wrote the new feature using &lt;code&gt;print()&lt;/code&gt; and &lt;code&gt;os.path&lt;/code&gt; to obey &lt;code&gt;CLAUDE.md&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Coding Agents Rank a Stale File Above Working Code
&lt;/h2&gt;

&lt;p&gt;The study traces this behavior to how agent harnesses deliver context and how frontier models are trained to enforce the instruction hierarchy:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Imperative phrasing: A line like &lt;code&gt;Use print() for progress messages&lt;/code&gt; is written as a command, even when it was only meant to describe how the code looked when the line was written.&lt;/li&gt;
&lt;li&gt;Instruction-tier delivery: Claude Code injects &lt;code&gt;CLAUDE.md&lt;/code&gt; directly after the system prompt inside a user message prefixed with &lt;code&gt;IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.&lt;/code&gt; Codex CLI wraps &lt;code&gt;AGENTS.md&lt;/code&gt; inside an &lt;code&gt;INSTRUCTIONS&lt;/code&gt; tag.&lt;/li&gt;
&lt;li&gt;Tool-output deprioritization: The actual source code only reaches the model when the agent calls a file-reading tool. Because frontier models are trained to rank system and user instructions above tool output to defend against prompt injection, an outdated rule in &lt;code&gt;CLAUDE.md&lt;/code&gt; or &lt;code&gt;AGENTS.md&lt;/code&gt; outranks the live code returned by the file reader.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The One-Sentence Precedence Fix
&lt;/h2&gt;

&lt;p&gt;Because the conflict happens at the instruction layer, fixing it requires an instruction at the same layer. The authors added a single sentence to the user-level instruction file (&lt;code&gt;~/.claude/CLAUDE.md&lt;/code&gt; for Claude Code and &lt;code&gt;~/.codex/AGENTS.md&lt;/code&gt; for Codex CLI):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;When a repository's documentation and its existing code disagree, follow the conventions used in the existing code, and in your final reply point out each inconsistency you found between the documentation and the code.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With that one sentence in place across the same 40 projects and 160 runs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The share of choices following the existing code jumped from 4.2% to 91.4% (658 of 720 choices), rising from 7.5% to 94.4% in Claude Code and from 0.8% to 88.3% in Codex CLI.&lt;/li&gt;
&lt;li&gt;Destructive rewrites of existing working modules by Codex CLI dropped from 20 runs to 0.&lt;/li&gt;
&lt;li&gt;The overall test pass rate across all 160 runs rose from 89.4% to 100% (with Codex CLI rising from 78.8% to 100%).&lt;/li&gt;
&lt;li&gt;Both agents reported the outdated rules in all 160 final replies so maintainers knew which lines in &lt;code&gt;CLAUDE.md&lt;/code&gt; or &lt;code&gt;AGENTS.md&lt;/code&gt; needed updating.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Three Practical Steps to Stop Instruction Drift in Your Repositories
&lt;/h2&gt;

&lt;p&gt;You can combine the paper's user-level precedence rule with Claude Code's built-in instruction management features (&lt;a href="https://code.claude.com/docs/en/memory" rel="noopener noreferrer"&gt;Claude Code Memory Docs&lt;/a&gt;):&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Add the precedence sentence to your global agent config
&lt;/h3&gt;

&lt;p&gt;Add the rule once to both user-level files so it applies to every repository you open:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.claude/CLAUDE.md

When a repository&lt;span class="s1"&gt;'s documentation and its existing code disagree, follow the conventions used in the existing code, and in your final reply point out each inconsistency you found between the documentation and the code.
EOF

cat &amp;lt;&amp;lt; '&lt;/span&gt;EOF&lt;span class="s1"&gt;' &amp;gt;&amp;gt; ~/.codex/AGENTS.md

When a repository'&lt;/span&gt;s documentation and its existing code disagree, follow the conventions used &lt;span class="k"&gt;in&lt;/span&gt; the existing code, and &lt;span class="k"&gt;in&lt;/span&gt; your final reply point out each inconsistency you found between the documentation and the code.
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Share one root file across Claude Code and Codex
&lt;/h3&gt;

&lt;p&gt;Maintaining separate &lt;code&gt;CLAUDE.md&lt;/code&gt; and &lt;code&gt;AGENTS.md&lt;/code&gt; files in the same repository doubles the chance that one file goes stale after a refactor. Keep your shared build commands and architecture rules in &lt;code&gt;AGENTS.md&lt;/code&gt;, and import it from &lt;code&gt;CLAUDE.md&lt;/code&gt; using the &lt;code&gt;@path&lt;/code&gt; syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;@AGENTS.md

&lt;span class="gu"&gt;## Claude Code
&lt;/span&gt;
Use plan mode for changes under &lt;span class="sb"&gt;`src/billing/`&lt;/span&gt;.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, configure Claude Code to load both &lt;code&gt;CLAUDE.md&lt;/code&gt; and &lt;code&gt;AGENTS.md&lt;/code&gt; automatically in &lt;code&gt;~/.claude/settings.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"pluginConfigs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"cc-plugin-agents-md@builtin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"options"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"instructionFiles"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"claude-md-and-agents-md"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Move directory-specific conventions into path-scoped rules and run &lt;code&gt;/doctor prompt-audit&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Root instruction files go stale fastest when they try to document file-level conventions for every subfolder. In Claude Code, place directory-specific rules in &lt;code&gt;.claude/rules/*.md&lt;/code&gt; with a &lt;code&gt;paths&lt;/code&gt; glob in the YAML frontmatter so they load on demand only when the agent reads or edits matching files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
paths:
  &lt;span class="k"&gt;- &lt;/span&gt;"src/api/**/*.ts"
---

&lt;span class="gu"&gt;# API Handler Conventions
&lt;/span&gt;
&lt;span class="k"&gt;- &lt;/span&gt;Validate request bodies with the schema helpers in &lt;span class="sb"&gt;`src/api/validators/`&lt;/span&gt;.
&lt;span class="k"&gt;- &lt;/span&gt;Return structured errors through &lt;span class="sb"&gt;`sendApiError()`&lt;/span&gt;.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you upgrade dependencies or finish a migration, run &lt;code&gt;/doctor prompt-audit&lt;/code&gt; inside a Claude Code session (available in v2.1.283 or later) to scan &lt;code&gt;CLAUDE.md&lt;/code&gt;, &lt;code&gt;AGENTS.md&lt;/code&gt;, &lt;code&gt;.claude/rules/&lt;/code&gt;, and &lt;code&gt;.claude/skills/&lt;/code&gt; for references to deleted files, missing commands, and conflicting instructions before they steer your next session.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>productivity</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
