<?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: Lyu yihang</title>
    <description>The latest articles on DEV Community by Lyu yihang (@oldsixxiaolv).</description>
    <link>https://dev.to/oldsixxiaolv</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4272432%2F9a604fe0-5b8b-45d5-92d4-1b4107d93e8a.jpg</url>
      <title>DEV Community: Lyu yihang</title>
      <link>https://dev.to/oldsixxiaolv</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oldsixxiaolv"/>
    <language>en</language>
    <item>
      <title>Why I Built a Physics-Checking Workflow (/physgate) for AI Coding Agents</title>
      <dc:creator>Lyu yihang</dc:creator>
      <pubDate>Sun, 29 Nov 2026 14:51:20 +0000</pubDate>
      <link>https://dev.to/oldsixxiaolv/why-i-built-a-physics-checking-workflow-physgate-for-ai-coding-agents-4egb</link>
      <guid>https://dev.to/oldsixxiaolv/why-i-built-a-physics-checking-workflow-physgate-for-ai-coding-agents-4egb</guid>
      <description>&lt;p&gt;I'm a PhD student in lightning and atmospheric physics at the University of Chinese Academy of Sciences (UCAS). Like a lot of people doing scientific computing lately, I've been using AI coding agents (Claude Code, Codex CLI, Gemini CLI) to write Python diagnostic scripts and data-processing pipelines.&lt;/p&gt;

&lt;p&gt;They are great at getting boilerplate running quickly, but I kept hitting a frustrating problem: the code runs cleanly, throws zero exceptions, and even passes basic unit tests, yet &lt;strong&gt;silently breaks physics&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;&lt;a href="https://github.com/oldsixxiaolv/PhysGate" rel="noopener noreferrer"&gt;PhysGate&lt;/a&gt;&lt;/strong&gt; (MIT license, free and open-source)—a lightweight &lt;code&gt;SKILL.md&lt;/code&gt; workflow (&lt;code&gt;/physgate&lt;/code&gt; or &lt;code&gt;$physgate&lt;/code&gt;) that gates AI coding agents behind executable physics contracts before any scientific code is accepted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flsj941ebbzl6kcfj1pwk.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flsj941ebbzl6kcfj1pwk.gif" alt="PhysGate 12-second animated workflow showing Claude, Gemini, and Codex" width="760" height="396"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What PhysGate Actually Does
&lt;/h2&gt;

&lt;p&gt;Instead of letting an agent jump straight into "vibe-coding" an implementation, &lt;code&gt;/physgate&lt;/code&gt; forces it through four strict gates:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Socratic Alignment (&lt;code&gt;QA_RAW.md&lt;/code&gt; → &lt;code&gt;SPEC.md&lt;/code&gt;)&lt;/strong&gt;&lt;br&gt;
Before touching implementation code, the agent has to ask clarifying questions in both technical and plain-language framing (no leading multiple-choice options) and freeze a &lt;code&gt;SPEC.md&lt;/code&gt; contract with explicit physical red lines.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Executable Physics Constraints (&lt;code&gt;PC-01, PC-02, …&lt;/code&gt;)&lt;/strong&gt;&lt;br&gt;
Instead of leaving conservation laws or dimensional checks as comments in a doc, PhysGate turns them into automated &lt;code&gt;pytest&lt;/code&gt; assertions—checking conservation, units, positivity/bounds, and limiting regimes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Isolated Git Worktree Slices (&lt;code&gt;TICKETS.md&lt;/code&gt;)&lt;/strong&gt;&lt;br&gt;
Implementation is split into 2–4 vertical slices dispatched to sub-agents inside separate &lt;code&gt;git worktree&lt;/code&gt;s, so parallel agents never overwrite each other's files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;3-Family Cross-Model Blind Review (&lt;code&gt;REVIEW_BOARD.md&lt;/code&gt;)&lt;/strong&gt;&lt;br&gt;
An LLM reviewing its own code is way too polite to itself. In PhysGate, the main coding agent is blocked from reviewing its own output. A non-voting clerk sub-agent sends the work to two &lt;em&gt;other&lt;/em&gt; distinct model families in read-only mode (for example, Gemini CLI + Codex CLI &lt;code&gt;-s read-only&lt;/code&gt;, or DeepSeek/MiniMax/OpenCode) and records any disagreements verbatim.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  3 Real-World Scientific Benchmarks (Baseline AI vs. PhysGate)
&lt;/h2&gt;

&lt;p&gt;To test whether this actually catches real bugs, I built three reproducible benchmark cases in the repo comparing an unconstrained baseline AI solution against a PhysGate-gated solution:&lt;/p&gt;

&lt;h3&gt;
  
  
  Case 1: 3D Atmospheric River &amp;amp; Moisture/Energy Flux (&lt;code&gt;examples/case1_atmospheric_river/&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Computing IVT, moisture flux divergence, MSE flux divergence, and geostrophic wind shear on a 3D North Pacific grid. Unconstrained AI code routinely misses the spherical &lt;code&gt;cos(phi)&lt;/code&gt; metric factor, leaves negative-humidity spectral ringing (&lt;code&gt;q &amp;lt; 0&lt;/code&gt;), or integrates pressure right through coastal mountains.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F20vt61i9119ahp50esrv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F20vt61i9119ahp50esrv.png" alt="Case 1: 3D Atmospheric River Physics Audit" width="799" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Case 2: Deep-Ocean Argo Float Profile (&lt;code&gt;examples/case2_deep_ocean_argo/&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Computing upper-700 m Ocean Heat Content, Brunt-Väisälä buoyancy frequency &lt;code&gt;N^2&lt;/code&gt;, and 2000 m seawater density using pure NumPy. PhysGate enforces hydrostatic/thermodynamic consistency, monotonicity, and boundary bounds so subtle unit or finite-difference sign bugs get caught immediately.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1qm3o508jixt6gy6mmqb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1qm3o508jixt6gy6mmqb.png" alt="Case 2: Deep-Ocean Argo Profile Audit" width="799" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Case 3: Capped Supercell Radiosonde CAPE/CIN (&lt;code&gt;examples/case3_capped_supercell_cape/&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Computing surface-based CAPE, CIN, LCL, LFC, and EL from a sounding profile. Parcel-lifting thermodynamics have nasty edge cases around capping inversions, virtual temperature corrections, and integration limits where naive AI implementations silently return plausible-looking wrong numbers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs57pv32kz4fjbdsxpibx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs57pv32kz4fjbdsxpibx.png" alt="Case 3: Capped Supercell CAPE/CIN Audit" width="799" height="367"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Try It Locally
&lt;/h2&gt;

&lt;p&gt;Clone the repo and run all &lt;code&gt;pytest&lt;/code&gt; physics-constraint checks + regenerate all three showcase figures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/oldsixxiaolv/PhysGate.git
&lt;span class="nb"&gt;cd&lt;/span&gt; PhysGate
python -m pip install -e . &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; python -m pytest -v
python examples/generate_all_showcases.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or install &lt;code&gt;/physgate&lt;/code&gt; directly as a skill for Claude Code, Antigravity, or Codex CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx skills@latest add oldsixxiaolv/PhysGate -s physgate -a claude-code -a antigravity -a codex -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Repo: &lt;a href="https://github.com/oldsixxiaolv/PhysGate" rel="noopener noreferrer"&gt;https://github.com/oldsixxiaolv/PhysGate&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're using coding agents for numerical modeling, scientific Python, or physics simulations, I'd love to hear what kind of silent domain bugs you've run into—and what invariant checks you enforce before trusting your results.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>science</category>
      <category>opensource</category>
      <category>python</category>
    </item>
  </channel>
</rss>
