<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Harshal on Medium]]></title>
        <description><![CDATA[Stories by Harshal on Medium]]></description>
        <link>https://medium.com/@McQuinTrix?source=rss-3c5dedea9159------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0QuSbMSpkjSBgLFcDdoLIw.png</url>
            <title>Stories by Harshal on Medium</title>
            <link>https://medium.com/@McQuinTrix?source=rss-3c5dedea9159------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 23:00:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@McQuinTrix/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How Adding AI-Generated Plans to PRs Makes Code Review Better]]></title>
            <link>https://medium.com/@McQuinTrix/how-adding-ai-generated-plans-to-prs-makes-code-review-better-c5daf9c6a7d2?source=rss-3c5dedea9159------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5daf9c6a7d2</guid>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[ai-tools]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[engineering-productivity]]></category>
            <dc:creator><![CDATA[Harshal]]></dc:creator>
            <pubDate>Sat, 07 Feb 2026 19:35:13 GMT</pubDate>
            <atom:updated>2026-02-07T19:44:20.063Z</atom:updated>
            <content:encoded><![CDATA[<p>The AI-generated plan is the missing layer in code review and it rarely survives into the PR.</p><p><strong>TL;DR:</strong> AI tools generate structured plans before code — but those plans don’t make it into pull requests, and reviewers end up inferring intent from diffs. Attaching those plans to PRs would make code review more effective.</p><p>I didn’t plan to write this post.</p><p>It came from a friction I kept hitting while working with AI agents.</p><p>When I work with an agent, I don’t start with a perfect prompt because I usually don’t yet know what constraints matter or which tradeoffs will surface.</p><p>Instead, I build a <strong>plan</strong> iteratively.</p><p>I explore the problem, clarify assumptions, add constraints, refine scope. The plan evolves as the conversation evolves — and it’s usually <em>very</em> readable.</p><p>Then the agent generates the code… and all that context that I just gave to build the plan vanishes.</p><p>What reviewers see is a big diff, minimal (or AI-generated) PR text, and none of the stitched-together plan that made the change make sense in the first place! That gap is what this post is about.</p><h3>This Is Not an Argument Against Pull Requests</h3><p>This is <strong>not</strong> “PRs are bad.” PRs are still where we:</p><ul><li>run CI</li><li>review implementation details</li><li>discuss edge cases</li><li>preserve project history</li></ul><p>What’s changed is <em>where the decisions happen</em>.</p><p>In software development, important decisions have always happened <strong>before the code exists</strong>. AI-assisted workflows simply make that gap impossible to ignore.</p><h3>Code Review Worked When the Diff Was the Thinking</h3><p>Code review worked because the diff <em>contained the reasoning</em>. Humans wrote code line by line; intent and tradeoffs were encoded in the change.</p><p>Now PRs are larger, faster, and often less explanatory. The old joke lands differently:</p><iframe src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=twitter&amp;url=https%3A//x.com/iamdevloper/status/397664295875805184%3Flang%3Den&amp;image=" width="500" height="281" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d105d8b033894c64319ede55ec9fa17/href">https://medium.com/media/5d105d8b033894c64319ede55ec9fa17/href</a></iframe><p>In an AI world, this isn’t just humor anymore it becomes a review-scaling problem.</p><iframe src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=twitter&amp;url=https%3A//x.com/petergyang/status/2019943121430392870&amp;image=" width="500" height="281" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd8a6384578294469336780acd5e2c7f/href">https://medium.com/media/dd8a6384578294469336780acd5e2c7f/href</a></iframe><h3>AI Didn’t Kill Code Review — It Moved the Decision Boundary</h3><p>AI didn’t just speed up execution. It moved the <strong>decision boundary</strong> earlier.</p><p>We’re no longer only reviewing hand-written logic we’re reviewing the output of a plan that often lives outside the PR.</p><p>That’s a big reason review load has exploded: more PRs, bigger diffs, and less shared context.</p><h3>Lines of Code Are No Longer the Work</h3><p>Statements like “10k LOC/day” are increasingly normal. In the past, LOC loosely correlated with effort and risk. Today it mostly correlates with how broad the plan was and how fast the model executed.</p><p>Lines of code are less “work” and more “artifact.”</p><iframe src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=twitter&amp;url=https%3A//x.com/garrytan/status/2018368316033946021&amp;image=" width="500" height="281" frameborder="0" scrolling="no"><a href="https://medium.com/media/0cb83a5a5cf177b237530151525d65a3/href">https://medium.com/media/0cb83a5a5cf177b237530151525d65a3/href</a></iframe><h3>The Real Problem: We’re Reviewing Too Late</h3><p>By the time a reviewer sees an AI-generated PR, <strong>the crucial choices have already been captured in the Plan Mode artifact produced by tools like Cursor or Claude Code</strong>:</p><ul><li>architecture and boundaries</li><li>constraints and assumptions</li><li>decomposition and failure modes</li></ul><p>Those decisions didn’t happen in the diff. They happened earlier, in the agent conversation and the plan.</p><p>So review becomes mostly:</p><ul><li>syntax correctness</li><li>surface-level logic</li><li>“does this look reasonable?”</li></ul><p>When reviewers lack the upfront plan, they spend time reconstructing intent — which is the most expensive part of review.</p><p>Necessary, but not where humans add the most value.</p><h3>PR Text After Code Gen Is the Wrong Abstraction</h3><p>AI-generated PR descriptions written <em>after</em> the code exists often feel like <strong>decoding an encrypted message without the key</strong>.</p><p>This is why tools like CodeRabbit or similar AI PR assistants never quite worked for me, the output feels technically accurate, but strangely unhelpful. It reads robotic. It explains the diff, not the decision.</p><p>These summaries usually capture <em>what</em> changed, but miss:</p><ul><li>why this approach was chosen</li><li>which alternatives were considered</li><li>what constraints actually mattered</li></ul><p>Because the real context lived <strong>before</strong> the code was generated.</p><p>Trying to reconstruct intent after the fact almost always loses signal.</p><iframe src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=twitter&amp;url=https%3A//x.com/GergelyOrosz/status/2010683228961509839&amp;image=" width="500" height="281" frameborder="0" scrolling="no"><a href="https://medium.com/media/f68eb8516a42a39c0f0d83858c479ead/href">https://medium.com/media/f68eb8516a42a39c0f0d83858c479ead/href</a></iframe><p>I also don’t think the answer is raw, one-shot human prompts either especially for complex changes.</p><p>In real projects, I rarely know the full context upfront. Complex code rarely comes from a single perfect prompt . It emerges from exploration, refinement, and constraint discovery &amp; almost everyone I know chats with the plan or just chats before making the change</p><p>One-shot prompts capture <em>ideas</em>.<br>They don’t capture <em>decisions</em>.</p><p>And reviews need decisions.</p><h3>What I Mean by “Plan” (Very Specifically)</h3><p>When I say <em>plan</em>, I don’t mean a chat transcript.<br>And I don’t mean a long PR description written after the code exists.</p><p>I mean the <strong>Plan Mode artifact generated <em>before</em> clicking “Build”</strong> the thing tools like Cursor or Claude Code already produce.</p><p>It usually looks something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7EV55-T-SUBuJ8AYZHtVBg.png" /><figcaption>Plan mode image from Cursor — This plan exists <em>before</em> code generation — and usually gets discarded.</figcaption></figure><p>This plan is:</p><ul><li>structured</li><li>sequential</li><li>scoped</li><li>intentionally written for execution</li></ul><p>And most importantly: <strong>it’s incredibly readable</strong>.</p><p>Ironically, this plan is often the <em>best explanation of the change</em> clearer than the diff, clearer than auto-generated PR text yet it never makes it into the pull request.</p><h3>Why Prompt Requests or Chat Logs Don’t Work</h3><p>I also don’t think “prompt requests” or raw chat logs are the right artifact to review.</p><p>In practice, I don’t know everything upfront. I can’t dump the entire context into one perfect prompt.</p><p>Instead, I explore. I ask questions. I refine the plan incrementally.</p><p>Chat logs capture <em>exploration</em>.</p><p>Plan Mode captures <strong>decisions -</strong> what the agent will do, in what order, and under what constraints.</p><p>That’s the artifact reviewers actually need.</p><h3>Syntax-Level Review Still Matters</h3><p>None of this is “stop reading code.” Syntax-level review will always matter and AI is actually helpful here.</p><p>AI-assisted checks and refactors can:</p><ul><li>catch obvious mistakes</li><li>improve consistency</li><li>make large diffs more skimmable</li></ul><p>Humans still need to read code. The point is that <strong>syntax review isn’t where the hardest decisions live anymore</strong>.</p><h3>A Concrete Example: Reviewing a PR With vs Without a Plan</h3><p>Imagine opening a pull request and seeing:</p><ul><li>~1,200 lines changed</li><li>tests passing</li><li>a short description: <em>“Used AI to implement smart categorization.”</em></li></ul><p>You can review the code for correctness and style but you’re still left guessing:</p><ul><li>Why was this approach chosen?</li><li>How do these pieces relate to each other?</li><li>What failure cases were considered?</li></ul><p>The review turns into reconstruction work.</p><p>Now imagine the same PR, but instead of a rewritten summary or chat transcript, it includes <strong>the Plan Mode output from the AI code editor captured <em>before</em> clicking Build</strong>.</p><p>Not prompts.<br>Not chat history.<br>The structured plan the agent &amp; the dev generated for execution.</p><p>You read the plan first.</p><p>Suddenly, the diff becomes readable in context.<br>You can map sections of code back to steps in the plan.<br>Questions move up a level from <em>“what is this doing?”</em> to <em>“is this the right approach?”</em></p><p>This is essentially the <strong>design-doc pattern applied to agent coding</strong>.</p><p>We don’t write design docs instead of code.<br>We write them so reviewers can evaluate intent <strong>before and alongside</strong> the implementation.</p><p>The Plan Mode artifact plays the same role and unlike design docs, it already exists.</p><p>Example: <a href="https://github.com/McQuinTrix/jira_clone/pull/1">https://github.com/McQuinTrix/jira_clone/pull/1</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PnxEBZbboyKZ7vw_G8WD2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1mHzyacX3itYV4BLD-az1Q.png" /></figure><h3>This Might Matter Even More for Open Source</h3><p>Open source maintainers often review PRs from people who <em>don’t share context</em>. Large, context-less PRs are expensive to understand, so many projects tighten contribution rules or close PRs quickly.</p><p>Attaching the <strong>plan used before generation</strong> lowers the cost of review and trust and could help projects that have reduced or stopped accepting open PRs.</p><h3>Make Plans First-Class in Pull Requests</h3><p>This doesn’t require new tools. It’s one habit change:</p><p><strong>Open PRs as usual, but attach the plan you reviewed before clicking “Build” like attaching a design doc for a large change.</strong></p><p>PRs stay. Code review stays. But reviewers get the context that makes review faster and more human.</p><h3>Where I’m At Right Now</h3><p>I’m experimenting with this: still opening PRs the same way, but attaching the original plan that produced the code.</p><p>No final conclusions yet but early on, one thing is obvious:</p><p><strong>Reviewing plans feels more human than reacting to massive diffs.</strong></p><p>I’ll write a follow-up once I’ve lived with it longer and can share what works, what breaks, and what changes in practice.</p><h3>Closing</h3><p>This isn’t about abandoning code review.</p><p>It’s about evolving from <strong>code review to plan review</strong> without losing the strengths of either.</p><p>Pull requests still matter. Code still matters.</p><p>But in AI-agent workflows, <strong>plans matter first</strong>.</p><p><strong>Open PRs. Attach the plan. Review both.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5daf9c6a7d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring the HTML Invokers API —  Command & Interest]]></title>
            <link>https://medium.com/@McQuinTrix/exploring-the-html-invokers-api-command-interest-11a2c3c4d08a?source=rss-3c5dedea9159------2</link>
            <guid isPermaLink="false">https://medium.com/p/11a2c3c4d08a</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[webapi]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[accessibility]]></category>
            <dc:creator><![CDATA[Harshal]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 19:34:14 GMT</pubDate>
            <atom:updated>2026-02-01T19:34:14.762Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring the HTML Invokers API — Command &amp; Interest</h3><p>With the Invokers API, we can now invoke native dialog and popover behavior directly from HTML, without writing JavaScript. Its biggest advantage though is that it standardizes accessibility &amp; establishes a consistent, browser-defined pattern for triggering dialog and popover UI components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qUuVy0buC-3AhCk9PbCzpQ.png" /></figure><h3>Invoker API: commandFor</h3><h4>How to use commandfor + command to open/close dialog:</h4><pre>&lt;h1&gt;Dialog&lt;/h1&gt;<br>&lt;button <br>  commandfor=&quot;dialogExample&quot;<br>  command=&quot;show-modal&quot;&gt;<br>  Button To Open Dialog<br>&lt;/button&gt;<br><br>&lt;dialog id=&quot;dialogExample&quot;&gt;<br>  &lt;h2&gt;Dialog Title&lt;/h2&gt;<br>  &lt;button <br>    commandfor=&quot;dialogExample&quot; <br>    command=&quot;close&quot;&gt;<br>    Button To Close Dialog<br>  &lt;/button&gt;<br>&lt;/dialog&gt;</pre><p>👉 View &amp; Interact with full CodePen:<br><a href="https://codepen.io/McQuinTrix/pen/PwzRQWR">https://codepen.io/McQuinTrix/pen/PwzRQWR</a></p><p><strong>3 main attributes to focus on:<br></strong>1. idon &lt;dialog&gt; <br>2. commandfor on &lt;button&gt;, which refers to id<br>3. command which command we are invoking.( show-modal &amp; close in example)</p><h4>How to use commandfor + command to show/hide tooltip:</h4><p>Same attributes as above but command has 3 different inbuilt values for tooltip:</p><ul><li>toggle-popover</li><li>hide-popover</li><li>show-popover</li></ul><pre>&lt;h1&gt;Popover&lt;/h1&gt;<br>&lt;button <br>  command=&quot;toggle-popover&quot; <br>  commandfor=&quot;popover&quot;&gt;<br>  Popover<br>&lt;/button&gt;<br><br>&lt;div id=&quot;popover&quot; popover&gt;<br>  Hello<br>  &lt;button <br>    type=&quot;button&quot; <br>    commandfor=&quot;popover&quot; <br>    command=&quot;hide-popover&quot;&gt;<br>  Hide<br>  &lt;/button&gt;<br>&lt;/div&gt;</pre><p>👉 View &amp; Interact with full CodePen:<br><a href="https://codepen.io/McQuinTrix/pen/dPXmdBd">https://codepen.io/McQuinTrix/pen/dPXmdBd</a></p><h4>Listening to Invoker API lifecycle events with JavaScript</h4><p>Dialog HTML element doesn’t have full support for listening to all the events easily. We can listen to “close” and “cancel” events but not when its opened officially. But we can use MutationObserver for listening to when dialog is invoked to open.</p><pre>/**<br>* Dialog events<br>*/<br>// on command=&#39;close&#39; &amp; clicking escape<br>document<br>  .getElementById(&quot;dialogExample&quot;)<br>  .addEventListener(&quot;close&quot;, (event) =&gt; {<br>  console.log(event.type)<br>})<br><br>// on clicking escape<br>document<br>  .getElementById(&quot;dialogExample&quot;)<br>  .addEventListener(&quot;cancel&quot;, (event) =&gt; {<br>  console.log(event.type);<br>})<br><br>// on command=&#39;showModal&#39;<br>const dialog = document<br>  .getElementById(&quot;dialogExample&quot;);<br><br>const observer = new MutationObserver(() =&gt; {<br>  if (dialog.hasAttribute(&#39;open&#39;)) {<br>    console.log(&#39;Dialog opened!&#39;);<br>  }<br>});<br><br>observer.observe(dialog, { attributes: true });</pre><p>👉 View &amp; Interact with full CodePen: <a href="https://codepen.io/McQuinTrix/pen/XJKEqPQ">https://codepen.io/McQuinTrix/pen/XJKEqPQ</a></p><p>Popover HTML attribute has support for “toggle” event so we can listen when popover dialog emits events “hide” &amp; “show”.</p><pre>/**<br> * Popover events<br> */<br><br>document<br>  .getElementById(&quot;popover&quot;)<br>  .addEventListener(&quot;toggle&quot;, (event) =&gt; {<br>  console.log(<br>    event.type, <br>    &#39;New State: &#39;+event.newState, <br>    &#39;Old State: &#39;+event.oldState<br>  );<br>})</pre><p>The event model may appear inconsistent at first, but this is not a flaw in the Invoker APIs, its how dialog &amp; popover HTML specs were written &amp; developed. I do agree that stakeholders should have defined Invoker APIs with full support of lifecycle events for dialog as frameworks like React, Angular etc will find it hard to use these in the app without lifecycle events.</p><h3>Invoker API custom commands</h3><p>As we have seen there are only few inbuilt commands, but there is a way to use custom commands. Custom commands start with “ — ” in the prefix. For eg.: command=“ — rotate-left” and then listening to it using JavaScript event listeners &amp; reacting based on variable name.</p><pre>&lt;h2&gt;Image&lt;/h2&gt;<br>&lt;button <br>        commandfor=&quot;myImg&quot; <br>        command=&quot;--rotate-left&quot;&gt;<br>  rotate left <br>&lt;/button&gt;<br>&lt;button <br>        commandfor=&quot;myImg&quot; <br>        command=&quot;--reset&quot;&gt;<br>  reset <br>&lt;/button&gt;<br>&lt;button <br>        commandfor=&quot;myImg&quot; <br>        command=&quot;--rotate-right&quot;&gt;<br>  rotate right<br>&lt;/button&gt;<br><br>&lt;br/&gt;<br>&lt;br/&gt;<br><br>&lt;div&gt;<br>  &lt;img <br>       id=&quot;myImg&quot;<br>     src=&quot;https://www.invaluable.com/blog/wp-content/uploads/sites/77/2023/01/Einstein-457x670.jpg&quot; width=&quot;100&quot;/&gt;<br>&lt;/div&gt;</pre><pre>/**<br> * Custom Commands<br> */<br><br>const myImg = document.getElementById(&quot;myImg&quot;);<br><br>myImg.addEventListener(&#39;command&#39;, (event) =&gt; {<br>  if (event.command === &#39;--rotate-right&#39;) {<br>    myImg.style.rotate = &#39;90deg&#39;;<br>  } else if (event.command === &#39;--rotate-left&#39;) {<br>    myImg.style.rotate = &#39;-90deg&#39;;<br>  } else if (event.command === &#39;--reset&#39;) {<br>    myImg.style.rotate = &#39;0deg&#39;;<br>  } <br>})</pre><p>👉 View &amp; Interact with full CodePen:<a href="https://codepen.io/McQuinTrix/pen/PwzRBzg"><br>https://codepen.io/McQuinTrix/pen/PwzRBzg</a></p><h4>Why do custom commands start with ‘—’ ?</h4><p>It explicitly marks a command as custom / user defined and prevents collisions with browser defined commands in future known as forward compatibility or forward compat. This is same rule as CSS custom properties / variables.</p><h3>Invoker API: interestFor</h3><p>This is invoked when a user “shows interest”. What does interest mean in developer terms? It means when user hovers over on an item, focuses on an item, or intent which is browser decided. Essentially its for helpful context elements that should never be required for user.</p><p>I found interestfor invoker command a bit confusing as a developer but I think something like this actually does exist in HTML, its the “title” attribute which only shows up on hover and no events are emitted for that as well.</p><h4>How to use `interestfor`?</h4><p>This invoker only works for HTML elements with popover=hint attribute.</p><pre>&lt;button <br>  interestfor=&quot;callout-1&quot;&gt;<br>  Product<br>&lt;/button&gt;<br><br>&lt;div id=&quot;callout-1&quot; popover=hint&gt;<br>  Product callout information here.<br>&lt;/div&gt;</pre><p>👉 View &amp; Interact with full CodePen:<br><a href="https://codepen.io/McQuinTrix/pen/NPrYBgq">https://codepen.io/McQuinTrix/pen/NPrYBgq</a></p><p>You can think of this as a native tooltip-like element that supports rich, custom styling. However, it should be used only for non-critical, supplementary content such as hints, explanations, or preview content (images, GIFs) that enhance the experience rather than being required to complete a task.</p><h4>Modify popover’s timing with new `interest-delay` CSS property</h4><p>Interest-driven popovers also come with a new CSS-level control over timing. The interest-delay property lets you tune how quickly a popover opens and closes in response to user interest. The default delay is 0.5s, but this can be reduced to make hints feel more immediate:</p><pre>[popover=&quot;hint&quot;] {<br>  interest-delay: 0.1s;<br>}</pre><p>Which means it will take 0.1s to open the popover=hint and 0.1s to close it after you move the cursor/interest from the target.</p><p>This delay is browser-controlled and applies uniformly across input types, helping maintain consistent and accessible behavior.</p><p>👉 View &amp; Interact with full CodePen: <a href="https://codepen.io/McQuinTrix/pen/dPXmQMe">https://codepen.io/McQuinTrix/pen/dPXmQMe</a></p><p>[popover=&quot;hint&quot;] also has another great advantage: it can be used without managing z-index. Because it renders in the browser’s top layer, it always appears above normal page/DOM content.</p><p>Also read: <a href="https://chrome.dev/css-wrapped-2025/">https://chrome.dev/css-wrapped-2025/</a></p><p>Finally, Invoker APIs standardize how elements reference and invoke each other, they do not redefine component lifecycle or state management.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11a2c3c4d08a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How the CSS property `display: contents` helped me]]></title>
            <link>https://medium.com/@McQuinTrix/how-the-css-property-display-contents-helped-me-2d2422c212a1?source=rss-3c5dedea9159------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d2422c212a1</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[flexbox]]></category>
            <dc:creator><![CDATA[Harshal]]></dc:creator>
            <pubDate>Mon, 11 Aug 2025 02:27:28 GMT</pubDate>
            <atom:updated>2025-08-11T02:27:28.637Z</atom:updated>
            <content:encoded><![CDATA[<p>I was working on a task to modify our nav component where we were to show a few items in the nav dynamically dependent on the response of multiple APIs and other hardcoded requirements</p><p>While we could add this whole business logic in the nav component, I wanted to keep the logic of dynamically generated nav items in separate component.</p><p>The component worked as expected but I faced a tricky styling problem as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*af0SL8LBx9j49Q_UCLvU2w.png" /><figcaption>Items with red border where the dynamic list container’s child do not obey the `display: flex` from nav component</figcaption></figure><p>The dynamic items were not obeying the css styling `display: flex;` as they all are now in one element itself.</p><p>Adding display: flex; with flex-wrap: wrap;to dynamic-list-container also didn’t work as expected as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*gWBPCLZMZFAcF4xMTzJrlA.png" /></figure><p>Instead of wrapping internally, the whole element wraps and if there are more dynamic elements it looks even worse:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*hXqMOpwRuhOa1uNzjEwkMw.png" /></figure><p>Fearing that I would have to move the whole logic and separation of this feature to parent I looked into any other way I could solve this with help of architecting the code in different way.</p><p>I stumbled upon display: contents and gave it a try. <em>It works!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CzKtEozBtglLDb1ViYpgdA.png" /></figure><p>Its almost like the dynamic-list-container has disappeared and thats exactly what display: contents; does. Somewhat like display: none — as they both are “Box Suppression” value type.</p><p>Important thing to remember while using it is that it is still present in the DOM tree and style applied to it will have an effect on the children &amp; some browsers do remove it from accessibility tree so use it with proper semantics.</p><p><a href="https://codepen.io/McQuinTrix/pen/VYvMeOx">Codepen link</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d2422c212a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to tackle Circular Dependencies in your NX project]]></title>
            <link>https://medium.com/@McQuinTrix/how-to-tackle-circular-dependencies-in-your-nx-project-0c71b09e796a?source=rss-3c5dedea9159------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c71b09e796a</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[nx]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Harshal]]></dc:creator>
            <pubDate>Sun, 16 Feb 2025 20:08:05 GMT</pubDate>
            <atom:updated>2025-02-16T20:08:05.865Z</atom:updated>
            <content:encoded><![CDATA[<p>Why should we resolve circular dependencies in your NX project ?</p><ol><li><strong>Predictable Build Times</strong>: Suppose we have multiple apps in your NX project &amp; we want to have separate single application deployments if our app depends on a library which has circular dependency on another app, we will have to build both the apps.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z3MnXfOLLGFi0njiAb9dhQ.png" /><figcaption>To build “Tiny App” it will have to build the “Big App”</figcaption></figure><p>2. <strong>NPM publishable libraries with straightforward dependency structure:</strong> If you have a NX library which is atomic library in your NX project and want to publish it to npm, circular dependency will package the library with all the other projects with which it has circular dependency &amp; all the other projects they have circular dependencies too.</p><p>3. <strong>Straightforward dependency tree for predictable CI (automated tests, build &amp; linting):</strong> One of the big reason why we use NX is because it has command nx affected which helps us reduce time &amp; resource to build, lint, test(UI &amp; unit tests) by determining what code would be affected by our changes looking at graph of our project dependencies. If our projects have circular dependencies, it will evaluate far more dependencies than it is needed.</p><p>4. <strong>Enhanced package integrity for future development</strong>: Even if we don’t cleanup existing circular dependencies, our new libraries which we initially thought of keeping it clean would be eventually be affected when it depends on a circular dependent library — making project even more complex &amp; ever more exponentially hard to maintain.</p><h3>Resolving circular dependencies</h3><p>Nx recommends that we enable @nx/enforce-module-boundaries eslint rule with error for our repo (<a href="https://nx.dev/features/enforce-module-boundaries">link</a>) but if we already have circular dependencies this rule is not helpful enough &amp; will become hinderance to a team of developers who are actively working on their features as it breaks builds.</p><p>To resolve it step by step:</p><ol><li>Enable @nx/enforce-module-boundaries in warn mode:</li></ol><pre>// File: eslintrc.json<br><br>{<br>  &quot;plugins&quot;: [&quot;@nx&quot;],<br>  // ...<br>  &quot;rules&quot;: {<br>    &quot;@nx/enforce-module-boundaries&quot;: [<br>      &quot;warn&quot;,<br>      {<br>        /* options */<br>      }<br>    ]<br>  }<br>}</pre><p>2. Add a Github Action task which runs a script which counts the number of circular dependencies in the project for each pull request &amp; make it “required” check in the repo settings for pull request to be merged.</p><pre>const { execSync } = require(&#39;child_process&#39;);<br>const fs = require(&#39;fs&#39;);<br><br>// Function to run nx graph command and get the dependency graph<br>function getDependencyGraph() {<br>    try {<br>        execSync(&#39;npx nx graph --file=dep-graph.json&#39;);<br>        const graphData = fs.readFileSync(&#39;dep-graph.json&#39;, &#39;utf8&#39;);<br>        return JSON.parse(graphData);<br>    } catch (error) {<br>        console.error(&#39;Error generating dependency graph:&#39;, error.message);<br>        process.exit(1);<br>    }<br>}<br><br>// Function to detect circular dependencies<br>function detectCircularDependencies(graph) {<br>    const circularDeps = [];<br>   <br>    // Check each node&#39;s direct dependencies only<br>    for (const node in graph.graph.nodes) {<br>        const dependencies = graph.graph.dependencies[node] || [];<br>       <br>        for (const dep of dependencies) {<br>            const targetNode = dep.target;<br>           <br>            // Check if the target node has a direct dependency back to the original node<br>            const targetDependencies = graph.graph.dependencies[targetNode] || [];<br>            if (targetDependencies.some(d =&gt; d.target === node)) {<br>                // Only add if this pair isn&#39;t already recorded (in either order)<br>                const pair = [node, targetNode].sort();<br>                const pairStr = JSON.stringify(pair);<br>                if (!circularDeps.some(dep =&gt; JSON.stringify(dep.sort()) === pairStr)) {<br>                    circularDeps.push([node, targetNode]);<br>                }<br>            }<br>        }<br>    }<br><br>    return circularDeps;<br>}<br><br>// Main function<br>function main() {<br>    const graph = getDependencyGraph();<br>    const circularDependencies = detectCircularDependencies(graph);<br><br>    console.log(`Found ${circularDependencies.length} circular dependencies:`);<br>    circularDependencies.forEach((cycle, index) =&gt; {<br>        console.log(`${index + 1}. ${cycle.join(&#39; &lt;-&gt; &#39;)}`);<br>    });<br><br>    // Clean up the temporary file<br>    fs.unlinkSync(&#39;dep-graph.json&#39;);<br><br>    // Exit with non-zero status if circular dependencies are found<br>    if (circularDependencies.length &gt; 0) {<br>        process.exit(1);<br>    }<br>}<br><br>main();</pre><pre>name: Circular Dependency Check<br><br>on:<br>  pull_request:<br>  branches:<br>    - &#39;**&#39;<br>    types: [opened, synchronize, reopened]<br><br>concurrency:<br>  group: ${{ github.workflow }}-${{ github.ref }}<br>  cancel-in-progress: true<br><br>env:<br>  // TODO: Set this to however many dependencies have been detected in the script<br>  MAX_CIRCULAR_DEPS: 10<br><br>jobs:<br>  check-circular-deps:<br>  name: Check Circular Dependencies<br>  runs-on: ubuntu-latest<br><br>steps:<br>  - uses: actions/checkout@v4<br>    name: Use Node.js<br>    uses: actions/setup-node@v4<br>    with:<br>      node-version: &#39;20.x&#39;<br><br>  - name: Run circular dependency check<br>    id: check<br>    run: |<br><br>      # Debug: Print current directory and check if script exists<br>      pwd<br>      ls -la scripts/<br><br>      # Make sure script is executable<br>      chmod +x scripts/check-circular-deps.js<br>      # Run with error handling<br>      output=$(node scripts/check-circular-deps.js 2&gt;&amp;1) || true<br><br>      # Store output regardless of success/failure<br>      echo &quot;$output&quot;<br>      echo &quot;OUTPUT&lt;&lt;EOF&quot; &gt;&gt; $GITHUB_ENV<br>      echo &quot;$output&quot; &gt;&gt; $GITHUB_ENV<br>      echo &quot;EOF&quot; &gt;&gt; $GITHUB_ENV<br><br>      # Count circular dependencies<br>      count=$(echo &quot;$output&quot; | grep -c &#39;^[0–9]\+\.&#39; || true)<br>      echo &quot;COUNT=$count&quot; &gt;&gt; $GITHUB_ENV<br>      echo &quot;count=$count&quot; &gt;&gt; $GITHUB_OUTPUT<br><br>      # Check against threshold<br>      if [ $count -gt $MAX_CIRCULAR_DEPS ]; then<br>      echo &quot;status=failure&quot; &gt;&gt; $GITHUB_OUTPUT<br>      echo &quot;Error: Found $count circular dependencies. Maximum allowed is $MAX_CIRCULAR_DEPS.&quot;<br>      exit 1<br>      fi<br>      echo &quot;status=success&quot; &gt;&gt; $GITHUB_OUTPUT<br>      echo &quot;Found $count circular dependencies. Within acceptable limit.&quot;<br><br>  - name: Comment PR on Failure<br>    if: failure() &amp;&amp; steps.check.outputs.status == &#39;failure&#39;<br>    uses: marocchino/sticky-pull-request-comment@v2<br>    with:<br>      GITHUB_TOKEN: // Optional TODO: add your github token here to display that this is company&#39;s or this repo&#39;s official comment<br>    header: circular-deps<br>    message: |<br>      Circular Dependency Check Failed<br>      Found ${{ env.COUNT }} circular dependencies (maximum allowed is ${{ env.MAX_CIRCULAR_DEPS }}).<br>      &lt;details&gt;<br>        &lt;summary&gt;View detected circular dependencies&lt;/summary&gt;<br>      ```<br>      ${{ env.OUTPUT }}<br>      ```<br>     &lt;/details&gt;<br>     Please review and reduce the number of circular dependencies in your code.<br><br>- name: Remove PR Comment on Success<br>  if: success() || steps.check.outputs.status == &#39;success&#39;<br>  uses: marocchino/sticky-pull-request-comment@v2<br>  with:<br>    GITHUB_TOKEN: // Optional TODO: add your github token here to display that this is company&#39;s or this repo&#39;s official comment<br>    header: circular-deps<br>  delete: true</pre><p>3. Modify the variable `MAX_CIRCULAR_DEPS` as you remove the circular dependencies in the project.</p><p>4. After you have removed all circular dependencies, enable @nx/enforce-module-boundaries in error mode:</p><pre>// File: eslintrc.json<br><br>{<br>  &quot;plugins&quot;: [&quot;@nx&quot;],<br>  // ...<br>  &quot;rules&quot;: {<br>    &quot;@nx/enforce-module-boundaries&quot;: [<br>      &quot;error&quot;,<br>      {<br>        /* options */<br>      }<br>    ]<br>  }<br>}</pre><p>5. Disable the Github check as @nx/enforce-module-boundaries in error mode will break the build if someone introduces the circular dependencies in the NX project.</p><p>Let me know if you found this helpful or can improve on it. Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c71b09e796a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>