<?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 Sahil on Medium]]></title>
        <description><![CDATA[Stories by Sahil on Medium]]></description>
        <link>https://medium.com/@sah1l?source=rss-f6aa6c7d7bf7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*flktjq54mVCvrI-XdEJJMA.png</url>
            <title>Stories by Sahil on Medium</title>
            <link>https://medium.com/@sah1l?source=rss-f6aa6c7d7bf7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 08:26:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sah1l/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[I had $5 of Jev credits, so I made it play Battleship]]></title>
            <link>https://medium.com/@sah1l/i-had-5-of-jev-credits-so-i-made-it-play-battleship-710bd7fde529?source=rss-f6aa6c7d7bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/710bd7fde529</guid>
            <category><![CDATA[astra]]></category>
            <category><![CDATA[jevs]]></category>
            <category><![CDATA[fable]]></category>
            <category><![CDATA[claude]]></category>
            <dc:creator><![CDATA[Sahil]]></dc:creator>
            <pubDate>Sun, 20 Sep 2026 08:12:37 GMT</pubDate>
            <atom:updated>2026-09-20T08:27:39.920Z</atom:updated>
            <content:encoded><![CDATA[<h4>How it did against Sonnet over the API and Fable and Astra through browser agents.</h4><p>I got access to Jev, the System One model from TypeSafe AI, along with $5 of credits. It takes some state and a fixed set of options, then returns a probability for each option.</p><p>I wanted to try it, but I did not have a use case in my day-to-day work. Most of my work uses models that need to reason through a problem.</p><p>So I picked Battleship. Each move is a choice from the remaining cells, and I could compare how many shots each model needed to sink the same fleet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1kizpmV0-hXMPHVwcy1xog.png" /></figure><h3>The setup</h3><p>An 8 x 8 board with four ships of length 4, 3, 3 and 2. Ships may touch.</p><p>I set one rule for myself: no strategy in code. The code is only allowed to check that the chosen cell is legal. No probability maps, no “if there is a hit, shoot next to it” logic. Whatever skill shows up has to come from the model reading the prompt.</p><p>The first version needed about 48 shots to clear a fleet, compared with 57 when firing at random. It would find a miss and keep extending a row of misses: A1, A2, A3. Rewording the instructions did almost nothing.</p><p>What helped was adding nearby cell observations to each option’s description. Every open cell is offered as an option, and its description states plainly what has been observed around it: the four neighbours, then the cells one step further. In my tests, Jev did better with explicit neighbour descriptions than with a grid. With that one change it dropped to about 30 shots per fleet over 28 test fleets. A classic probability-density solver, which I only used offline as a yardstick, averages 28.6 on the same fleets.</p><h3>Round one: Claude Sonnet 4.6, over the API</h3><p>Best of five. Both players attack the same hidden fleet with the same prompt and the same option order, and the fewest shots wins. Sonnet ran at temperature 0 with no extended thinking and had to answer with a single JSON choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SCx54RB_n7cm_mO3cK_JWA.gif" /></figure><p>Sonnet won the series 3 to 2, averaging 30.4 shots against Jev’s 33.0.</p><p>Jev was faster and cheaper in this series:</p><ul><li>Median latency per move with back-to-back API calls: Jev 388 ms, Sonnet 1,297 ms.</li><li>Total API time for five games: Jev 73 seconds, Sonnet 232 seconds.</li><li>Cost for five games: Jev $0.029, Sonnet $1.72. That is a 60x gap.</li></ul><p>In the replay above the clock is real measured API time, sped up. Jev finishes its fleet while Sonnet is still in the middle of the board.</p><h3>Rounds two and three: Claude Fable 5.1 and Astra, in the browser</h3><p>I put the game on a web page and let Claude Fable 5.1 play through Claude Code and Astra through Codex, clicking cells in Chrome. In these games, each side attacks the other’s fleet. The first to sink all four ships wins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zNQb1ZqBlkuT9PDGzyyRKQ.gif" /></figure><p>Fable sank Jev’s fleet in 27 shots. At that point Jev had landed 10 of the 12 hits it needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EuDCNHHYUKzzqYqFaMhC2A.gif" /></figure><p>Astra needed 37 shots. Jev was again sitting on 10 of 12 hits when it ended.</p><p>Two games, two losses, and both times Jev was two hits away from winning. Each full game cost about half a cent on the Jev side: $0.0043 against Fable and $0.0055 against Astra, as reported by the game page. The agents took roughly 14 and 19 seconds per turn including browser control, which is a different kind of workload altogether, so I did not try to put a price on their side.</p><p>For completeness, I also ran the API series against a smaller general-purpose model, MiniMax M3. Jev won that one 3 to 2, at about a fifth of the cost and under half the latency.</p><h3>What I took away</h3><p>Some practical notes from a weekend with it:</p><ul><li>Clearer option descriptions helped more than rewording the instructions. I had to spell out distances between cells, and wrong labels led to bad choices in my tests.</li><li>Latency depends on a warm connection. Called back to back, the median was 388 ms. In the browser games, where the agents took many seconds between moves, most calls paid for a fresh connection and came in around 1.2 seconds.</li><li>At the recorded API-series costs, $5 would cover about 875 games with Jev or 15 with Sonnet.</li></ul><p>I would try it next for request routing or ticket triage, where the choices are known and response time matters. I would still need to check its accuracy on that workload.</p><h3>Caveats</h3><p>These are small samples: five games per API series and one game each in the browser. Sonnet 4.6 was the newest Sonnet my account could call. Ten of Sonnet’s answers were invalid and counted as wasted shots. Their response time and token cost are included in the totals. Costs are calculated from token usage and the list prices used for the run.</p><p>If you want the prompt, the harness or the raw results, I am happy to share them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=710bd7fde529" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS accounts that close themselves]]></title>
            <link>https://medium.com/@sah1l/aws-accounts-that-close-themselves-d6610044a1e7?source=rss-f6aa6c7d7bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6610044a1e7</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[billing]]></category>
            <dc:creator><![CDATA[Sahil]]></dc:creator>
            <pubDate>Thu, 03 Sep 2026 06:47:08 GMT</pubDate>
            <atom:updated>2026-09-23T13:05:03.486Z</atom:updated>
            <content:encoded><![CDATA[<p>Developers learn AWS by breaking things in AWS. A shared account with a read only role does not teach anyone much. So we give people their own account.</p><p>The problem was never handing out the account. It was everything after. Someone leaves a NAT gateway running and it quietly bills 32 dollars a month. Someone finishes the training and the account sits there with live keys in it. Cleanup depends on a person remembering, and people do not remember.</p><p>We built a small Terraform module to fix that. One command creates a throwaway AWS account with a hard budget and an expiry date, and the account closes itself when either one runs out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GO40GRM3D2VWQeD43yxnZA.png" /><figcaption>Every resource the module creates. The two triggers on the right both land on close_account.</figcaption></figure><h3>One apply, one account</h3><p>The whole request is four values.</p><pre>terraform workspace new 1001<br><br>terraform apply \<br>  -var=&quot;username=riya&quot; \<br>  -var=&quot;request_id=1001&quot; \<br>  -var=&#39;user_emails=[&quot;riya@corp.com&quot;]&#39; \<br>  -var=&quot;budget_amount=100&quot; \<br>  -var=&quot;expiry_date=2026-03-31&quot; \<br>  -var=&quot;parent_ou_id=ou-xxxx-xxxxxxxx&quot;</pre><p>Who it is for, how much they can spend, when it ends, and a ticket number. That is it.</p><p>The ticket number does more work than it looks. It is the Terraform workspace name, so every account gets its own state file and two requests can never touch each other. It is also in the account name, the alias, the budget name and the root email, so anything you find in the console tells you which request created it.</p><p>Root emails use plus addressing, ops+1001@corp.com. AWS wants a unique email per account and this avoids creating a real mailbox for every learner.</p><h3>The money watch</h3><p>Budgets are the part most people get wrong, so this is the bit worth stealing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rcBp0dex-BaDN96yoOAuzg.png" /><figcaption>Three thresholds send an email. The fourth one ends the account.</figcaption></figure><p>Four thresholds on one monthly budget. 50 percent sends an email. 80 percent sends two, one on actual spend and one on forecast, because forecast is what warns you the day before things get bad. 95 percent publishes to an SNS topic, and a Lambda subscribed to that topic closes the account.</p><p>Two details took a while to get right.</p><p>First, the cost filter. Without a LinkedAccount filter the budget watches the whole organization, and every learner gets alerts about somebody else’s spend.</p><p>Second, and this one cost us a week of silent failures:</p><pre>cost_types {<br>  include_credit = false<br>  include_refund = false<br>}</pre><p>Our organization has credits. Credits offset usage, so net cost stays at zero, so the budget never crosses a threshold and no alert ever fires. The account looks free while it is burning real usage. Counting gross usage fixed it. If you run budgets under an organization with credits, check this before you trust your alerts.</p><h3>The clock watch</h3><p>Money is only half of it. Most accounts never touch the budget, they just outlive their purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jLB3TwYXU_Xw8CTT6A05XA.png" /><figcaption>The warning lands before the closure. That gap is the whole point.</figcaption></figure><p>Two EventBridge schedules, both one shot. The first fires three days before the expiry date and sends a warning email through SES. The second fires the day after expiry and closes the account.</p><p>The warning is not decoration. Closing an AWS account is close to permanent, so people need a window to pull out whatever they built. Three days has been enough.</p><h3>Two triggers, one Lambda</h3><p>The budget path and the expiry path end in the same place. close_account.py reads the event, works out whether SNS or the scheduler woke it up, logs the reason, and calls organizations:CloseAccount.</p><p>Keeping one Lambda for both was deliberate. Closure is the only irreversible thing this module does, so we wanted one place to read, one place to log, and one thing to disable if it ever misbehaves.</p><h3>The ugly part</h3><p>IAM users have to be created inside the new account, and the new account sits on the other side of the Organizations boundary. The provider is configured for the management account, so we shell out. A null_resource assumes OrganizationAccountAccessRole in the new account and runs AWS CLI commands to set the alias and create the user.</p><p>This works and I still do not like it. Anything created that way is invisible to Terraform state, so there is no drift detection on those users. Delete one by hand and Terraform will happily report no changes.</p><p>We kept it because the alternative is a second provider block pointing at an account that does not exist until apply time. A provisioner is at least honest about being a script. A half working provider configuration would not be.</p><p>The other cost is platform. The Unix path uses bash and jq, and Windows has neither, so every one of those resources has a PowerShell twin behind an is_windows flag. Not elegant, but it is the difference between the tool running on everyone’s laptop and running on mine.</p><h3>What I would change</h3><p>Right now a person runs the command. That is fine at our volume and it is the wrong answer at ten times the volume. The next step is a form that opens a pull request with the variables filled in, so requests get reviewed and the apply is just CI.</p><p>I would also make SSO the default instead of IAM users. Handing someone a generated password over chat works, but their company badge already exists.</p><h3>The lesson</h3><p>The rule we started with was please delete your learning account when you are done. It did not work, because it was a rule that lived in people’s heads.</p><p>The version that works has no rule in it. There is a budget that closes the account and a date that closes the account, and both of them run whether anyone remembers or not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6610044a1e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Outpost: A sharable link for the file your AI agent just made for you]]></title>
            <link>https://medium.com/@sah1l/outpost-a-sharable-link-for-the-file-your-ai-agent-just-made-for-you-db9fce56cb2e?source=rss-f6aa6c7d7bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/db9fce56cb2e</guid>
            <category><![CDATA[share]]></category>
            <category><![CDATA[agent-skills]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Sahil]]></dc:creator>
            <pubDate>Tue, 28 Apr 2026 01:49:49 GMT</pubDate>
            <atom:updated>2026-04-28T01:49:49.838Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How I built a tiny “share to a public URL” tool — and the agent skill that lets Claude Code (or any agent) hand me back a link without leaving the chat.</em></p><h3>The annoying 30 seconds</h3><p>I keep ending up in the same loop with my AI coding agents.</p><blockquote><em>“Generate a one-page HTML report from this CSV.”</em></blockquote><blockquote>Claude Code writes report.html.</blockquote><blockquote><em>“Cool. Send it to my teammate.”</em></blockquote><blockquote>…now I open the file, screenshot it, paste it in Slack. Or zip it. Or spin up a gist.</blockquote><p>Every time, the agent stops one step short of the thing I actually wanted: a <strong>link</strong>. Something I can drop in a DM. Something the recipient can open on their phone without installing anything.</p><p>Outpost is the missing step. It’s a Next.js app on Cloud Run that takes an HTML or Markdown file and gives you back https://outpost.offsprint.xyz/s/&lt;slug&gt;. There&#39;s a CLI. There&#39;s an Agent Skill. The agent runs the CLI, you get a URL, you paste it. End of loop.</p><p>Live: <a href="https://outpost.offsprint.xyz/"><strong>https://outpost.offsprint.xyz</strong></a> <br>Code: <a href="https://github.com/sah1l/outpost"><strong>https://github.com/sah1l/outpost</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*85DQbtNLejmstRuXshwLzw.png" /></figure><h3>What it does, in one screen</h3><ul><li><strong>Upload</strong> an .html, .md, or zipped static site.</li><li><strong>Get a link.</strong> Public if you want it, private otherwise.</li><li><strong>Edit</strong> in the browser. Markdown gets rendered server-side; HTML is served as-is.</li><li><strong>Anonymous works too</strong> — no signup needed for a quick share, with a 30-day TTL and a per-IP quota.</li><li><strong>CLI for terminals and agents</strong> — outpost upload ./report.html --public returns the URL.</li></ul><p>That’s the user surface. The interesting bit is what I had to do to make “user-uploaded HTML” not be a security disaster.</p><h3>The one design decision everything else hangs on: two domains</h3><p>If you let users upload HTML and serve it from your main domain, you’ve just handed every user an XSS primitive against every other user. Their &lt;script&gt; runs on outpost.offsprint.xyz, reads the session cookie, and now they&#39;re you.</p><p>So Outpost is split across two origins:</p><ul><li><strong>outpost.offsprint.xyz</strong> — the trusted app. Auth, dashboard, editor, all the upload APIs. Owns the Firebase session cookie.</li><li><strong>usercontent.offsprint.xyz</strong> — the untrusted content origin. Streams uploaded HTML/MD/zips from Google Cloud Storage. <strong>No auth happens here at all.</strong></li></ul><p>When you visit outpost.offsprint.xyz/s/&lt;slug&gt; for a public doc, the app does a 302 to usercontent.offsprint.xyz/view/&lt;slug&gt;. The user-uploaded JavaScript that eventually runs there can do whatever it wants — read its own DOM, fetch its own assets — but it cannot read the session cookie on the trusted origin. It&#39;s on a different site, full stop. Browser same-origin policy does the heavy lifting; I just had to commit to the split.</p><h3>The CLI, and why agents are the real audience</h3><p>The web upload UI exists, but I almost never use it anymore. The CLI is shorter:</p><pre>outpost upload ./report.md --public<br># → https://outpost.offsprint.xyz/s/quiet-mountain</pre><p>There’s a --json flag that prints {slug, url, title, type} for piping. There&#39;s stdin support so cat note.md | outpost upload - --format md works. There&#39;s an OAuth-style <strong>device flow</strong> for login — the CLI prints a code, you approve it in a browser, the CLI gets a 90-day bearer token. Same shape as gh auth login.</p><p>But the part I’m actually proud of is the <strong>Agent Skill</strong>.</p><p><a href="https://agentskills.io/specification">Agent Skills</a> are a portable spec for teaching AI coding agents how to use a tool. One SKILL.md file with frontmatter, instructions, and example invocations. Claude Code, Copilot CLI, Cursor, Codex, Gemini CLI, and Antigravity all consume the same format.</p><p>So I shipped one for Outpost:</p><pre>gh skill install sah1l/outpost outpost</pre><p>After that, in any session with a supported agent:</p><blockquote><em>share </em><em>report.html as html and give me a public link</em></blockquote><p>The agent picks up the skill, runs outpost upload report.html --public, parses the URL out of the response, and hands it back. No screenshot. No Slack file upload. No &quot;let me paste this into a gist.&quot; Just a link.</p><p>The skill itself is mostly <em>boundaries</em>: don’t generate content just to upload it, don’t use --public unless the user asked, don&#39;t try to run login on the user&#39;s behalf (it needs a browser). Most of writing a good skill, it turns out, is writing down what the agent should <em>not</em> do.</p><h3>Three upload paths (because one wasn’t enough)</h3><p>This is where the architecture got opinionated. There are three different ways content gets into GCS, and each has a different threat model:</p><ol><li><strong>Browser, signed in, large or zipped uploads.</strong> The browser hits /api/docs/init, gets a V4 signed PUT URL for GCS, uploads directly to GCS, then calls /api/docs/finalize. Why: I don&#39;t want a 50 MB zip transiting my Cloud Run instance just so I can forward it to GCS — the browser can talk to GCS directly. ZIPs get extracted server-side at finalize, with zip-slip checks, compression-ratio bomb checks, and an extension allowlist. They have to contain index.html.</li><li><strong>Browser, anonymous.</strong> Plain multipart POST to /api/anon/upload. 2 MB cap, per-IP daily quota, 30-day TTL. No signed URL dance because the threat model is different: the cap is small enough that round-tripping through Cloud Run is fine, and I want the rate limit to be enforced <em>before</em> anything touches GCS.</li><li><strong>CLI / agent.</strong> Bearer-auth POST to /api/cli/upload, accepting either JSON ({text, format, title?}) or multipart. 10 MB cap. Tokens are stored hashed in Firestore (cliTokens/{sha256(token)}), with lastUsedAt write-throttled to once per hour so a chatty agent doesn&#39;t amplify Firestore load.</li></ol><p>Three paths sounds like over-engineering until you try to make one path serve all three audiences and watch it collapse under the conflicting constraints.</p><h3>The boring infra stuff that actually matters</h3><p>A few things I’d do the same way again:</p><ul><li><strong>Firestore TTL on a collection field.</strong> The docs.expiresAt field is configured as the TTL property in production. Anonymous docs set expiresAt = now + 30 days. Firestore reaps them. No cron job, no cleanup worker.</li><li><strong>GCS lifecycle rules as a backstop.</strong> Even if my Firestore-driven cleanup misses an object, a 90-day GCS lifecycle rule sweeps anon prefixes. Belt and suspenders, because storage cost from orphaned uploads is the kind of bug you only discover via a billing alert.</li><li><strong>output: &quot;standalone&quot; on both Next apps.</strong> Cloud Run wants a single-process container with a small image, and Next&#39;s standalone build does exactly that.</li><li><strong>Content-aware slug allocation.</strong> When the LLM API key is set, slugs are 2–4 readable words inferred from the doc title (quiet-mountain, sprint-notes). Falls back to a 10-char nanoid otherwise. Collisions retry with a short suffix. The shareability of outpost.offsprint.xyz/s/sprint-notes over /s/jX9k2pQ7m1 is worth the API call.</li></ul><h3>What I learned</h3><p><strong>The split-origin pattern is non-negotiable for user content.</strong> Anything else is a vulnerability waiting to be filed. Pick the boundary early — retrofitting it later means migrating every URL.</p><p><strong>Make the CLI happy and the agent will be happy.</strong> I did not set out to build “the agent integration” — I built a CLI I liked using, and the agent skill was 100 lines of markdown on top of it. If your CLI has good --json output and clear exit codes, half the agent integration work is already done.</p><p><strong>Anonymous + signed-in is two products.</strong> I spent a week trying to make one upload path serve both. It does not work. The auth surface, the quota model, and the storage prefix are all different. Splitting them was the right call.</p><p><strong>Skills are punching way above their weight.</strong> A SKILL.md is just markdown. But a well-written one — with explicit <em>don&#39;t</em>s as well as <em>do</em>s — turns &quot;I made a CLI&quot; into &quot;my CLI works inside every major coding agent.&quot; The leverage is wild for the effort.</p><h3>Try it</h3><p>If you want a public link for an HTML or Markdown file you already have:</p><pre>npx @offsprint/outpost login<br>npx @offsprint/outpost upload ./report.md --public</pre><p>If you want your AI agent to do that for you:</p><pre>gh skill install sah1l/outpost outpost</pre><p>Then ask it: <em>“share </em><em>report.md as md and give me a public link.&quot;</em></p><p>Code, infra config, and the agent skill spec are all at <a href="https://github.com/sah1l/outpost"><strong>https://github.com/sah1l/outpost</strong></a> — issues and PRs welcome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db9fce56cb2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your SQL Query Was Fast Yesterday. What Happened?]]></title>
            <link>https://medium.com/@sah1l/your-sql-query-was-fast-yesterday-what-happened-e2f505fda146?source=rss-f6aa6c7d7bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2f505fda146</guid>
            <category><![CDATA[query-plan]]></category>
            <category><![CDATA[database-performance]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Sahil]]></dc:creator>
            <pubDate>Thu, 19 Mar 2026 23:52:27 GMT</pubDate>
            <atom:updated>2026-03-20T00:08:07.801Z</atom:updated>
            <content:encoded><![CDATA[<p>Yesterday: 50ms. Today: 12 seconds.</p><p>Same query. Same code. Same database. Nothing changed — except everything changed.</p><p>The culprit is invisible: <strong>the query plan</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d9dkM5kfgjycdSISESbGuA.png" /></figure><h3>What Is a Query Plan?</h3><p>SQL is declarative. You tell the database <em>what</em> you want, not <em>how</em> to get it. The database figures out the “how” using a component called the <strong>query optimizer</strong>. Its output is the <strong>query plan</strong> — a step-by-step strategy for fetching your data.</p><p>Think of it like GPS navigation. You say “take me home.” The GPS decides: highway, side streets, or some questionable shortcut through a parking lot. And just like GPS, it changes routes based on current conditions.</p><p>The query plan is the database’s route. And it’s not permanent.</p><h3>Same Query, Two Worlds</h3><p>Take a simple query:</p><pre>SELECT * FROM Users WHERE Email = &#39;john@example.com&#39;;</pre><p>Two possible execution paths:</p><ul><li><strong>No index on </strong><strong>Email</strong> → The database reads every single row. Full table scan.</li><li><strong>Index on </strong><strong>Email</strong> → The database jumps directly to the matching row. Index seek.</li></ul><p>Same query. Wildly different cost. The optimizer picks whichever it <em>believes</em> is cheaper based on the information it has.</p><h3>When Data Grows, Plans Shift</h3><p>Here’s where it gets dangerous. The optimizer doesn’t make permanent decisions. It adapts based on:</p><ul><li><strong>Table size</strong> — a scan on 1,000 rows is trivial; on 10 million, it’s a disaster</li><li><strong>Data distribution</strong> — are values spread evenly, or does one value dominate?</li><li><strong>Index selectivity</strong> — does the index narrow results down significantly?</li><li><strong>Statistics</strong> — the optimizer’s internal metadata about your data</li></ul><p>Let’s walk through the lifecycle of a single query as data grows.</p><h4>Stage 1: Small Table (1,000 rows)</h4><p>A full table scan is cheap. The optimizer doesn’t even bother with your index. It reads the whole table because it’s faster than the overhead of seeking through an index tree.</p><p><strong>Result:</strong> Table Scan. Fast. No one notices.</p><h4>Stage 2: Medium Table (500,000 rows)</h4><p>The table is big enough that scanning hurts. The index now provides real value — it eliminates most rows before touching the table.</p><p><strong>Result:</strong> Index Seek. Still fast. Everyone’s happy.</p><h4>Stage 3: Large Table with Skewed Data (5 million rows)</h4><p>Now things get interesting.</p><pre>SELECT * FROM Orders WHERE Status = &#39;Completed&#39;;</pre><ul><li>If only 5% of orders are Completed → the index is excellent. It narrows the search to a small slice.</li><li>If 90% of orders are Completed → the index is useless. You&#39;re reading almost every row anyway, and the random I/O of index lookups is <em>more</em> expensive than a sequential scan.</li></ul><p><strong>Result:</strong> The optimizer might flip back to a Table Scan — even though the index exists and was working fine last month.</p><p><strong>Same query. Same index. Different data. Different plan.</strong></p><h3>Why This Happens: Statistics</h3><p>The database doesn’t inspect every row before running your query. That would defeat the purpose. Instead, it relies on <strong>statistics</strong> — precomputed summaries about your data: row counts, value distributions, histograms of column values.</p><p>When statistics are accurate, the optimizer makes good decisions. When they’re stale or misleading, it guesses wrong. And a wrong guess means a bad plan.</p><p>Common triggers for bad statistics:</p><ul><li>Rapid data growth (bulk imports, migration bursts)</li><li>Changing data distribution over time</li><li>Statistics that haven’t been refreshed</li></ul><p><strong>The optimizer is only as smart as its statistics.</strong></p><h3>A Real Example: The Missing Tenant Filter</h3><p>This is where theory meets production.</p><p>If you work on a multi-tenant SaaS application — where all tenants share the same database tables, separated by a TenantID or CompanyID column — there&#39;s a class of query plan disasters that&#39;s extremely common and surprisingly subtle.</p><p>Consider a simplified version of a dashboard stats query from our SaaS platform:</p><pre>-- Get total revenue per customer for a specific tenant<br>WITH CustomerTotals AS (<br>    SELECT <br>        c.Id,<br>        c.Name,<br>        TotalRevenue = SUM(i.Amount)<br>    FROM Sales.Customers c<br>        JOIN Sales.Invoices i<br>            ON i.CustomerId = c.Id<br>    WHERE c.TenantId = @TenantId<br>      AND i.InvoiceDate BETWEEN @StartDate AND @EndDate<br>    GROUP BY c.Id, c.Name<br>)<br>SELECT <br>    @ActiveCustomers = COUNT(*),<br>    @TotalRevenue = SUM(TotalRevenue),<br>    @AvgRevenue = AVG(TotalRevenue)<br>FROM CustomerTotals;</pre><p>Looks clean. Filters on TenantId. Has a date range. Groups and aggregates. Should be fast.</p><p><strong>But there’s a problem.</strong> The Invoices table is joined to Customers only on CustomerId. The WHERE c.TenantId = @TenantId clause filters the Customers table, but <strong>the optimizer has no guarantee that the same tenant filter applies to </strong><strong>Invoices</strong>.</p><p>In a correctly designed schema, every invoice for Customer #42 belongs to the same tenant as Customer #42. You know that. I know that. <strong>The query optimizer does not know that.</strong></p><p>Without TenantId in the join condition to the Invoices table, the optimizer might decide it needs to read the <em>entire</em> Invoices table — across all tenants — and then filter after the join. On a small database, this is invisible. On a production database with millions of invoices across hundreds of tenants, this is the difference between 50ms and 12 seconds.</p><h4>The Fix</h4><pre>JOIN Sales.Invoices i<br>        ON i.CustomerId = c.Id<br>        AND i.TenantId = c.TenantId   -- This changes everything</pre><p>One line. That’s it.</p><p>By adding TenantId to the join, you&#39;re telling the optimizer: &quot;You can filter invoices by tenant <em>before</em> joining.&quot; Now it can use the index on (TenantId, CustomerId) to seek directly to the right slice of data, instead of scanning the whole table.</p><h4>Why This Is So Common</h4><p>In multi-tenant applications, developers tend to put the tenant filter in the WHERE clause of the driving table and assume it cascades through the joins. It doesn&#39;t. Each table in a join is a separate decision for the optimizer. If it can&#39;t prove a filter applies to a table, it won&#39;t use it.</p><p>This pattern shows up everywhere:</p><ul><li>Dashboard aggregation queries</li><li>Reporting queries that join fact tables to dimension tables</li><li>Search queries that join across multiple entity tables</li><li>Any query where the “main” table is filtered by tenant but joined tables are linked only by a foreign key</li></ul><p><strong>Consistently joining on </strong><strong>TenantID across every table in the query is one of the highest-impact optimizations you can make in a multi-tenant database.</strong> It&#39;s not glamorous. It won&#39;t make a conference talk. But it will prevent more production incidents than almost anything else.</p><h3>The “Works in Dev, Breaks in Prod” Problem</h3><p>This is where engineers panic:</p><ul><li>Query runs perfectly in dev (1,000 rows per tenant, 3 tenants)</li><li>Same query crawls in production (50,000 rows per tenant, 500 tenants)</li><li>CPU spikes, users complain, dashboards time out</li></ul><p>The root cause is almost always the same: the optimizer chose a different plan because the data shape is different. Dev databases are small, clean, and uniformly distributed. Production databases are massive, skewed, and full of surprises.</p><p>A query that scans a 3,000-row table in dev will happily scan a 25-million-row table in production if the plan doesn’t change. And whether the plan changes depends entirely on whether the optimizer has enough information — through indexes, statistics, and join conditions — to find a better path.</p><h3>How to Detect Plan Changes</h3><p>Don’t guess. Inspect.</p><p><strong>SQL Server:</strong></p><pre>SET STATISTICS IO ON;<br>SET STATISTICS TIME ON;<br>-- Run your query<br>-- Check: logical reads, scan count, elapsed time</pre><p>Or grab the actual execution plan and look for:</p><ul><li><strong>Table Scan</strong> vs <strong>Index Seek</strong> — the most common red flag</li><li><strong>Estimated rows vs actual rows</strong> — if these differ by 10x or more, statistics are lying</li><li><strong>Fat arrows</strong> in the plan — data flowing where it shouldn’t</li><li><strong>Join type changes</strong> — Nested Loop to Hash Join often signals a missing filter</li></ul><p><strong>PostgreSQL:</strong></p><pre>EXPLAIN (ANALYZE, BUFFERS) SELECT ...</pre><p>Look for Seq Scan where you expected Index Scan, and compare rows= estimate vs actual rows=.</p><h3>How to Stay in Control</h3><p>No silver bullets. Just discipline.</p><h4>1. Keep Statistics Updated</h4><p>In SQL Server: UPDATE STATISTICS or enable auto-update. In PostgreSQL: ANALYZE. If stats are stale, every plan decision is built on a lie.</p><p>For queries that are particularly sensitive to parameter values, consider OPTION (RECOMPILE) in SQL Server to force a fresh plan each execution — but be aware this trades CPU for plan accuracy.</p><h4>2. Index With Intent</h4><p>Not more indexes — <em>better</em> indexes. Focus on:</p><ul><li>High-selectivity columns (tenant ID, status codes, date ranges)</li><li>Composite indexes that match your query patterns</li><li>Covering indexes for your heaviest queries</li></ul><h4>3. Join on Every Filter Column</h4><p>In multi-tenant systems, include TenantID in every join. Not just the WHERE clause. Every. Single. Join. This gives the optimizer permission to filter early.</p><h4>4. Stop Writing SELECT *</h4><p>Every unnecessary column is data the database has to read, transport, and discard. It also prevents the use of covering indexes that could serve the query from the index alone.</p><h4>5. Test With Production-Scale Data</h4><p>Your staging database with 1,000 rows is lying to you. Simulate production volume and distribution. The plan that works on small data is not the plan that runs in production.</p><h4>6. Monitor Plans Over Time</h4><p>Performance is not a one-time event. A query that’s fast today might be slow next month after a data migration, a bulk import, or just organic growth. Track your critical queries and alert on plan regressions.</p><h3>Going Deeper</h3><p>If you want to go beyond the fundamentals:</p><ul><li><strong>Parameter sniffing</strong> — the optimizer caches a plan based on the first parameter values it sees. If those values are atypical (e.g., a tiny tenant on first run), every subsequent execution reuses that suboptimal plan.</li><li><strong>Plan caching</strong> — SQL Server and PostgreSQL both reuse plans. A cached plan from yesterday might be wrong for today’s data. SQL Server’s sp_recompile or PostgreSQL’s `DISCARD PLANS` can flush stale entries.<br> Monitor the plan cache hit ratio to know when this is a problem.</li><li><strong>Cardinality estimation errors</strong> — the root cause of most plan disasters. When the optimizer misjudges how many rows a step will produce, every downstream decision is wrong. Check Estimated Rows vs Actual Rows in execution plans — a 10x+ difference is a red flag.</li><li><strong>Plan forcing and query hints</strong> — you can pin a plan with USE PLAN (SQL Server) or pg_hint_plan (PostgreSQL), but a forced plan today can become tomorrow’s bottleneck as data changes. Use as a last resort<br> while you fix the underlying issue (missing index, stale stats, bad query shape).</li></ul><h3>Final Thought</h3><p>SQL performance is not about writing a good query once. It’s about understanding that the database will <em>reinterpret</em> your query as your data changes — and giving it enough information to make the right call every time.</p><p>Your query isn’t slow.</p><p>Your query plan is.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2f505fda146" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your GitHub Repositories are Probably Insecure. Here’s How to Fix Them in 60 Seconds.]]></title>
            <link>https://medium.com/@sah1l/your-github-repositories-are-probably-insecure-heres-how-to-fix-them-in-60-seconds-a642fe5eb146?source=rss-f6aa6c7d7bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a642fe5eb146</guid>
            <dc:creator><![CDATA[Sahil]]></dc:creator>
            <pubDate>Thu, 12 Feb 2026 21:12:41 GMT</pubDate>
            <atom:updated>2026-06-18T13:20:33.506Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ja6MPXWdN3Udm00w2mXz3g.png" /></figure><p>I audited a batch of GitHub repositories recently.</p><p>Not random side projects. Real repositories. Production code.</p><p>What I found was uncomfortable:</p><ul><li>Default branches without protection</li><li>No required pull request reviews</li><li>Force pushes allowed on main</li><li>Secret scanning disabled</li><li>No SECURITY.md</li><li>No Dependabot</li></ul><p>None of this happened because engineers don’t care about security.</p><p>It happened because GitHub makes the secure path longer than the insecure one.</p><p>And most teams don’t have time for 15-minute configuration rituals on every single repo.</p><p>So I built a tool to fix that.</p><h3>The Real Problem: Security Is Scattered</h3><p>If you want to properly secure a GitHub repository, here’s what you actually need to touch:</p><ul><li>Merge strategy settings</li><li>Branch protection rules</li><li>Repository rulesets</li><li>Vulnerability alerts</li><li>Secret scanning and push protection</li><li>Dependabot configuration</li><li>Community health files like SECURITY.md and CODEOWNERS</li></ul><p>These settings live across multiple pages. Different APIs. Different toggles. Different UI sections.</p><p>There is no “secure this repo” button.</p><p>So most repositories end up partially configured. Or inconsistently configured. Or not configured at all.</p><p>That’s the gap.</p><h3>Why This Actually Matters</h3><p>This isn’t theoretical hygiene.</p><ul><li>Force pushes can rewrite history.</li><li>No required reviews increases the chance of production bugs.</li><li>No secret scanning means leaked tokens live forever.</li><li>No dependency alerts means vulnerable packages quietly ship to production.</li></ul><p>Security failures rarely happen because engineers don’t care.</p><p>They happen because the secure setup is tedious.</p><h3>Introducing gh-secure</h3><p>I built <strong>gh-secure</strong>, a GitHub CLI extension that audits, scores, and hardens repositories in under a minute.</p><p><strong>Prerequisites:</strong></p><ul><li><a href="https://cli.github.com/">GitHub CLI</a> installed (gh)</li><li>Authenticated with sufficient repo/admin permissions gh auth login</li></ul><p>Install it:</p><pre>gh extension install sah1l/gh-secure</pre><p>Then audit any repository:</p><pre>gh secure audit --repo your-org/your-repo</pre><p>You get a clear, no-fluff breakdown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*o-kVvKhJc8d-XVnL-S-pTA.png" /></figure><p>That F isn’t a judgment. It’s a baseline.</p><p>Now you know exactly where you stand.</p><h3>Fix Everything With One Command</h3><p>Instead of clicking through five settings pages, you can run:</p><pre>gh secure init --preset oss</pre><p>Or:</p><pre>gh secure init --preset private</pre><p>Or, if you want full lockdown:</p><pre>gh secure init --preset strict</pre><p>Each preset configures:</p><ul><li>Branch protection with required reviews</li><li>Force push and deletion prevention</li><li>Merge strategy (squash-only by default)</li><li>Vulnerability alerts and automated fixes</li><li>Secret scanning with push protection</li><li>SECURITY.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md</li><li>CODEOWNERS</li><li>A properly configured Dependabot file</li></ul><p>One command. Consistent setup.</p><p>The oss preset is tuned for open-source.<br>The private preset is designed for team repositories.<br>The strict preset enforces signed commits, linear history, and no admin bypass.</p><p>You can also run an interactive wizard:</p><pre>gh secure init</pre><p>It walks you through every decision and shows a final summary before applying anything.</p><p>Nothing happens blindly.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fw8kN7Hl_7Mk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dw8kN7Hl_7Mk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fw8kN7Hl_7Mk%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e299510cef3fbf02d5cb128bed6259d/href">https://medium.com/media/0e299510cef3fbf02d5cb128bed6259d/href</a></iframe><h3>Built to Handle GitHub’s Quirks</h3><p>GitHub now has two protection systems:</p><ul><li>Modern Repository Rulesets</li><li>Legacy Branch Protection</li></ul><p>Most tools pick one.</p><p>gh-secure detects what your repository supports and uses the best available option automatically.</p><p>If branch protection blocks direct commits, it creates a new branch and opens a pull request instead of failing.</p><p>It works with your security posture, not against it.</p><p>Under the hood, it talks directly to GitHub’s REST and GraphQL APIs through your authenticated gh session. No external service. No separate login.</p><h3>Scale It Across Your Organization</h3><p>Here’s where it gets interesting.</p><p>You can export your security configuration:</p><pre>gh secure export --repo your-org/flagship-repo -o security-config.yaml</pre><p>This generates a portable YAML file describing your entire setup.</p><p>Then apply it everywhere:</p><pre>gh secure import -f security-config.yaml --repo your-org/another-repo --yes</pre><p>Or script it:</p><pre>REPOS=(&quot;org/api&quot; &quot;org/frontend&quot; &quot;org/mobile&quot;)<br>for repo in &quot;${REPOS[@]}&quot;; do<br>  gh secure import -f company-security.yaml --repo &quot;$repo&quot; --yes<br>done</pre><p>Now your organization has a security baseline.</p><p>No drift. No inconsistencies. No forgotten toggles.</p><p>You could even run this in CI on a schedule to enforce policy automatically.</p><h3>What This Is Not</h3><p>This is not an enterprise compliance platform.</p><p>It doesn’t replace SAST tools.<br> It doesn’t scan your codebase.<br> It doesn’t sell you dashboards.</p><p>It enforces the baseline hygiene most repositories forget.</p><p>And it does it inside your existing GitHub CLI workflow.</p><h3>Why I Built It</h3><p>I was securing repositories at work and realized I was repeating the same 15-minute dance over and over:</p><p>Open Settings.<br>Add branch protection.<br>Enable vulnerability alerts.<br>Create SECURITY.md.<br>Add Dependabot.</p><p>Then repeat.</p><p>Security at scale should be automated.</p><p>So I built a tool that makes the secure path shorter than the insecure one.</p><h3>Try It</h3><p>Install:</p><pre>gh extension install sah1l/gh-secure</pre><p>Then run:</p><pre>gh secure audit</pre><p>If your repository is already an A, you’re ahead of the curve.</p><p>If it’s not, you can fix it in under a minute.</p><p><strong>GitHub:</strong> <a href="https://github.com/sah1l/gh-secure">https://github.com/sah1l/gh-secure</a></p><p>If you think repositories deserve better defaults, give it a star and share it with your team.</p><p>The easiest security wins are the ones you can automate.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a642fe5eb146" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DevCred: Why I Built a Unified Developer Contribution Tracker]]></title>
            <link>https://medium.com/@sah1l/devcred-why-i-built-a-unified-developer-contribution-tracker-96d2e98084ca?source=rss-f6aa6c7d7bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/96d2e98084ca</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Sahil]]></dc:creator>
            <pubDate>Mon, 26 Jan 2026 05:31:11 GMT</pubDate>
            <atom:updated>2026-02-12T20:14:04.985Z</atom:updated>
            <content:encoded><![CDATA[<h3>DevCred: Unified Developer Contribution Tracker</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8VLv2ehTCq2r4a9JoGjUwA.png" /></figure><h3>Why I Built DevCred</h3><p>As an interviewer, I’ve lost count of how many times this has happened:</p><p>I open a candidate’s GitHub profile.<br>I look at the contribution graph.<br>It’s… underwhelming.</p><p>Then I start talking to them.</p><p>They’ve built production systems.<br>Handled migrations.<br>Shipped features used by real customers.</p><p>So the obvious question becomes:<br>If they’re that active, why doesn’t their GitHub show it?</p><p>The answer is almost always the same.</p><ul><li>Their company uses GitLab or Azure DevOps</li><li>Most of their work is in private repositories</li><li>They contribute under company-managed accounts</li><li>Their side projects live on another platform</li><li>Their enterprise work simply isn’t publicly visible</li></ul><p>In other words, I wasn’t evaluating their engineering ability — I started evaluating the visibility of their work.</p><p>That mismatch is what led me to build DevCred.</p><h3>The Real Problem: GitHub Is Not the Full Story</h3><p>GitHub has become the default signal for developer credibility. Recruiters check it. Interviewers check it. Even peers check it.</p><p>But modern developers rarely operate on just one platform.</p><p>Enterprise teams use:</p><ul><li>GitLab</li><li>Azure DevOps</li><li>Bitbucket</li><li>Internal VCS setups</li></ul><p>And most meaningful production work happens in private repositories.</p><p>So when hiring decisions heavily weigh a public GitHub graph, we unintentionally favor:</p><ul><li>Open-source-heavy contributors</li><li>Developers with time for public side projects</li><li>Engineers whose companies allow public attribution</li></ul><p>Meanwhile, strong enterprise engineers may appear inactive — simply because their work isn’t public.</p><p>That’s a flawed signal.</p><h3>What DevCred Does</h3><p>DevCred is a unified developer contribution tracker that aggregates activity across multiple platforms into a single, visual summary.</p><p>Instead of relying on one public profile, it brings together:</p><ul><li>GitHub</li><li>GitLab</li><li>Bitbucket (Coming soon!)</li><li>Azure DevOps</li></ul><p>And combines contribution activity into:</p><ul><li>A unified contribution heatmap</li><li>Embeddable widgets for README files, portfolios, or resumes</li></ul><p>The goal is simple:<br>Show a developer’s real contribution pattern across platforms — not just what happens to be publicly visible.</p><p>DevCred uses OAuth to connect accounts and only stores aggregated contribution data. <strong>It does not access or display private code or commit messages. The focus is on activity metrics, not source code</strong>.</p><p>You can see an example heatmap directly in my github profile: <a href="https://github.com/sah1l/devcred?utm_source=chatgpt.com">https://github.com/sah1l</a></p><p>And actual public profile page at <a href="https://devcred.offsprint.xyz/sahil">https://devcred.offsprint.xyz/sahil</a></p><h3>How This Changes Interviews</h3><p>When reviewing candidates, this shifts the conversation.</p><p>Instead of: “Your GitHub looks quiet.”<br>You can say: “Can you share your DevCred profile?”</p><p>Now you’re evaluating:</p><ul><li>Contribution consistency</li><li>Cross-platform experience</li><li>Collaboration patterns</li><li>Real-world activity over time</li></ul><p>It removes bias toward public-only work and gives a fairer, more complete signal.</p><h3>Why This Matters</h3><p>Engineering credibility should not depend on whether your company uses GitHub publicly.</p><p>A unified contribution tracker doesn’t replace interviews, technical rounds, or system design discussions.</p><p>But it does improve the initial signal.</p><p>And in hiring, better signals lead to better decisions.</p><h3>Get Started</h3><ol><li>Visit <a href="https://devcred.offsprint.xyz/">https://devcred.offsprint.xyz</a></li><li>Sign in with Google</li><li>Connect your platforms</li><li>Set your username</li><li>Share your profile everywhere</li></ol><p>Your contributions deserve to be seen. All of them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96d2e98084ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>