<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Deslop</title>
  <subtitle>Find duplicate code in nine languages. Deslop ranks what to remove first and tells your coding agent when similar code already exists — live in VS Code.</subtitle>
  <link href="https://deslop.live/feed.xml" rel="self"/>
  <link href="https://deslop.live/"/>
  <updated>2026-07-28T00:00:00.000Z</updated>
  <id>https://deslop.live/</id>
  <author><name>Christian Findlay</name></author>
  <entry>
    <title>Regex on source code is illegal</title>
    <link href="https://deslop.live/blog/tree-sitter-over-regex/"/>
    <id>https://deslop.live/blog/tree-sitter-over-regex/</id>
    <updated>2026-04-10T00:00:00.000Z</updated>
    <content type="html">https://deslop.live/%3Cp%3EMost%20clone%20detectors%20you%20have%20used%20%E2%80%94%20CPD,%20Simian,%20jscpd%20%E2%80%94%20are%20fundamentally%20line-matchers.%20They%20take%20your%20source,%20tokenize%20or%20hash%20it%20by%20line,%20and%20find%20runs%20of%20matching%20lines.%20That%20approach%20has%20two%20features:%20it%20is%20fast,%20and%20it%20predates%20anyone%20writing%20a%20parser%20that%20is%20fast%20enough%20to%20not%20be%20the%20bottleneck.%20Tree-sitter%20changed%20the%20second%20fact.%20Deslop%20refuses%20to%20pretend%20otherwise.%3C/p%3E%3Ch2%20id=%22what-line-matching-misses%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-line-matching-misses%22%3EWhat%20line-matching%20misses%3C/a%3E%3C/h2%3E%3Cp%3EA%20line-matcher%20cannot%20see%20past:%3C/p%3E%3Cul%3E%3Cli%3E%3Cstrong%3EFormatting.%3C/strong%3E%20Two%20identical%20functions%20formatted%20differently%20look%20like%20different%20code.%3C/li%3E%3Cli%3E%3Cstrong%3ERename.%3C/strong%3E%20Changing%20%3Ccode%3Euser%3C/code%3E%20to%20%3Ccode%3Ecustomer%3C/code%3E%20across%20a%20method%20breaks%20every%20match.%3C/li%3E%3Cli%3E%3Cstrong%3EReorder.%3C/strong%3E%20Swapping%20two%20independent%20statements%20produces%20zero%20overlap%20in%20the%20tokenizer&#39;s%20world.%3C/li%3E%3Cli%3E%3Cstrong%3ESugar.%3C/strong%3E%20LINQ%20versus%20%3Ccode%3Eforeach%3C/code%3E,%20%3Ccode%3Easync/await%3C/code%3E%20versus%20callbacks,%20list%20comprehension%20versus%20loop%20%E2%80%94%20all%20the%20same%20code,%20all%20invisible%20to%20a%20tokenizer.%3C/li%3E%3C/ul%3E%3Cp%3EYou%20can%20patch%20around%20each%20individually.%20CPD%20normalizes%20whitespace.%20jscpd%20has%20mode%20toggles.%20Simian%20lets%20you%20configure%20what%20counts%20as%20a%20match.%20Every%20patch%20is%20a%20pile%20of%20heuristics%20that%20fail%20at%20the%20next%20edge%20case.%20The%20architecture%20does%20not%20support%20doing%20better.%3C/p%3E%3Ch2%20id=%22what-tree-sitter-lets-us-do%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-tree-sitter-lets-us-do%22%3EWhat%20tree-sitter%20lets%20us%20do%3C/a%3E%3C/h2%3E%3Cp%3EA%20tree-sitter%20parser%20produces%20an%20AST%20for%20every%20file%20in%20the%20repo.%20From%20that%20tree%20we%20can:%3C/p%3E%3Cul%3E%3Cli%3Enormalize%20identifiers%20and%20literals%20to%20canonical%20placeholders,%20so%20renames%20collapse%20to%20the%20same%20fingerprint;%3C/li%3E%3Cli%3Ehash%20subtrees%20independently,%20so%20the%20fingerprint%20of%20a%20method%20is%20stable%20regardless%20of%20where%20it%20lives%20in%20the%20file;%3C/li%3E%3Cli%3Eoperate%20on%20subtrees%20rather%20than%20lines,%20so%20formatting%20and%20whitespace%20are%20irrelevant;%3C/li%3E%3Cli%3Eemit%20byte%20ranges%20that%20survive%20every%20kind%20of%20source%20transformation%20except%20semantic%20rewrite.%3C/li%3E%3C/ul%3E%3Cp%3EThe%20pipeline%20this%20enables%20is%20linear,%20deterministic,%20and%20cheap.%20No%20heuristics.%20No%20per-language%20special%20cases%20beyond%20the%20grammar.%20Adding%20a%20language%20is:%20implement%20the%20%3Ccode%3ELanguageParser%3C/code%3E%20trait,%20pin%20the%20grammar,%20done.%3C/p%3E%3Ch2%20id=%22why-no-regex-is-written-into-the-rulebook%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#why-no-regex-is-written-into-the-rulebook%22%3EWhy%20&amp;quot;no%20regex&amp;quot;%20is%20written%20into%20the%20rulebook%3C/a%3E%3C/h2%3E%3Cp%3EThe%20%3Ccode%3ECLAUDE.md%3C/code%3E%20for%20this%20repo%20says%20it%20plainly:%20%3Cstrong%3Eregex%20on%20source%20code%20is%20prohibited.%3C/strong%3E%20Not%20&amp;quot;avoid,&amp;quot;%20not%20&amp;quot;prefer%20parsers&amp;quot;%20%E2%80%94%20illegal.%20That%20rule%20exists%20because%20regex-on-source%20is%20a%20slippery%20slope.%20The%20first%20one%20handles%20a%20niche%20case%20a%20parser%20cannot%20easily%20express.%20The%20second%20one%20fixes%20a%20bug%20in%20the%20first.%20By%20the%20fifth,%20the%20codebase%20has%20a%20regex%20layer%20shadowing%20a%20parser%20layer%20and%20nobody%20can%20reason%20about%20which%20one%20fires%20first.%3C/p%3E%3Cp%3ETree-sitter%20is%20not%20a%20convenience%20in%20Deslop%20%E2%80%94%20it%20is%20the%20entire%20foundation.%20Every%20clone%20type%20the%20tool%20detects,%20every%20signal%20it%20fuses,%20every%20byte%20range%20it%20emits%20comes%20from%20the%20AST.%20Removing%20tree-sitter%20would%20not%20cost%20a%20feature;%20it%20would%20leave%20no%20tool%20behind.%3C/p%3E%3Ch2%20id=%22what-this-means-for-you%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-this-means-for-you%22%3EWhat%20this%20means%20for%20you%3C/a%3E%3C/h2%3E%3Cul%3E%3Cli%3E%3Cstrong%3ERename%20refactors%20do%20not%20hide%20duplication.%3C/strong%3E%20A%20cluster%20survives%20an%20identifier%20rename%20because%20the%20fingerprint%20runs%20on%20the%20normalized%20AST.%3C/li%3E%3Cli%3E%3Cstrong%3EFormatting%20changes%20do%20not%20create%20false%20positives.%3C/strong%3E%20Reformatting%20a%20file%20with%20%3Ccode%3Erustfmt%3C/code%3E%20does%20not%20change%20what%20Deslop%20sees.%3C/li%3E%3Cli%3E%3Cstrong%3ELanguage%20parity%20is%20real.%3C/strong%3E%20The%20same%20fingerprinting%20logic%20runs%20on%20C#,%20Rust,%20Python,%20Dart,%20JavaScript,%20TypeScript,%20and%20every%20language%20added%20later.%20Cross-language%20comparisons%20(when%20they%20make%20sense)%20use%20the%20same%20math.%3C/li%3E%3C/ul%3E%3Cp%3ELine-matching%20is%20a%201990s%20compromise%20with%20hardware%20that%20no%20longer%20exists.%20Tree-sitter%20is%20the%20upgrade.%20Deslop%20ships%20the%20upgrade%20as%20the%20baseline,%20not%20a%20premium%20tier.%3C/p%3E</content>
    <summary>Deslop parses every language with tree-sitter — no regex, no line-matching. Why that constraint matters, and how it survives reformatting and identifier renaming.</summary>
  </entry>
  <entry>
    <title>Why the ranking formula is the entire product</title>
    <link href="https://deslop.live/blog/ranking-formula/"/>
    <id>https://deslop.live/blog/ranking-formula/</id>
    <updated>2026-04-15T00:00:00.000Z</updated>
    <content type="html">https://deslop.live/%3Cp%3EA%20duplicate-detection%20tool%20that%20reports%20clusters%20without%20ranking%20them%20is%20a%20search%20engine%20that%20returns%20results%20in%20insertion%20order.%20You%20can%20tell%20the%20user%20&amp;quot;there%20are%20142%20clusters,&amp;quot;%20and%20you%20have%20just%20transferred%20the%20problem%20from%20the%20tool%20to%20the%20human.%20Line%20one%20of%20the%20report%20is%20the%20only%20line%20that%20matters%20on%20the%20first%20look.%20Everything%20else%20in%20Deslop%20exists%20to%20make%20line%20one%20correct.%3C/p%3E%3Ch2%20id=%22the-formula%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#the-formula%22%3EThe%20formula%3C/a%3E%3C/h2%3E%3Cpre%3E%3Ccode%3Eweight%20=%20clone_node_count%20%C3%97%20(cluster_size%20%E2%88%92%201)%20%C3%97%20log2(1%20+%20spanned_bytes)%3C/code%3E%3C/pre%3E%3Cp%3EImplemented%20in%20%3Ca%20href=%22https://github.com/Nimblesite/Deslop/blob/main/crates/deslop-core/src/cluster.rs%22%3E%3Ccode%3Ecrates/deslop-core/src/cluster.rs::rank_weight%3C/code%3E%3C/a%3E.%20Three%20factors,%20all%20multiplicative,%20with%20one%20logarithmic%20damper.%3C/p%3E%3Cp%3E%3Cstrong%3E%3Ccode%3Eclone_node_count%3C/code%3E%3C/strong%3E%20%E2%80%94%20the%20AST%20node%20count%20of%20the%20duplicated%20fragment.%20A%20five-node%20getter%20is%20not%20interesting.%20A%20fifty-node%20method%20with%20nested%20control%20flow%20is.%20Node%20count%20is%20the%20closest%20proxy%20we%20have%20to%20&amp;quot;how%20much%20effort%20was%20duplicated.&amp;quot;%3C/p%3E%3Cp%3E%3Cstrong%3E%3Ccode%3Ecluster_size%20%E2%88%92%201%3C/code%3E%3C/strong%3E%20%E2%80%94%20the%20number%20of%20%3Cem%3Eadditional%3C/em%3E%20members%20beyond%20the%20first.%20Two%20copies%20counts%20as%20one%20duplicate%20pair.%20Five%20copies%20counts%20as%20four.%20A%20singleton%20cluster%20scores%20zero%20by%20construction,%20which%20is%20the%20mathematically%20honest%20version%20of%20&amp;quot;one%20occurrence%20isn&#39;t%20a%20duplicate.&amp;quot;%3C/p%3E%3Cp%3E%3Cstrong%3E%3Ccode%3Elog2(1%20+%20spanned_bytes)%3C/code%3E%3C/strong%3E%20%E2%80%94%20payoff%20scale,%20in%20bytes,%20dampened%20by%20%3Ccode%3Elog2%3C/code%3E.%20The%20byte%20total%20tracks%20how%20much%20code%20an%20extraction%20would%20actually%20move;%20the%20logarithm%20prevents%20a%20single%205000-line%20vendored%20file%20from%20dominating%20four%20genuine%2050-line%20method%20copies.%20Bytes%20(not%20lines)%20are%20the%20source%20of%20truth%20because%20Deslop%20addresses%20occurrences%20by%20%3Ccode%3E[byte_start,%20byte_end)%3C/code%3E%20everywhere%20%E2%80%94%20line%20numbers%20are%20render-time%20only.%3C/p%3E%3Cp%3EMultiplying%20the%20three%20gives%20a%20number%20that%20is%20dimensionally%20sensible%20(effort%20%C3%97%20repetition%20%C3%97%20blast%20radius)%20and%20monotonic%20in%20every%20argument.%20Doubling%20the%20node%20count%20doubles%20the%20weight;%20doubling%20the%20cluster%20size%20more%20than%20doubles%20it%20%E2%80%94%20the%20boost%20is%20biggest%20for%20small%20clusters%20(going%20from%20two%20copies%20to%20four%20triples%20the%20%3Ccode%3Esize%20%E2%88%92%201%3C/code%3E%20term)%20and%20settles%20toward%20an%20exact%20doubling%20as%20clusters%20grow;%20doubling%20the%20bytes%20adds%20one%20to%20the%20log%20term.%3C/p%3E%3Ch2%20id=%22what-the-formula-deliberately-excludes%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-the-formula-deliberately-excludes%22%3EWhat%20the%20formula%20deliberately%20excludes%3C/a%3E%3C/h2%3E%3Cul%3E%3Cli%3E%3Cstrong%3ELanguage%20weight.%3C/strong%3E%20An%20identical-code%20C#%20duplicate%20and%20an%20identical-code%20Rust%20duplicate%20score%20identically%20if%20their%20nodes%20%C3%97%20(size%20%E2%88%92%201)%20%C3%97%20log%20spans%20match.%20Language%20preferences%20belong%20in%20configuration,%20not%20the%20ranking.%3C/li%3E%3Cli%3E%3Cstrong%3ESignal%20weight.%3C/strong%3E%20The%20ranking%20does%20not%20multiply%20by%20%3Ccode%3Eembedding_cos%3C/code%3E%20or%20%3Ccode%3Estructural%3C/code%3E.%20Those%20signals%20gate%20whether%20a%20cluster%20exists%20at%20all%20(the%20fused%20threshold%20sits%20at%200.85%20in%20%3Ca%20href=%22https://github.com/Nimblesite/Deslop/blob/main/crates/deslop-core/src/pair.rs%22%3E%3Ccode%3Epair.rs%3C/code%3E%3C/a%3E).%20Once%20accepted,%20every%20cluster%20is%20ranked%20on%20the%20same%20scale.%3C/li%3E%3Cli%3E%3Cstrong%3EFile%20age%20/%20churn.%3C/strong%3E%20Tempting,%20and%20wrong.%20Old%20stable%20duplication%20is%20still%20duplication.%20Adding%20a%20churn%20factor%20would%20hide%20long-standing%20problems%20that%20the%20team%20has%20learned%20to%20live%20with%20%E2%80%94%20which%20is%20precisely%20the%20kind%20of%20problem%20Deslop%20should%20surface.%3C/li%3E%3Cli%3E%3Cstrong%3EUser-configurable%20weights.%3C/strong%3E%20Non-negotiable.%20If%20every%20team%20tuned%20their%20own%20weights,%20cross-repo%20comparison%20would%20be%20meaningless,%20and%20&amp;quot;weight%20=%202184&amp;quot;%20in%20a%20blog%20post%20would%20communicate%20nothing.%3C/li%3E%3C/ul%3E%3Ch2%20id=%22the-consequence-of-that-choice%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#the-consequence-of-that-choice%22%3EThe%20consequence%20of%20that%20choice%3C/a%3E%3C/h2%3E%3Cp%3EBecause%20the%20ranking%20is%20a%20single%20fixed%20formula,%20two%20things%20become%20true:%3C/p%3E%3Col%3E%3Cli%3E%3Cstrong%3EEvery%20report%20is%20comparable.%3C/strong%3E%20The%20worst%20cluster%20in%20your%20repo%20can%20be%20directly%20compared%20to%20the%20worst%20cluster%20in%20someone%20else&#39;s%20repo.%20Numbers%20mean%20the%20same%20thing%20everywhere.%3C/li%3E%3Cli%3E%3Cstrong%3EEvery%20bug%20in%20the%20ranking%20is%20a%20user-visible%20bug.%3C/strong%3E%20If%20I%20change%20the%20formula%20in%20a%20minor%20version,%20every%20CI%20pipeline%20that%20gates%20on%20a%20score%20threshold%20breaks%20silently.%20So%20the%20formula%20is%20load-bearing,%20and%20changes%20go%20through%20the%20same%20review%20bar%20as%20the%20JSON%20schema.%3C/li%3E%3C/ol%3E%3Ch2%20id=%22what-changes-what-doesnt%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-changes-what-doesnt%22%3EWhat%20changes,%20what%20doesn&#39;t%3C/a%3E%3C/h2%3E%3Cp%3ESignals%20evolve.%20The%20embedding%20model%20will%20change.%20The%20LSH%20bands%20will%20be%20retuned.%20Clone-type%20definitions%20may%20pick%20up%20a%20fifth%20category%20for%20ML-generated%20near-misses.%20All%20of%20that%20is%20downstream%20of%20ranking.%3C/p%3E%3Cp%3EThe%20ranking%20formula%20is%20the%20one%20surface%20we%20commit%20to%20keeping%20stable.%20It%20is%20what%20makes%20Deslop%20a%20tool%20you%20can%20trust%20%E2%80%94%20rather%20than%20a%20search%20engine%20that%20returns%20142%20clusters%20in%20insertion%20order.%3C/p%3E</content>
    <summary>Deslop ranks duplicate-code clusters by clone_node_count × (cluster_size − 1) × log2(1 + spanned_bytes). The worst offender is always line one. Here&#39;s why the formula is not configurable.</summary>
  </entry>
  <entry>
    <title>Duplication is the tax LLMs charge for speed</title>
    <link href="https://deslop.live/blog/ai-era-duplication/"/>
    <id>https://deslop.live/blog/ai-era-duplication/</id>
    <updated>2026-04-20T00:00:00.000Z</updated>
    <content type="html">https://deslop.live/%3Cp%3EEvery%20coding%20agent%20I%20have%20worked%20with%20has%20the%20same%20pathology.%20Given%20a%20request%20that%20resembles%20a%20request%20it%20has%20fulfilled%20before,%20it%20will%20cheerfully%20reach%20for%20the%20same%20shape%20of%20code%20%E2%80%94%20even%20when%20that%20shape%20already%20exists%20in%20the%20repo%20under%20a%20different%20name.%20Multiply%20that%20instinct%20across%20a%20team%20of%20three%20engineers%20and%20four%20agents,%20and%20you%20arrive%20at%20the%20condition%20that%20defines%20the%20current%20era%20of%20software:%20%3Cstrong%3Erepositories%20where%20the%20duplication%20rate%20grows%20faster%20than%20the%20feature%20rate%3C/strong%3E.%3C/p%3E%3Cp%3EThis%20is%20not%20a%20story%20about%20sloppy%20agents.%20The%20pattern-matching%20that%20makes%20an%20LLM%20useful%20is%20the%20same%20pattern-matching%20that%20makes%20it%20duplicate.%20A%20transformer%20does%20not%20know%20your%20repo%20has%20a%20%3Ccode%3EUserRepository%3C/code%3E%20already.%20It%20knows%20that%20the%20training%20distribution%20contains%20a%20shape%20called%20&amp;quot;repository,&amp;quot;%20and%20it%20reproduces%20that%20shape.%20Three%20times,%20in%20three%20files,%20under%20three%20slightly-different%20names.%3C/p%3E%3Ch2%20id=%22why-existing-tools-are-not-the-answer%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#why-existing-tools-are-not-the-answer%22%3EWhy%20existing%20tools%20are%20not%20the%20answer%3C/a%3E%3C/h2%3E%3Cp%3EThe%20clone-detection%20field%20has%20thirty%20years%20of%20literature%20and%20a%20handful%20of%20production%20tools%20%E2%80%94%20CPD,%20Simian,%20jscpd,%20Sonar%20CPD.%20They%20all%20share%20two%20assumptions%20that%20no%20longer%20hold:%3C/p%3E%3Col%3E%3Cli%3E%3Cstrong%3EDuplication%20is%20an%20occasional%20bug.%3C/strong%3E%20These%20tools%20surface%20duplication%20as%20a%20list,%20sorted%20by%20discovery%20order%20or%20file%20name.%20That%20worked%20when%20the%20occasional%20duplication%20was%20hand-crafted.%20It%20does%20not%20work%20when%20duplication%20is%20the%20default%20state%20of%20the%20repo.%3C/li%3E%3Cli%3E%3Cstrong%3EHumans%20are%20the%20primary%20reader.%3C/strong%3E%20Output%20formats%20assume%20a%20developer%20will%20squint%20at%20a%20table,%20pick%20a%20cluster%20to%20investigate,%20and%20clean%20it%20up%20at%20their%20leisure.%20An%20agent%20cannot%20squint.%20An%20agent%20needs%20byte%20ranges,%20stable%20IDs,%20and%20a%20schema.%3C/li%3E%3C/ol%3E%3Cp%3EDeslop%20rebuilds%20from%20both%20assumptions.%20Output%20is%20ranked%20by%20the%20weighted%20impact%20of%20each%20cluster%20so%20the%20top%20row%20is%20always%20where%20the%20largest%20payoff%20lives.%20Output%20is%20JSON%20first,%20with%20text%20and%20HTML%20as%20views%20over%20the%20same%20schema.%20The%20audience%20is%20dual:%20the%20human%20who%20installs%20it%20and%20the%20agent%20who%20queries%20it.%3C/p%3E%3Ch2%20id=%22fast-feedback-is-the-entire-product%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#fast-feedback-is-the-entire-product%22%3EFast%20feedback%20is%20the%20entire%20product%3C/a%3E%3C/h2%3E%3Cp%3EThe%20feature%20that%20matters%20most%20is%20not%20the%20breadth%20of%20languages,%20not%20the%20precision%20of%20same-behavior%20detection%20(Type-4),%20not%20the%20cleverness%20of%20the%20fusion.%20It%20is%20%3Cstrong%3Etime%20to%20first%20useful%20signal%3C/strong%3E.%20A%20duplicate%20that%20surfaces%20three%20commits%20after%20it%20lands%20is%20a%20duplicate%20you%20will%20not%20refactor.%20A%20duplicate%20that%20surfaces%20while%20the%20agent%20is%20still%20holding%20the%20file%20open%20is%20a%20duplicate%20you%20fix%20before%20the%20next%20message.%3C/p%3E%3Cp%3ESo%20the%20entire%20pipeline%20is%20tuned%20for%20that.%20The%20cache%20is%20keyed%20so%20unchanged%20files%20are%20free,%20so%20a%20warm%20pass%20only%20re-parses%20the%20files%20you%20just%20touched.%20The%20ranking%20is%20cheap%20%E2%80%94%20two%20multiplications%20and%20a%20logarithm%20per%20cluster.%20The%20LSP%20shell%20ships%20today%20and%20lights%20duplication%20up%20in%20the%20editor%20at%20the%20speed%20of%20a%20spellchecker;%20the%20MCP%20shell%20exposes%20the%20same%20live%20analysis%20to%20Claude,%20Cursor,%20and%20Copilot%20before%20the%20agent%20even%20types%20the%20duplicate.%3C/p%3E%3Cp%3ESpeed%20is%20not%20a%20feature%20of%20Deslop.%20Speed%20is%20the%20whole%20point.%3C/p%3E%3Ch2%20id=%22what-to-do-with-a-finding%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-to-do-with-a-finding%22%3EWhat%20to%20do%20with%20a%20finding%3C/a%3E%3C/h2%3E%3Cp%3EA%20cluster%20in%20a%20Deslop%20report%20is%20a%20decision,%20not%20a%20verdict.%20The%20tool%20reports;%20you%20decide.%20Broadly%20there%20are%20three%20paths:%3C/p%3E%3Cul%3E%3Cli%3E%3Cstrong%3EExtract.%3C/strong%3E%20The%20fragments%20are%20identical%20enough,%20and%20share%20enough%20of%20a%20call%20graph,%20that%20a%20shared%20function%20is%20the%20clear%20answer.%20The%20%3Ccode%3Eaction_hints%3C/code%3E%20in%20the%20JSON%20flag%20these.%3C/li%3E%3Cli%3E%3Cstrong%3EReuse.%3C/strong%3E%20One%20of%20the%20fragments%20is%20the%20&amp;quot;real&amp;quot;%20implementation%20and%20the%20others%20should%20call%20into%20it.%20Pick%20the%20one%20with%20the%20best%20tests%20and%20delete%20the%20others.%3C/li%3E%3Cli%3E%3Cstrong%3EAccept.%3C/strong%3E%20Some%20duplication%20is%20intentional%20%E2%80%94%20test%20fixtures,%20bootstrapping,%20two%20things%20that%20look%20alike%20today%20but%20will%20diverge.%20Annotate%20and%20move%20on.%20Deslop%20does%20not%20judge;%20it%20just%20keeps%20score.%3C/li%3E%3C/ul%3E%3Cp%3EThe%20only%20wrong%20move%20is%20to%20ignore%20the%20top%20of%20the%20report.%20That%20is%20where%20the%20money%20is.%3C/p%3E%3Ch2%20id=%22where-this-goes%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#where-this-goes%22%3EWhere%20this%20goes%3C/a%3E%3C/h2%3E%3Cp%3EDeslop%20today%20is%20the%20live%20server.%20Two%20cooperating%20processes%20%E2%80%94%20a%20file%20watcher%20and%20LSP%20shell%20in%20one,%20an%20MCP%20shell%20in%20the%20other,%20talking%20over%20a%20local%20IPC%20socket%20%E2%80%94%20plus%20a%20focused%20set%20of%20MCP%20tools,%20led%20by%20find-similar,%20the%20agent%20can%20call%20mid-generation.%20Same%20pipeline,%20same%20schema,%20same%20cache%20as%20the%20CLI%20%E2%80%94%20the%20CLI%20is%20now%20the%20cold-cache%20fallback%20for%20CI%20gates.%20The%20VS%20Code%20extension%20bundles%20all%20of%20it%20(LSP,%20MCP,%20CLI)%20in%20a%20single%20VSIX.%20JetBrains%20is%20next.%3C/p%3E%3Cp%3EThe%20primary%20user%20of%20the%20server%20is%20not%20you.%20It%20is%20the%20agent%20you%20are%20pair-programming%20with.%20Which%20is%20as%20it%20should%20be:%20agents%20generate%20duplication;%20agents%20should%20fix%20it%20%E2%80%94%20and,%20with%20%3Ccode%3Efind-similar%3C/code%3E%20in%20their%20inner%20loop,%20agents%20should%20prevent%20it.%3C/p%3E%3Cp%3EInstall%20today.%20Open%20your%20messiest%20repo.%20Read%20line%20one.%3C/p%3E</content>
    <summary>Coding agents duplicate code faster than humans can review it. Why Deslop&#39;s live LSP + MCP server treats duplication as the defining problem of the AI era.</summary>
  </entry>
  <entry>
    <title>AI-Generated Code and Duplicate Code: What to Check</title>
    <link href="https://deslop.live/blog/ai-generated-code-duplicate-code/"/>
    <id>https://deslop.live/blog/ai-generated-code-duplicate-code/</id>
    <updated>2026-04-23T00:00:00.000Z</updated>
    <content type="html">https://deslop.live/%3Cp%3EIf%20you%20searched%20for%20&amp;quot;AI-generated%20code%20technical%20debt&amp;quot;,%20&amp;quot;duplicate%20code%20detection&amp;quot;,%20or%20&amp;quot;code%20clone%20detection&amp;quot;,%20the%20practical%20answer%20is%20this:%20AI%20does%20not%20have%20to%20generate%20broken%20code%20to%20make%20a%20codebase%20harder%20to%20maintain.%20It%20only%20has%20to%20generate%20the%20same%20idea%20twice,%20in%20two%20slightly%20different%20shapes,%20before%20anyone%20notices.%3C/p%3E%3Cp%3EThat%20is%20the%20duplicate-code%20problem%20in%20the%20AI%20era.%20The%20code%20may%20compile.%20The%20tests%20may%20pass.%20The%20pull%20request%20may%20look%20reasonable.%20But%20the%20repository%20now%20has%20two%20implementations%20that%20need%20the%20same%20future%20fix.%3C/p%3E%3Cp%3EFor%20the%20full%20implementation%20map,%20see%20the%20Deslop%20docs%20page:%20%3Ca%20href=%22/docs/research-background/%22%3EResearch%20Background%3C/a%3E.%20This%20post%20is%20the%20shorter%20version%20for%20teams%20trying%20to%20decide%20what%20to%20check%20first.%3C/p%3E%3Ch2%20id=%22the-search-terms-are-plain-english%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#the-search-terms-are-plain-english%22%3EThe%20search%20terms%20are%20plain%20English%3C/a%3E%3C/h2%3E%3Cp%3EGoogle%20Trends%20topic%20suggestions%20for%20this%20area%20are%20not%20academic%20labels%20like%20&amp;quot;Type-2%20clone&amp;quot;%20or%20&amp;quot;Type-3%20near-miss&amp;quot;.%20They%20are%20phrases%20engineers%20and%20managers%20actually%20search%20for:%3C/p%3E%3Cul%3E%3Cli%3EAI-generated%20code%3C/li%3E%3Cli%3Etechnical%20debt%3C/li%3E%3Cli%3Eduplicate%20code%3C/li%3E%3Cli%3Ecode%20duplication%3C/li%3E%3Cli%3Ecode%20clone%20detection%3C/li%3E%3Cli%3Evibe%20coding%3C/li%3E%3C/ul%3E%3Cp%3EThose%20phrases%20matter%20because%20they%20describe%20the%20operational%20problem.%20A%20team%20is%20not%20usually%20asking,%20&amp;quot;Do%20I%20have%20a%20Type-3%20clone?&amp;quot;%20It%20is%20asking,%20&amp;quot;Did%20AI%20just%20add%20the%20same%20business%20rule%20in%20three%20places?&amp;quot;%3C/p%3E%3Ch2%20id=%22does-ai-generated-code-create-technical-debt%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#does-ai-generated-code-create-technical-debt%22%3EDoes%20AI-generated%20code%20create%20technical%20debt?%3C/a%3E%3C/h2%3E%3Cp%3EIt%20can.%20The%20risk%20is%20not%20magic,%20and%20it%20is%20not%20unique%20to%20AI.%20Humans%20have%20copied%20code%20for%20decades.%20The%20change%20is%20throughput.%3C/p%3E%3Cp%3EAI%20coding%20assistants%20can%20produce%20a%20plausible%20repository-shaped%20answer%20quickly.%20When%20the%20prompt%20is%20similar%20to%20a%20previous%20task,%20the%20answer%20often%20has%20a%20familiar%20shape%20too:%20another%20repository%20class,%20another%20validation%20function,%20another%20mapper,%20another%20retry%20wrapper,%20another%20test%20fixture.%20That%20is%20useful%20in%20the%20moment%20and%20expensive%20later.%3C/p%3E%3Cp%3EThe%20research%20direction%20is%20moving%20the%20same%20way:%3C/p%3E%3Cul%3E%3Cli%3E%3Ca%20href=%22https://arxiv.org/abs/2504.12608%22%3ECode%20Copycat%20Conundrum%3C/a%3E%20studies%20repetition%20in%20LLM-generated%20code%20across%20character,%20statement,%20and%20block%20levels.%3C/li%3E%3Cli%3E%3Ca%20href=%22https://conf.researchr.org/details/fse-2025/fse-2025-research-papers/111/An-Empirical-Study-of-Code-Clones-from-Commercial-AI-Code-Generators%22%3EAn%20Empirical%20Study%20of%20Code%20Clones%20from%20Commercial%20AI%20Code%20Generators%3C/a%3E%20reports%20measurable%20Type-1%20and%20Type-2%20clone%20rates%20from%20studied%20commercial%20code%20generators.%3C/li%3E%3Cli%3E%3Ca%20href=%22https://arxiv.org/abs/2603.28592%22%3EDebt%20Behind%20the%20AI%20Boom%3C/a%3E%20studies%20technical%20debt%20introduced%20by%20AI-authored%20commits%20in%20production%20repositories.%3C/li%3E%3C/ul%3E%3Cp%3ENone%20of%20that%20means%20every%20AI-written%20line%20is%20bad.%20It%20means%20AI-generated%20code%20deserves%20the%20same%20repository-level%20appraisal%20as%20human%20code,%20only%20faster.%3C/p%3E%3Ch2%20id=%22what-should-a-duplicate-code-check-look-for%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-should-a-duplicate-code-check-look-for%22%3EWhat%20should%20a%20duplicate-code%20check%20look%20for?%3C/a%3E%3C/h2%3E%3Cp%3EA%20useful%20AI-era%20duplicate-code%20check%20should%20not%20stop%20at%20exact%20line%20matches.%20It%20should%20look%20for%20four%20levels%20of%20similarity:%3C/p%3E%3Col%3E%3Cli%3E%3Cstrong%3EExact%20duplicate%20code%3C/strong%3E:%20the%20same%20code%20copied%20with%20formatting%20or%20comment%20changes.%3C/li%3E%3Cli%3E%3Cstrong%3ERenamed%20duplicate%20code%3C/strong%3E:%20the%20same%20structure%20with%20different%20variable%20names%20or%20constants.%3C/li%3E%3Cli%3E%3Cstrong%3ENear-duplicate%20code%3C/strong%3E:%20mostly%20the%20same%20logic%20with%20inserted,%20deleted,%20or%20reordered%20statements.%3C/li%3E%3Cli%3E%3Cstrong%3ESame%20behavior,%20different%20code%3C/strong%3E:%20two%20implementations%20that%20solve%20the%20same%20problem%20with%20different%20syntax.%3C/li%3E%3C/ol%3E%3Cp%3EClassic%20code%20clone%20detection%20research%20calls%20those%20Type-1,%20Type-2,%20Type-3,%20and%20Type-4%20clones.%20Deslop%20uses%20those%20ideas,%20but%20the%20detailed%20algorithm%20write-up%20lives%20in%20%3Ca%20href=%22/docs/research-background/%22%3EResearch%20Background%3C/a%3E%20so%20this%20post%20does%20not%20repeat%20the%20whole%20docs%20page.%3C/p%3E%3Ch2%20id=%22why-line-matching-is-not-enough%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#why-line-matching-is-not-enough%22%3EWhy%20line%20matching%20is%20not%20enough%3C/a%3E%3C/h2%3E%3Cp%3ELine-based%20duplicate-code%20tools%20are%20good%20at%20finding%20obvious%20copy-paste.%20They%20are%20weaker%20when%20AI%20changes%20the%20surface%20shape:%3C/p%3E%3Cul%3E%3Cli%3E%3Ccode%3EcustomerId%3C/code%3E%20becomes%20%3Ccode%3EaccountId%3C/code%3E.%3C/li%3E%3Cli%3E%3Ccode%3Eforeach%3C/code%3E%20becomes%20a%20comprehension.%3C/li%3E%3Cli%3Ea%20helper%20is%20copied%20but%20moved%20into%20a%20different%20class.%3C/li%3E%3Cli%3Ethe%20same%20validation%20rule%20is%20rewritten%20with%20a%20different%20branch%20order.%3C/li%3E%3C/ul%3E%3Cp%3EThat%20is%20why%20Deslop%20starts%20from%20parsed%20syntax%20trees%20rather%20than%20raw%20text.%20It%20parses%20each%20file%20with%20tree-sitter,%20then%20strips%20out%20identifier%20and%20literal%20names%20so%20renamed%20copies%20still%20match.%20It%20fingerprints%20the%20tree%20structure,%20widens%20the%20net%20to%20near-duplicates%20with%20sibling%20windows%20and%20MinHash,%20and%20can%20optionally%20add%20embeddings%20for%20same-behavior%20matches.%20The%20short%20version:%20it%20compares%20code%20structure%20first,%20not%20lines%20first.%3C/p%3E%3Cp%3EThe%20full%20audit%20trail%20is%20in%20%3Ca%20href=%22/docs/how-it-works/%22%3EHow%20It%20Works%3C/a%3E%20and%20%3Ca%20href=%22/docs/research-background/%22%3EResearch%20Background%3C/a%3E.%3C/p%3E%3Ch2%20id=%22what-to-do-when-you-find-duplicate-code%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-to-do-when-you-find-duplicate-code%22%3EWhat%20to%20do%20when%20you%20find%20duplicate%20code%3C/a%3E%3C/h2%3E%3Cp%3EDo%20not%20treat%20every%20clone%20as%20a%20bug.%20Treat%20it%20as%20a%20decision.%3C/p%3E%3Cp%3E%3Cstrong%3EExtract%3C/strong%3E%20when%20the%20copies%20are%20clearly%20the%20same%20abstraction%20and%20will%20change%20together.%3C/p%3E%3Cp%3E%3Cstrong%3EReuse%3C/strong%3E%20when%20one%20implementation%20is%20already%20the%20better%20source%20of%20truth%20and%20the%20others%20should%20call%20it.%3C/p%3E%3Cp%3E%3Cstrong%3EAccept%3C/strong%3E%20when%20duplication%20is%20deliberate:%20fixtures,%20generated%20code,%20compatibility%20shims,%20or%20two%20paths%20that%20look%20alike%20now%20but%20are%20expected%20to%20diverge.%3C/p%3E%3Cp%3EThe%20mistake%20is%20not%20accepting%20duplication.%20The%20mistake%20is%20accepting%20it%20accidentally%20because%20no%20one%20measured%20it.%3C/p%3E%3Ch2%20id=%22why-deslop-ranks-findings%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#why-deslop-ranks-findings%22%3EWhy%20Deslop%20ranks%20findings%3C/a%3E%3C/h2%3E%3Cp%3EA%20duplicate-code%20report%20with%20200%20unordered%20findings%20is%20just%20another%20backlog.%20Deslop%20ranks%20clusters%20by%20impact%20so%20the%20first%20item%20is%20meant%20to%20be%20the%20highest-payoff%20review%20target.%3C/p%3E%3Cp%3EThat%20matters%20for%20AI%20coding%20agents.%20An%20agent%20does%20not%20need%20a%20wall%20of%20clone%20data.%20It%20needs%20a%20small,%20structured%20answer:%3C/p%3E%3Cul%3E%3Cli%3Ewhich%20duplicate%20cluster%20matters%20most,%3C/li%3E%3Cli%3Ewhere%20the%20byte%20ranges%20are,%3C/li%3E%3Cli%3Ewhy%20the%20cluster%20was%20flagged,%3C/li%3E%3Cli%3Ewhether%20the%20signal%20came%20from%20structure,%20token%20similarity,%20or%20embeddings.%3C/li%3E%3C/ul%3E%3Cp%3EThat%20is%20the%20reason%20Deslop%20is%20JSON-first%20and%20why%20the%20LSP/MCP%20path%20exists.%20AI%20can%20create%20duplicate%20code%20quickly;%20the%20feedback%20loop%20has%20to%20be%20just%20as%20close%20to%20the%20edit.%3C/p%3E%3Ch2%20id=%22faq%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#faq%22%3EFAQ%3C/a%3E%3C/h2%3E%3Ch3%20id=%22is-duplicate-code-always-technical-debt%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#is-duplicate-code-always-technical-debt%22%3EIs%20duplicate%20code%20always%20technical%20debt?%3C/a%3E%3C/h3%3E%3Cp%3ENo.%20Some%20duplicate%20code%20is%20intentional%20and%20cheaper%20than%20the%20abstraction%20it%20would%20replace.%20Deslop&#39;s%20job%20is%20to%20surface%20the%20evidence,%20not%20force%20a%20refactor.%3C/p%3E%3Ch3%20id=%22is-this-only-an-ai-problem%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#is-this-only-an-ai-problem%22%3EIs%20this%20only%20an%20AI%20problem?%3C/a%3E%3C/h3%3E%3Cp%3ENo.%20The%20code-clone%20literature%20predates%20modern%20LLMs%20by%20decades.%20AI%20matters%20because%20it%20can%20increase%20how%20quickly%20duplicate%20logic%20appears.%3C/p%3E%3Ch3%20id=%22can-an-llm-just-review-its-own-code-for-duplication%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#can-an-llm-just-review-its-own-code-for-duplication%22%3ECan%20an%20LLM%20just%20review%20its%20own%20code%20for%20duplication?%3C/a%3E%3C/h3%3E%3Cp%3ESometimes,%20but%20a%20deterministic%20report%20is%20easier%20to%20audit.%20Deslop%20points%20to%20files,%20byte%20ranges,%20signal%20scores,%20and%20report%20schema%20fields.%20An%20agent%20can%20read%20that%20report%20and%20then%20make%20a%20refactor%20plan.%3C/p%3E%3Ch3%20id=%22where-is-the-academic-background%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#where-is-the-academic-background%22%3EWhere%20is%20the%20academic%20background?%3C/a%3E%3C/h3%3E%3Cp%3EStart%20with%20%3Ca%20href=%22/docs/research-background/%22%3EDeslop&#39;s%20Research%20Background%3C/a%3E,%20then%20follow%20the%20linked%20papers.%20The%20most%20relevant%20entry%20points%20are:%3C/p%3E%3Cul%3E%3Cli%3E%3Ca%20href=%22https://leodemoura.github.io/files/ICSM98.pdf%22%3EClone%20Detection%20Using%20Abstract%20Syntax%20Trees%3C/a%3E%3C/li%3E%3Cli%3E%3Ca%20href=%22https://igm.univ-mlv.fr/~chilowi/research/syntax_tree_fingerprinting/syntax_tree_fingerprinting_ICPC09.pdf%22%3ESyntax%20Tree%20Fingerprinting%20for%20Source%20Code%20Similarity%20Detection%3C/a%3E%3C/li%3E%3Cli%3E%3Ca%20href=%22https://arxiv.org/abs/1512.06448%22%3ESourcererCC:%20Scaling%20Code%20Clone%20Detection%20to%20Big%20Code%3C/a%3E%3C/li%3E%3Cli%3E%3Ca%20href=%22https://arxiv.org/abs/2309.06424%22%3EUnveiling%20the%20potential%20of%20large%20language%20models%20in%20generating%20semantic%20and%20cross-language%20clones%3C/a%3E%3C/li%3E%3Cli%3E%3Ca%20href=%22https://arxiv.org/abs/2509.25754%22%3EAre%20Classical%20Clone%20Detectors%20Good%20Enough%20For%20the%20AI%20Era?%3C/a%3E%3C/li%3E%3C/ul%3E%3Cp%3EAI-generated%20code%20is%20not%20automatically%20bad%20code.%20But%20if%20it%20creates%20duplicate%20code%20faster%20than%20your%20team%20can%20review%20it,%20the%20maintenance%20bill%20is%20real.%20Measure%20it%20while%20the%20code%20is%20still%20fresh.%3C/p%3E</content>
    <summary>AI-generated code can create duplicate code and technical debt. Learn what to check with code clone detection and how Deslop audits AI-era codebases.</summary>
  </entry>
  <entry>
    <title>Deduplicating Dart Code When AI Writes Your Flutter App</title>
    <link href="https://deslop.live/blog/deduplicating-dart-code-ai-flutter/"/>
    <id>https://deslop.live/blog/deduplicating-dart-code-ai-flutter/</id>
    <updated>2026-06-05T00:00:00.000Z</updated>
    <content type="html">https://deslop.live/%3Cp%3EIf%20you%20searched%20for%20&amp;quot;Flutter%20code%20duplication&amp;quot;,%20&amp;quot;deduplicate%20Dart%20code&amp;quot;,%20or%20&amp;quot;AI-generated%20Flutter%20technical%20debt&amp;quot;,%20the%20short%20answer%20is%20this:%20AI%20does%20not%20need%20to%20write%20%3Cem%3Ewrong%3C/em%3E%20Dart%20to%20hurt%20a%20Flutter%20codebase.%20It%20only%20needs%20to%20write%20the%20same%20widget,%20the%20same%20repository,%20or%20the%20same%20validation%20rule%20twice%20%E2%80%94%20in%20two%20slightly%20different%20shapes%20%E2%80%94%20faster%20than%20anyone%20can%20notice.%3C/p%3E%3Cp%3EFlutter%20is%20unusually%20good%20at%20hiding%20that.%20A%20widget%20tree%20is%20verbose%20by%20design,%20so%20a%20forty-line%20%3Ccode%3Ebuild%3C/code%3E%20method%20that%20is%2080%%20identical%20to%20one%20three%20files%20away%20does%20not%20stand%20out%20in%20review.%20The%20diff%20looks%20like%20normal%20Flutter.%20The%20app%20runs.%20And%20the%20codebase%20now%20has%20two%20implementations%20that%20need%20the%20same%20future%20fix.%3C/p%3E%3Cp%3EFor%20the%20full%20algorithm%20write-up,%20see%20%3Ca%20href=%22/docs/research-background/%22%3EResearch%20Background%3C/a%3E.%20This%20post%20is%20the%20Dart-and-Flutter-specific%20version.%3C/p%3E%3Ch2%20id=%22ai-increased-how-fast-code-gets-copied-not-how-carefully%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#ai-increased-how-fast-code-gets-copied-not-how-carefully%22%3EAI%20increased%20how%20fast%20code%20gets%20copied,%20not%20how%20carefully%3C/a%3E%3C/h2%3E%3Cp%3EThe%20throughput%20change%20is%20now%20measured,%20not%20anecdotal.%20GitClear&#39;s%20%3Ca%20href=%22https://www.gitclear.com/ai_assistant_code_quality_2025_research%22%3E2025%20AI%20Copilot%20Code%20Quality%20study%3C/a%3E%20analysed%20211%20million%20changed%20lines%20and%20found%20that%20copy/pasted%20lines%20rose%20from%208.3%%20in%202021%20to%2012.3%%20in%202024,%20with%20an%20eight-fold%20increase%20in%20duplicated%20blocks%20of%20five%20or%20more%20lines.%20In%202024,%20copy/pasted%20code%20exceeded%20%3Cem%3Emoved%3C/em%3E%20code%20for%20the%20first%20time%20on%20record%20%E2%80%94%20and%20&amp;quot;moved&amp;quot;%20code,%20the%20signal%20that%20someone%20consolidated%20logic%20into%20something%20reusable,%20fell%20below%2010%,%20a%2044%%20year-on-year%20drop.%3C/p%3E%3Cp%3EThe%20framing%20is%20consistent%20across%20the%20industry.%20LeadDev&#39;s%20coverage%20of%20%3Ca%20href=%22https://leaddev.com/technical-direction/how-ai-generated-code-accelerates-technical-debt%22%3Ehow%20AI-generated%20code%20accelerates%20technical%20debt%3C/a%3E%20quotes%20API%20evangelist%20Kin%20Lane:%20&amp;quot;I%20don&#39;t%20think%20I%20have%20ever%20seen%20so%20much%20technical%20debt%20being%20created%20in%20such%20a%20short%20period%20of%20time%20during%20my%2035-year%20career%20in%20technology.&amp;quot;%20The%20research%20direction%20agrees%20too%20%E2%80%94%20the%20%3Ca%20href=%22https://arxiv.org/abs/2504.12608%22%3ECode%20Copycat%20Conundrum%3C/a%3E%20measures%20repetition%20in%20LLM-generated%20code%20at%20the%20character,%20statement,%20and%20block%20level.%3C/p%3E%3Cp%3ENone%20of%20this%20means%20AI-written%20Dart%20is%20bad.%20It%20means%20AI-written%20Dart%20deserves%20the%20same%20repository-level%20appraisal%20as%20hand-written%20Dart%20%E2%80%94%20only%20faster,%20because%20it%20arrives%20faster.%3C/p%3E%3Ch2%20id=%22why-flutter-codebases-duplicate-more-than-most%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#why-flutter-codebases-duplicate-more-than-most%22%3EWhy%20Flutter%20codebases%20duplicate%20more%20than%20most%3C/a%3E%3C/h2%3E%3Cp%3EFlutter%20has%20a%20few%20structural%20traits%20that%20make%20AI-generated%20duplication%20easier%20to%20create%20and%20harder%20to%20spot:%3C/p%3E%3Cul%3E%3Cli%3E%3Cstrong%3EWidget%20trees%20are%20verbose.%3C/strong%3E%20A%20coding%20agent%20will%20happily%20inline%20a%20card,%20a%20list%20tile,%20or%20a%20form%20field%20directly%20into%20a%20%3Ccode%3Ebuild%3C/code%3E%20method%20instead%20of%20extracting%20a%20reusable%20widget.%20Ten%20screens%20later%20you%20have%20ten%20near-identical%20card%20layouts,%20each%20lightly%20tweaked.%3C/li%3E%3Cli%3E%3Cstrong%3E%3Ccode%3Ebuild%3C/code%3E%20methods%20are%20long%20by%20default.%3C/strong%3E%20Length%20is%20normal%20in%20Flutter,%20so%20a%20long,%20partly-duplicated%20method%20does%20not%20trip%20the%20usual%20&amp;quot;this%20file%20is%20too%20big&amp;quot;%20instinct.%3C/li%3E%3Cli%3E%3Cstrong%3EState%20management%20gets%20mixed.%3C/strong%3E%20AI%20tools%20frequently%20blend%20patterns%20from%20%3Ccode%3EProvider%3C/code%3E,%20%3Ccode%3ERiverpod%3C/code%3E,%20and%20%3Ccode%3EBloc%3C/code%3E%20within%20one%20project,%20producing%20several%20differently-shaped%20solutions%20to%20the%20same%20state%20problem.%3C/li%3E%3Cli%3E%3Cstrong%3EThe%20repeating%20layers%20are%20repetitive%20on%20purpose.%3C/strong%3E%20Repositories,%20data%20mappers,%20%3Ccode%3EcopyWith%3C/code%3E%20methods,%20retry%20wrappers,%20and%20%3Ccode%3E*_test.dart%3C/code%3E%20setup%20blocks%20all%20follow%20predictable%20shapes%20%E2%80%94%20exactly%20the%20shapes%20an%20LLM%20reproduces%20from%20one%20task%20to%20the%20next.%3C/li%3E%3C/ul%3E%3Cp%3EFlutter%20has%20good%20answers%20for%20all%20of%20this.%20You%20can%20extract%20a%20custom%20widget,%20lift%20shared%20styling%20into%20%3Ca%20href=%22https://docs.flutter.dev/cookbook/design/themes%22%3E%3Ccode%3EThemeData%3C/code%3E%3C/a%3E,%20%3Ca%20href=%22https://medium.com/@remirousselet/flutter-reducing-widgets-boilerplate-3e635f10685e%22%3Ereduce%20widget%20boilerplate%20with%20hooks%3C/a%3E,%20or%20lean%20on%20%3Ca%20href=%22https://codewithandrea.com/articles/dart-flutter-code-generation/%22%3Ecode%20generation%3C/a%3E%20for%20the%20boilerplate%20layers.%20The%20problem%20is%20not%20a%20lack%20of%20tools.%20The%20problem%20is%20%3Cem%3Enoticing%3C/em%3E%20that%20two%20pieces%20of%20Dart%20are%20the%20same%20abstraction%20before%20the%20second%20copy%20lands.%3C/p%3E%3Ch2%20id=%22what-a-dart-duplicate-code-check-should-look-for%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-a-dart-duplicate-code-check-should-look-for%22%3EWhat%20a%20Dart%20duplicate-code%20check%20should%20look%20for%3C/a%3E%3C/h2%3E%3Cp%3EA%20useful%20check%20does%20not%20stop%20at%20exact%20line%20matches.%20It%20should%20find%20four%20levels%20of%20similarity:%3C/p%3E%3Col%3E%3Cli%3E%3Cstrong%3EExact%20duplicate%20code%3C/strong%3E%20%E2%80%94%20the%20same%20Dart%20copied%20with%20only%20formatting%20or%20comment%20changes.%3C/li%3E%3Cli%3E%3Cstrong%3ERenamed%20duplicate%20code%3C/strong%3E%20%E2%80%94%20the%20same%20structure%20with%20different%20identifiers:%20a%20%3Ccode%3ECustomerCard%3C/code%3E%20widget%20cloned%20into%20%3Ccode%3EAccountCard%3C/code%3E,%20%3Ccode%3EcustomerId%3C/code%3E%20swapped%20for%20%3Ccode%3EaccountId%3C/code%3E.%3C/li%3E%3Cli%3E%3Cstrong%3ENear-duplicate%20code%3C/strong%3E%20%E2%80%94%20mostly%20the%20same%20logic%20with%20statements%20inserted,%20deleted,%20or%20reordered:%20the%20same%20form%20validation%20with%20one%20extra%20branch.%3C/li%3E%3Cli%3E%3Cstrong%3ESame%20behaviour,%20different%20code%3C/strong%3E%20%E2%80%94%20two%20widgets%20or%20functions%20that%20solve%20the%20same%20problem%20with%20different%20syntax%20(a%20%3Ccode%3Efor%3C/code%3E%20loop%20versus%20a%20%3Ccode%3Emap().toList()%3C/code%3E).%3C/li%3E%3C/ol%3E%3Cp%3EClassic%20clone-detection%20research%20calls%20these%20Type-1%20through%20Type-4%20%E2%80%94%20in%20Deslop&#39;s%20terms,%20identical%20code,%20nearly%20identical%20code,%20loosely%20similar%20code,%20and%20same%20behavior,%20different%20code.%20The%20same%20taxonomy%20applies%20to%20Dart%20%E2%80%94%20token-based%20and%20structural%20clone%20detectors%20for%20Dart%20exist%20in%20the%20literature,%20including%20a%20%3Ca%20href=%22https://techniumscience.com/index.php/technium/article/view/6732%22%3Etoken-based%20clone%20detector%20built%20specifically%20for%20the%20Dart%20language%3C/a%3E%20and%20the%20cross-language%20structural%20work%20in%20%3Ca%20href=%22https://www.sciencedirect.com/science/article/pii/S0167642324000352%22%3EOut%20of%20Step%3C/a%3E,%20which%20reports%20over%2080%%20similarity%20detection%20on%20Dart%20and%20Kotlin%20feature%20sets.%3C/p%3E%3Ch2%20id=%22why-line-matching-is-not-enough-for-dart%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#why-line-matching-is-not-enough-for-dart%22%3EWhy%20line%20matching%20is%20not%20enough%20for%20Dart%3C/a%3E%3C/h2%3E%3Cp%3ELine-based%20tools%20catch%20literal%20copy-paste.%20They%20go%20blind%20the%20moment%20an%20agent%20changes%20the%20surface%20shape%20%E2%80%94%20which%20it%20does%20constantly:%3C/p%3E%3Cul%3E%3Cli%3E%3Ccode%3ECustomerCard%3C/code%3E%20becomes%20%3Ccode%3EAccountCard%3C/code%3E,%20every%20identifier%20renamed.%3C/li%3E%3Cli%3Ea%20helper%20is%20copied%20into%20a%20different%20class%20and%20re-indented.%3C/li%3E%3Cli%3E%3Ccode%3EsetState%3C/code%3E%20logic%20is%20rewritten%20as%20a%20%3Ccode%3ERiverpod%3C/code%3E%20notifier%20that%20does%20the%20same%20thing.%3C/li%3E%3Cli%3Ethe%20same%20validation%20rule%20is%20rebuilt%20with%20the%20branches%20in%20a%20different%20order.%3C/li%3E%3C/ul%3E%3Cp%3EThat%20is%20why%20Deslop%20starts%20from%20the%20parsed%20syntax%20tree,%20not%20the%20text.%20It%20parses%20each%20%3Ccode%3E.dart%3C/code%3E%20file%20with%20%3Cstrong%3Etree-sitter%3C/strong%3E,%20strips%20out%20identifier%20and%20literal%20names%20so%20renamed%20copies%20still%20match,%20fingerprints%20the%20tree%20%3Cem%3Estructure%3C/em%3E,%20widens%20the%20net%20to%20near-duplicates%20with%20sibling%20windows%20and%20MinHash,%20and%20can%20optionally%20add%20embeddings%20for%20same-behaviour%20matches.%20The%20short%20version:%20it%20compares%20structure%20first,%20lines%20never.%20The%20full%20audit%20trail%20is%20in%20%3Ca%20href=%22/docs/how-it-works/%22%3EHow%20It%20Works%3C/a%3E.%3C/p%3E%3Ch2%20id=%22prevention-beats-cleanup-ask-before-you-write%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#prevention-beats-cleanup-ask-before-you-write%22%3EPrevention%20beats%20cleanup:%20ask%20before%20you%20write%3C/a%3E%3C/h2%3E%3Cp%3EDeduplicating%20after%20the%20fact%20is%20what%20every%20static%20analyzer%20already%20does.%20Deslop&#39;s%20edge%20is%20being%20%3Cstrong%3Elive%20in%20the%20agent&#39;s%20inner%20loop%3C/strong%3E,%20so%20the%20second%20copy%20never%20lands.%3C/p%3E%3Cp%3EIf%20you%20drive%20Flutter%20work%20through%20a%20coding%20agent%20(Claude%20Code,%20Cursor,%20Copilot,%20Codex,%20Continue),%20wire%20it%20to%20call%20Deslop&#39;s%20%3Ccode%3Efind-similar%3C/code%3E%20tool%20%3Cstrong%3Ebefore%20it%20writes%20a%20new%20widget,%20repository,%20mapper,%20or%20test%20setup%3C/strong%3E.%20If%20a%20high-similarity%20match%20already%20exists,%20the%20agent%20reuses%20the%20canonical%20implementation%20instead%20of%20authoring%20copy%20number%20two.%20Quality%20stops%20being%20a%20periodic%20audit%20and%20becomes%20a%20continuous%20loop%20%E2%80%94%20the%20same%20direction%20%3Ca%20href=%22https://dcm.dev/blog/2025/08/25/agentic-code-quality-dcm-mcp/%22%3Ethe%20Dart/Flutter%20tooling%20community%20is%20moving%20with%20MCP-driven%20code%20quality%3C/a%3E.%20See%20%3Ca%20href=%22/docs/ai-integration/%22%3EAI%20Integration%3C/a%3E%20for%20the%20setup.%3C/p%3E%3Ch2%20id=%22ranking-the-worst-offender-is-line-one%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#ranking-the-worst-offender-is-line-one%22%3ERanking:%20the%20worst%20offender%20is%20line%20one%3C/a%3E%3C/h2%3E%3Cp%3EA%20duplicate-code%20report%20with%20200%20unordered%20findings%20is%20just%20another%20backlog.%20Deslop%20ranks%20clusters%20by%20impact%20%E2%80%94%20clone%20size%20%C3%97%20clone%20count%20%C3%97%20spanned%20lines%20%E2%80%94%20so%20the%20first%20item%20is%20the%20highest-payoff%20target,%20not%20the%20alphabetically-first%20one.%3C/p%3E%3Cp%3EThat%20matters%20more%20for%20an%20agent%20than%20a%20human.%20An%20agent%20does%20not%20need%20a%20wall%20of%20clone%20data;%20it%20needs%20a%20small,%20structured%20answer:%20which%20cluster%20matters%20most,%20where%20the%20byte%20ranges%20are,%20why%20it%20was%20flagged,%20and%20whether%20the%20signal%20came%20from%20structure,%20tokens,%20or%20embeddings.%20That%20is%20why%20Deslop%20is%20JSON-first%20and%20why%20the%20LSP%20and%20MCP%20surfaces%20exist%20%E2%80%94%20AI%20creates%20duplicate%20Dart%20quickly,%20so%20the%20feedback%20has%20to%20sit%20right%20next%20to%20the%20edit.%3C/p%3E%3Ch2%20id=%22what-to-do-when-you-find-duplicate-dart%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-to-do-when-you-find-duplicate-dart%22%3EWhat%20to%20do%20when%20you%20find%20duplicate%20Dart%3C/a%3E%3C/h2%3E%3Cp%3EDo%20not%20treat%20every%20clone%20as%20a%20bug.%20Treat%20it%20as%20a%20decision.%3C/p%3E%3Cul%3E%3Cli%3E%3Cstrong%3EExtract%3C/strong%3E%20when%20the%20copies%20are%20clearly%20the%20same%20abstraction%20and%20will%20change%20together%20%E2%80%94%20pull%20the%20repeated%20layout%20into%20a%20custom%20widget,%20lift%20the%20shared%20styling%20into%20%3Ccode%3EThemeData%3C/code%3E.%3C/li%3E%3Cli%3E%3Cstrong%3EReuse%3C/strong%3E%20when%20one%20implementation%20is%20already%20the%20better%20source%20of%20truth%20and%20the%20others%20should%20call%20it.%3C/li%3E%3Cli%3E%3Cstrong%3EAccept%3C/strong%3E%20when%20the%20duplication%20is%20deliberate:%20generated%20code,%20fixtures,%20platform%20shims,%20or%20two%20paths%20that%20look%20alike%20today%20but%20are%20expected%20to%20diverge.%3C/li%3E%3C/ul%3E%3Cp%3EThe%20mistake%20is%20not%20accepting%20duplication.%20The%20mistake%20is%20accepting%20it%20%3Cem%3Eaccidentally%3C/em%3E,%20because%20no%20one%20measured%20it.%3C/p%3E%3Ch2%20id=%22faq%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#faq%22%3EFAQ%3C/a%3E%3C/h2%3E%3Ch3%20id=%22does-deslop-support-dart%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#does-deslop-support-dart%22%3EDoes%20Deslop%20support%20Dart?%3C/a%3E%3C/h3%3E%3Cp%3EYes.%20Dart%20is%20a%20first-class%20language%20today,%20parsed%20with%20tree-sitter%20alongside%20C#,%20Rust,%20Python,%20JavaScript,%20TypeScript,%20PHP,%20F#,%20and%20Go.%20Java%20and%20C/C++%20are%20on%20the%20roadmap.%3C/p%3E%3Ch3%20id=%22is-duplicate-code-always-technical-debt%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#is-duplicate-code-always-technical-debt%22%3EIs%20duplicate%20code%20always%20technical%20debt?%3C/a%3E%3C/h3%3E%3Cp%3ENo.%20Some%20duplication%20is%20intentional%20and%20cheaper%20than%20the%20abstraction%20that%20would%20replace%20it.%20Deslop%20surfaces%20the%20evidence;%20it%20does%20not%20force%20a%20refactor.%3C/p%3E%3Ch3%20id=%22cant-i-just-ask-the-llm-to-review-its-own-flutter-code-for-duplication%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#cant-i-just-ask-the-llm-to-review-its-own-flutter-code-for-duplication%22%3ECan&#39;t%20I%20just%20ask%20the%20LLM%20to%20review%20its%20own%20Flutter%20code%20for%20duplication?%3C/a%3E%3C/h3%3E%3Cp%3ESometimes.%20But%20a%20deterministic%20report%20is%20far%20easier%20to%20audit%20%E2%80%94%20it%20points%20to%20files,%20byte%20ranges,%20signal%20scores,%20and%20schema%20fields.%20The%20agent%20reads%20that%20and%20%3Cem%3Ethen%3C/em%3E%20makes%20a%20refactor%20plan.%3C/p%3E%3Ch3%20id=%22is-this-only-an-ai-problem%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#is-this-only-an-ai-problem%22%3EIs%20this%20only%20an%20AI%20problem?%3C/a%3E%3C/h3%3E%3Cp%3ENo.%20The%20clone-detection%20literature%20predates%20modern%20LLMs%20by%20decades,%20and%20Flutter%20has%20been%20verbose%20since%201.0.%20AI%20matters%20because%20it%20raises%20how%20quickly%20duplicate%20Dart%20appears%20%E2%80%94%20and,%20per%20the%20GitClear%20data,%20how%20rarely%20it%20gets%20consolidated%20afterwards.%3C/p%3E%3Cp%3EAI-generated%20Dart%20is%20not%20automatically%20bad%20Dart.%20But%20if%20it%20produces%20the%20same%20widget%20faster%20than%20your%20team%20reviews%20it,%20the%20Flutter%20maintenance%20bill%20is%20real.%20Measure%20it%20while%20the%20code%20is%20still%20fresh.%3C/p%3E</content>
    <summary>AI writes Dart faster than you can review it, and Flutter&#39;s verbose widget trees hide the duplication. How to detect and deduplicate cloned Dart code.</summary>
  </entry>
  <entry>
    <title>MCP for Coding Agents: Stop Duplicate Code Before It Lands</title>
    <link href="https://deslop.live/blog/live-mcp-lsp-duplicate-code-prevention/"/>
    <id>https://deslop.live/blog/live-mcp-lsp-duplicate-code-prevention/</id>
    <updated>2026-06-12T00:00:00.000Z</updated>
    <content type="html">https://deslop.live/%3Cp%3EBy%20the%20time%20duplicate%20code%20shows%20up%20in%20CI,%20the%20agent%20has%20already%20written%20it,%20the%20pull%20request%20already%20contains%20it,%20and%20a%20reviewer%20has%20to%20ask%20why%20the%20same%20rule%20now%20exists%20in%20two%20places.%3C/p%3E%3Cp%3EDeslop%20moves%20that%20check%20earlier.%20When%20a%20coding%20agent%20is%20about%20to%20add%20a%20mapper,%20validator,%20widget,%20or%20test%20helper,%20it%20can%20ask%20the%20live%20workspace%20whether%20that%20shape%20already%20exists.%3C/p%3E%3Ch2%20id=%22mcp-is-now-the-agent-tool-layer%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#mcp-is-now-the-agent-tool-layer%22%3EMCP%20is%20now%20the%20agent%20tool%20layer%3C/a%3E%3C/h2%3E%3Cp%3EThe%20Model%20Context%20Protocol%20gives%20AI%20coding%20tools%20a%20standard%20way%20to%20reach%20outside%20the%20model.%20That%20is%20useful,%20but%20MCP%20alone%20does%20not%20make%20a%20tool%20trustworthy.%20A%20stale%20duplicate-code%20report%20is%20still%20stale,%20even%20when%20a%20coding%20agent%20can%20call%20it%20through%20an%20MCP%20server.%3C/p%3E%3Cp%3EDeslop&#39;s%20use%20of%20MCP%20is%20deliberately%20specific:%20expose%20live%20duplicate-code%20analysis%20to%20the%20agent%20at%20the%20moment%20it%20is%20deciding%20what%20to%20write.%20That%20turns%20duplicate%20code%20from%20an%20after-the-fact%20technical%20debt%20report%20into%20a%20prevention%20loop.%3C/p%3E%3Cp%3EThat%20matches%20the%20protocol%20landscape.%20The%20official%20%3Ca%20href=%22https://modelcontextprotocol.io/docs/getting-started/intro%22%3EModel%20Context%20Protocol%20introduction%3C/a%3E%20defines%20MCP%20as%20an%20open%20standard%20for%20connecting%20AI%20applications%20to%20external%20systems.%20The%20%3Ca%20href=%22https://modelcontextprotocol.io/specification/2025-06-18/server/tools%22%3EMCP%20tools%20specification%3C/a%3E%20says%20tools%20let%20models%20invoke%20external%20systems.%20VS%20Code&#39;s%20own%20documentation%20now%20explains%20how%20to%20%3Ca%20href=%22https://code.visualstudio.com/docs/agent-customization/mcp-servers%22%3Eadd%20and%20manage%20MCP%20servers%3C/a%3E,%20and%20OpenAI&#39;s%20Agents%20SDK%20has%20%3Ca%20href=%22https://openai.github.io/openai-agents-python/mcp/%22%3EMCP%20support%3C/a%3E%20for%20connecting%20agents%20to%20MCP%20servers.%3C/p%3E%3Cp%3EFor%20Deslop,%20the%20product%20question%20is%20simple:%20can%20the%20agent%20check%20the%20live%20repo%20before%20it%20writes%20the%20second%20copy?%3C/p%3E%3Ch2%20id=%22mcp-alone-is-not-repository-memory%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#mcp-alone-is-not-repository-memory%22%3EMCP%20alone%20is%20not%20repository%20memory%3C/a%3E%3C/h2%3E%3Cp%3EAn%20MCP%20server%20can%20expose%20a%20tool.%20That%20does%20not%20mean%20the%20tool%20is%20fresh,%20cheap,%20or%20safe%20to%20call%20often.%3C/p%3E%3Cp%3EFor%20duplicate-code%20prevention,%20freshness%20is%20the%20entire%20product.%20An%20AI%20coding%20agent%20changes%20files%20quickly.%20A%20human%20changes%20another%20file%20in%20the%20editor.%20A%20formatter%20runs.%20A%20test%20generator%20adds%20a%20fixture.%20A%20one-shot%20CLI%20report%20taken%20at%20the%20start%20of%20the%20session%20is%20already%20stale%20after%20the%20first%20edit.%3C/p%3E%3Cp%3EDeslop&#39;s%20architecture%20is%20deliberately%20split:%3C/p%3E%3Cul%3E%3Cli%3EThe%20%3Cstrong%3ELSP%20server%3C/strong%3E%20lives%20with%20the%20editor,%20watches%20the%20workspace,%20and%20keeps%20the%20current%20duplicate-code%20report%20hot.%3C/li%3E%3Cli%3EThe%20%3Cstrong%3EMCP%20server%3C/strong%3E%20exposes%20agent-facing%20tools%20and%20delegates%20reads%20and%20compute%20calls%20to%20that%20running%20LSP%20process.%3C/li%3E%3Cli%3EThe%20%3Cstrong%3ECLI%3C/strong%3E%20remains%20the%20cold-cache%20fallback%20for%20CI%20gates%20and%20one-shot%20audits.%3C/li%3E%3C/ul%3E%3Cp%3EThat%20split%20follows%20the%20shape%20of%20the%20two%20protocols.%20The%20%3Ca%20href=%22https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/%22%3ELanguage%20Server%20Protocol%20specification%3C/a%3E%20standardizes%20JSON-RPC%20messages%20between%20editors%20and%20language%20servers.%20VS%20Code&#39;s%20%3Ca%20href=%22https://code.visualstudio.com/api/language-extensions/language-server-extension-guide%22%3Elanguage%20server%20guide%3C/a%3E%20describes%20language%20servers%20as%20the%20way%20to%20power%20editor%20features%20like%20diagnostics,%20jump-to-definition,%20and%20language%20intelligence%20across%20clients.%20MCP,%20by%20contrast,%20is%20the%20agent&#39;s%20tool%20interface.%3C/p%3E%3Cp%3ELSP%20is%20how%20the%20human%20sees%20the%20duplicate.%20MCP%20is%20how%20the%20agent%20avoids%20writing%20it.%3C/p%3E%3Ch2%20id=%22the-new-loop-ask-before-writing%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#the-new-loop-ask-before-writing%22%3EThe%20new%20loop:%20ask%20before%20writing%3C/a%3E%3C/h2%3E%3Cp%3EThe%20keystone%20Deslop%20tool%20is%20%3Ccode%3Efind-similar%3C/code%3E.%3C/p%3E%3Cp%3EThe%20rule%20is%20simple:%3C/p%3E%3Cpre%20class=%22language-text%22%3E%3Ccode%20class=%22language-text%22%3EBefore%20writing%20a%20new%20function,%20class,%20helper,%20widget,%20mapper,%20or%20test%20setup,call%20find-similar%20with%20the%20snippet%20or%20range%20you%20are%20about%20to%20create.If%20a%20high-similarity%20cluster%20already%20exists,%20reuse%20the%20canonical%20occurrenceinstead%20of%20creating%20another%20copy.%3C/code%3E%3C/pre%3E%3Cp%3EThat%20sounds%20small.%20It%20is%20not.%20It%20moves%20duplicate-code%20detection%20from%20&amp;quot;audit%20the%20mess%20later&amp;quot;%20to%20&amp;quot;query%20the%20workspace%20before%20the%20copy%20exists.&amp;quot;%3C/p%3E%3Cp%3EThe%20loop%20looks%20like%20this:%3C/p%3E%3Col%3E%3Cli%3EThe%20agent%20plans%20a%20new%20block%20of%20code.%3C/li%3E%3Cli%3EIt%20calls%20Deslop&#39;s%20MCP%20%3Ccode%3Efind-similar%3C/code%3E%20tool%20with%20either%20a%20file%20range%20or%20an%20in-memory%20snippet%20plus%20language.%3C/li%3E%3Cli%3EDeslop%20parses%20the%20candidate%20with%20%3Ca%20href=%22https://tree-sitter.github.io/tree-sitter/%22%3Etree-sitter%3C/a%3E,%20normalizes%20identifiers%20and%20literals,%20fingerprints%20the%20structure,%20probes%20the%20live%20index,%20and%20returns%20matching%20clusters.%3C/li%3E%3Cli%3EThe%20agent%20either%20reuses%20the%20canonical%20implementation,%20extracts%20shared%20logic,%20or%20writes%20the%20new%20code%20because%20no%20meaningful%20match%20exists.%3C/li%3E%3Cli%3EThe%20LSP%20watcher%20sees%20the%20resulting%20file%20change%20and%20updates%20the%20editor%20surfaces%20and%20MCP%20report%20generation.%3C/li%3E%3C/ol%3E%3Cp%3EThe%20point%20is%20not%20to%20make%20the%20agent%20timid.%20The%20point%20is%20to%20give%20it%20the%20same%20repo-level%20memory%20a%20careful%20maintainer%20has,%20at%20the%20exact%20moment%20that%20memory%20matters.%3C/p%3E%3Ch2%20id=%22why-this-matters-for-ai-generated-code%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#why-this-matters-for-ai-generated-code%22%3EWhy%20this%20matters%20for%20AI-generated%20code%3C/a%3E%3C/h2%3E%3Cp%3EAI-generated%20code%20does%20not%20have%20to%20be%20broken%20to%20become%20expensive.%20It%20only%20has%20to%20repeat%20a%20business%20rule%20in%20two%20places.%3C/p%3E%3Cp%3EThe%20risk%20is%20now%20visible%20in%20the%20public%20literature.%20GitClear&#39;s%20%3Ca%20href=%22https://www.gitclear.com/ai_assistant_code_quality_2025_research%22%3E2025%20AI%20Copilot%20Code%20Quality%20study%3C/a%3E%20reports%20a%20rise%20in%20duplicate%20code%20blocks%20and%20a%20decline%20in%20moved%20lines,%20the%20signal%20that%20code%20was%20consolidated%20rather%20than%20copied.%20The%20%3Ca%20href=%22https://arxiv.org/abs/2504.12608%22%3ECode%20Copycat%20Conundrum%3C/a%3E%20studies%20repetition%20in%20LLM-generated%20code%20across%20character,%20statement,%20and%20block%20levels.%20Google&#39;s%20DORA%20team%20frames%20AI-assisted%20development%20as%20an%20amplifier%20in%20the%20%3Ca%20href=%22https://dora.dev/dora-report-2025/%22%3EState%20of%20AI-assisted%20Software%20Development%202025%20report%3C/a%3E:%20teams%20get%20the%20strongest%20results%20when%20the%20underlying%20engineering%20system%20is%20already%20healthy.%3C/p%3E%3Cp%3EThat%20is%20the%20operational%20lesson.%20Do%20not%20ask%20a%20coding%20agent%20to%20&amp;quot;be%20careful&amp;quot;%20in%20prose%20and%20hope%20it%20remembers.%20Put%20the%20repository%20memory%20in%20the%20tool%20loop.%3C/p%3E%3Ch2%20id=%22what-deslop-returns-to-the-agent%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-deslop-returns-to-the-agent%22%3EWhat%20Deslop%20returns%20to%20the%20agent%3C/a%3E%3C/h2%3E%3Cp%3EAn%20agent%20cannot%20use%20a%20vague%20warning%20like%20&amp;quot;there%20might%20be%20duplication.&amp;quot;%20It%20needs%20structured%20data%20with%20stable%20identifiers%20and%20a%20bounded%20context%20cost.%3C/p%3E%3Cp%3EDeslop&#39;s%20MCP%20surface%20returns%20duplicate%20clusters%20worst-first,%20with%20the%20fields%20an%20agent%20can%20act%20on:%3C/p%3E%3Cul%3E%3Cli%3Ea%20stable%20cluster%20id,%3C/li%3E%3Cli%3Ethe%20clone%20bucket,%20such%20as%20identical%20code%20or%20nearly%20identical%20code,%3C/li%3E%3Cli%3Ethe%20ranking%20score,%3C/li%3E%3Cli%3Eoccurrence%20paths%20and%20byte%20ranges,%3C/li%3E%3Cli%3Estructural,%20token,%20and%20embedding%20signals%20where%20available,%3C/li%3E%3Cli%3Ean%20interpretation%20string,%3C/li%3E%3Cli%3Eaction%20hints.%3C/li%3E%3C/ul%3E%3Cp%3EThe%20report%20is%20deliberately%20JSON-first.%20The%20human-readable%20text%20and%20HTML%20views%20are%20renderings%20of%20the%20same%20schema,%20not%20a%20second%20truth.%20The%20docs%20page%20on%20%3Ca%20href=%22/docs/configuration/#report-output%22%3EOutput%20Formats%3C/a%3E%20explains%20the%20consumer%20contract,%20and%20%3Ca%20href=%22/docs/how-it-works/%22%3EHow%20It%20Works%3C/a%3E%20explains%20the%20parse,%20normalize,%20fingerprint,%20cluster,%20and%20rank%20pipeline.%3C/p%3E%3Cp%3EThe%20MCP%20tools%20also%20carry%20an%20occurrence%20budget.%20Real%20repositories%20can%20have%20clusters%20with%20dozens%20of%20locations,%20and%20dumping%20every%20occurrence%20into%20an%20agent%20context%20window%20is%20not%20helpful.%20Deslop%20tools%20such%20as%20%3Ccode%3Etop-offenders%3C/code%3E,%20%3Ccode%3Ereport-for-file%3C/code%3E,%20%3Ccode%3Ereport-for-range%3C/code%3E,%20and%20%3Ccode%3Efind-similar%3C/code%3E%20accept%20a%20%3Ccode%3Emax_occurrences%3C/code%3E%20budget%20so%20the%20result%20stays%20useful%20instead%20of%20becoming%20a%20transcript%20flood.%20When%20an%20agent%20truly%20needs%20the%20full%20cluster,%20it%20can%20follow%20up%20with%20%3Ccode%3Ecluster-by-id%3C/code%3E.%3C/p%3E%3Cp%3EThat%20small%20constraint%20matters.%20Agent%20tools%20should%20be%20designed%20for%20the%20agent&#39;s%20context%20budget,%20not%20merely%20exposed%20because%20the%20protocol%20allows%20it.%3C/p%3E%3Ch2%20id=%22why-the-mcp-delegates-to-the-lsp%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#why-the-mcp-delegates-to-the-lsp%22%3EWhy%20the%20MCP%20delegates%20to%20the%20LSP%3C/a%3E%3C/h2%3E%3Cp%3EThe%20tempting%20design%20is%20to%20let%20the%20MCP%20server%20scan%20the%20repository%20itself.%20That%20looks%20simpler%20until%20you%20care%20about%20correctness.%3C/p%3E%3Cp%3EIf%20the%20LSP%20and%20MCP%20each%20run%20their%20own%20analysis,%20you%20now%20have%20two%20watchers,%20two%20caches,%20two%20reports,%20and%20two%20chances%20to%20disagree.%20If%20the%20MCP%20reads%20an%20old%20file%20report%20from%20disk,%20the%20agent%20can%20act%20on%20a%20cluster%20the%20editor%20has%20already%20removed.%20If%20the%20MCP%20starts%20a%20cold%20scan%20on%20every%20tool%20call,%20the%20agent%20stops%20calling%20it%20because%20it%20is%20too%20slow.%3C/p%3E%3Cp%3EDeslop%20uses%20one%20live%20engine.%20The%20LSP%20owns%20the%20analysis%20session%20and%20watches%20the%20workspace.%20The%20MCP%20asks%20the%20running%20LSP%20for%20the%20current%20report%20over%20local%20IPC.%20The%20project%20specs%20describe%20this%20in%20%3Ca%20href=%22https://github.com/Nimblesite/Deslop/blob/main/docs/specs/mcp.md%22%3Ethe%20MCP%20shell%20design%3C/a%3E%20and%20%3Ca%20href=%22https://github.com/Nimblesite/Deslop/blob/main/docs/specs/live.md%22%3Ethe%20live%20analysis%20design%3C/a%3E:%20the%20MCP%20is%20a%20transport%20adapter,%20not%20a%20second%20analysis%20engine.%3C/p%3E%3Cp%3EThat%20is%20the%20difference%20between%20a%20tool%20that%20can%20answer%20and%20a%20tool%20an%20agent%20can%20safely%20call%20mid-generation.%3C/p%3E%3Ch2%20id=%22what-changed-for-real-world-workspaces%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-changed-for-real-world-workspaces%22%3EWhat%20changed%20for%20real-world%20workspaces%3C/a%3E%3C/h2%3E%3Cp%3EThe%20live%20path%20has%20picked%20up%20several%20features%20that%20matter%20when%20coding%20agents%20are%20not%20just%20demos.%3C/p%3E%3Cp%3E%3Cstrong%3EExternal%20MCP%20clients%20use%20the%20VSIX-bundled%20binary.%3C/strong%3E%20Claude%20Code,%20Claude%20Desktop,%20Cursor,%20Continue,%20Codex,%20and%20other%20external%20MCP%20clients%20should%20point%20at%20the%20%3Ccode%3Edeslop-mcp%3C/code%3E%20binary%20bundled%20inside%20the%20installed%20VS%20Code%20extension,%20unless%20the%20user%20installed%20the%20CLI%20through%20Homebrew%20or%20Scoop.%20That%20avoids%20a%20local%20%3Ccode%3Etarget/release%3C/code%3E%20binary%20drifting%20away%20from%20the%20extension&#39;s%20wire%20contract.%20The%20setup%20path%20is%20in%20%3Ca%20href=%22/docs/ai-integration/%22%3EAI%20Integration%3C/a%3E.%3C/p%3E%3Cp%3E%3Cstrong%3EWindows%20no%20longer%20needs%20Unix%20sockets.%3C/strong%3E%20On%20Unix-like%20systems,%20the%20LSP%20exposes%20a%20local%20Unix%20socket.%20On%20Windows,%20Deslop%20uses%20a%20token-gated%20TCP%20loopback%20endpoint%20published%20in%20%3Ccode%3E.deslop/cache/deslop.port%3C/code%3E,%20so%20the%20MCP%20and%20LSP%20still%20speak%20the%20same%20JSON-RPC%20protocol%20without%20pretending%20Windows%20has%20Unix%20sockets.%20The%20implementation%20is%20described%20in%20the%20live%20spec&#39;s%20%3Ca%20href=%22https://github.com/Nimblesite/Deslop/blob/main/docs/specs/live.md#live-ipc-tcp%22%3ETCP%20loopback%20transport%3C/a%3E.%3C/p%3E%3Cp%3E%3Cstrong%3EThe%20editor%20and%20the%20agent%20share%20the%20same%20report.%3C/strong%3E%20The%20VSIX%20surfaces%20clusters%20through%20the%20editor%20UI,%20while%20MCP%20tools%20expose%20the%20same%20live%20data%20to%20the%20agent.%20The%20%3Ca%20href=%22/docs/vscode-cluster-panel/%22%3EVS%20Code%20cluster%20panel%20docs%3C/a%3E%20cover%20the%20human%20side.%20The%20MCP%20tools%20cover%20the%20agent%20side.%20The%20important%20property%20is%20that%20both%20are%20reading%20the%20same%20engine.%3C/p%3E%3Ch2%20id=%22what-to-put-in-your-agent-instructions%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-to-put-in-your-agent-instructions%22%3EWhat%20to%20put%20in%20your%20agent%20instructions%3C/a%3E%3C/h2%3E%3Cp%3EIf%20your%20repo%20uses%20Deslop,%20the%20best%20instruction%20is%20direct%20and%20mechanical:%3C/p%3E%3Cpre%20class=%22language-text%22%3E%3Ccode%20class=%22language-text%22%3EBefore%20writing%20any%20new%20function,%20class,%20helper,%20widget,%20mapper,%20repository,or%20test%20setup,%20call%20Deslop&#39;s%20find-similar%20MCP%20tool.%20If%20a%20high-similaritycluster%20exists,%20reuse%20the%20canonical%20implementation%20instead%20of%20creatinganother%20copy.%3C/code%3E%3C/pre%3E%3Cp%3EThat%20instruction%20is%20stronger%20than%20&amp;quot;avoid%20duplication.&amp;quot;%20It%20names%20the%20tool,%20the%20timing,%20and%20the%20expected%20action.%3C/p%3E%3Cp%3EFor%20teams%20that%20already%20maintain%20an%20%3Ccode%3EAGENTS.md%3C/code%3E,%20%3Ccode%3ECLAUDE.md%3C/code%3E,%20or%20equivalent%20coding-agent%20instruction%20file,%20this%20is%20where%20Deslop%20belongs.%20The%20tool%20is%20most%20valuable%20before%20the%20agent%20writes%20code,%20not%20after%20a%20reviewer%20asks%20why%20the%20same%20validation%20rule%20appears%20in%20four%20files.%3C/p%3E%3Ch2%20id=%22faq%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#faq%22%3EFAQ%3C/a%3E%3C/h2%3E%3Ch3%20id=%22what-is-an-mcp-server-for-coding-agents%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-is-an-mcp-server-for-coding-agents%22%3EWhat%20is%20an%20MCP%20server%20for%20coding%20agents?%3C/a%3E%3C/h3%3E%3Cp%3EAn%20MCP%20server%20exposes%20tools%20and%20resources%20to%20an%20AI%20application%20through%20the%20Model%20Context%20Protocol.%20In%20a%20coding%20workflow,%20that%20might%20mean%20codebase%20lookup,%20docs%20lookup,%20issue%20access,%20build%20actions,%20or%20repository%20analysis.%20Deslop&#39;s%20MCP%20server%20exposes%20duplicate-code%20analysis%20tools,%20led%20by%20%3Ccode%3Efind-similar%3C/code%3E.%3C/p%3E%3Ch3%20id=%22why-does-deslop-also-need-an-lsp-server%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#why-does-deslop-also-need-an-lsp-server%22%3EWhy%20does%20Deslop%20also%20need%20an%20LSP%20server?%3C/a%3E%3C/h3%3E%3Cp%3EBecause%20duplicate-code%20prevention%20has%20two%20audiences.%20The%20human%20needs%20editor%20feedback%20through%20LSP:%20diagnostics,%20hovers,%20code%20lens,%20and%20navigation.%20The%20agent%20needs%20callable%20tools%20through%20MCP.%20A%20live%20LSP%20process%20is%20also%20the%20right%20owner%20for%20watching%20the%20workspace%20and%20keeping%20the%20report%20current.%3C/p%3E%3Ch3%20id=%22why-not-just-run-the-cli-before-a-pull-request%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#why-not-just-run-the-cli-before-a-pull-request%22%3EWhy%20not%20just%20run%20the%20CLI%20before%20a%20pull%20request?%3C/a%3E%3C/h3%3E%3Cp%3EThe%20CLI%20is%20still%20useful%20for%20CI%20and%20one-shot%20audits.%20It%20is%20too%20late%20for%20prevention.%20Once%20the%20duplicate%20is%20in%20a%20pull%20request,%20the%20agent%20has%20already%20spent%20context%20and%20code%20review%20has%20already%20started.%20%3Ccode%3Efind-similar%3C/code%3E%20belongs%20before%20generation.%3C/p%3E%3Ch3%20id=%22does-this-replace-code-review%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#does-this-replace-code-review%22%3EDoes%20this%20replace%20code%20review?%3C/a%3E%3C/h3%3E%3Cp%3ENo.%20Deslop%20reports%20evidence:%20cluster%20ids,%20locations,%20scores,%20and%20signals.%20A%20human%20or%20agent%20still%20decides%20whether%20to%20extract,%20reuse,%20or%20accept%20the%20duplication.%20The%20difference%20is%20that%20the%20decision%20happens%20while%20the%20code%20is%20fresh.%3C/p%3E%3Ch3%20id=%22is-this-only-about-exact-copy-paste%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#is-this-only-about-exact-copy-paste%22%3EIs%20this%20only%20about%20exact%20copy-paste?%3C/a%3E%3C/h3%3E%3Cp%3ENo.%20Exact%20duplicates%20are%20the%20easy%20case.%20Deslop&#39;s%20parser-first%20pipeline%20is%20designed%20to%20catch%20renamed%20and%20near-duplicate%20structure%20as%20well.%20The%20clone%20taxonomy%20is%20discussed%20in%20%3Ca%20href=%22/docs/research-background/%22%3EResearch%20Background%3C/a%3E%20and%20in%20the%20classic%20survey%20paper%20%3Ca%20href=%22https://www.cs.usask.ca/~croy/papers/2009/RCK_SCP_Clones.pdf%22%3EComparison%20and%20Evaluation%20of%20Code%20Clone%20Detection%20Techniques%20and%20Tools%3C/a%3E.%3C/p%3E%3Cp%3EMCP%20gives%20the%20agent%20hands.%20LSP%20gives%20the%20editor%20eyes.%20Deslop%20uses%20both%20so%20duplicate%20code%20can%20be%20stopped%20at%20the%20only%20point%20where%20prevention%20is%20cheap:%20before%20the%20second%20copy%20lands.%3C/p%3E</content>
    <summary>How Deslop&#39;s live MCP + LSP server lets coding agents call find-similar before writing code, preventing duplicate code while the repo is still changing.</summary>
  </entry>
  <entry>
    <title>Find Duplicate Code in Go: Deslop Adds Go Support</title>
    <link href="https://deslop.live/blog/find-duplicate-code-go/"/>
    <id>https://deslop.live/blog/find-duplicate-code-go/</id>
    <updated>2026-07-28T00:00:00.000Z</updated>
    <content type="html">https://deslop.live/%3Cp%3EIf%20you%20searched%20for%20%3Cstrong%3E%E2%80%9Cfind%20duplicate%20code%20in%20Go,%E2%80%9D%20%E2%80%9CGolang%20duplicate%20code,%E2%80%9D%3C/strong%3E%20or%20%3Cstrong%3E%E2%80%9CGo%20linter%20for%20duplicate%20code,%E2%80%9D%3C/strong%3E%20the%20short%20answer%20is%20this:%20Deslop%20now%20understands%20%3Ccode%3E.go%3C/code%3E%20files.%3C/p%3E%3Cp%3EGo%20support%20runs%20through%20the%20same%20structural%20clone-detection%20pipeline%20as%20every%20other%20Deslop%20language.%20That%20means%20tree-sitter%20parsing%20instead%20of%20regex,%20identifier%20and%20literal%20normalization%20instead%20of%20raw%20line%20matching,%20worst-offender-first%20ranking%20instead%20of%20an%20unordered%20warning%20pile,%20and%20live%20LSP%20+%20MCP%20feedback%20while%20the%20repository%20is%20changing.%3C/p%3E%3Cp%3EThe%20useful%20question%20is%20no%20longer%20whether%20two%20Go%20files%20contain%20the%20same%20text.%20It%20is%20whether%20they%20contain%20the%20same%20idea%20in%20a%20different%20jacket.%3C/p%3E%3Ch2%20id=%22go-support-is-a-community-contribution%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#go-support-is-a-community-contribution%22%3EGo%20support%20is%20a%20community%20contribution%3C/a%3E%3C/h2%3E%3Cp%3EGo%20support%20was%20contributed%20by%20%3Cstrong%3E%3Ca%20href=%22https://haigmail.com%22%3ELance%20Haig%3C/a%3E%3C/strong%3E%20in%20%3Ca%20href=%22https://github.com/Nimblesite/Deslop/pull/310%22%3EPR%20#310%3C/a%3E.%20His%20work%20added%20the%20parser%20and%20initial%20end-to-end%20language%20wiring,%20from%20%3Ccode%3E.go%3C/code%3E%20file%20discovery%20through%20normalization,%20reporting,%20editor%20activation,%20fixtures,%20and%20regression%20coverage.%3C/p%3E%3Ch2%20id=%22what-go-support-actually-adds%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-go-support-actually-adds%22%3EWhat%20Go%20support%20actually%20adds%3C/a%3E%3C/h2%3E%3Cp%3EDeslop%20now%20discovers%20%3Ccode%3E.go%3C/code%3E%20files%20and%20parses%20them%20with%20%3Ca%20href=%22https://github.com/tree-sitter/tree-sitter-go%22%3E%3Ccode%3Etree-sitter-go%3C/code%3E%3C/a%3E.%20The%20parser%20keeps%20the%20program&#39;s%20structure%20while%20removing%20spelling%20changes%20that%20should%20not%20hide%20a%20clone:%3C/p%3E%3Cul%3E%3Cli%3Eidentifiers%20such%20as%20function,%20field,%20type,%20package,%20blank,%20and%20label%20names%20collapse%20to%20a%20common%20structural%20marker;%3C/li%3E%3Cli%3Eintegers,%20floats,%20runes,%20strings,%20booleans,%20%3Ccode%3Enil%3C/code%3E,%20and%20%3Ccode%3Eiota%3C/code%3E%20collapse%20to%20a%20common%20literal%20marker;%3C/li%3E%3Cli%3Ecomments%20disappear%20from%20the%20comparison;%3C/li%3E%3Cli%3Ecomposite%20literals%20and%20function%20literals%20keep%20their%20shape%20because%20that%20shape%20is%20useful%20evidence;%3C/li%3E%3Cli%3Epackage%20clauses%20and%20import%20declarations%20are%20treated%20as%20prologue,%20so%20repeated%20imports%20do%20not%20masquerade%20as%20duplicated%20business%20logic.%3C/li%3E%3C/ul%3E%3Cp%3EThat%20normalized%20tree%20enters%20the%20same%20fingerprint,%20sibling-window,%20token,%20fusion,%20clustering,%20and%20ranking%20stages%20documented%20in%20%3Ca%20href=%22/docs/how-it-works/%22%3EHow%20It%20Works%3C/a%3E.%20Go%20is%20not%20a%20bolt-on%20text%20scanner.%20It%20is%20a%20first-class%20parser%20feeding%20the%20shared%20engine.%3C/p%3E%3Cp%3EThe%20language%20is%20also%20wired%20through%20the%20human-facing%20surfaces.%20Go%20appears%20as%20%3Cstrong%3EGo%3C/strong%3E%20in%20reports%20and%20filters,%20%3Ccode%3E.go%3C/code%3E%20files%20wake%20the%20editor%20extension,%20and%20the%20live%20loop%20can%20refresh%20findings%20as%20a%20Go%20buffer%20changes.%3C/p%3E%3Ch2%20id=%22why-duplicate-go-can-be-hard-to-see%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#why-duplicate-go-can-be-hard-to-see%22%3EWhy%20duplicate%20Go%20can%20be%20hard%20to%20see%3C/a%3E%3C/h2%3E%3Cp%3EGo&#39;s%20simplicity%20is%20a%20strength,%20but%20consistent%20code%20shapes%20are%20easy%20to%20reproduce.%20Humans%20copy%20them.%20Coding%20agents%20reproduce%20them%20even%20faster.%3C/p%3E%3Cp%3EThe%20usual%20hiding%20places%20are%20familiar:%3C/p%3E%3Cul%3E%3Cli%3EHTTP%20handlers%20that%20bind%20input,%20validate%20it,%20call%20a%20service,%20map%20an%20error,%20and%20write%20a%20response;%3C/li%3E%3Cli%3Erepository%20methods%20that%20differ%20only%20by%20entity%20name%20or%20query;%3C/li%3E%3Cli%3Emiddleware%20with%20the%20same%20guard%20and%20context%20plumbing;%3C/li%3E%3Cli%3EDTO-to-domain%20mappers%20repeated%20across%20packages;%3C/li%3E%3Cli%3Eretry%20and%20error-wrapping%20paths%20with%20lightly%20changed%20literals;%3C/li%3E%3Cli%3Etable-driven%20tests%20whose%20setup%20grows%20into%20several%20near-identical%20fixtures.%3C/li%3E%3C/ul%3E%3Cp%3E%3Ccode%3Egofmt%3C/code%3E%20makes%20those%20copies%20beautifully%20consistent.%20A%20renamed%20handler%20in%20another%20package%20can%20still%20look%20reasonable%20in%20review%20because%20the%20code%20is%20tidy,%20compiles,%20and%20follows%20the%20local%20style.%20The%20maintenance%20cost%20arrives%20later,%20when%20one%20copy%20gets%20the%20security%20fix%20and%20the%20other%20does%20not.%3C/p%3E%3Ch2%20id=%22a-go-linter-is-not-necessarily-a-clone-detector%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#a-go-linter-is-not-necessarily-a-clone-detector%22%3EA%20Go%20linter%20is%20not%20necessarily%20a%20clone%20detector%3C/a%3E%3C/h2%3E%3Cp%3ESearches%20around%20this%20problem%20often%20include%20%E2%80%9CGo%20linter,%E2%80%9D%20but%20linting%20covers%20several%20different%20jobs.%20%3Ccode%3Ego%20vet%3C/code%3E,%20Staticcheck,%20and%20the%20checks%20collected%20by%20golangci-lint%20are%20excellent%20at%20suspicious%20constructs,%20correctness%20problems,%20simplification,%20style,%20and%20unused%20code.%20Those%20are%20not%20the%20same%20question%20as%20repository-wide%20structural%20duplication.%3C/p%3E%3Cp%3EGo%20already%20has%20a%20focused%20clone%20detector:%20%3Ca%20href=%22https://pkg.go.dev/github.com/golangci/dupl%22%3E%3Ccode%3Edupl%3C/code%3E%3C/a%3E,%20also%20available%20through%20%3Ca%20href=%22https://golangci-lint.run/docs/linters/#dupl%22%3Egolangci-lint%3C/a%3E.%20It%20serializes%20Go%20ASTs,%20searches%20them%20with%20a%20suffix%20tree,%20and%20deliberately%20ignores%20node%20values%20so%20renamed%20fragments%20can%20match.%20Its%20own%20documentation%20also%20warns%20that%20the%20method%20can%20report%20false%20positives%20and%20uses%20a%20minimum%20token%20sequence%20to%20control%20noise.%3C/p%3E%3Cp%3EDeslop%20occupies%20a%20different%20part%20of%20the%20workflow.%20It%20combines%20normalized%20structural%20fingerprints%20with%20near-miss%20signals,%20ranks%20findings%20by%20impact,%20and%20exposes%20the%20live%20result%20to%20both%20the%20editor%20and%20the%20coding%20agent.%20%3Ccode%3Edupl%3C/code%3E%20is%20a%20useful%20batch%20clone%20check.%20Deslop%20is%20repository%20memory%20in%20the%20inner%20loop.%3C/p%3E%3Ch2%20id=%22what-the-detector-looks-for%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-the-detector-looks-for%22%3EWhat%20the%20detector%20looks%20for%3C/a%3E%3C/h2%3E%3Cp%3EA%20useful%20Go%20duplicate-code%20check%20needs%20more%20than%20exact%20copy-paste:%3C/p%3E%3Col%3E%3Cli%3E%3Cstrong%3EIdentical%20code%20(Type-1)%3C/strong%3E%20%E2%80%94%20the%20same%20Go%20structure%20with%20only%20layout%20or%20comment%20differences.%3C/li%3E%3Cli%3E%3Cstrong%3ENearly%20identical%20code%20(Type-2)%3C/strong%3E%20%E2%80%94%20the%20same%20structure%20with%20identifiers%20or%20literals%20changed,%20such%20as%20%3Ccode%3ECustomerHandler%3C/code%3E%20becoming%20%3Ccode%3EAccountHandler%3C/code%3E.%3C/li%3E%3Cli%3E%3Cstrong%3ELoosely%20similar%20code%20(Type-3)%3C/strong%3E%20%E2%80%94%20mostly%20the%20same%20control%20flow%20with%20a%20statement%20inserted,%20removed,%20or%20moved.%3C/li%3E%3Cli%3E%3Cstrong%3ESame%20behavior,%20different%20code%20(Type-4)%3C/strong%3E%20%E2%80%94%20two%20implementations%20solving%20the%20same%20problem%20with%20substantially%20different%20syntax;%20this%20optional%20layer%20uses%20embeddings.%3C/li%3E%3C/ol%3E%3Cp%3EThe%20first%20two%20are%20where%20Go&#39;s%20new%20parser%20matters%20most.%20Once%20names,%20constants,%20and%20comments%20stop%20dominating%20the%20comparison,%20a%20copied%20function%20cannot%20disappear%20merely%20because%20an%20agent%20renamed%20every%20local%20variable.%3C/p%3E%3Ch2%20id=%22prevention-beats-the-cleanup-sprint%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#prevention-beats-the-cleanup-sprint%22%3EPrevention%20beats%20the%20cleanup%20sprint%3C/a%3E%3C/h2%3E%3Cp%3EFinding%20duplicate%20Go%20after%20merge%20is%20useful.%20Stopping%20the%20duplicate%20before%20it%20lands%20is%20better.%3C/p%3E%3Cp%3EDeslop&#39;s%20MCP%20server%20gives%20coding%20agents%20a%20%3Ccode%3Efind-similar%3C/code%3E%20tool%20backed%20by%20the%20live%20workspace.%20Before%20an%20agent%20writes%20another%20handler,%20mapper,%20repository%20method,%20or%20test%20helper,%20it%20can%20submit%20the%20proposed%20shape%20and%20ask%20whether%20the%20repository%20already%20contains%20it.%20A%20strong%20match%20changes%20the%20task%20from%20%E2%80%9Cwrite%20a%20new%20implementation%E2%80%9D%20to%20%E2%80%9Creuse%20or%20extend%20the%20canonical%20one.%E2%80%9D%3C/p%3E%3Cp%3EThat%20is%20the%20practical%20loop:%3C/p%3E%3Col%3E%3Cli%3Edescribe%20or%20draft%20the%20Go%20unit%20you%20are%20about%20to%20add;%3C/li%3E%3Cli%3Ecall%20%3Ccode%3Efind-similar%3C/code%3E%20before%20authoring%20it;%3C/li%3E%3Cli%3Einspect%20the%20highest-similarity%20occurrence;%3C/li%3E%3Cli%3Ereuse,%20extract,%20or%20deliberately%20accept%20the%20duplication;%3C/li%3E%3Cli%3Elet%20the%20live%20LSP%20refresh%20the%20report%20as%20the%20file%20changes.%3C/li%3E%3C/ol%3E%3Cp%3ESee%20%3Ca%20href=%22/docs/ai-integration/%22%3EAI%20Integration%3C/a%3E%20for%20the%20MCP%20setup%20and%20%3Ca%20href=%22/blog/live-mcp-lsp-duplicate-code-prevention/%22%3EMCP%20for%20Coding%20Agents%3C/a%3E%20for%20the%20full%20prevention%20model.%3C/p%3E%3Ch2%20id=%22what-to-do-with-a-duplicate-go-finding%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#what-to-do-with-a-duplicate-go-finding%22%3EWhat%20to%20do%20with%20a%20duplicate%20Go%20finding%3C/a%3E%3C/h2%3E%3Cp%3EDo%20not%20refactor%20on%20autopilot.%20A%20clone%20is%20evidence,%20not%20a%20verdict.%3C/p%3E%3Cul%3E%3Cli%3E%3Cstrong%3EExtract%3C/strong%3E%20when%20two%20handlers,%20mappers,%20or%20validation%20paths%20are%20one%20stable%20abstraction%20that%20will%20change%20together.%3C/li%3E%3Cli%3E%3Cstrong%3EReuse%3C/strong%3E%20when%20one%20implementation%20is%20already%20the%20tested%20source%20of%20truth%20and%20the%20other%20should%20call%20it.%3C/li%3E%3Cli%3E%3Cstrong%3EAccept%3C/strong%3E%20when%20duplication%20is%20cheaper%20than%20the%20coupling%20an%20abstraction%20would%20introduce,%20or%20when%20generated%20code%20and%20fixtures%20are%20intentionally%20independent.%3C/li%3E%3C/ul%3E%3Cp%3EThe%20dangerous%20state%20is%20accidental%20duplication:%20two%20copies%20that%20%3Cem%3Eshould%3C/em%3E%20change%20together,%20owned%20by%20people%20who%20do%20not%20know%20both%20exist.%3C/p%3E%3Ch2%20id=%22try-it-on-a-go-repository%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#try-it-on-a-go-repository%22%3ETry%20it%20on%20a%20Go%20repository%3C/a%3E%3C/h2%3E%3Cp%3EInstall%20Deslop%20from%20the%20%3Ca%20href=%22/docs/%22%3EGetting%20Started%20guide%3C/a%3E,%20open%20a%20Go%20workspace,%20and%20run:%3C/p%3E%3Cpre%20class=%22language-bash%22%3E%3Ccode%20class=%22language-bash%22%3Edeslop%20%3Cspan%20class=%22token%20builtin%20class-name%22%3E.%3C/span%3E%3C/code%3E%3C/pre%3E%3Cp%3EThe%20CLI%20writes%20JSON,%20text,%20and%20HTML%20reports.%20The%20VS%20Code%20extension%20adds%20live%20findings%20and%20a%20worst-first%20cluster%20view.%20Connect%20the%20MCP%20server%20and%20your%20coding%20agent%20can%20query%20the%20same%20running%20analysis%20before%20it%20writes.%3C/p%3E%3Cp%3EStart%20with%20the%20first%20cluster.%20That%20is%20the%20duplicate%20with%20the%20largest%20measured%20impact,%20not%20merely%20the%20first%20one%20the%20scanner%20happened%20to%20encounter.%3C/p%3E%3Ch2%20id=%22faq%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#faq%22%3EFAQ%3C/a%3E%3C/h2%3E%3Ch3%20id=%22does-deslop-support-go-or-golang%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#does-deslop-support-go-or-golang%22%3EDoes%20Deslop%20support%20Go%20or%20Golang?%3C/a%3E%3C/h3%3E%3Cp%3EYes.%20The%20language&#39;s%20proper%20name%20is%20Go;%20%E2%80%9CGolang%E2%80%9D%20is%20the%20search-friendly%20label.%20Deslop%20discovers%20%3Ccode%3E.go%3C/code%3E%20files%20and%20reports%20the%20language%20as%20Go.%3C/p%3E%3Ch3%20id=%22does-this-replace-gofmt-go-vet-staticcheck-or-golangci-lint%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#does-this-replace-gofmt-go-vet-staticcheck-or-golangci-lint%22%3EDoes%20this%20replace%20gofmt,%20go%20vet,%20Staticcheck,%20or%20golangci-lint?%3C/a%3E%3C/h3%3E%3Cp%3ENo.%20Keep%20them.%20They%20solve%20formatting,%20correctness,%20style,%20security,%20and%20other%20static-analysis%20problems.%20Deslop%20is%20focused%20on%20code%20clones%20and%20duplicate-code%20prevention.%3C/p%3E%3Ch3%20id=%22does-deslop-compare-go-with-regex-or-raw-lines%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#does-deslop-compare-go-with-regex-or-raw-lines%22%3EDoes%20Deslop%20compare%20Go%20with%20regex%20or%20raw%20lines?%3C/a%3E%3C/h3%3E%3Cp%3ENeither.%20It%20parses%20Go%20with%20tree-sitter%20and%20compares%20normalized%20syntax-tree%20structure%20before%20adding%20token%20and%20optional%20semantic%20signals.%20Read%20%3Ca%20href=%22/blog/tree-sitter-over-regex/%22%3ETree-sitter%20Over%20Regex%3C/a%3E%20for%20why%20that%20boundary%20matters.%3C/p%3E%3Ch3%20id=%22is-all-duplicate-go-code-bad%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#is-all-duplicate-go-code-bad%22%3EIs%20all%20duplicate%20Go%20code%20bad?%3C/a%3E%3C/h3%3E%3Cp%3ENo.%20Generated%20files,%20small%20test%20fixtures,%20and%20intentionally%20separate%20paths%20may%20be%20cheaper%20to%20leave%20alone.%20Deslop%20ranks%20the%20evidence;%20you%20decide%20whether%20to%20extract,%20reuse,%20or%20accept%20it.%3C/p%3E%3Ch3%20id=%22can-a-coding-agent-check-before-writing-go%22%20tabindex=%22-1%22%3E%3Ca%20class=%22header-anchor%22%20href=%22#can-a-coding-agent-check-before-writing-go%22%3ECan%20a%20coding%20agent%20check%20before%20writing%20Go?%3C/a%3E%3C/h3%3E%3Cp%3EYes.%20That%20is%20the%20point%20of%20%3Ccode%3Efind-similar%3C/code%3E:%20the%20agent%20asks%20the%20live%20repository%20whether%20the%20proposed%20shape%20already%20exists,%20while%20it%20can%20still%20choose%20reuse%20over%20copy%20number%20two.%3C/p%3E%3Cp%3EGo%20support%20is%20here%20because%20Lance%20contributed%20it,%20the%20shared%20engine%20was%20ready%20for%20it,%20and%20Go%20teams%20deserve%20better%20than%20finding%20the%20second%20implementation%20during%20a%20production%20incident.%20Open%20the%20messiest%20Go%20repository%20you%20own.%20Read%20line%20one.%3C/p%3E</content>
    <summary>Find duplicate code in Go and Golang repositories with structural clone detection. Deslop now parses .go files with tree-sitter and checks code live through LSP and MCP.</summary>
  </entry>
</feed>
