<?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: Genevieve Breton</title>
    <description>The latest articles on DEV Community by Genevieve Breton (@genevieve_breton_cb795f52).</description>
    <link>https://dev.to/genevieve_breton_cb795f52</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3871062%2Fc7d07369-125b-45ef-aa07-49eb6d9ee21d.png</url>
      <title>DEV Community: Genevieve Breton</title>
      <link>https://dev.to/genevieve_breton_cb795f52</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/genevieve_breton_cb795f52"/>
    <language>en</language>
    <item>
      <title>PromptCape vs PromptBase: similar names, different products</title>
      <dc:creator>Genevieve Breton</dc:creator>
      <pubDate>Tue, 26 May 2026 14:40:32 +0000</pubDate>
      <link>https://dev.to/genevieve_breton_cb795f52/promptcape-vs-promptbase-similar-names-different-products-4pej</link>
      <guid>https://dev.to/genevieve_breton_cb795f52/promptcape-vs-promptbase-similar-names-different-products-4pej</guid>
      <description>&lt;p&gt;I keep getting the same question: &lt;em&gt;"Is PromptCape the same thing as PromptBase?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;No. They're different products solving different problems for different audiences. The names look alike, the spaces overlap (both are AI-adjacent), and Google sometimes autocorrects one to the other. This short article exists to make the distinction explicit — for humans, and for search engines.&lt;/p&gt;

&lt;p&gt;If you're here because you typed "promptcape" into Google and landed on PromptBase, this article is the bridge.&lt;/p&gt;




&lt;h2&gt;
  
  
  PromptBase, in one paragraph
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://promptbase.com/" rel="noopener noreferrer"&gt;PromptBase&lt;/a&gt; is a marketplace for AI prompts. Designers, copywriters, and AI hobbyists list prompts they've engineered for image models (Midjourney, Stable Diffusion, DALL·E) and for text models (ChatGPT, Claude). Buyers download the prompts and use them to generate their own content. Think of it as Etsy for prompt engineering. It launched in 2022 and has been growing steadily as the "selling prompts as digital products" niche matured.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Target user:&lt;/strong&gt; anyone who uses AI tools to generate content (visual, marketing, copy) and wants higher-quality prompts than they could write themselves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem solved:&lt;/strong&gt; distribution and monetization of prompt engineering as craft.&lt;/p&gt;




&lt;h2&gt;
  
  
  PromptCape, in one paragraph
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://promptcape.com/" rel="noopener noreferrer"&gt;PromptCape&lt;/a&gt; is a Java code obfuscation proxy for AI coding assistants. It sits between your IDE (Claude Code, Cursor, Mistral) and the AI API, renames every identifier in your source code — &lt;code&gt;InvoiceService&lt;/code&gt; becomes &lt;code&gt;Cls_a1b2c3d4&lt;/code&gt;, &lt;code&gt;customerName&lt;/code&gt; becomes &lt;code&gt;fld_e5f6a7b8&lt;/code&gt; — sends the obfuscated version to the AI, then reverses the rename on the way back. The AI works on the obfuscated code without ever seeing your real class names, package structure, or business domain language. It targets developers and teams who have IP protection clauses, NDAs, or compliance requirements that constrain what can be sent to cloud-based AI tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Target user:&lt;/strong&gt; Java developers and engineering teams who want to use AI coding assistants without exposing proprietary source code to AI training corpora or third-party logs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem solved:&lt;/strong&gt; keeping source code IP private while still benefiting from AI coding assistance.&lt;/p&gt;




&lt;h2&gt;
  
  
  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;&lt;/th&gt;
&lt;th&gt;PromptBase&lt;/th&gt;
&lt;th&gt;PromptCape&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;What it is&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Marketplace for AI prompts&lt;/td&gt;
&lt;td&gt;Code obfuscation proxy for AI assistants&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Audience&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Content creators, designers, marketers&lt;/td&gt;
&lt;td&gt;Software developers and engineering teams&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Primary value&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Buy/sell pre-engineered prompts&lt;/td&gt;
&lt;td&gt;Protect source code from AI cloud APIs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Used for&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Image generation, copywriting&lt;/td&gt;
&lt;td&gt;Java coding with Claude Code / Cursor / Mistral&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Touches your code?&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes — that's the whole point&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Pricing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Per-prompt purchases&lt;/td&gt;
&lt;td&gt;Free for 3 months, then paid license&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Founded&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2022&lt;/td&gt;
&lt;td&gt;2026&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The overlap is zero. PromptBase is about the inputs (prompts as digital products). PromptCape is about the inputs &lt;em&gt;and&lt;/em&gt; the outputs of an AI coding loop, with a strong focus on what leaves your machine.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why the names look so close
&lt;/h2&gt;

&lt;p&gt;Both names start with &lt;em&gt;"Prompt"&lt;/em&gt; because both are in the AI space. The follow-on word makes the difference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PromptBase&lt;/strong&gt; — "Base" as in &lt;em&gt;database&lt;/em&gt;, &lt;em&gt;foundation&lt;/em&gt;, the collection where prompts live and are exchanged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PromptCape&lt;/strong&gt; — "Cape" as in &lt;em&gt;the garment that shields&lt;/em&gt;; a cape over your code before it travels to the AI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I picked "Cape" for the protection metaphor, knowing the proximity to existing names was a risk. The metaphor is the whole product positioning: &lt;em&gt;your code is protected when it goes out and comes back.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Which one do you actually need?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;"I want to find a great Midjourney prompt for a vaporwave cityscape"&lt;/em&gt; → &lt;strong&gt;PromptBase&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;"I want to find a great ChatGPT prompt for cold sales emails"&lt;/em&gt; → &lt;strong&gt;PromptBase&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;"I want to use Claude Code on a private Java repo without sending real class names to Anthropic"&lt;/em&gt; → &lt;strong&gt;PromptCape&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;"My client added a no-AI-assistants clause and I want to comply without giving up AI productivity"&lt;/em&gt; → &lt;strong&gt;PromptCape&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;"I work in a regulated industry (banking, health, defense) and need to obfuscate source identifiers before AI calls"&lt;/em&gt; → &lt;strong&gt;PromptCape&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're a developer and the latter sounds relevant, the landing page is at &lt;a href="https://promptcape.com/" rel="noopener noreferrer"&gt;promptcape.com&lt;/a&gt;. If you're looking for prompts to buy, you want &lt;a href="https://promptbase.com/" rel="noopener noreferrer"&gt;promptbase.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;No rivalry, no overlap. Just two products with names that happen to start with the same five letters.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>java</category>
      <category>security</category>
    </item>
    <item>
      <title>Building a transparent terminal-based proxy for Claude Code in Cursor (or any IDE)</title>
      <dc:creator>Genevieve Breton</dc:creator>
      <pubDate>Thu, 21 May 2026 16:18:14 +0000</pubDate>
      <link>https://dev.to/genevieve_breton_cb795f52/building-a-transparent-terminal-based-proxy-for-claude-code-in-cursor-or-any-ide-3k1p</link>
      <guid>https://dev.to/genevieve_breton_cb795f52/building-a-transparent-terminal-based-proxy-for-claude-code-in-cursor-or-any-ide-3k1p</guid>
      <description>&lt;p&gt;The previous two articles in this series (&lt;a href="https://dev.to/genevieve_breton_cb795f52/java-code-obfuscation-for-ai-assistants-ensuring-the-full-cycle-works-d5"&gt;part 1: obfuscation&lt;/a&gt;, &lt;a href="https://dev.to/genevieve_breton_cb795f52/reverse-applying-ai-changes-to-obfuscated-code-a-3-way-merge-that-actually-works-15gm"&gt;part 2: the 3-way merge&lt;/a&gt;) were about what happens to your code. This one is about what happens to your &lt;em&gt;developer&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I had a CLI that could obfuscate a Java project, send it to Claude, and merge the changes back. The pipeline worked. But the actual day-to-day flow was: run a CLI command to obfuscate, copy the obfuscated workspace path, paste it into Claude Code, work in Claude, copy the AI's output back, run another CLI command to merge. Five context switches per AI interaction. Nobody — including me — was going to use it twice.&lt;/p&gt;

&lt;p&gt;The friction was the integration. Every IDE has its own way of talking to Claude or to OpenAI. Cursor has its own Claude pane, JetBrains has its own AI assistant, VS Code has Copilot. I was &lt;em&gt;not&lt;/em&gt; going to build a plugin for each one, maintain it, watch them break every release.&lt;/p&gt;

&lt;p&gt;The shortcut that solved it: a transparent localhost HTTP proxy. About 200 lines of code, no IDE plugin, no Cursor extension, no fork of anything. The developer types &lt;code&gt;claude&lt;/code&gt; in Cursor's built-in terminal and PromptCape is silently between them and the API.&lt;/p&gt;

&lt;p&gt;This article is the &lt;em&gt;how&lt;/em&gt; of that proxy: the architectural choice, the five traps that made it harder than I expected, and why this approach generalizes to almost anything that talks to an LLM.&lt;/p&gt;




&lt;h2&gt;
  
  
  The decision: don't wrap the IDE, wrap the network
&lt;/h2&gt;

&lt;p&gt;When you set out to integrate a tool into an IDE, the obvious-looking path is to write a plugin. JetBrains has its plugin API, VS Code has its extension model, Cursor has its own integrations. You quickly realize:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each IDE has its own API, packaging, and review process.&lt;/li&gt;
&lt;li&gt;AI features inside each IDE evolve fast — every release threatens to move where the conversation hooks live.&lt;/li&gt;
&lt;li&gt;For a tool that has to see &lt;em&gt;every&lt;/em&gt; prompt and &lt;em&gt;every&lt;/em&gt; response, you end up reimplementing the wire protocol per IDE anyway.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The shortcut nobody mentions: &lt;strong&gt;every modern AI coding assistant respects a base URL environment variable.&lt;/strong&gt; Claude Code uses &lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt;. The OpenAI ecosystem (which Cursor and many others speak) uses &lt;code&gt;OPENAI_BASE_URL&lt;/code&gt;. Set it, and the client points at &lt;em&gt;your&lt;/em&gt; server instead of &lt;code&gt;api.anthropic.com&lt;/code&gt; or &lt;code&gt;api.openai.com&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That collapses the integration problem from "write N IDE plugins" to "run a reverse proxy on localhost." One code path. Every IDE that respects the env var works for free.&lt;/p&gt;

&lt;p&gt;The mental model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Cursor terminal               PromptCape proxy        Anthropic API
 ┌─────────────┐  obfuscation  ┌──────────────┐  HTTPS  ┌──────────┐
 │   claude    │ ────────────► │  localhost   │ ───────►│  real    │
 │   (CLI)     │ ◄──────────── │   :8077      │ ◄───────│  API     │
 └─────────────┘   de-obf'd    └──────────────┘   obf'd └──────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From Cursor's point of view, the user opened a terminal and ran &lt;code&gt;claude&lt;/code&gt;. There is no extension. There is no patched binary. The proxy is invisible to the IDE because the IDE was never the integration point — the network was.&lt;/p&gt;




&lt;h2&gt;
  
  
  The bare minimum
&lt;/h2&gt;

&lt;p&gt;Stripped of the obfuscation logic, the proxy is uncomfortably simple. A Javalin-based catch-all that takes any POST, rewrites the body, forwards it to the real API, and pipes the response back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;post&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/*"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&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;ctx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;rewritten&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;interceptRequest&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nc"&gt;HttpRequest&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;HttpRequest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;newBuilder&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;URI&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;targetBaseUrl&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="o"&gt;()))&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;POST&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpRequest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;BodyPublishers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rewritten&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
        &lt;span class="c1"&gt;// ... forward headers, minus hop-by-hop&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;HttpResponse&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;httpClient&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                             &lt;span class="nc"&gt;BodyHandlers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofString&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;result&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;interceptResponse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;()));&lt;/span&gt;
&lt;span class="o"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your "interception" is a no-op, that's a transparent proxy. The two interception methods are where obfuscation happens — translating real names → obfuscated names on the way out, and obfuscated → real on the way back.&lt;/p&gt;

&lt;p&gt;The thing that surprised me is how &lt;em&gt;little&lt;/em&gt; IDE knowledge is needed. The IDE never sees the proxy, never knows the URL was rewritten, never knows the conversation passed through anything. The contract is HTTP and a base URL.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trap 1: streaming responses
&lt;/h2&gt;

&lt;p&gt;The first version handled responses with &lt;code&gt;BodyHandlers.ofString()&lt;/code&gt; — buffer the whole response, transform, return. Claude Code uses streaming responses (SSE — server-sent events). The first time I tested under real load, the user-visible behavior was: silence for 8 seconds, then the entire answer dumped at once.&lt;/p&gt;

&lt;p&gt;Streaming isn't a nice-to-have. Developers expect tokens to flow as they're generated; that's a big chunk of what "feels like AI" is. You have to forward chunks as they arrive &lt;em&gt;and&lt;/em&gt; de-obfuscate them on the fly.&lt;/p&gt;

&lt;p&gt;The Java HTTP client supports &lt;code&gt;BodyHandlers.ofInputStream()&lt;/code&gt;, which gives you an open socket. You read SSE events line by line, run each one through the de-obfuscation pass, write it back to the client's output stream, flush after each event boundary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;HttpResponse&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;InputStream&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;httpClient&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                         &lt;span class="nc"&gt;BodyHandlers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofInputStream&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BufferedReader&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BufferedReader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; 
                &lt;span class="nc"&gt;InputStreamReader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="no"&gt;UTF_8&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
     &lt;span class="nc"&gt;OutputStream&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;outputStream&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;readLine&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;processed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;processLine&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;write&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;processed&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getBytes&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;UTF_8&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;write&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="sc"&gt;'\n'&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="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isEmpty&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;flush&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;&lt;span class="c1"&gt;// SSE event boundary&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The subtlety is in &lt;code&gt;processor.processLine&lt;/code&gt;. SSE events look like:&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="err"&gt;event:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;content_block_delta&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;data:&lt;/span&gt;&lt;span class="w"&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;"content_block_delta"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"index"&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="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"delta"&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;&lt;span class="w"&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;"text_delta"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"InvoiceService"&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can't just regex-replace on the raw line — &lt;code&gt;InvoiceService&lt;/code&gt; might be split across two chunks (&lt;code&gt;Invoice&lt;/code&gt; in one, &lt;code&gt;Service&lt;/code&gt; in the next) by the server's tokenizer. The processor maintains a small carry-over buffer that holds the trailing bit of the previous chunk, joins it with the new chunk, runs the replacement, then writes everything except a tail of length max-mapping-length back out.&lt;/p&gt;

&lt;p&gt;This is the kind of thing that doesn't show up in unit tests with full strings but breaks the moment a real API tokenizes mid-identifier. The fix is mechanical once you see it — but you'll only see it if you test against the real API, not a mocked one.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trap 2: accept-encoding
&lt;/h2&gt;

&lt;p&gt;This one cost me a day. The proxy was buffering responses fine, but the de-obfuscation logic was matching zero identifiers. The response body looked like binary garbage in the logs.&lt;/p&gt;

&lt;p&gt;The cause: I was faithfully forwarding the IDE's request headers — including &lt;code&gt;accept-encoding: gzip, br&lt;/code&gt;. The real API obliged and returned a gzipped response. My text-based interceptor parsed the gzipped bytes as if they were JSON, found no identifiers to replace, and forwarded the still-gzipped bytes to the client. The client decompressed them on its end, so the user saw a plausible response — but with no obfuscation reversal.&lt;/p&gt;

&lt;p&gt;The fix is one line: strip &lt;code&gt;accept-encoding&lt;/code&gt; from the forwarded request. Now the API returns uncompressed JSON, the interceptor sees text, the round trip works.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;HOP_BY_HOP_HEADERS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"host"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"connection"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"keep-alive"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"transfer-encoding"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"te"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"trailer"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"upgrade"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"content-length"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"accept-encoding"&lt;/span&gt; &lt;span class="c1"&gt;// ← critical: keep responses uncompressed&lt;/span&gt;
&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Worth a half-line comment in the code. It's the kind of single-character mistake that produces a &lt;em&gt;silently wrong&lt;/em&gt; system, not a noisy crash.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trap 3: don't translate tool blocks
&lt;/h2&gt;

&lt;p&gt;Claude's API content isn't a flat string. It's a list of typed blocks:&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="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&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="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Refactor InvoiceService to use Optional"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&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="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tool_result"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"tool_use_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"package com.acme; ..."&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&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="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tool_use"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"read_file"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"input"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user-typed text needs translation: &lt;code&gt;InvoiceService&lt;/code&gt; → &lt;code&gt;Cls_a1b2c3d4&lt;/code&gt;. But the &lt;code&gt;tool_result&lt;/code&gt; block contains the contents of a file the AI just read — &lt;em&gt;from the obfuscated workspace&lt;/em&gt;. It's already obfuscated. If I run it through the translator, nothing visibly happens (the obfuscated names don't match the real-name patterns), but the moment a real name accidentally appears in a comment that survived stripping, you've now obfuscated something inside a string that came from an already-obfuscated context. It rapidly gets harder to round-trip.&lt;/p&gt;

&lt;p&gt;The fix: walk the content array, look at the &lt;code&gt;type&lt;/code&gt; field, only translate &lt;code&gt;"text"&lt;/code&gt; blocks. Leave &lt;code&gt;"tool_result"&lt;/code&gt; and &lt;code&gt;"tool_use"&lt;/code&gt; blocks untouched.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;JsonNode&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;contentArray&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"type"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;asText&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;""&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="s"&gt;"text"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;has&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"text"&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="nc"&gt;ObjectNode&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; 
          &lt;span class="n"&gt;translateText&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;asText&lt;/span&gt;&lt;span class="o"&gt;()));&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;//tool_use, tool_result → leave alone, already in obfuscated space&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the corollary of the bigger architectural choice: the AI works in an obfuscated &lt;em&gt;workspace&lt;/em&gt;, not just on obfuscated &lt;em&gt;prompts&lt;/em&gt;. The file system the AI sees through &lt;code&gt;read_file&lt;/code&gt; is the obfuscated cache directory. Everything it reads is already obfuscated. The proxy only needs to translate the human-readable channel: what the user types, and what the AI replies in text.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trap 4: HTTP/2 pseudo-headers
&lt;/h2&gt;

&lt;p&gt;This was the obscure one. The Java HTTP client speaks HTTP/2 to modern APIs. HTTP/2 has pseudo-headers — &lt;code&gt;:status&lt;/code&gt;, &lt;code&gt;:method&lt;/code&gt;, &lt;code&gt;:path&lt;/code&gt; — that are legal at the protocol layer but illegal in HTTP/1.1 responses. My proxy was happily copying &lt;em&gt;every&lt;/em&gt; response header from the API back to the Cursor terminal, including &lt;code&gt;:status&lt;/code&gt;. Some clients tolerate this; some (Claude Code) reject the response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;apiResponse&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;forEach&lt;/span&gt;&lt;span class="o"&gt;((&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;lower&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toLowerCase&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="n"&gt;lower&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;startsWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;":"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="c1"&gt;// skip HTTP/2 pseudo-headers&lt;/span&gt;
    &lt;span class="c1"&gt;// ... forward the rest&lt;/span&gt;
&lt;span class="o"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One of those bugs that exists at the protocol seam between two HTTP versions. The Java HTTP client gives you the HTTP/2 headers in their HTTP/2 form, and you're shipping them to a client that may or may not be reading HTTP/2 framing. Filter aggressively.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trap 5: making it forget-about-it-able
&lt;/h2&gt;

&lt;p&gt;A foreground proxy in a terminal works for a demo. For daily use, developers want the proxy running quietly in the background so they can open a new terminal and &lt;code&gt;claude&lt;/code&gt; immediately. So the CLI grew a &lt;code&gt;--detach&lt;/code&gt; mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spawn a child JVM running the proxy in the foreground.&lt;/li&gt;
&lt;li&gt;Inherit env (so the license key propagates).&lt;/li&gt;
&lt;li&gt;Redirect stdout/stderr to &lt;code&gt;~/.promptcape/proxy.log&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Write the child PID to &lt;code&gt;~/.promptcape/proxy.pid&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Wait up to 5 seconds for the port to come up, then exit.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;ProcessBuilder&lt;/span&gt; &lt;span class="n"&gt;pb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ProcessBuilder&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;redirectErrorStream&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;redirectOutput&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ProcessBuilder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Redirect&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;appendTo&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logFile&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toFile&lt;/span&gt;&lt;span class="o"&gt;()));&lt;/span&gt;
&lt;span class="n"&gt;pb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;redirectInput&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isWin&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s"&gt;"NUL"&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"/dev/null"&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;

&lt;span class="nc"&gt;Process&lt;/span&gt; &lt;span class="n"&gt;child&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;start&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="nc"&gt;Files&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;writeString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pidFile&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;valueOf&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;child&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;pid&lt;/span&gt;&lt;span class="o"&gt;()));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plus a &lt;code&gt;--stop&lt;/code&gt; that's idempotent (returns 0 if the proxy is already gone — a stale PID file isn't an error), and a &lt;code&gt;--logs&lt;/code&gt; that tails the log file with the rotation handling you'd expect.&lt;/p&gt;

&lt;p&gt;These are the kinds of features users discover they need three days in. &lt;em&gt;"How do I see what the proxy is doing without restarting it in the foreground?"&lt;/em&gt; — &lt;code&gt;--logs&lt;/code&gt;. &lt;em&gt;"I don't remember if the proxy is running, can I just run &lt;code&gt;--stop&lt;/code&gt; to be safe?"&lt;/em&gt; — yes, it's idempotent. None of this is technically deep, but skipping it makes the tool feel rough.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Cursor angle: there is no Cursor angle
&lt;/h2&gt;

&lt;p&gt;Here's the punchline. Once you have a localhost reverse proxy that respects &lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt;, integrating with Cursor isn't a feature. It's the absence of one.&lt;/p&gt;

&lt;p&gt;The workflow inside Cursor:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Cursor.&lt;/li&gt;
&lt;li&gt;Open the built-in terminal (Ctrl+`).&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;promptcape proxy --detach&lt;/code&gt; (or have it running already from a startup script).&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;ANTHROPIC_BASE_URL=http://localhost:8077 claude&lt;/code&gt; — or just &lt;code&gt;claude&lt;/code&gt; if you exported the env var.&lt;/li&gt;
&lt;li&gt;Use Claude Code normally.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There is no Cursor plugin to install. There is no JSON config to edit. There is no &lt;code&gt;.cursorrules&lt;/code&gt; file to set up. The terminal is just a shell, the shell respects environment variables, the env var changes the API endpoint, the proxy does the rest.&lt;/p&gt;

&lt;p&gt;That's the win. The integration cost — for me, for the user, for every future IDE — collapsed to nothing.&lt;/p&gt;

&lt;p&gt;You can wrap it up as a small launcher script. I called mine &lt;code&gt;pcc&lt;/code&gt; (PromptCape Claude). It does &lt;code&gt;export ANTHROPIC_BASE_URL=...; exec claude "$@"&lt;/code&gt;. Three lines. The user types &lt;code&gt;pcc&lt;/code&gt; instead of &lt;code&gt;claude&lt;/code&gt; and everything is obfuscated end to end.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why this generalizes
&lt;/h2&gt;

&lt;p&gt;I think the broader takeaway is worth more than the specific implementation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If a tool you want to integrate with reads an HTTP endpoint, write a reverse proxy before you write a plugin.&lt;/strong&gt; The endpoint is the integration point. The plugin is at best a config helper around the same indirection.&lt;/p&gt;

&lt;p&gt;This applies far beyond AI tooling. Anything that talks to a SaaS API and respects a base URL — analytics, observability, payments — can be sandboxed, intercepted, transformed, or replayed with the same pattern. Plugins are per-IDE; proxies are per-protocol. Per-protocol wins.&lt;/p&gt;

&lt;p&gt;The specific lesson for AI tooling: &lt;strong&gt;the prompt and the workspace are different channels.&lt;/strong&gt; Translating the workspace (the file system the AI reads through tools) and translating the prompt (the human-typed text) are two different problems. Conflate them and you double-obfuscate. Keep them separate, type-tagged content blocks make this trivial, and the proxy stays small.&lt;/p&gt;




&lt;p&gt;If you want to see the proxy code in full, the streaming SSE processor, and the conversation samples (real-name in, obfuscated-name on the wire, real-name back), the worked examples are in &lt;a href="https://gitlab.com/gbreton7/promptcape-docs" rel="noopener noreferrer"&gt;gitlab.com/gbreton7/promptcape-docs&lt;/a&gt;. This is the third and last article of the &lt;strong&gt;&lt;a href="https://promptcape.com/" rel="noopener noreferrer"&gt;PromptCape&lt;/a&gt;&lt;/strong&gt; series — obfuscation pipeline, 3-way merge, transparent proxy. MRs welcome on the docs repo if you've integrated this pattern with an IDE I haven't tried.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>security</category>
    </item>
    <item>
      <title>Building a transparent terminal-based proxy for Claude Code in Cursor (or any IDE)</title>
      <dc:creator>Genevieve Breton</dc:creator>
      <pubDate>Thu, 21 May 2026 16:18:14 +0000</pubDate>
      <link>https://dev.to/genevieve_breton_cb795f52/building-a-transparent-terminal-based-proxy-for-claude-code-in-cursor-or-any-ide-3i9j</link>
      <guid>https://dev.to/genevieve_breton_cb795f52/building-a-transparent-terminal-based-proxy-for-claude-code-in-cursor-or-any-ide-3i9j</guid>
      <description>&lt;p&gt;The previous two articles in this series (&lt;a href="https://dev.to/genevieve_breton_cb795f52/java-code-obfuscation-for-ai-assistants-ensuring-the-full-cycle-works-d5"&gt;part 1: obfuscation&lt;/a&gt;, &lt;a href="https://dev.to/genevieve_breton_cb795f52/reverse-applying-ai-changes-to-obfuscated-code-a-3-way-merge-that-actually-works-15gm"&gt;part 2: the 3-way merge&lt;/a&gt;) were about what happens to your code. This one is about what happens to your &lt;em&gt;developer&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I had a CLI that could obfuscate a Java project, send it to Claude, and merge the changes back. The pipeline worked. But the actual day-to-day flow was: run a CLI command to obfuscate, copy the obfuscated workspace path, paste it into Claude Code, work in Claude, copy the AI's output back, run another CLI command to merge. Five context switches per AI interaction. Nobody — including me — was going to use it twice.&lt;/p&gt;

&lt;p&gt;The friction was the integration. Every IDE has its own way of talking to Claude or to OpenAI. Cursor has its own Claude pane, JetBrains has its own AI assistant, VS Code has Copilot. I was &lt;em&gt;not&lt;/em&gt; going to build a plugin for each one, maintain it, watch them break every release.&lt;/p&gt;

&lt;p&gt;The shortcut that solved it: a transparent localhost HTTP proxy. About 200 lines of code, no IDE plugin, no Cursor extension, no fork of anything. The developer types &lt;code&gt;claude&lt;/code&gt; in Cursor's built-in terminal and PromptCape is silently between them and the API.&lt;/p&gt;

&lt;p&gt;This article is the &lt;em&gt;how&lt;/em&gt; of that proxy: the architectural choice, the five traps that made it harder than I expected, and why this approach generalizes to almost anything that talks to an LLM.&lt;/p&gt;




&lt;h2&gt;
  
  
  The decision: don't wrap the IDE, wrap the network
&lt;/h2&gt;

&lt;p&gt;When you set out to integrate a tool into an IDE, the obvious-looking path is to write a plugin. JetBrains has its plugin API, VS Code has its extension model, Cursor has its own integrations. You quickly realize:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each IDE has its own API, packaging, and review process.&lt;/li&gt;
&lt;li&gt;AI features inside each IDE evolve fast — every release threatens to move where the conversation hooks live.&lt;/li&gt;
&lt;li&gt;For a tool that has to see &lt;em&gt;every&lt;/em&gt; prompt and &lt;em&gt;every&lt;/em&gt; response, you end up reimplementing the wire protocol per IDE anyway.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The shortcut nobody mentions: &lt;strong&gt;every modern AI coding assistant respects a base URL environment variable.&lt;/strong&gt; Claude Code uses &lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt;. The OpenAI ecosystem (which Cursor and many others speak) uses &lt;code&gt;OPENAI_BASE_URL&lt;/code&gt;. Set it, and the client points at &lt;em&gt;your&lt;/em&gt; server instead of &lt;code&gt;api.anthropic.com&lt;/code&gt; or &lt;code&gt;api.openai.com&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That collapses the integration problem from "write N IDE plugins" to "run a reverse proxy on localhost." One code path. Every IDE that respects the env var works for free.&lt;/p&gt;

&lt;p&gt;The mental model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Cursor terminal               PromptCape proxy        Anthropic API
 ┌─────────────┐  obfuscation  ┌──────────────┐  HTTPS  ┌──────────┐
 │   claude    │ ────────────► │  localhost   │ ───────►│  real    │
 │   (CLI)     │ ◄──────────── │   :8077      │ ◄───────│  API     │
 └─────────────┘   de-obf'd    └──────────────┘   obf'd └──────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From Cursor's point of view, the user opened a terminal and ran &lt;code&gt;claude&lt;/code&gt;. There is no extension. There is no patched binary. The proxy is invisible to the IDE because the IDE was never the integration point — the network was.&lt;/p&gt;




&lt;h2&gt;
  
  
  The bare minimum
&lt;/h2&gt;

&lt;p&gt;Stripped of the obfuscation logic, the proxy is uncomfortably simple. A Javalin-based catch-all that takes any POST, rewrites the body, forwards it to the real API, and pipes the response back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;post&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/*"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&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;ctx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;rewritten&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;interceptRequest&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nc"&gt;HttpRequest&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;HttpRequest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;newBuilder&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;URI&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;targetBaseUrl&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="o"&gt;()))&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;POST&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpRequest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;BodyPublishers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rewritten&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
        &lt;span class="c1"&gt;// ... forward headers, minus hop-by-hop&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;HttpResponse&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;httpClient&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                             &lt;span class="nc"&gt;BodyHandlers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofString&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;result&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;interceptResponse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;()));&lt;/span&gt;
&lt;span class="o"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your "interception" is a no-op, that's a transparent proxy. The two interception methods are where obfuscation happens — translating real names → obfuscated names on the way out, and obfuscated → real on the way back.&lt;/p&gt;

&lt;p&gt;The thing that surprised me is how &lt;em&gt;little&lt;/em&gt; IDE knowledge is needed. The IDE never sees the proxy, never knows the URL was rewritten, never knows the conversation passed through anything. The contract is HTTP and a base URL.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trap 1: streaming responses
&lt;/h2&gt;

&lt;p&gt;The first version handled responses with &lt;code&gt;BodyHandlers.ofString()&lt;/code&gt; — buffer the whole response, transform, return. Claude Code uses streaming responses (SSE — server-sent events). The first time I tested under real load, the user-visible behavior was: silence for 8 seconds, then the entire answer dumped at once.&lt;/p&gt;

&lt;p&gt;Streaming isn't a nice-to-have. Developers expect tokens to flow as they're generated; that's a big chunk of what "feels like AI" is. You have to forward chunks as they arrive &lt;em&gt;and&lt;/em&gt; de-obfuscate them on the fly.&lt;/p&gt;

&lt;p&gt;The Java HTTP client supports &lt;code&gt;BodyHandlers.ofInputStream()&lt;/code&gt;, which gives you an open socket. You read SSE events line by line, run each one through the de-obfuscation pass, write it back to the client's output stream, flush after each event boundary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;HttpResponse&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;InputStream&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;httpClient&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                         &lt;span class="nc"&gt;BodyHandlers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofInputStream&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BufferedReader&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BufferedReader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; 
                &lt;span class="nc"&gt;InputStreamReader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="no"&gt;UTF_8&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
     &lt;span class="nc"&gt;OutputStream&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;outputStream&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;readLine&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;processed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;processLine&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;write&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;processed&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getBytes&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;UTF_8&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;write&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="sc"&gt;'\n'&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="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isEmpty&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;flush&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;&lt;span class="c1"&gt;// SSE event boundary&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The subtlety is in &lt;code&gt;processor.processLine&lt;/code&gt;. SSE events look like:&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="err"&gt;event:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;content_block_delta&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;data:&lt;/span&gt;&lt;span class="w"&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;"content_block_delta"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"index"&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="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"delta"&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;&lt;span class="w"&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;"text_delta"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"InvoiceService"&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can't just regex-replace on the raw line — &lt;code&gt;InvoiceService&lt;/code&gt; might be split across two chunks (&lt;code&gt;Invoice&lt;/code&gt; in one, &lt;code&gt;Service&lt;/code&gt; in the next) by the server's tokenizer. The processor maintains a small carry-over buffer that holds the trailing bit of the previous chunk, joins it with the new chunk, runs the replacement, then writes everything except a tail of length max-mapping-length back out.&lt;/p&gt;

&lt;p&gt;This is the kind of thing that doesn't show up in unit tests with full strings but breaks the moment a real API tokenizes mid-identifier. The fix is mechanical once you see it — but you'll only see it if you test against the real API, not a mocked one.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trap 2: accept-encoding
&lt;/h2&gt;

&lt;p&gt;This one cost me a day. The proxy was buffering responses fine, but the de-obfuscation logic was matching zero identifiers. The response body looked like binary garbage in the logs.&lt;/p&gt;

&lt;p&gt;The cause: I was faithfully forwarding the IDE's request headers — including &lt;code&gt;accept-encoding: gzip, br&lt;/code&gt;. The real API obliged and returned a gzipped response. My text-based interceptor parsed the gzipped bytes as if they were JSON, found no identifiers to replace, and forwarded the still-gzipped bytes to the client. The client decompressed them on its end, so the user saw a plausible response — but with no obfuscation reversal.&lt;/p&gt;

&lt;p&gt;The fix is one line: strip &lt;code&gt;accept-encoding&lt;/code&gt; from the forwarded request. Now the API returns uncompressed JSON, the interceptor sees text, the round trip works.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;HOP_BY_HOP_HEADERS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"host"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"connection"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"keep-alive"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"transfer-encoding"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"te"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"trailer"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"upgrade"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"content-length"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"accept-encoding"&lt;/span&gt; &lt;span class="c1"&gt;// ← critical: keep responses uncompressed&lt;/span&gt;
&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Worth a half-line comment in the code. It's the kind of single-character mistake that produces a &lt;em&gt;silently wrong&lt;/em&gt; system, not a noisy crash.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trap 3: don't translate tool blocks
&lt;/h2&gt;

&lt;p&gt;Claude's API content isn't a flat string. It's a list of typed blocks:&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="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&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="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Refactor InvoiceService to use Optional"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&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="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tool_result"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"tool_use_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"package com.acme; ..."&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&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="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tool_use"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"read_file"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
       &lt;/span&gt;&lt;span class="nl"&gt;"input"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user-typed text needs translation: &lt;code&gt;InvoiceService&lt;/code&gt; → &lt;code&gt;Cls_a1b2c3d4&lt;/code&gt;. But the &lt;code&gt;tool_result&lt;/code&gt; block contains the contents of a file the AI just read — &lt;em&gt;from the obfuscated workspace&lt;/em&gt;. It's already obfuscated. If I run it through the translator, nothing visibly happens (the obfuscated names don't match the real-name patterns), but the moment a real name accidentally appears in a comment that survived stripping, you've now obfuscated something inside a string that came from an already-obfuscated context. It rapidly gets harder to round-trip.&lt;/p&gt;

&lt;p&gt;The fix: walk the content array, look at the &lt;code&gt;type&lt;/code&gt; field, only translate &lt;code&gt;"text"&lt;/code&gt; blocks. Leave &lt;code&gt;"tool_result"&lt;/code&gt; and &lt;code&gt;"tool_use"&lt;/code&gt; blocks untouched.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;JsonNode&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;contentArray&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"type"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;asText&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;""&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="s"&gt;"text"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;has&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"text"&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="nc"&gt;ObjectNode&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; 
          &lt;span class="n"&gt;translateText&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;asText&lt;/span&gt;&lt;span class="o"&gt;()));&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;//tool_use, tool_result → leave alone, already in obfuscated space&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the corollary of the bigger architectural choice: the AI works in an obfuscated &lt;em&gt;workspace&lt;/em&gt;, not just on obfuscated &lt;em&gt;prompts&lt;/em&gt;. The file system the AI sees through &lt;code&gt;read_file&lt;/code&gt; is the obfuscated cache directory. Everything it reads is already obfuscated. The proxy only needs to translate the human-readable channel: what the user types, and what the AI replies in text.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trap 4: HTTP/2 pseudo-headers
&lt;/h2&gt;

&lt;p&gt;This was the obscure one. The Java HTTP client speaks HTTP/2 to modern APIs. HTTP/2 has pseudo-headers — &lt;code&gt;:status&lt;/code&gt;, &lt;code&gt;:method&lt;/code&gt;, &lt;code&gt;:path&lt;/code&gt; — that are legal at the protocol layer but illegal in HTTP/1.1 responses. My proxy was happily copying &lt;em&gt;every&lt;/em&gt; response header from the API back to the Cursor terminal, including &lt;code&gt;:status&lt;/code&gt;. Some clients tolerate this; some (Claude Code) reject the response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;apiResponse&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;forEach&lt;/span&gt;&lt;span class="o"&gt;((&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;lower&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toLowerCase&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="n"&gt;lower&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;startsWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;":"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="c1"&gt;// skip HTTP/2 pseudo-headers&lt;/span&gt;
    &lt;span class="c1"&gt;// ... forward the rest&lt;/span&gt;
&lt;span class="o"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One of those bugs that exists at the protocol seam between two HTTP versions. The Java HTTP client gives you the HTTP/2 headers in their HTTP/2 form, and you're shipping them to a client that may or may not be reading HTTP/2 framing. Filter aggressively.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trap 5: making it forget-about-it-able
&lt;/h2&gt;

&lt;p&gt;A foreground proxy in a terminal works for a demo. For daily use, developers want the proxy running quietly in the background so they can open a new terminal and &lt;code&gt;claude&lt;/code&gt; immediately. So the CLI grew a &lt;code&gt;--detach&lt;/code&gt; mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spawn a child JVM running the proxy in the foreground.&lt;/li&gt;
&lt;li&gt;Inherit env (so the license key propagates).&lt;/li&gt;
&lt;li&gt;Redirect stdout/stderr to &lt;code&gt;~/.promptcape/proxy.log&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Write the child PID to &lt;code&gt;~/.promptcape/proxy.pid&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Wait up to 5 seconds for the port to come up, then exit.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;ProcessBuilder&lt;/span&gt; &lt;span class="n"&gt;pb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ProcessBuilder&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;redirectErrorStream&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;redirectOutput&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ProcessBuilder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Redirect&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;appendTo&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logFile&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toFile&lt;/span&gt;&lt;span class="o"&gt;()));&lt;/span&gt;
&lt;span class="n"&gt;pb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;redirectInput&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isWin&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s"&gt;"NUL"&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"/dev/null"&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;

&lt;span class="nc"&gt;Process&lt;/span&gt; &lt;span class="n"&gt;child&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;start&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="nc"&gt;Files&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;writeString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pidFile&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;valueOf&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;child&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;pid&lt;/span&gt;&lt;span class="o"&gt;()));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plus a &lt;code&gt;--stop&lt;/code&gt; that's idempotent (returns 0 if the proxy is already gone — a stale PID file isn't an error), and a &lt;code&gt;--logs&lt;/code&gt; that tails the log file with the rotation handling you'd expect.&lt;/p&gt;

&lt;p&gt;These are the kinds of features users discover they need three days in. &lt;em&gt;"How do I see what the proxy is doing without restarting it in the foreground?"&lt;/em&gt; — &lt;code&gt;--logs&lt;/code&gt;. &lt;em&gt;"I don't remember if the proxy is running, can I just run &lt;code&gt;--stop&lt;/code&gt; to be safe?"&lt;/em&gt; — yes, it's idempotent. None of this is technically deep, but skipping it makes the tool feel rough.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Cursor angle: there is no Cursor angle
&lt;/h2&gt;

&lt;p&gt;Here's the punchline. Once you have a localhost reverse proxy that respects &lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt;, integrating with Cursor isn't a feature. It's the absence of one.&lt;/p&gt;

&lt;p&gt;The workflow inside Cursor:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Cursor.&lt;/li&gt;
&lt;li&gt;Open the built-in terminal (Ctrl+`).&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;promptcape proxy --detach&lt;/code&gt; (or have it running already from a startup script).&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;ANTHROPIC_BASE_URL=http://localhost:8077 claude&lt;/code&gt; — or just &lt;code&gt;claude&lt;/code&gt; if you exported the env var.&lt;/li&gt;
&lt;li&gt;Use Claude Code normally.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There is no Cursor plugin to install. There is no JSON config to edit. There is no &lt;code&gt;.cursorrules&lt;/code&gt; file to set up. The terminal is just a shell, the shell respects environment variables, the env var changes the API endpoint, the proxy does the rest.&lt;/p&gt;

&lt;p&gt;That's the win. The integration cost — for me, for the user, for every future IDE — collapsed to nothing.&lt;/p&gt;

&lt;p&gt;You can wrap it up as a small launcher script. I called mine &lt;code&gt;pcc&lt;/code&gt; (PromptCape Claude). It does &lt;code&gt;export ANTHROPIC_BASE_URL=...; exec claude "$@"&lt;/code&gt;. Three lines. The user types &lt;code&gt;pcc&lt;/code&gt; instead of &lt;code&gt;claude&lt;/code&gt; and everything is obfuscated end to end.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why this generalizes
&lt;/h2&gt;

&lt;p&gt;I think the broader takeaway is worth more than the specific implementation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If a tool you want to integrate with reads an HTTP endpoint, write a reverse proxy before you write a plugin.&lt;/strong&gt; The endpoint is the integration point. The plugin is at best a config helper around the same indirection.&lt;/p&gt;

&lt;p&gt;This applies far beyond AI tooling. Anything that talks to a SaaS API and respects a base URL — analytics, observability, payments — can be sandboxed, intercepted, transformed, or replayed with the same pattern. Plugins are per-IDE; proxies are per-protocol. Per-protocol wins.&lt;/p&gt;

&lt;p&gt;The specific lesson for AI tooling: &lt;strong&gt;the prompt and the workspace are different channels.&lt;/strong&gt; Translating the workspace (the file system the AI reads through tools) and translating the prompt (the human-typed text) are two different problems. Conflate them and you double-obfuscate. Keep them separate, type-tagged content blocks make this trivial, and the proxy stays small.&lt;/p&gt;




&lt;p&gt;If you want to see the proxy code in full, the streaming SSE processor, and the conversation samples (real-name in, obfuscated-name on the wire, real-name back), the worked examples are in &lt;a href="https://gitlab.com/gbreton7/promptcape-docs" rel="noopener noreferrer"&gt;gitlab.com/gbreton7/promptcape-docs&lt;/a&gt;. This is the third and last article of the &lt;strong&gt;&lt;a href="https://promptcape.com/" rel="noopener noreferrer"&gt;PromptCape&lt;/a&gt;&lt;/strong&gt; series — obfuscation pipeline, 3-way merge, transparent proxy. MRs welcome on the docs repo if you've integrated this pattern with an IDE I haven't tried.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>security</category>
    </item>
    <item>
      <title>Reverse-applying AI changes to obfuscated code: a 3-way merge that actually works</title>
      <dc:creator>Genevieve Breton</dc:creator>
      <pubDate>Tue, 19 May 2026 20:02:23 +0000</pubDate>
      <link>https://dev.to/genevieve_breton_cb795f52/reverse-applying-ai-changes-to-obfuscated-code-a-3-way-merge-that-actually-works-15gm</link>
      <guid>https://dev.to/genevieve_breton_cb795f52/reverse-applying-ai-changes-to-obfuscated-code-a-3-way-merge-that-actually-works-15gm</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/genevieve_breton_cb795f52/java-code-obfuscation-for-ai-assistants-ensuring-the-full-cycle-works-d5"&gt;last article&lt;/a&gt; I went through what breaks when you obfuscate Java code before sending it to an AI assistant — Spring Data, JPA, Lombok, the whole framework iceberg. That was about getting the obfuscated source &lt;em&gt;out&lt;/em&gt; in a state the AI can work on.&lt;/p&gt;

&lt;p&gt;This one is about the much subtler half: getting the AI's changes back &lt;em&gt;in&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;It looks trivial. You sent &lt;code&gt;Cls_a1b2c3d4&lt;/code&gt; to the AI, the AI returned a modified &lt;code&gt;Cls_a1b2c3d4&lt;/code&gt;, you have a mapping table, just walk the file and replace each obfuscated identifier with its original. Done in twenty lines of code.&lt;/p&gt;

&lt;p&gt;Except your real file — the one a human will read tomorrow morning — now has no comments, no Javadoc, no blank lines between methods, no formatting choices you made over six months. The obfuscation pipeline stripped all of that on the way out. Reversing the rename doesn't bring it back.&lt;/p&gt;

&lt;p&gt;This is the story of why naive reverse-translation is wrong, why &lt;strong&gt;it's a 3-way merge problem, not a translation problem&lt;/strong&gt;, and what the merge actually has to handle in practice.&lt;/p&gt;




&lt;h2&gt;
  
  
  The naive reverse
&lt;/h2&gt;

&lt;p&gt;Here's what most people try first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;aiOutput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;readAiResponse&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;realSource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;aiOutput&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Mapping&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;mappings&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;realSource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;realSource&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;replace&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;obfuscated&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;real&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;writeRealFile&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;realSource&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set aside that you also need word-boundary regex and longest-match-first ordering to avoid prefix collisions — assume you handled all of that. The output is still wrong.&lt;/p&gt;

&lt;p&gt;Why? Because the file you sent to the AI was not just &lt;em&gt;renamed&lt;/em&gt;. It was also:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Comment-stripped.&lt;/strong&gt; Sending Javadoc and inline comments to the AI is gratuitous leakage — they contain plain-English domain language. So they get replaced with blank-equivalent lines before transmission.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reformatted in subtle ways.&lt;/strong&gt; Multi-line string literals get sanitized. Annotations on separate lines get coalesced. Blank lines are preserved but only by accident.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you reverse-translate the AI's output and write it back, you're overwriting your real source with the &lt;em&gt;obfuscation-pipeline-shaped&lt;/em&gt; version of itself, plus the AI's changes. Every comment you wrote is gone. Every formatting choice. Every blank line at the right place.&lt;/p&gt;

&lt;p&gt;The first time I ran this end-to-end on a real project, I tested it on a service class. The AI added one method. I diffed the result against my source: &lt;strong&gt;312 lines changed.&lt;/strong&gt; One of them was the AI's new method. The other 311 were comments and formatting I had just nuked.&lt;/p&gt;




&lt;h2&gt;
  
  
  The mental shift: it's a merge, not a translation
&lt;/h2&gt;

&lt;p&gt;Here's the model that finally clicked. The obfuscated file is not the canonical version of your source. It is a &lt;em&gt;projection&lt;/em&gt; of your source — one that lost information on purpose. You can't reconstruct your source from the projection alone. You need both.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;git&lt;/code&gt; terms: this is a 3-way merge.&lt;/p&gt;

&lt;p&gt;Three inputs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Snapshot&lt;/strong&gt; — the obfuscated version of your code &lt;em&gt;before&lt;/em&gt; the AI touched it. (Your "common ancestor.")&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache&lt;/strong&gt; — the obfuscated version &lt;em&gt;after&lt;/em&gt; the AI's changes. (The "their" side.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real&lt;/strong&gt; — your actual source file, with all comments and formatting intact. (The "ours" side.)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The output is your real file, with only the AI's changes applied.&lt;/p&gt;

&lt;p&gt;The merge logic, in one sentence: &lt;strong&gt;for each line, if the AI didn't change it (snapshot line == cache line), keep your real line; if the AI changed it, de-obfuscate the cache line and use that.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Stated like that, it's almost obvious. The implementation has interesting corners.&lt;/p&gt;




&lt;h2&gt;
  
  
  The easy case: same line count
&lt;/h2&gt;

&lt;p&gt;When the AI modifies lines without adding or removing any, the line indices line up across all three files. The merge is one pass:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;snapshotLines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;split&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"\n"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;cacheLines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;split&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"\n"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;realLines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;real&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;split&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"\n"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

&lt;span class="nc"&gt;StringBuilder&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;StringBuilder&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;cacheLines&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++)&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="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="sc"&gt;'\n'&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="n"&gt;snapshotLines&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;].&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cacheLines&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// AI didn't touch this line — keep the real version (with comments, formatting)&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;realLines&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// AI changed this line — de-obfuscate it&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deobfuscate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cacheLines&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. The whole trick is the &lt;code&gt;snapshotLines[i].equals(cacheLines[i])&lt;/code&gt; check. Equal obfuscated lines mean the AI didn't write here, so your real line — comments, blank lines, formatting — survives untouched. Only the cells the AI actually changed get the de-obfuscated translation.&lt;/p&gt;

&lt;p&gt;This single trick made the merge usable. On a typical edit (the AI adds a parameter, changes a return type, inserts a guard clause), it touches 5–20 lines and the rest of the file stays bit-for-bit identical to my source. No phantom formatting changes, no destroyed Javadoc.&lt;/p&gt;




&lt;h2&gt;
  
  
  The hard case: AI added or removed lines
&lt;/h2&gt;

&lt;p&gt;When the AI adds an &lt;code&gt;if&lt;/code&gt; block or removes a redundant method, line counts diverge between snapshot and cache. Now indices don't line up — line &lt;em&gt;N&lt;/em&gt; of the cache might correspond to line &lt;em&gt;N+3&lt;/em&gt; of the snapshot, or to nothing at all.&lt;/p&gt;

&lt;p&gt;You can pull in &lt;a href="https://github.com/java-diff-utils/java-diff-utils" rel="noopener noreferrer"&gt;java-diff-utils&lt;/a&gt; and run a real LCS-based diff here. I tried that first. It works, but it adds a dependency, the diff format needs translation, and for the size of edits the AI typically makes (5–50 lines), a homegrown linear walker is faster and easier to reason about.&lt;/p&gt;

&lt;p&gt;The walker keeps three indices — one per file — and decides at each step whether the current cache line is an unchanged line (advance all three), a modification (advance all three, but de-obfuscate the cache line), or an insertion (advance only the cache index):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;si&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ci&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ci&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;cacheLines&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="o"&gt;)&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="n"&gt;si&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;snapshotLines&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;snapshotLines&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;si&lt;/span&gt;&lt;span class="o"&gt;].&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cacheLines&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ci&lt;/span&gt;&lt;span class="o"&gt;]))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// unchanged → keep real&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;realLines&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ri&lt;/span&gt;&lt;span class="o"&gt;]);&lt;/span&gt;
        &lt;span class="n"&gt;si&lt;/span&gt;&lt;span class="o"&gt;++;&lt;/span&gt; &lt;span class="n"&gt;ci&lt;/span&gt;&lt;span class="o"&gt;++;&lt;/span&gt; &lt;span class="n"&gt;ri&lt;/span&gt;&lt;span class="o"&gt;++;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// changed: modification or insertion?&lt;/span&gt;
        &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;isInsertion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&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="n"&gt;si&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;snapshotLines&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;look&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ci&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;look&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;cacheLines&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;look&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;ci&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;look&lt;/span&gt;&lt;span class="o"&gt;++)&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="n"&gt;snapshotLines&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;si&lt;/span&gt;&lt;span class="o"&gt;].&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cacheLines&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;look&lt;/span&gt;&lt;span class="o"&gt;]))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                    &lt;span class="n"&gt;isInsertion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
                    &lt;span class="k"&gt;break&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="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="n"&gt;isInsertion&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// AI inserted a new line before the next snapshot line&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deobfuscate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cacheLines&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ci&lt;/span&gt;&lt;span class="o"&gt;]));&lt;/span&gt;
            &lt;span class="n"&gt;ci&lt;/span&gt;&lt;span class="o"&gt;++;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// AI modified or replaced this line&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deobfuscate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cacheLines&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ci&lt;/span&gt;&lt;span class="o"&gt;]));&lt;/span&gt;
            &lt;span class="n"&gt;si&lt;/span&gt;&lt;span class="o"&gt;++;&lt;/span&gt; &lt;span class="n"&gt;ci&lt;/span&gt;&lt;span class="o"&gt;++;&lt;/span&gt; &lt;span class="n"&gt;ri&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="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 50-line look-ahead window deserves a comment. It's the heuristic that decides "did the AI insert new code before this snapshot line, or did it modify this snapshot line?" If the next snapshot line shows up within the next 50 cache lines, treat the current cache line as an insertion. Otherwise treat it as a modification.&lt;/p&gt;

&lt;p&gt;Why 50? Two reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cost.&lt;/strong&gt; A full O(N²) LCS on a 2000-line file does ~4M comparisons. Bounded look-ahead caps each step at 50 comparisons → 100k total. On a real file this is microseconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Realism about edit shapes.&lt;/strong&gt; AI assistants rarely insert 50+ contiguous lines without also modifying surrounding code. When they do, you're outside "merge a small edit" territory and you should be re-running the obfuscation pipeline on the result anyway.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It is a heuristic. On pathological inputs (the AI rewrites the entire file), it degrades to "treat everything as modification" which produces a usable but heavily de-obfuscated file. That's the right failure mode — you'll lose formatting on the affected stretch, but you won't lose data.&lt;/p&gt;




&lt;h2&gt;
  
  
  Three traps that the test suite found
&lt;/h2&gt;

&lt;p&gt;The merge in the previous sections is the version that &lt;em&gt;works&lt;/em&gt;. Getting there involved walking face-first into a few traps that aren't obvious from the algorithm.&lt;/p&gt;

&lt;h3&gt;
  
  
  Trap 1: snapshot and cache disagree on line count even when the AI didn't add lines
&lt;/h3&gt;

&lt;p&gt;Early on I was confused by failures that looked like the AI had inserted lines, when the diff in the assistant's output clearly hadn't.&lt;/p&gt;

&lt;p&gt;What was happening: the snapshot had been written months earlier, when the obfuscation pipeline's comment-stripping pass replaced multi-line &lt;code&gt;/* ... */&lt;/code&gt; comments with a single empty line. The current version replaces each line of the comment with its own empty line — preserving line count. So a snapshot from version &lt;em&gt;v1&lt;/em&gt; and a cache from version &lt;em&gt;v2&lt;/em&gt; could disagree by dozens of lines for the same source file, just because of comment-stripping format drift.&lt;/p&gt;

&lt;p&gt;The fix: when snapshot and cache disagree on line count, &lt;em&gt;re-obfuscate the real file on the fly&lt;/em&gt; to get a fresh snapshot in the current format, and use that as the merge ancestor. Only &lt;code&gt;.java&lt;/code&gt; files — sanitizers for &lt;code&gt;.properties&lt;/code&gt;, &lt;code&gt;.yml&lt;/code&gt;, and &lt;code&gt;pom.xml&lt;/code&gt; preserve line count by construction, so any line-count drift on those files is a genuine AI edit, not a format mismatch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snapshotLines&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;cacheLines&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;obfRelativePath&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;endsWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;".java"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;freshObfuscated&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;obfuscateContent&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;realContent&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="n"&gt;freshObfuscated&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;snapshotContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;freshObfuscated&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I did &lt;em&gt;not&lt;/em&gt; gate this on the obfuscation pipeline version — the cost of re-obfuscating one file on demand is negligible, and the alternative (storing version metadata per snapshot and migrating on read) was complexity I didn't want.&lt;/p&gt;

&lt;h3&gt;
  
  
  Trap 2: don't run the Java obfuscation pipeline on a .properties file
&lt;/h3&gt;

&lt;p&gt;There's a sharp corner in the fix above. The re-obfuscation call is &lt;code&gt;engine.obfuscateContent(realContent)&lt;/code&gt;. That method runs the &lt;em&gt;Java&lt;/em&gt; pipeline — JavaParser AST walk, identifier replacement, comment stripping, reflection-string post-processing.&lt;/p&gt;

&lt;p&gt;If I run it on a &lt;code&gt;.properties&lt;/code&gt; file, it produces a near-identity transformation (no Java identifiers to rename, no comments to strip the same way). The output is almost-but-not-quite the same as the real file. Now I have a "snapshot" that diverges from the cache on every single line, because the &lt;em&gt;properties sanitizer&lt;/em&gt; (a different pipeline) produced the cache, while the Java pipeline produced this fresh "snapshot."&lt;/p&gt;

&lt;p&gt;The merge then concludes that the AI rewrote every line of the properties file, and helpfully writes the sanitized (&lt;code&gt;REDACTED&lt;/code&gt; placeholder) values back into the real &lt;code&gt;application.properties&lt;/code&gt;. That's not a corrupted file — that's a data exfiltration risk inverted: the redaction now overwrites the real secret.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;.endsWith(".java")&lt;/code&gt; guard above isn't a perf optimization. It's a correctness boundary.&lt;/p&gt;

&lt;h3&gt;
  
  
  Trap 3: AI-created files don't have a snapshot at all
&lt;/h3&gt;

&lt;p&gt;When the AI creates a new file — &lt;code&gt;Cls_a1b2c3d4Test.java&lt;/code&gt;, say — there's no snapshot to merge against. There's no real file either. You just have the cache.&lt;/p&gt;

&lt;p&gt;This case is simpler in some ways (full de-obfuscation of the content, no merge) but it has its own corner: the &lt;em&gt;filename itself&lt;/em&gt; contains obfuscated identifiers. &lt;code&gt;Cls_a1b2c3d4Test.java&lt;/code&gt; needs to become &lt;code&gt;InvoiceServiceTest.java&lt;/code&gt; — the AI used the obfuscated class name as a prefix to a new identifier, and the path resolver has to recognize the embedded mapping.&lt;/p&gt;

&lt;p&gt;The strategy: try a full-filename match against known class mappings first (&lt;code&gt;Cls_a1b2c3d4.java&lt;/code&gt; → &lt;code&gt;InvoiceService.java&lt;/code&gt;). If that fails, run the standard line de-obfuscation on the filename without extension and treat whatever comes out as the real name (&lt;code&gt;Cls_a1b2c3d4Test&lt;/code&gt; → &lt;code&gt;InvoiceServiceTest&lt;/code&gt;). Same for package path segments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;matched&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;fileName&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;endsWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;".java"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;stem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fileName&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;substring&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fileName&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;fileName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;deobfuscateLine&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stem&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;".java"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same machinery you wrote to de-obfuscate file &lt;em&gt;contents&lt;/em&gt; solves the file &lt;em&gt;path&lt;/em&gt; problem if you feed it the path as a string. Once I noticed this, several other corner cases I'd been hand-rolling (paths in stack traces, file references in error messages) collapsed into the same call.&lt;/p&gt;




&lt;h2&gt;
  
  
  What about deletions?
&lt;/h2&gt;

&lt;p&gt;The AI sometimes "cleans up" by deleting a file. I do not auto-apply deletions. The merge reports them — &lt;code&gt;applied: 3, created: 1, deletedByAi: 1&lt;/code&gt; — and the developer decides whether to follow through.&lt;/p&gt;

&lt;p&gt;This is not a technical limitation. It's a deliberate asymmetry. The cost of accidentally creating a file is a &lt;code&gt;git rm&lt;/code&gt; away. The cost of accidentally deleting a file the developer hadn't checked in yet is unrecoverable. The merge plays defense on the irreversible side.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why this generalizes
&lt;/h2&gt;

&lt;p&gt;I started building this for obfuscation because I had to. But the pattern — &lt;em&gt;projection, transformation in the projected space, merge back into the original&lt;/em&gt; — shows up in a lot of places once you look for it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Source maps in JavaScript bundlers.&lt;/strong&gt; The bundled file is a projection; the original sources are the real version; you map errors back via the source map.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AST-based refactoring tools.&lt;/strong&gt; The AST is a projection; the textual source has comments and formatting the AST doesn't; round-tripping requires a 3-way merge.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Notebook → script extraction and back.&lt;/strong&gt; Strip cells to a script for review; merge edits back into the notebook.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Anything that asks an LLM to edit code with stripped context.&lt;/strong&gt; Hide secrets, hide proprietary names, hide internal comments — and now you own a merge problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The takeaway from six months of breaking my own merge: &lt;strong&gt;don't think of the projection as a translation. Think of it as a branch.&lt;/strong&gt; Once you call it a branch, you stop trying to invent a clever inverse and you start writing a merge — which is a problem the industry has spent decades solving.&lt;/p&gt;




&lt;p&gt;If you want to see the merge running on real Java edits — including the tricky cases — the example diffs and test fixtures live in &lt;a href="https://gitlab.com/gbreton7/promptcape-docs" rel="noopener noreferrer"&gt;gitlab.com/gbreton7/promptcape-docs&lt;/a&gt;. It's the docs and worked-examples companion to &lt;em&gt;**&lt;a href="https://promptcape.com" rel="noopener noreferrer"&gt;PromptCape&lt;/a&gt;&lt;/em&gt;*, the obfuscation proxy I'm building for Claude Code and Cursor. MRs welcome if you've run into a merge case I haven't.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>java</category>
      <category>security</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Java Code Obfuscation for AI Assistants: Ensuring the Full Cycle Works</title>
      <dc:creator>Genevieve Breton</dc:creator>
      <pubDate>Mon, 04 May 2026 18:14:55 +0000</pubDate>
      <link>https://dev.to/genevieve_breton_cb795f52/java-code-obfuscation-for-ai-assistants-ensuring-the-full-cycle-works-d5</link>
      <guid>https://dev.to/genevieve_breton_cb795f52/java-code-obfuscation-for-ai-assistants-ensuring-the-full-cycle-works-d5</guid>
      <description>&lt;p&gt;&lt;em&gt;How to obfuscate Java code for AI coding tools while guaranteeing that compilation, tests, and reverse-application all succeed.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;AI coding assistants (Claude Code, Cursor, GitHub Copilot) need access to your source code to help you. But sending proprietary code to an LLM means exposing your business domain, architecture, and intellectual property, and configuration data, even personal data.&lt;/p&gt;

&lt;p&gt;Code obfuscation can solve this: rename identifiers before the AI sees the code, let the AI work on the obfuscated version, then reverse the changes back. Simple in theory. In practice, Java's rich ecosystem of frameworks, annotations, and conventions makes this a minefield.&lt;/p&gt;

&lt;p&gt;This article describes what a Java obfuscation tool must handle to guarantee the &lt;strong&gt;full cycle&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source compiles &amp;amp; tests pass
    -&amp;gt; Obfuscation
        -&amp;gt; AI modifies code
            -&amp;gt; Obfuscated code compiles &amp;amp; tests pass
                -&amp;gt; De-obfuscation (apply)
                    -&amp;gt; Source compiles &amp;amp; tests pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each transition can break. Here is what you need to address at each step, and how PromptCape solves it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Source -&amp;gt; Obfuscation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.1 What to rename
&lt;/h3&gt;

&lt;p&gt;A Java obfuscator for AI must rename:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Element&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Package names&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;com.acme.billing&lt;/code&gt; -&amp;gt; &lt;code&gt;pkg_a1b2c3d4&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Reveals company and domain&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Class names&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;InvoiceService&lt;/code&gt; -&amp;gt; &lt;code&gt;Cls_e5f6a7b8&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Reveals business concepts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Method names&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;calculateDiscount&lt;/code&gt; -&amp;gt; &lt;code&gt;mtd_1a2b3c4d&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Reveals business logic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Field names&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;customerName&lt;/code&gt; -&amp;gt; &lt;code&gt;fld_9e8d7c6b&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Reveals data model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Comments&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;// Apply VAT to invoice&lt;/code&gt; -&amp;gt; &lt;code&gt;// Processed.&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Reveals business context&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Javadoc&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;/** Calculates the total with tax */&lt;/code&gt; -&amp;gt; &lt;code&gt;/** Processed. */&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Same&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Config values&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;jdbc:postgresql://prod.acme.com&lt;/code&gt; -&amp;gt; &lt;code&gt;REDACTED&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Reveals infrastructure&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  1.2 What NOT to rename
&lt;/h3&gt;

&lt;p&gt;This is where most naive approaches fail. The following must be preserved:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JDK types and methods:&lt;/strong&gt; &lt;code&gt;String&lt;/code&gt;, &lt;code&gt;List&lt;/code&gt;, &lt;code&gt;Map&lt;/code&gt;, &lt;code&gt;Optional&lt;/code&gt;, &lt;code&gt;toString&lt;/code&gt;, &lt;code&gt;equals&lt;/code&gt;, &lt;code&gt;hashCode&lt;/code&gt;, &lt;code&gt;main&lt;/code&gt;, &lt;code&gt;stream&lt;/code&gt;, &lt;code&gt;forEach&lt;/code&gt;...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Framework annotations:&lt;/strong&gt; &lt;code&gt;@Autowired&lt;/code&gt;, &lt;code&gt;@Entity&lt;/code&gt;, &lt;code&gt;@RestController&lt;/code&gt;, &lt;code&gt;@GetMapping&lt;/code&gt;, &lt;code&gt;@JsonProperty&lt;/code&gt;, &lt;code&gt;@Data&lt;/code&gt;, &lt;code&gt;@Builder&lt;/code&gt;...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Framework-specific identifiers&lt;/strong&gt; that carry semantic meaning for the framework at runtime:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Framework&lt;/th&gt;
&lt;th&gt;What breaks if renamed&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Spring Data JPA&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Derived query methods&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;findByActiveTrue()&lt;/code&gt; -&amp;gt; the method name IS the query. Renaming it to &lt;code&gt;mtd_xxx&lt;/code&gt; makes Spring fail with "No property mtd found"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;JPA/Hibernate&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Entity names in JPQL&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;@Query("SELECT e FROM Invoice e")&lt;/code&gt; — the string &lt;code&gt;Invoice&lt;/code&gt; must match the entity class name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Lombok&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Generated accessor names&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;@Data&lt;/code&gt; generates &lt;code&gt;getName()&lt;/code&gt; from field &lt;code&gt;name&lt;/code&gt;. If &lt;code&gt;name&lt;/code&gt; is renamed to &lt;code&gt;fld_xxx&lt;/code&gt;, Lombok generates &lt;code&gt;getFld_xxx()&lt;/code&gt; — but code calling &lt;code&gt;getName()&lt;/code&gt; is also renamed to &lt;code&gt;getMtd_xxx()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Jackson&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;JSON field mapping&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;@JsonProperty&lt;/code&gt; fields, or fields in DTOs in &lt;code&gt;model&lt;/code&gt;/&lt;code&gt;dto&lt;/code&gt; packages — renaming breaks serialization/deserialization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Spring Config&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Property binding&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;@ConfigurationProperties&lt;/code&gt; binds YAML keys to field names&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Bean Validation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Field references&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;@NotBlank&lt;/code&gt; on a field — the constraint message references the field name&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The solution: framework detection (Pass 0).&lt;/strong&gt; Before collecting identifiers, scan the entire project for framework annotations and produce exclusion rules. Each framework has a dedicated detector:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Project scan -&amp;gt; LombokDetector       -&amp;gt; exclude fields + get/set/is accessors
             -&amp;gt; SpringDataDetector   -&amp;gt; exclude findByXxx, countByXxx, existsByXxx methods
             -&amp;gt; JacksonDetector      -&amp;gt; exclude @Entity/@JsonProperty fields
             -&amp;gt; JpaHibernateDetector -&amp;gt; exclude @MappedSuperclass/@Embeddable fields
             -&amp;gt; SpringConfigDetector -&amp;gt; exclude @ConfigurationProperties fields
             -&amp;gt; ValidationDetector   -&amp;gt; exclude @NotBlank/@Min/@Size fields
             -&amp;gt; OpenApiDetector      -&amp;gt; exclude @Schema/@Operation fields and methods
             -&amp;gt; SpringBootDetector   -&amp;gt; track @SpringBootApplication for test fixing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.3 String literals: a hidden trap
&lt;/h3&gt;

&lt;p&gt;Code replacement must skip string literals to avoid breaking values like &lt;code&gt;"Hello World"&lt;/code&gt; or &lt;code&gt;"/api/v1/users"&lt;/code&gt;. But some strings DO reference identifiers:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Context&lt;/th&gt;
&lt;th&gt;String content&lt;/th&gt;
&lt;th&gt;Must be updated?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;@Query("SELECT e FROM Invoice e")&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;JPQL entity name&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Class.forName("com.acme.InvoiceService")&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fully qualified class name&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;getMethod("calculateTotal")&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Reflection method name&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;@ComponentScan("com.acme.service")&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Package name&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;"Hello World"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;User-facing string&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;"/api/v1/invoices"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;REST endpoint&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The obfuscator must apply identifier replacement INSIDE specific string contexts while leaving general strings untouched. This requires post-processing passes for &lt;code&gt;@Query&lt;/code&gt;, reflection calls, and package annotations.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.4 Comment stripping and special characters
&lt;/h3&gt;

&lt;p&gt;Comments contain business context that reveals your domain. But stripping them introduces two problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Line count changes:&lt;/strong&gt; A multi-line Javadoc becomes a single-line &lt;code&gt;/** Processed. */&lt;/code&gt;, breaking line-number correspondence between obfuscated and original files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Special characters in comments:&lt;/strong&gt; French (and other languages) comments contain apostrophes (&lt;code&gt;// Service d'injection&lt;/code&gt;), accented characters, and other non-ASCII text. A character-by-character scanner that treats &lt;code&gt;'&lt;/code&gt; as a Java char literal delimiter will be confused by &lt;code&gt;l'injection&lt;/code&gt;, potentially skipping code after the comment.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Process comments before string/char literal scanning. Replace line comments (&lt;code&gt;//&lt;/code&gt;) in-place (one line in, one line out). For multi-line Javadoc and block comments, accept the line count change and handle it during the reverse-apply step with a 3-way merge.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: Obfuscated code -&amp;gt; AI modification -&amp;gt; Compilation &amp;amp; tests
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1 The obfuscated code must compile
&lt;/h3&gt;

&lt;p&gt;This seems obvious but is surprisingly hard. Even with framework detection, some identifiers cause compilation failures that can only be detected by actually compiling. Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A method name that collides with a JDK method after obfuscation&lt;/li&gt;
&lt;li&gt;A field name that matches a Java keyword&lt;/li&gt;
&lt;li&gt;An annotation processor that generates code based on identifier names&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Solution: auto-fix loop.&lt;/strong&gt; Compile the obfuscated code. If it fails, parse the compiler errors, reverse-map the broken identifiers, add them to an exclusion list, and re-obfuscate. Repeat until green or max iterations reached. Persist exclusions for future runs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Obfuscate -&amp;gt; Compile -&amp;gt; Parse errors -&amp;gt; Exclude broken identifiers -&amp;gt; Re-obfuscate -&amp;gt; Compile -&amp;gt; ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2 Tests must pass on obfuscated code
&lt;/h3&gt;

&lt;p&gt;Compilation is necessary but not sufficient. Tests exercise the runtime behavior where framework conventions matter most:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Spring context loading:&lt;/strong&gt; &lt;code&gt;@SpringBootTest&lt;/code&gt; boots the full application context. A broken repository method or missing bean crashes the entire test suite.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Spring Data query derivation:&lt;/strong&gt; happens at context startup, not at compile time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JPA schema generation:&lt;/strong&gt; Hibernate creates tables from &lt;code&gt;@Entity&lt;/code&gt; classes. If JPQL &lt;code&gt;@Query&lt;/code&gt; strings reference the original entity name but the class is renamed, the context fails.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;H2 compatibility:&lt;/strong&gt; Test profiles often use H2 instead of PostgreSQL. Database-specific types (&lt;code&gt;JSONB&lt;/code&gt;, &lt;code&gt;ARRAY&lt;/code&gt;) in column definitions fail on H2 regardless of obfuscation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key insight:&lt;/strong&gt; If the source tests pass and the obfuscated tests don't, the obfuscation broke something. The auto-fix loop should use &lt;code&gt;mvn test-compile&lt;/code&gt; (or even &lt;code&gt;mvn test&lt;/code&gt;) as the build command to catch these failures.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.3 The AI must be able to work effectively
&lt;/h3&gt;

&lt;p&gt;The AI needs to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read and understand the code structure (even with obfuscated names)&lt;/li&gt;
&lt;li&gt;Create new files, classes, and methods&lt;/li&gt;
&lt;li&gt;Modify existing code&lt;/li&gt;
&lt;li&gt;Run builds and tests to verify its work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The obfuscated names should be &lt;strong&gt;deterministic&lt;/strong&gt; (same input always produces the same hash) so the AI can learn patterns across files. Prefixes (&lt;code&gt;Cls_&lt;/code&gt;, &lt;code&gt;mtd_&lt;/code&gt;, &lt;code&gt;fld_&lt;/code&gt;, &lt;code&gt;pkg_&lt;/code&gt;) help the AI understand the identifier type.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: De-obfuscation (apply) -&amp;gt; Source compiles &amp;amp; tests pass
&lt;/h2&gt;

&lt;p&gt;This is where most obfuscation tools stop — they handle the forward direction but not the reverse. For AI coding, the reverse is just as critical.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1 Only apply what the AI changed
&lt;/h3&gt;

&lt;p&gt;The naive approach: read the obfuscated file, de-obfuscate all identifiers, overwrite the real file. This breaks because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Comments were stripped during obfuscation.&lt;/strong&gt; The de-obfuscated file has &lt;code&gt;/** Processed. */&lt;/code&gt; where the original had full Javadoc. If the AI didn't touch that line, the original comment should be preserved.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Formatting may differ.&lt;/strong&gt; The obfuscated file may have different whitespace or line endings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Solution: 3-way merge.&lt;/strong&gt; Compare the snapshot (obfuscated, pre-AI) with the cache (obfuscated, post-AI) line by line:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lines unchanged by the AI -&amp;gt; keep the original source line&lt;/li&gt;
&lt;li&gt;Lines modified by the AI -&amp;gt; de-obfuscate the new version
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Snapshot line == Cache line?
    Yes -&amp;gt; keep original source line (preserves comments, formatting)
    No  -&amp;gt; de-obfuscate cache line (AI changed it)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For added/removed lines, use chunk-based alignment to find sync points and apply the changes surgically.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.2 Handle AI-generated variable names
&lt;/h3&gt;

&lt;p&gt;When the AI creates a new variable for an obfuscated class, it invents a name based on what it sees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// AI writes:&lt;/span&gt;
&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="n"&gt;Cls_f45371c4&lt;/span&gt; &lt;span class="n"&gt;fld_f45371c4&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Standard de-obfuscation produces:&lt;/span&gt;
&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;ZipBuilderService&lt;/span&gt; &lt;span class="n"&gt;fld_f45371c4&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// class de-obfuscated, but variable name is unreadable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The variable name &lt;code&gt;fld_f45371c4&lt;/code&gt; is not in the mapping registry — the AI invented it. But the hash &lt;code&gt;f45371c4&lt;/code&gt; matches the known class &lt;code&gt;ZipBuilderService&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; After standard de-obfuscation, scan for remaining &lt;code&gt;fld_XXXXXXXX&lt;/code&gt;/&lt;code&gt;cls_XXXXXXXX&lt;/code&gt;/&lt;code&gt;mtd_XXXXXXXX&lt;/code&gt; patterns. If the hash matches a known entry, generate a camelCase variable name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;ZipBuilderService&lt;/span&gt; &lt;span class="n"&gt;zipBuilderService&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// readable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Track each unique token across the file to ensure consistent renaming (declaration and all usages get the same name).&lt;/p&gt;

&lt;h3&gt;
  
  
  3.3 Don't apply build artifacts
&lt;/h3&gt;

&lt;p&gt;The AI may run &lt;code&gt;mvn package&lt;/code&gt; in the obfuscated workspace, creating &lt;code&gt;target/&lt;/code&gt; with compiled &lt;code&gt;.class&lt;/code&gt; files, &lt;code&gt;.jar&lt;/code&gt; archives, and test reports. These must be excluded from the diff detection:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Skip directories: &lt;code&gt;target/&lt;/code&gt;, &lt;code&gt;build/&lt;/code&gt;, &lt;code&gt;node_modules/&lt;/code&gt;, &lt;code&gt;.idea/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Skip binary files: &lt;code&gt;.class&lt;/code&gt;, &lt;code&gt;.jar&lt;/code&gt;, &lt;code&gt;.war&lt;/code&gt;, images, fonts&lt;/li&gt;
&lt;li&gt;These patterns match what the obfuscation engine already skips&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3.4 Snapshot management
&lt;/h3&gt;

&lt;p&gt;The apply command needs a "before" snapshot to detect what the AI changed. After a successful apply, the snapshot is updated. But if the apply fails or the user reverts with &lt;code&gt;git restore&lt;/code&gt;, the snapshot is out of sync.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don't update the snapshot when the apply has errors&lt;/li&gt;
&lt;li&gt;Provide a &lt;code&gt;--reset-snapshot&lt;/code&gt; option that re-obfuscates the source into the snapshot directory without touching the cache&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The complete cycle
&lt;/h2&gt;

&lt;p&gt;Here is what must work end-to-end:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. mvn test                       -&amp;gt; GREEN (source is healthy)
2. promptcape obfuscate --verify  -&amp;gt; Obfuscated workspace created
3. mvn test (in workspace)        -&amp;gt; GREEN (obfuscation didn't break anything)
4. AI modifies obfuscated code
5. mvn test (in workspace)        -&amp;gt; GREEN (AI changes work)
6. promptcape apply               -&amp;gt; Changes applied to source
7. mvn test                       -&amp;gt; GREEN (de-obfuscated changes work)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each transition requires specific handling:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Transition&lt;/th&gt;
&lt;th&gt;Challenge&lt;/th&gt;
&lt;th&gt;Solution&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1 -&amp;gt; 2&lt;/td&gt;
&lt;td&gt;Framework identifiers break&lt;/td&gt;
&lt;td&gt;Framework detection (8 detectors)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1 -&amp;gt; 2&lt;/td&gt;
&lt;td&gt;Some identifiers cause compile errors&lt;/td&gt;
&lt;td&gt;Auto-fix loop with exclusion persistence&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2 -&amp;gt; 3&lt;/td&gt;
&lt;td&gt;JPQL strings reference original names&lt;/td&gt;
&lt;td&gt;Post-processing: replace entity names in &lt;code&gt;@Query&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2 -&amp;gt; 3&lt;/td&gt;
&lt;td&gt;Reflection strings reference original names&lt;/td&gt;
&lt;td&gt;Post-processing: replace in &lt;code&gt;getMethod()&lt;/code&gt;, &lt;code&gt;forName()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2 -&amp;gt; 3&lt;/td&gt;
&lt;td&gt;Spring Data query derivation fails&lt;/td&gt;
&lt;td&gt;Repository method name protection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4 -&amp;gt; 5&lt;/td&gt;
&lt;td&gt;AI must understand the code&lt;/td&gt;
&lt;td&gt;Deterministic naming, type prefixes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5 -&amp;gt; 6&lt;/td&gt;
&lt;td&gt;Comments stripped during obfuscation&lt;/td&gt;
&lt;td&gt;3-way merge (only apply AI-changed lines)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5 -&amp;gt; 6&lt;/td&gt;
&lt;td&gt;AI invents unreadable variable names&lt;/td&gt;
&lt;td&gt;Hash-based name resolution&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5 -&amp;gt; 6&lt;/td&gt;
&lt;td&gt;Build artifacts in workspace&lt;/td&gt;
&lt;td&gt;Directory and binary file filtering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6 -&amp;gt; 7&lt;/td&gt;
&lt;td&gt;Applied changes don't compile&lt;/td&gt;
&lt;td&gt;User review + re-apply capability&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  What PromptCape implements
&lt;/h2&gt;

&lt;p&gt;PromptCape is a Java-first obfuscation tool designed for this exact cycle. Here is what it covers today:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Obfuscation engine:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AST-based identifier collection via JavaParser (packages, classes, methods, fields, enums, records)&lt;/li&gt;
&lt;li&gt;Deterministic HMAC-SHA256 naming with type prefixes&lt;/li&gt;
&lt;li&gt;Package hierarchy flattening&lt;/li&gt;
&lt;li&gt;Word-boundary replacement (&lt;code&gt;\b&lt;/code&gt;) with longest-match-first ordering&lt;/li&gt;
&lt;li&gt;String literal preservation with post-processing for &lt;code&gt;@Query&lt;/code&gt;, reflection, &lt;code&gt;@ComponentScan&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Full comment stripping (Javadoc, block, and line comments)&lt;/li&gt;
&lt;li&gt;POM, properties, YAML, and XML file sanitization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Framework detection (8 detectors):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lombok: field + accessor protection&lt;/li&gt;
&lt;li&gt;Spring Boot: application class tracking, test annotation fixing&lt;/li&gt;
&lt;li&gt;Spring Data: repository derived query method protection&lt;/li&gt;
&lt;li&gt;JPA/Hibernate: entity field protection, JPQL entity name replacement&lt;/li&gt;
&lt;li&gt;Jackson: DTO/entity field protection&lt;/li&gt;
&lt;li&gt;Spring Config: property-bound field protection&lt;/li&gt;
&lt;li&gt;Validation: constraint field protection&lt;/li&gt;
&lt;li&gt;OpenAPI: schema field and method protection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Auto-fix:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compile-and-fix loop with configurable build command&lt;/li&gt;
&lt;li&gt;Compiler error parsing and reverse mapping&lt;/li&gt;
&lt;li&gt;Persistent exclusion lists across runs&lt;/li&gt;
&lt;li&gt;Source verification option&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Reverse application:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;3-way merge (preserve original lines for unchanged content)&lt;/li&gt;
&lt;li&gt;AI-generated variable name resolution (hash-based)&lt;/li&gt;
&lt;li&gt;Build artifact and binary file exclusion&lt;/li&gt;
&lt;li&gt;Snapshot management with reset capability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Two modes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CLI workspace (obfuscate -&amp;gt; AI works -&amp;gt; apply)&lt;/li&gt;
&lt;li&gt;HTTP proxy (transparent interception for IDE-based tools — see below)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Metrics:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Final identifier and duration counters at the end of every run, for instance:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+-------------------------------+----------+
| Final Summary                 |          |
+-------------------------------+----------+
| Iterations                    |       4  |
| Identifiers obfuscated        |    3287  |
| Packages (flattened)          |      74  |
| Exclusions loaded (previous)  |       0  |
| Exclusions added (this run)   |     152  |
| Exclusions total              |     152  |
| Verification time             |  106,1s  |
| Total time                    |  224,5s  |
+-------------------------------+----------+
| Compilation                   |    OK    |
+-------------------------------+----------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Seamless IDE integration
&lt;/h2&gt;

&lt;p&gt;The obfuscation cycle described above can run as a one-shot CLI workflow, but friction kills adoption. Developers don't want to leave their IDE, run &lt;code&gt;promptcape obfuscate&lt;/code&gt;, switch to a workspace folder, ask the AI to do something, then run &lt;code&gt;promptcape apply&lt;/code&gt; and switch back. They want the assistant they already use, in the IDE they already use, with the obfuscation invisible.&lt;/p&gt;

&lt;p&gt;PromptCape provides this via an &lt;strong&gt;HTTP proxy mode&lt;/strong&gt; that intercepts traffic to the AI provider and applies the same forward/reverse cycle on the fly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IDE -&amp;gt; Claude Code -&amp;gt; [PromptCape proxy] -&amp;gt; Anthropic API
                          obfuscates the prompt going out
                          de-obfuscates the response coming back
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The "PromptCape Claude" terminal in Cursor
&lt;/h3&gt;

&lt;p&gt;The simplest integration is a dedicated terminal profile. In Cursor (and equally in VS Code or any IDE that supports terminal profiles), you create a profile named &lt;strong&gt;PromptCape Claude&lt;/strong&gt; that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Starts the proxy in the background if it is not already running&lt;/li&gt;
&lt;li&gt;Sets &lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt; (and equivalent variables) to point Claude Code at the local proxy&lt;/li&gt;
&lt;li&gt;Launches &lt;code&gt;claude&lt;/code&gt; (the Claude Code CLI) inside that environment&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From the developer's perspective, this is just &lt;strong&gt;another terminal in the IDE sidebar&lt;/strong&gt;. They open the &lt;em&gt;PromptCape Claude&lt;/em&gt; terminal instead of the default one, type their request to Claude as usual, and watch the AI work on their codebase. Behind the scenes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Outbound prompt:&lt;/strong&gt; identifiers, comments, and config values are obfuscated before leaving the machine&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inbound response:&lt;/strong&gt; file edits, suggestions, and explanations are de-obfuscated before reaching the IDE&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build artifacts and binaries&lt;/strong&gt; are filtered out of the cycle&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No workflow change. No &lt;code&gt;obfuscate&lt;/code&gt; or &lt;code&gt;apply&lt;/code&gt; command to remember. The same Claude Code experience, with the obfuscation guaranteeing that &lt;strong&gt;what reaches the provider is not your real source code&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why a terminal profile is the right shape for this
&lt;/h3&gt;

&lt;p&gt;The CLI workspace is the right primitive — it gives full control and fits CI/CD or one-shot review use cases. But for daily AI-assisted coding, friction wins or loses the security battle. A proxy that hooks into the existing tool's trust chain (env vars, &lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt;) gives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zero training cost:&lt;/strong&gt; developers keep using Claude Code exactly as before — same commands, same outputs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero forgotten steps:&lt;/strong&gt; there is no &lt;code&gt;apply&lt;/code&gt; to forget — the response is reverse-mapped on the wire&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Per-project configuration:&lt;/strong&gt; terminal profiles ship in &lt;code&gt;.vscode/settings.json&lt;/code&gt;, &lt;code&gt;.cursor/&lt;/code&gt;, or JetBrains run configurations, so opening a project pre-configures the secure terminal automatically&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auditability by default:&lt;/strong&gt; every prompt and response transits the proxy, which can log, redact, or block on policy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same pattern extends to any AI tool that respects a base-URL override (Cursor's built-in chat, Aider, Continue.dev, OpenAI-compatible clients, etc.). The IDE doesn't need a plugin and the AI tool doesn't need to know the proxy exists — the integration is just a terminal away.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Java obfuscation for AI coding assistants is not just about renaming identifiers. It requires deep understanding of how Java frameworks use naming conventions, how annotation processors derive behavior from names, and how to surgically apply AI changes without losing information that was stripped during obfuscation.&lt;/p&gt;

&lt;p&gt;The key insight: &lt;strong&gt;framework detection before obfuscation is more effective than reactive error fixing after.&lt;/strong&gt; Proactively protecting Spring Data repository methods, JPA entity fields, and Lombok-generated accessors eliminates most compilation failures before they happen.&lt;/p&gt;

&lt;p&gt;The second insight: &lt;strong&gt;the reverse direction is just as hard as the forward.&lt;/strong&gt; A 3-way merge that only applies AI-changed lines, combined with hash-based resolution of AI-invented names, makes the de-obfuscated code readable and correct.&lt;/p&gt;

&lt;p&gt;The third insight: &lt;strong&gt;friction kills adoption, so the obfuscation has to disappear into the IDE.&lt;/strong&gt; A dedicated terminal profile (the &lt;em&gt;PromptCape Claude&lt;/em&gt; terminal in Cursor) that boots Claude Code through the proxy turns the entire cycle into a transparent operation — same tool, same commands, no extra steps. Security that requires discipline gets bypassed; security that ships as a terminal in the sidebar gets used.&lt;/p&gt;

&lt;p&gt;PromptCape is open for trial at &lt;a href="https://promptcape.com/" rel="noopener noreferrer"&gt;promptcape.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>java</category>
      <category>privacy</category>
      <category>security</category>
    </item>
    <item>
      <title>Why Your Source Code Is at Risk When Using AI Coding Assistants, but no dev future without AI coding!</title>
      <dc:creator>Genevieve Breton</dc:creator>
      <pubDate>Fri, 01 May 2026 16:41:29 +0000</pubDate>
      <link>https://dev.to/genevieve_breton_cb795f52/why-your-source-code-is-at-risk-when-using-ai-coding-assistants-but-no-dev-future-without-ai-5513</link>
      <guid>https://dev.to/genevieve_breton_cb795f52/why-your-source-code-is-at-risk-when-using-ai-coding-assistants-but-no-dev-future-without-ai-5513</guid>
      <description>&lt;p&gt;&lt;em&gt;Every line you send to an AI coding tool leaves your control. Here's what that means for your business, your clients, and your legal obligations.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  You are sending your source code to a foreign server
&lt;/h2&gt;

&lt;p&gt;When you use Claude Code, Cursor, GitHub Copilot, ChatGPT, Mistral Vibe, or any LLM-based coding assistant, your source code is sent over HTTPS to a remote API. That API runs on servers you don't control, in a jurisdiction you didn't choose, operated by a company whose data practices you've accepted by clicking "I agree."&lt;/p&gt;

&lt;p&gt;Let's be specific about where your code goes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;API provider&lt;/th&gt;
&lt;th&gt;Server locations&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Claude Code / Cursor (Claude)&lt;/td&gt;
&lt;td&gt;Anthropic&lt;/td&gt;
&lt;td&gt;US (AWS us-east, us-west)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GitHub Copilot&lt;/td&gt;
&lt;td&gt;Microsoft / OpenAI&lt;/td&gt;
&lt;td&gt;US (Azure data centers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ChatGPT&lt;/td&gt;
&lt;td&gt;OpenAI&lt;/td&gt;
&lt;td&gt;US (Azure data centers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cursor (OpenAI mode)&lt;/td&gt;
&lt;td&gt;OpenAI&lt;/td&gt;
&lt;td&gt;US&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mistral Vibe / Le Chat&lt;/td&gt;
&lt;td&gt;Mistral AI&lt;/td&gt;
&lt;td&gt;EU (France, via cloud providers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DeepSeek&lt;/td&gt;
&lt;td&gt;DeepSeek&lt;/td&gt;
&lt;td&gt;China&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gemini Code Assist&lt;/td&gt;
&lt;td&gt;Google&lt;/td&gt;
&lt;td&gt;US (GCP data centers)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Most developers don't think twice about this. They open their IDE, the AI suggests code, they accept. Behind the scenes, the IDE sent the contents of the current file — and often surrounding files, imports, and project context — to a server thousands of kilometers away.&lt;/p&gt;




&lt;h2&gt;
  
  
  What exactly is being sent?
&lt;/h2&gt;

&lt;p&gt;It's not just "a few lines of code." Modern AI coding tools send rich context to produce better suggestions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The current file&lt;/strong&gt; — full content, not just the cursor position&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open tabs and imported files&lt;/strong&gt; — the AI reads your project structure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File paths&lt;/strong&gt; — revealing your package hierarchy (&lt;code&gt;com.acme.billing.service.InvoiceService&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configuration files&lt;/strong&gt; — &lt;code&gt;application.yml&lt;/code&gt;, &lt;code&gt;pom.xml&lt;/code&gt;, &lt;code&gt;.env&lt;/code&gt; with database URLs, API keys, internal hostnames&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comments and Javadoc&lt;/strong&gt; — containing business logic descriptions, TODO items, bug references&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test files&lt;/strong&gt; — revealing edge cases, business rules, validation logic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Git context&lt;/strong&gt; — commit messages, branch names, sometimes diffs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A single prompt to an AI coding assistant can contain more context about your business than a 10-page architecture document.&lt;/p&gt;




&lt;h2&gt;
  
  
  The risks are real and specific
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Source code leakage
&lt;/h3&gt;

&lt;p&gt;Your code is transmitted to and processed on third-party infrastructure. Even if the provider promises not to train on your data (and many do), the code still:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Transits through networks&lt;/strong&gt; you don't control — intermediate proxies, load balancers, logging systems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is stored temporarily&lt;/strong&gt; for processing — cache layers, request logs, debugging infrastructure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;May be retained for abuse detection&lt;/strong&gt; — most providers log requests for safety monitoring&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Could be subpoenaed&lt;/strong&gt; — US providers are subject to US law enforcement requests, including the CLOUD Act which allows cross-border data access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The question is not "will the provider deliberately steal my code?" It's "how many systems touch my code between my IDE and the model, and who has access to those systems?"&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Intellectual property exposure
&lt;/h3&gt;

&lt;p&gt;Source code is a trade secret. Once exposed, trade secret protection can be lost permanently — unlike patents or copyrights, trade secrets only have value as long as they remain secret.&lt;/p&gt;

&lt;p&gt;What your code reveals:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Element&lt;/th&gt;
&lt;th&gt;What it exposes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Class and method names&lt;/td&gt;
&lt;td&gt;Your business domain and capabilities (&lt;code&gt;FraudDetector&lt;/code&gt;, &lt;code&gt;TaxCalculator&lt;/code&gt;, &lt;code&gt;PatentAnalyzer&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Package structure&lt;/td&gt;
&lt;td&gt;Your architecture and module boundaries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Algorithm implementations&lt;/td&gt;
&lt;td&gt;Your competitive advantage (pricing logic, recommendation engines, risk models)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database schema&lt;/td&gt;
&lt;td&gt;Your data model and relationships&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API endpoints&lt;/td&gt;
&lt;td&gt;Your service surface and capabilities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Configuration&lt;/td&gt;
&lt;td&gt;Your infrastructure topology&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Comments&lt;/td&gt;
&lt;td&gt;Your business rules in plain language&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A competitor with access to your AI provider's logs could reconstruct your product's architecture, business rules, and technical approach without ever seeing your actual repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Client code exposure (integrators and freelancers)
&lt;/h3&gt;

&lt;p&gt;If you're a &lt;strong&gt;consulting firm&lt;/strong&gt;, &lt;strong&gt;systems integrator&lt;/strong&gt;, or &lt;strong&gt;freelance developer&lt;/strong&gt;, the risk multiplies. You're not just exposing your own code — you're exposing your client's code.&lt;/p&gt;

&lt;p&gt;Consider the scenarios:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You customize an ERP for a bank.&lt;/strong&gt; You send controller code to Claude that contains transaction processing logic, compliance rules, and internal API endpoints. That code belongs to the bank, not to you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You build a SaaS platform for a healthcare company.&lt;/strong&gt; You use Copilot while working on patient data models. HIPAA-regulated data structures are now on Microsoft's servers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You maintain a defense contractor's codebase.&lt;/strong&gt; You use an AI to debug a networking module. The code may be subject to ITAR export controls — sending it to a US cloud provider may technically comply, but sending it to a Chinese provider (DeepSeek) would be a violation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most client contracts include clauses about code confidentiality and data handling. Using AI coding tools on client code may violate these contracts — and the client may never know until a breach occurs. But if it occurs and you are the one in charge of the code, this may a very bad stone in your shoe.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Regulatory and compliance risks
&lt;/h3&gt;

&lt;p&gt;Depending on your industry and jurisdiction, sending source code to external AI services can create compliance issues:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Regulation&lt;/th&gt;
&lt;th&gt;Risk&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;GDPR&lt;/strong&gt; (EU)&lt;/td&gt;
&lt;td&gt;If your code processes personal data and the code itself contains PII patterns, field names, or test data, sending it to a US server may violate data transfer rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SOC 2&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Requires documented controls over data access. Using AI tools without DLP controls may fail audit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ISO 27001&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Requires risk assessment for third-party data processing. AI coding tools are a new attack vector&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;HIPAA&lt;/strong&gt; (US healthcare)&lt;/td&gt;
&lt;td&gt;Code containing PHI field names, validation rules, or test fixtures with patient data patterns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PCI DSS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Code handling payment card data, encryption keys, or tokenization logic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;ITAR&lt;/strong&gt; (US defense)&lt;/td&gt;
&lt;td&gt;Export-controlled technical data cannot be shared with foreign persons or servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;NIS2&lt;/strong&gt; (EU)&lt;/td&gt;
&lt;td&gt;Critical infrastructure operators must control their software supply chain&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Even if you're not in a regulated industry, your clients might be. And their auditors will ask how their code is protected.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. The training data question
&lt;/h3&gt;

&lt;p&gt;Most AI providers now offer policies like "we don't train on your data." But:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Policies change.&lt;/strong&gt; OpenAI initially trained on API data, then reversed course after backlash. What's the policy today may not be tomorrow's policy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Policies have exceptions.&lt;/strong&gt; Abuse detection, safety monitoring, and model evaluation may still use your data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free tiers have different rules.&lt;/strong&gt; ChatGPT Free explicitly trains on your conversations. Many developers prototype with the free tier before switching to paid.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subprocessors matter.&lt;/strong&gt; The AI provider may not train on your data, but what about their cloud provider? Their logging vendor? Their CDN?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data breaches happen.&lt;/strong&gt; Samsung's semiconductor division leaked proprietary chip designs through ChatGPT in 2023. OpenAI suffered a data breach in March 2023 where users could see other users' chat titles. Even claude code has recently leaked!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The safest assumption: anything you send to an AI service should be treated as if it could become public.&lt;/p&gt;




&lt;h2&gt;
  
  
  The false sense of security
&lt;/h2&gt;

&lt;h3&gt;
  
  
  "But we use the enterprise plan"
&lt;/h3&gt;

&lt;p&gt;Enterprise plans typically offer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No training on your data&lt;/li&gt;
&lt;li&gt;Data processing agreements (DPAs)&lt;/li&gt;
&lt;li&gt;SOC 2 compliance of the provider&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What they don't offer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Control over where the data is processed&lt;/li&gt;
&lt;li&gt;Guarantees about intermediate systems&lt;/li&gt;
&lt;li&gt;Protection against subpoenas or government data requests&lt;/li&gt;
&lt;li&gt;Deletion verification (you can't audit what you can't see)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  "But we use a self-hosted model"
&lt;/h3&gt;

&lt;p&gt;Self-hosted models (Llama, Mistral, CodeLlama) solve the data residency problem but introduce others:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dramatically lower code quality compared to frontier models&lt;/li&gt;
&lt;li&gt;Significant infrastructure costs&lt;/li&gt;
&lt;li&gt;No access to the latest model capabilities (Claude Opus, GPT-4o)&lt;/li&gt;
&lt;li&gt;Still requires GPU infrastructure that someone must maintain&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  "But we only send small snippets"
&lt;/h3&gt;

&lt;p&gt;AI coding tools send more context than you think. And even small snippets reveal information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// "Just a small function"&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;BigDecimal&lt;/span&gt; &lt;span class="nf"&gt;calculateRoyalty&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Contract&lt;/span&gt; &lt;span class="n"&gt;contract&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SalesReport&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;BigDecimal&lt;/span&gt; &lt;span class="n"&gt;baseRate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;contract&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getRoyaltyRate&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;BigDecimal&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getNetSales&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;subtract&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getReturns&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="n"&gt;contract&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;hasMinimumGuarantee&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;multiply&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;baseRate&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;max&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;contract&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getMinimumGuarantee&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;multiply&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;baseRate&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This "small snippet" reveals: you have a royalty calculation business, contracts have minimum guarantees, you track returns separately from net sales, and your financial model uses &lt;code&gt;BigDecimal&lt;/code&gt; precision. A competitor now knows your pricing model structure.&lt;/p&gt;




&lt;h2&gt;
  
  
  The solution: pseudonimyse and obfuscate before sending
&lt;/h2&gt;

&lt;p&gt;The principle is simple: &lt;strong&gt;rename everything that reveals business meaning before the AI sees it, then reverse the renaming when applying the AI's changes.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your code:                          What the AI sees:
calculateRoyalty()          -&amp;gt;      mtd_a1b2c3d4()
Contract contract           -&amp;gt;      Cls_e5f6a7b8 fld_9c8d7e6f
getRoyaltyRate()            -&amp;gt;      mtd_1a2b3c4d()
hasMinimumGuarantee()       -&amp;gt;      mtd_5e6f7a8b()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The AI can still:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understand the code structure (types, control flow, patterns)&lt;/li&gt;
&lt;li&gt;Suggest refactorings and bug fixes&lt;/li&gt;
&lt;li&gt;Add new functionality&lt;/li&gt;
&lt;li&gt;Write tests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What it cannot do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Infer your business domain&lt;/li&gt;
&lt;li&gt;Reconstruct your architecture from meaningful names&lt;/li&gt;
&lt;li&gt;Extract business rules from comments (stripped)&lt;/li&gt;
&lt;li&gt;Identify your company from package names (flattened)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What a proper obfuscation tool must handle
&lt;/h3&gt;

&lt;p&gt;It's not as simple as find-and-replace. Java's framework ecosystem means certain identifiers carry semantic meaning for the runtime:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Spring Data&lt;/strong&gt; repository methods (&lt;code&gt;findByName&lt;/code&gt;) derive SQL queries from the method name&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lombok&lt;/strong&gt; generates accessor methods from field names&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JPA&lt;/strong&gt; uses entity class names in JPQL query strings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Jackson&lt;/strong&gt; derives JSON field names from Java field names&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Spring Config&lt;/strong&gt; binds YAML keys to field names&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good obfuscation tool detects these frameworks and protects the identifiers that would break. Everything else gets renamed.&lt;/p&gt;

&lt;h3&gt;
  
  
  The full cycle must work
&lt;/h3&gt;

&lt;p&gt;Obfuscation is only useful if the cycle is complete:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source compiles     -&amp;gt; Obfuscate -&amp;gt; Obfuscated compiles
                                 -&amp;gt; AI modifies -&amp;gt; Still compiles
                                                -&amp;gt; Apply back -&amp;gt; Source still compiles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every transition can break. Framework detection, JPQL string updating, comment stripping, 3-way merge for reverse-application — all are necessary for a production-ready workflow.&lt;/p&gt;




&lt;h2&gt;
  
  
  What you should do today
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Immediate steps
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Audit what your AI tools send.&lt;/strong&gt; Enable request logging or use a proxy to see what context is transmitted. You'll likely be surprised.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Check your client contracts.&lt;/strong&gt; Look for clauses about code confidentiality, data processing, and third-party tools. Many contracts written before 2023 don't explicitly address AI coding tools — which doesn't mean they allow them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Establish an AI coding policy.&lt;/strong&gt; Define which projects can use AI tools, which cannot (client code, regulated code), and what safeguards are required.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Consider obfuscation.&lt;/strong&gt; For projects where AI assistance is valuable but code exposure is unacceptable, obfuscation provides the best of both worlds: AI productivity without IP exposure.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  For regulated industries
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Document your AI tool usage&lt;/strong&gt; in your risk register. Auditors will ask.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Include AI tools in your data processing agreements&lt;/strong&gt; with clients.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Evaluate data residency requirements.&lt;/strong&gt; If your data must stay in the EU, most US-based AI providers don't qualify without additional safeguards.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  For integrators and freelancers
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Get explicit written consent&lt;/strong&gt; from clients before using AI tools on their code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use obfuscation by default&lt;/strong&gt; on client projects. It's a competitive advantage: "We use AI to deliver faster, and we protect your code while doing it."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Include AI tool policies in your contracts.&lt;/strong&gt; Define what tools you use, how code is protected, and what the client's options are.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;AI coding assistants are transformative tools. They make developers faster, reduce boilerplate, and help navigate unfamiliar codebases. But they come with a fundamental trade-off: to help you, the AI needs to see your code. And "seeing your code" means transmitting it to infrastructure you don't control, in jurisdictions you didn't choose, with data handling practices you can't verify.&lt;/p&gt;

&lt;p&gt;The answer is not to stop using AI tools. The answer is to stop sending your code in clear text.&lt;/p&gt;

&lt;p&gt;Obfuscate your identifiers. Strip your comments. Sanitize your configuration. Let the AI work on the structure of your code without knowing what your code does. You get the productivity benefits. Your intellectual property stays yours.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;PromptCape is a Java code obfuscation tool designed for AI coding workflows. It handles framework detection, compilation verification, and smart reverse-application. Free trial at &lt;a href="https://promptcape.com/" rel="noopener noreferrer"&gt;promptcape.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why Your Source Code Is at Risk When Using AI Coding Assistants</title>
      <dc:creator>Genevieve Breton</dc:creator>
      <pubDate>Fri, 10 Apr 2026 06:35:02 +0000</pubDate>
      <link>https://dev.to/genevieve_breton_cb795f52/why-your-source-code-is-at-risk-when-using-ai-coding-assistants-29hn</link>
      <guid>https://dev.to/genevieve_breton_cb795f52/why-your-source-code-is-at-risk-when-using-ai-coding-assistants-29hn</guid>
      <description>&lt;p&gt;&lt;em&gt;Every line you send to an AI coding tool leaves your control. Here's what that means for your business, your clients, and your legal obligations.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  You are sending your source code to a foreign server
&lt;/h2&gt;

&lt;p&gt;When you use Claude Code, Cursor, GitHub Copilot, ChatGPT, Mistral Vibe, or any LLM-based coding assistant, your source code is sent over HTTPS to a remote API. That API runs on servers you don't control, in a jurisdiction you didn't choose, operated by a company whose data practices you've accepted by clicking "I agree."&lt;/p&gt;

&lt;p&gt;Let's be specific about where your code goes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;API provider&lt;/th&gt;
&lt;th&gt;Server locations&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Claude Code / Cursor (Claude)&lt;/td&gt;
&lt;td&gt;Anthropic&lt;/td&gt;
&lt;td&gt;US (AWS us-east, us-west)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GitHub Copilot&lt;/td&gt;
&lt;td&gt;Microsoft / OpenAI&lt;/td&gt;
&lt;td&gt;US (Azure data centers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ChatGPT&lt;/td&gt;
&lt;td&gt;OpenAI&lt;/td&gt;
&lt;td&gt;US (Azure data centers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cursor (OpenAI mode)&lt;/td&gt;
&lt;td&gt;OpenAI&lt;/td&gt;
&lt;td&gt;US&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mistral Vibe / Le Chat&lt;/td&gt;
&lt;td&gt;Mistral AI&lt;/td&gt;
&lt;td&gt;EU (France, via cloud providers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DeepSeek&lt;/td&gt;
&lt;td&gt;DeepSeek&lt;/td&gt;
&lt;td&gt;China&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gemini Code Assist&lt;/td&gt;
&lt;td&gt;Google&lt;/td&gt;
&lt;td&gt;US (GCP data centers)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Most developers don't think twice about this. They open their IDE, the AI suggests code, they accept. Behind the scenes, the IDE sent the contents of the current file — and often surrounding files, imports, and project context — to a server thousands of kilometers away.&lt;/p&gt;




&lt;h2&gt;
  
  
  What exactly is being sent?
&lt;/h2&gt;

&lt;p&gt;It's not just "a few lines of code." Modern AI coding tools send rich context to produce better suggestions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The current file&lt;/strong&gt; — full content, not just the cursor position&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open tabs and imported files&lt;/strong&gt; — the AI reads your project structure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File paths&lt;/strong&gt; — revealing your package hierarchy (&lt;code&gt;com.acme.billing.service.InvoiceService&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configuration files&lt;/strong&gt; — &lt;code&gt;application.yml&lt;/code&gt;, &lt;code&gt;pom.xml&lt;/code&gt;, &lt;code&gt;.env&lt;/code&gt; with database URLs, API keys, internal hostnames&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comments and Javadoc&lt;/strong&gt; — containing business logic descriptions, TODO items, bug references&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test files&lt;/strong&gt; — revealing edge cases, business rules, validation logic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Git context&lt;/strong&gt; — commit messages, branch names, sometimes diffs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A single prompt to an AI coding assistant can contain more context about your business than a 10-page architecture document.&lt;/p&gt;




&lt;h2&gt;
  
  
  The risks are real and specific
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Source code leakage
&lt;/h3&gt;

&lt;p&gt;Your code is transmitted to and processed on third-party infrastructure. Even if the provider promises not to train on your data (and many do), the code still:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Transits through networks&lt;/strong&gt; you don't control — intermediate proxies, load balancers, logging systems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is stored temporarily&lt;/strong&gt; for processing — cache layers, request logs, debugging infrastructure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;May be retained for abuse detection&lt;/strong&gt; — most providers log requests for safety monitoring&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Could be subpoenaed&lt;/strong&gt; — US providers are subject to US law enforcement requests, including the CLOUD Act which allows cross-border data access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The question is not "will the provider deliberately steal my code?" It's "how many systems touch my code between my IDE and the model, and who has access to those systems?"&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Intellectual property exposure
&lt;/h3&gt;

&lt;p&gt;Source code is a trade secret. Once exposed, trade secret protection can be lost permanently — unlike patents or copyrights, trade secrets only have value as long as they remain secret.&lt;/p&gt;

&lt;p&gt;What your code reveals:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Element&lt;/th&gt;
&lt;th&gt;What it exposes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Class and method names&lt;/td&gt;
&lt;td&gt;Your business domain and capabilities (&lt;code&gt;FraudDetector&lt;/code&gt;, &lt;code&gt;TaxCalculator&lt;/code&gt;, &lt;code&gt;PatentAnalyzer&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Package structure&lt;/td&gt;
&lt;td&gt;Your architecture and module boundaries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Algorithm implementations&lt;/td&gt;
&lt;td&gt;Your competitive advantage (pricing logic, recommendation engines, risk models)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database schema&lt;/td&gt;
&lt;td&gt;Your data model and relationships&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API endpoints&lt;/td&gt;
&lt;td&gt;Your service surface and capabilities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Configuration&lt;/td&gt;
&lt;td&gt;Your infrastructure topology&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Comments&lt;/td&gt;
&lt;td&gt;Your business rules in plain language&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A competitor with access to your AI provider's logs could reconstruct your product's architecture, business rules, and technical approach without ever seeing your actual repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Client code exposure (integrators and freelancers)
&lt;/h3&gt;

&lt;p&gt;If you're a &lt;strong&gt;consulting firm&lt;/strong&gt;, &lt;strong&gt;systems integrator&lt;/strong&gt;, or &lt;strong&gt;freelance developer&lt;/strong&gt;, the risk multiplies. You're not just exposing your own code — you're exposing your client's code.&lt;/p&gt;

&lt;p&gt;Consider the scenarios:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You customize an ERP for a bank.&lt;/strong&gt; You send controller code to Claude that contains transaction processing logic, compliance rules, and internal API endpoints. That code belongs to the bank, not to you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You build a SaaS platform for a healthcare company.&lt;/strong&gt; You use Copilot while working on patient data models. HIPAA-regulated data structures are now on Microsoft's servers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You maintain a defense contractor's codebase.&lt;/strong&gt; You use an AI to debug a networking module. The code may be subject to ITAR export controls — sending it to a US cloud provider may technically comply, but sending it to a Chinese provider (DeepSeek) would be a violation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most client contracts include clauses about code confidentiality and data handling. Using AI coding tools on client code may violate these contracts — and the client may never know until a breach occurs. But if it occurs and you are the one in charge of the code, this may a very bad stone in your shoe.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Regulatory and compliance risks
&lt;/h3&gt;

&lt;p&gt;Depending on your industry and jurisdiction, sending source code to external AI services can create compliance issues:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Regulation&lt;/th&gt;
&lt;th&gt;Risk&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;GDPR&lt;/strong&gt; (EU)&lt;/td&gt;
&lt;td&gt;If your code processes personal data and the code itself contains PII patterns, field names, or test data, sending it to a US server may violate data transfer rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SOC 2&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Requires documented controls over data access. Using AI tools without DLP controls may fail audit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ISO 27001&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Requires risk assessment for third-party data processing. AI coding tools are a new attack vector&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;HIPAA&lt;/strong&gt; (US healthcare)&lt;/td&gt;
&lt;td&gt;Code containing PHI field names, validation rules, or test fixtures with patient data patterns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PCI DSS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Code handling payment card data, encryption keys, or tokenization logic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;ITAR&lt;/strong&gt; (US defense)&lt;/td&gt;
&lt;td&gt;Export-controlled technical data cannot be shared with foreign persons or servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;NIS2&lt;/strong&gt; (EU)&lt;/td&gt;
&lt;td&gt;Critical infrastructure operators must control their software supply chain&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Even if you're not in a regulated industry, your clients might be. And their auditors will ask how their code is protected.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. The training data question
&lt;/h3&gt;

&lt;p&gt;Most AI providers now offer policies like "we don't train on your data." But:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Policies change.&lt;/strong&gt; OpenAI initially trained on API data, then reversed course after backlash. What's the policy today may not be tomorrow's policy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Policies have exceptions.&lt;/strong&gt; Abuse detection, safety monitoring, and model evaluation may still use your data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free tiers have different rules.&lt;/strong&gt; ChatGPT Free explicitly trains on your conversations. Many developers prototype with the free tier before switching to paid.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subprocessors matter.&lt;/strong&gt; The AI provider may not train on your data, but what about their cloud provider? Their logging vendor? Their CDN?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data breaches happen.&lt;/strong&gt; Samsung's semiconductor division leaked proprietary chip designs through ChatGPT in 2023. OpenAI suffered a data breach in March 2023 where users could see other users' chat titles. Even claude code has recently leaked!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The safest assumption: anything you send to an AI service should be treated as if it could become public.&lt;/p&gt;




&lt;h2&gt;
  
  
  The false sense of security
&lt;/h2&gt;

&lt;h3&gt;
  
  
  "But we use the enterprise plan"
&lt;/h3&gt;

&lt;p&gt;Enterprise plans typically offer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No training on your data&lt;/li&gt;
&lt;li&gt;Data processing agreements (DPAs)&lt;/li&gt;
&lt;li&gt;SOC 2 compliance of the provider&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What they don't offer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Control over where the data is processed&lt;/li&gt;
&lt;li&gt;Guarantees about intermediate systems&lt;/li&gt;
&lt;li&gt;Protection against subpoenas or government data requests&lt;/li&gt;
&lt;li&gt;Deletion verification (you can't audit what you can't see)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  "But we use a self-hosted model"
&lt;/h3&gt;

&lt;p&gt;Self-hosted models (Llama, Mistral, CodeLlama) solve the data residency problem but introduce others:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dramatically lower code quality compared to frontier models&lt;/li&gt;
&lt;li&gt;Significant infrastructure costs&lt;/li&gt;
&lt;li&gt;No access to the latest model capabilities (Claude Opus, GPT-4o)&lt;/li&gt;
&lt;li&gt;Still requires GPU infrastructure that someone must maintain&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  "But we only send small snippets"
&lt;/h3&gt;

&lt;p&gt;AI coding tools send more context than you think. And even small snippets reveal information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// "Just a small function"&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;BigDecimal&lt;/span&gt; &lt;span class="nf"&gt;calculateRoyalty&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Contract&lt;/span&gt; &lt;span class="n"&gt;contract&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SalesReport&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;BigDecimal&lt;/span&gt; &lt;span class="n"&gt;baseRate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;contract&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getRoyaltyRate&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;BigDecimal&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getNetSales&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;subtract&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getReturns&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="n"&gt;contract&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;hasMinimumGuarantee&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;multiply&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;baseRate&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;max&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;contract&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getMinimumGuarantee&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;sales&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;multiply&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;baseRate&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This "small snippet" reveals: you have a royalty calculation business, contracts have minimum guarantees, you track returns separately from net sales, and your financial model uses &lt;code&gt;BigDecimal&lt;/code&gt; precision. A competitor now knows your pricing model structure.&lt;/p&gt;




&lt;h2&gt;
  
  
  The solution: obfuscate before sending
&lt;/h2&gt;

&lt;p&gt;The principle is simple: &lt;strong&gt;rename everything that reveals business meaning before the AI sees it, then reverse the renaming when applying the AI's changes.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your code:                          What the AI sees:
calculateRoyalty()          -&amp;gt;      mtd_a1b2c3d4()
Contract contract           -&amp;gt;      Cls_e5f6a7b8 fld_9c8d7e6f
getRoyaltyRate()            -&amp;gt;      mtd_1a2b3c4d()
hasMinimumGuarantee()       -&amp;gt;      mtd_5e6f7a8b()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The AI can still:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understand the code structure (types, control flow, patterns)&lt;/li&gt;
&lt;li&gt;Suggest refactorings and bug fixes&lt;/li&gt;
&lt;li&gt;Add new functionality&lt;/li&gt;
&lt;li&gt;Write tests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What it cannot do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Infer your business domain&lt;/li&gt;
&lt;li&gt;Reconstruct your architecture from meaningful names&lt;/li&gt;
&lt;li&gt;Extract business rules from comments (stripped)&lt;/li&gt;
&lt;li&gt;Identify your company from package names (flattened)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What a proper obfuscation tool must handle
&lt;/h3&gt;

&lt;p&gt;It's not as simple as find-and-replace. Java's framework ecosystem means certain identifiers carry semantic meaning for the runtime:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Spring Data&lt;/strong&gt; repository methods (&lt;code&gt;findByName&lt;/code&gt;) derive SQL queries from the method name&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lombok&lt;/strong&gt; generates accessor methods from field names&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JPA&lt;/strong&gt; uses entity class names in JPQL query strings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Jackson&lt;/strong&gt; derives JSON field names from Java field names&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Spring Config&lt;/strong&gt; binds YAML keys to field names&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good obfuscation tool detects these frameworks and protects the identifiers that would break. Everything else gets renamed.&lt;/p&gt;

&lt;h3&gt;
  
  
  The full cycle must work
&lt;/h3&gt;

&lt;p&gt;Obfuscation is only useful if the cycle is complete:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source compiles     -&amp;gt; Obfuscate -&amp;gt; Obfuscated compiles
                                 -&amp;gt; AI modifies -&amp;gt; Still compiles
                                                -&amp;gt; Apply back -&amp;gt; Source still compiles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every transition can break. Framework detection, JPQL string updating, comment stripping, 3-way merge for reverse-application — all are necessary for a production-ready workflow.&lt;/p&gt;




&lt;h2&gt;
  
  
  What you should do today
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Immediate steps
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Audit what your AI tools send.&lt;/strong&gt; Enable request logging or use a proxy to see what context is transmitted. You'll likely be surprised.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Check your client contracts.&lt;/strong&gt; Look for clauses about code confidentiality, data processing, and third-party tools. Many contracts written before 2023 don't explicitly address AI coding tools — which doesn't mean they allow them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Establish an AI coding policy.&lt;/strong&gt; Define which projects can use AI tools, which cannot (client code, regulated code), and what safeguards are required.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Consider obfuscation.&lt;/strong&gt; For projects where AI assistance is valuable but code exposure is unacceptable, obfuscation provides the best of both worlds: AI productivity without IP exposure.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  For regulated industries
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Document your AI tool usage&lt;/strong&gt; in your risk register. Auditors will ask.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Include AI tools in your data processing agreements&lt;/strong&gt; with clients.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Evaluate data residency requirements.&lt;/strong&gt; If your data must stay in the EU, most US-based AI providers don't qualify without additional safeguards.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  For integrators and freelancers
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Get explicit written consent&lt;/strong&gt; from clients before using AI tools on their code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use obfuscation by default&lt;/strong&gt; on client projects. It's a competitive advantage: "We use AI to deliver faster, and we protect your code while doing it."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Include AI tool policies in your contracts.&lt;/strong&gt; Define what tools you use, how code is protected, and what the client's options are.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;AI coding assistants are transformative tools. They make developers faster, reduce boilerplate, and help navigate unfamiliar codebases. But they come with a fundamental trade-off: to help you, the AI needs to see your code. And "seeing your code" means transmitting it to infrastructure you don't control, in jurisdictions you didn't choose, with data handling practices you can't verify.&lt;/p&gt;

&lt;p&gt;The answer is not to stop using AI tools. The answer is to stop sending your code in clear text.&lt;/p&gt;

&lt;p&gt;Obfuscate your identifiers. Strip your comments. Sanitize your configuration. Let the AI work on the structure of your code without knowing what your code does. You get the productivity benefits. Your intellectual property stays yours.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;PromptCape is a Java code obfuscation tool designed for AI coding workflows. It handles framework detection, compilation verification, and smart reverse-application. Free trial at &lt;a href="https://promptcape.com/" rel="noopener noreferrer"&gt;PromptCape&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>privacy</category>
      <category>promptcape</category>
      <category>java</category>
    </item>
  </channel>
</rss>
