<?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 Sumit Suthar on Medium]]></title>
        <description><![CDATA[Stories by Sumit Suthar on Medium]]></description>
        <link>https://medium.com/@sumitsuthar_95414?source=rss-b8476e9bbf13------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*AZ-FLAV1WNH32aR8</url>
            <title>Stories by Sumit Suthar on Medium</title>
            <link>https://medium.com/@sumitsuthar_95414?source=rss-b8476e9bbf13------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 21:23:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sumitsuthar_95414/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[One Waiter, Many Tables: How the Node.js Event Loop Really Works (and When to Pick Node Over Java)]]></title>
            <link>https://medium.com/@sumitsuthar_95414/one-waiter-many-tables-how-the-node-js-event-loop-really-works-and-when-to-pick-node-over-java-784642b31bda?source=rss-b8476e9bbf13------2</link>
            <guid isPermaLink="false">https://medium.com/p/784642b31bda</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[book-recommendations]]></category>
            <category><![CDATA[node-js-tutorial]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Sumit Suthar]]></dc:creator>
            <pubDate>Wed, 18 Nov 2026 12:35:03 GMT</pubDate>
            <atom:updated>2026-11-18T12:35:03.993Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rkqwx9uh-RafD2J51V512A.png" /></figure><p>Picture a busy restaurant with just one waiter. You’d expect chaos. But this waiter never stands at the kitchen door waiting for a dish. They take an order, pass it to the kitchen, and move straight to the next table. When a dish is ready, the kitchen rings a bell and the waiter carries it out.</p><p>That waiter is Node.js. The kitchen is your operating system, database and network. And the bell-and-walk routine is the <strong>event loop</strong>, the single idea that explains almost everything about how Node behaves, why it’s fast for some jobs, and why it falls over on others.</p><p>In this post we’ll open up the event loop, run some code that proves how it works, and then answer the question every team eventually asks: <em>should we build this in Node, or in Java, Go or Python?</em></p><h3>One thread, many requests</h3><p>Traditional servers (classic Java servlet containers, for example) handled each request on its own thread. A thread waiting for a database query simply sits there, holding memory, doing nothing. Want 10,000 concurrent connections? You need a lot of threads, and a lot of RAM.</p><p>Node takes a different route. Your JavaScript runs on <strong>one main thread</strong>. Whenever your code asks for something slow (read a file, query a database, call an API), Node hands that work off and keeps going. When the result comes back, a callback is queued, and the event loop runs it as soon as the thread is free.</p><p>Under the hood, this is powered by <strong>libuv</strong>, a C library that does two things:</p><ul><li>For network I/O, it uses the operating system’s own non-blocking mechanisms (epoll on Linux, kqueue on macOS, IOCP on Windows). No extra threads needed.</li><li>For work the OS can’t do asynchronously (file system calls, DNS lookups, crypto, compression), it uses a small <strong>thread pool</strong>, 4 threads by default, adjustable with UV_THREADPOOL_SIZE.</li></ul><p>So “single-threaded” is only half true. Your JavaScript is single-threaded. Node itself is not.</p><h3>The phases of the event loop</h3><p>The event loop isn’t one big queue. It cycles through phases, each with its own queue of callbacks:</p><ol><li><strong>Timers</strong>: runs callbacks from setTimeout and setInterval whose time has come.</li><li><strong>Pending callbacks</strong>: some system-level callbacks deferred from the previous loop.</li><li><strong>Poll</strong>: fetches new I/O events and runs their callbacks. This is where Node spends most of its life, waiting for work.</li><li><strong>Check</strong>: runs setImmediate callbacks.</li><li><strong>Close callbacks</strong>: things like a socket’s ‘close’ event.</li></ol><p>And then there are two VIP queues that jump the line. After <em>every</em> callback, before moving on, Node drains:</p><ul><li>the <strong>process.nextTick</strong> queue, then</li><li>the <strong>microtask</strong> queue (resolved promises, and therefore the code after every await).</li></ul><h3>See it for yourself</h3><p>Save this as order.js and run it with node order.js:</p><pre>console.log(&#39;script start&#39;);</pre><pre>setTimeout(() =&gt; console.log(&#39;setTimeout&#39;), 0);<br>setImmediate(() =&gt; console.log(&#39;setImmediate&#39;));</pre><pre>Promise.resolve().then(() =&gt; console.log(&#39;promise&#39;));<br>process.nextTick(() =&gt; console.log(&#39;nextTick&#39;));</pre><pre>console.log(&#39;script end&#39;);</pre><p>You’ll see:</p><pre>script start<br>script end<br>nextTick<br>promise<br>setTimeout<br>setImmediate</pre><p>Synchronous code always finishes first. Then nextTick, then promises. Only then does the loop start its phases. (One honest footnote: when this runs from the main module, setTimeout and setImmediate can occasionally swap places, depending on how fast your machine enters the loop. Inside an I/O callback, setImmediate always wins.)</p><h3>The one rule: never block the waiter</h3><p>Here’s the catch. If the waiter stops to cook a twelve-course meal himself, every other table waits. In Node, any long synchronous work freezes <em>every</em> request on the server:</p><pre>app.get(&#39;/report&#39;, (req, res) =&gt; {<br>  let total = 0;<br>  for (let i = 0; i &lt; 5_000_000_000; i++) total += i; // blocks everyone<br>  res.json({ total });<br>});</pre><p>While that loop runs, no other request gets answered, no timer fires, no health check responds. The fixes:</p><ul><li>Use the async versions of APIs (fs.promises.readFile, not fs.readFileSync) in request paths.</li><li>Move CPU-heavy work to <strong>worker_threads</strong>, or to a separate service or job queue.</li><li>Stream large data instead of loading it all into memory.</li><li>Watch event loop lag in production (perf_hooks.monitorEventLoopDelay is built in).</li></ul><blockquote><em>Want to go deeper? I wrote </em><a href="https://a.co/d/0e7b8wqc"><em>One Thread, Many Requests: A Beginner’s Guide to Node.js</em></a><em> around exactly this waiter analogy. It takes you from installing Node to callbacks, promises, async/await, events and streams, and then has you build a real backend step by step.</em></blockquote><h3>So why choose Node.js over Java (and others)?</h3><p>Let’s be fair to Java first. Modern Java is excellent. Java 21’s virtual threads make thread-per-request cheap again, and the JVM’s JIT and garbage collectors are world-class for long-running, CPU-heavy services. “Node is faster than Java” is not a serious claim on its own.</p><p>The real question is fit. Node shines when:</p><ul><li><strong>Your workload is I/O-bound.</strong> APIs, BFFs (backend-for-frontend), gateways, chat, notifications, dashboards and real-time apps spend most of their time waiting on databases and networks. That’s exactly what the event loop is built for.</li><li><strong>You want one language across the stack.</strong> The same TypeScript types, validation schemas and utility code can live in the browser and the server. Small teams move noticeably faster when nobody switches mental gears.</li><li><strong>JSON is your lingua franca.</strong> No mapping layers, no annotations. A request body is already a JavaScript object.</li><li><strong>You value fast startup and a small footprint.</strong> Node starts in milliseconds, which suits serverless functions, containers that scale up and down, and quick CLIs.</li><li><strong>You want the biggest package ecosystem.</strong> npm has a library for nearly everything (just choose carefully and audit your dependencies).</li><li><strong>You need real-time features.</strong> WebSockets and server-sent events with thousands of mostly idle connections are cheap in Node.</li></ul><h3>When something else is the better choice</h3><ul><li><strong>Java / Kotlin</strong>: large enterprise systems with heavy domain logic, strict typing across huge teams, mature frameworks like Spring, and CPU-intensive processing.</li><li><strong>Go</strong>: infrastructure tools, high-throughput network services, and cases where you want a single static binary and true parallelism with goroutines.</li><li><strong>Python</strong>: data science, machine learning and scripting, where its libraries are unmatched.</li><li><strong>Rust / C++</strong>: when every microsecond and byte matters.</li></ul><p>A practical rule of thumb: <strong>if your server mostly waits, choose Node. If it mostly computes, look elsewhere</strong> (or offload that part to worker threads or a separate service).</p><h3>Quick comparison</h3><ul><li><strong>Concurrency model</strong>: Node uses an event loop and non-blocking I/O. Java uses threads (now lightweight virtual threads). Go uses goroutines.</li><li><strong>Best at</strong>: Node for I/O-heavy APIs and real-time apps. Java for large, CPU-heavy enterprise systems. Go for infrastructure and network services.</li><li><strong>Startup time</strong>: Node and Go are fast. The JVM is slower to warm up (GraalVM native images help).</li><li><strong>Language across the stack</strong>: only Node lets you use one language in browser and server.</li></ul><h3>Key takeaways</h3><ul><li>Your JavaScript runs on one thread; libuv and the OS do the waiting.</li><li>The loop runs in phases: timers, pending, poll, check, close.</li><li>process.nextTick and promise microtasks run between every callback.</li><li>Never block the event loop. Offload CPU work.</li><li>Choose Node for I/O-bound, real-time and full-stack JavaScript work, not for heavy number crunching.</li></ul><h3>Learn Node the way it actually works</h3><p>If this post clicked for you, my book <a href="https://a.co/d/0e7b8wqc"><strong>One Thread, Many Requests: A Beginner’s Guide to Node.js</strong></a> takes the same approach from first principles, written for beginners, students and developers new to backend work.</p><p>You’ll start from zero, learn just the modern JavaScript you need, and really understand the event loop, callbacks, promises, async/await, errors, files, events and streams. Then you’ll build <strong>Lunchline</strong>, an office cafeteria ordering API, step by step: from a bare HTTP server to an Express REST API with input validation, a SQLite database, safe password logins and calls to other services. Finally you’ll test it with Node’s built-in test runner, configure and log like a professional, keep it fast, and deploy it.</p><p>Every listing is tested, every term is explained the first time it appears, and every chapter ends with a checklist.</p><p>👉 <a href="https://a.co/d/0e7b8wqc"><strong>Get One Thread, Many Requests on Amazon</strong></a></p><p>If you found this useful, give it a clap and follow for more on backend engineering and system design. What part of the event loop confused you most when you started? Tell me in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=784642b31bda" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Mac Knows Where Your Day Went. FocusLens Tells You.]]></title>
            <link>https://medium.com/@sumitsuthar_95414/your-mac-knows-where-your-day-went-focuslens-tells-you-a4ede674c9e8?source=rss-b8476e9bbf13------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4ede674c9e8</guid>
            <category><![CDATA[focuslens]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <category><![CDATA[time-management-tools]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[productivity-tools]]></category>
            <dc:creator><![CDATA[Sumit Suthar]]></dc:creator>
            <pubDate>Wed, 11 Nov 2026 12:43:01 GMT</pubDate>
            <atom:updated>2026-11-11T12:43:01.537Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uH7VwLptn58ufyVIDNMPrA.png" /></figure><h3>A private, permission-free focus tracker for macOS that turns app switching into a score you can actually take apart</h3><p>You sit down at nine with one job to do. By lunch you have answered Slack eleven times, checked email “just quickly”, lost twenty minutes to a YouTube tab, and the one job is still sitting there, half-done. It felt like a busy morning. It wasn’t a productive one.</p><p>The trouble is that we are terrible at remembering where our attention went. We remember the effort, not the leaks. That gap is exactly what <strong>FocusLens</strong> was built to close.</p><h3>What FocusLens is</h3><p>FocusLens is a productivity app for macOS that watches which app is in front of you, sorts your day into productive, distracting and neutral time, and turns it into a <strong>focus score out of 100</strong>. It prices what context switching costs you, keeps every session in a log you can walk back through, and does all of it on your Mac — no account, no Screen Time API, and no permission prompt to get started.</p><h3>Tracking that asks for nothing</h3><p>Most time trackers start by asking for the keys to the house: Accessibility access, Screen Time data, a browser extension, a cloud account. FocusLens asks for none of it.</p><p>Instead, it listens for the app-activation notifications macOS already broadcasts — the same signals the Dock uses — and times the gap between them. Anything under five seconds is thrown away as noise. It stops counting when your screen sleeps, and it never records itself. It does not see what you type, and it does not look at what is on your screen.</p><h3>A score you can take apart</h3><p>A single productivity number is useless if it can’t explain itself. FocusLens breaks its score into four parts:</p><ul><li><strong>Deep work</strong> — how much time went to focused, productive apps</li><li><strong>Context switching</strong> — how often you bounced between apps</li><li><strong>Low distraction</strong> — how little time leaked into distracting apps</li><li><strong>Longest streak</strong> — your longest unbroken run of focus</li></ul><p>Each component has its own bar and its own ceiling. So when you have a bad day, you don’t just see a low number — you see <em>which part</em> went wrong. Maybe your deep work was fine but you switched apps 300 times. That is a very different fix from a day spent in the wrong apps entirely.</p><h3>What switching actually costs</h3><p>This is the feature that tends to change behaviour. FocusLens counts every jump between apps, and the disruptive ones — jumps into something distracting — are priced at the twenty-three minutes research says it takes to get back on task.</p><p>Suddenly “just checking Twitter” stops being free. The worst offenders are named, and rapid-fire switch chains are grouped together, so you can see the bursts where your attention fell apart.</p><h3>Categories you can argue with</h3><p>Apps land in productive, communication, distracting, entertainment, utilities or neutral by default. But no classifier is right for everyone — YouTube is a distraction for most people and a work tool for a video editor. When FocusLens gets one wrong, override it in Settings and <strong>every past day recalculates</strong> around your answer.</p><h3>Goals that read from reality</h3><p>Set a daily target or limit against any category — “four hours of productive work”, “no more than 45 minutes of entertainment” — and the progress bar fills from the hours you actually logged, not a number you typed once and forgot. Goals can be paused, deleted, or set to notify you when they’re met.</p><h3>Every day, replayable</h3><p>The timeline keeps a per-session log for any day you pick: app, category, start, end and duration, with the totals and category split beside it. The Applications view flips the same data around so you can study one app at a time — its sessions, its busiest day, and how long you typically stay in it.</p><h3>Reports that leave the app</h3><p>Weekly, monthly or a custom date range, each with a written summary, your score history, and a first-half-versus-second-half comparison so you can see whether you are trending up or down. Export as a <strong>PDF</strong> to share, or as <strong>CSV</strong> to crunch elsewhere.</p><h3>Your day stays on your Mac</h3><p>This one matters. A record of every app you use, all day, is sensitive data. FocusLens has no account, no sign-in, no analytics and no advertising. Everything it records stays in its own storage on your Mac and is gone when the app is gone. It only goes online to check its licence and fetch signed updates.</p><h3>The details</h3><ul><li>macOS 14 Sonoma or later</li><li>Universal — runs natively on Apple silicon and Intel</li><li>Signed and notarized by Apple, updates itself</li><li><strong>$19.99 one-time</strong> per seat — no subscription</li><li>Three-day free trial</li></ul><p>FocusLens is made by one person, who reads every message sent to the support address. Bugs, questions and feature requests all reach the developer directly.</p><h3>Try it for three days</h3><p>You don’t need another app telling you to “be more productive”. You need an honest picture of where the hours went — and a way to see which part of the day to fix. Give FocusLens three days and look at the switching cost on day one. Most people are surprised.</p><p>👉 <a href="https://appverz.com/apps/focuslens">Download the free trial of FocusLens</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4ede674c9e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Two Questions My Mac Couldn’t Answer: Where Did My Disk Go, and Where Did My Day Go?]]></title>
            <link>https://medium.com/@sumitsuthar_95414/two-questions-my-mac-couldnt-answer-where-did-my-disk-go-and-where-did-my-day-go-63b9ff9e13bc?source=rss-b8476e9bbf13------2</link>
            <guid isPermaLink="false">https://medium.com/p/63b9ff9e13bc</guid>
            <category><![CDATA[mac-apps]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[malware-removal]]></category>
            <category><![CDATA[mac-security]]></category>
            <dc:creator><![CDATA[Sumit Suthar]]></dc:creator>
            <pubDate>Sat, 07 Nov 2026 10:35:44 GMT</pubDate>
            <atom:updated>2026-11-07T10:35:44.646Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Eo-x8fTlbqlLrDVSTVSAg.png" /></figure><p>Every Mac user eventually runs into two small mysteries.</p><p>The first shows up as a warning: <em>Your disk is almost full.</em> You open Storage settings, and a big grey bar labelled “System Data” tells you almost nothing.</p><p>The second never shows up as a warning. You sit down at 10 a.m. to do one important thing, and at 6 p.m. you’re not sure where the hours went. Screen Time gives you a list of apps and minutes, but it doesn’t tell you whether the day was <em>good</em>.</p><p>I wanted honest answers to both questions, without handing my data to a cloud service or installing something that behaves like adware. Here’s what I learned, and the two small native utilities I ended up keeping.</p><h3>Part 1: Cleaning a Mac without trusting it blindly</h3><p>Mac cleaners have a reputation problem, and most of it is earned. Many of them scare you with huge “junk” numbers, delete things you can’t get back, and phone home with your usage data. So I had three rules for any cleaning tool:</p><ol><li>Show me what it wants to delete before it deletes anything.</li><li>Make everything reversible.</li><li>Collect nothing about me.</li></ol><p><a href="https://appverz.com/apps/sweepymac"><strong>SweepyMac</strong></a> was the first one I found that met all three. It’s a single window with about a dozen modules, and the design choice that matters most is this: <strong>nothing is permanently deleted.</strong> Everything it removes goes to the regular macOS Trash, and destructive actions come with an in-app Undo. Once you know that, you stop being nervous about pressing buttons.</p><p>What’s inside, and what each part is useful for:</p><p><strong>Smart Scan.</strong> One pass over user caches, app logs and saved app state, with a total of how much you could reclaim. Only the conservative categories are selected by default. Riskier things, like developer caches and app leftovers, are listed but left unticked. Every group expands so you can see the individual files before cleaning.</p><p><strong>Mac Health score.</strong> A single number out of 100, based on storage, memory, battery and startup load. The recommendations are written in plain sentences (“disk is almost full”) rather than error codes, and each one takes you to the module that fixes it.</p><p><strong>Space Lens and Disk.</strong> This is where the “System Data” mystery gets solved. Space Lens draws your folders as bubbles you can click into, and it updates while it’s still measuring. The Disk view shows the whole volume to scale. I liked that when it can’t measure something fully, it says so rather than guessing.</p><p><strong>A real uninstaller.</strong> Dragging an app to the Trash leaves its preferences, caches and launch agents behind. The Applications module lists every installed app with its size and removes those leftovers too, into the Trash, so even a full uninstall can be undone.</p><p><strong>Large, old and duplicate files.</strong> Point it at any folder, set a minimum size and age, and see what’s actually taking up room. The duplicate finder only matches byte-identical files, not “similar-looking” ones, and it always keeps one copy of each set.</p><p><strong>Cloud Cleanup.</strong> This is the clever one. If you use iCloud Drive, you probably have gigabytes of files downloaded locally that are already safe in the cloud. This module removes the local copies. Nothing is deleted from iCloud, the files still appear in Finder, and opening one downloads it again.</p><p><strong>Performance tools.</strong> Live CPU, memory and disk meters, plus one-click versions of chores you’d normally use Terminal for: freeing inactive memory, flushing the DNS cache, running macOS’s periodic maintenance scripts. It also lists login items and lets you disable them.</p><p><strong>Privacy and malware checks.</strong> Browser data is split by browser and profile, with every row unticked by default. The malware scan uses a definitions file that the app verifies by signature before using. It’s also upfront that some files can only be read with root access, which I appreciated.</p><p><strong>Battery.</strong> Battery health as reported by macOS, including when the system says it needs service.</p><p>On privacy: no account, no telemetry, no analytics. Scans run locally and results stay local. It does ask for Full Disk Access for a complete scan, which any tool that reads your whole drive needs.</p><p><strong>The practical details:</strong> macOS 14 Sonoma or later, runs natively on Apple silicon and Intel, three-day free trial, then $14.99/year or a one-time purchase of $59.96. It’s signed and notarized by Apple and updates itself.</p><h3>Part 2: Finding out where my attention actually went</h3><p>The disk problem was easy to fix once I could see it. The attention problem was harder, because the usual tools measure <em>time</em> but not <em>focus</em>. Four hours in Slack and four hours in your code editor look the same on a bar chart. They are not the same day.</p><p><a href="https://appverz.com/apps/focuslens"><strong>FocusLens</strong></a> approaches this differently, and the first surprise is how little it asks for. It doesn’t use the Screen Time API, it doesn’t need Accessibility permission, and there’s no browser extension. It listens to the same app-switching notifications macOS already sends (the ones the Dock uses), measures time between them, and ignores anything under five seconds. It pauses when the screen sleeps. It never sees what you type or what’s on your screen; it only knows which app was in front.</p><p>Here’s what it does with that:</p><p><strong>A focus score you can break down.</strong> One number out of 100, built from four parts: deep work, context switching, low distraction, and your longest uninterrupted streak. Each part has its own bar, so a bad day tells you <em>which</em> part went wrong. On my worst days it was never total hours; it was the switching.</p><p><strong>The cost of context switching.</strong> Every app switch is counted, and the disruptive ones (leaving real work, or jumping into something distracting) are priced at about 23 minutes of recovery time, a figure often cited from attention research. It names the apps that interrupt you most and groups rapid back-and-forth switching into bursts. Seeing “Slack → Mail → Slack → Browser” clustered together is more convincing than any productivity article.</p><p><strong>Categories you can correct.</strong> Apps are sorted into productive, communication, distracting, entertainment, utilities or neutral. The defaults will be wrong for someone. YouTube might be research for you, and a design tool might be play. When you change a category, all your past days are recalculated.</p><p><strong>Goals based on real data.</strong> Set a daily target (“three hours productive”) or a limit (“under an hour of entertainment”), and progress fills in from what you actually logged. Goals can be paused, deleted, or set to notify you when you hit them.</p><p><strong>A replayable timeline.</strong> For any day, you get a full session log: app, category, start, end, duration. An Applications view flips the same data per app: how often you open it, your busiest day with it, and how long you usually stay.</p><p><strong>Reports you can export.</strong> Weekly, monthly or custom ranges, with a written summary, score history, and a first-half vs second-half comparison. Export as PDF to share, or CSV if you want to do your own analysis.</p><p>Like SweepyMac, everything stays on your Mac. No account, no sign-in, no analytics, no ads. It only goes online to check its licence and fetch signed updates.</p><p><strong>The practical details:</strong> macOS 14 Sonoma or later, Apple silicon and Intel, three-day free trial, then a one-time $19.99 (currently marked down from $39.98).</p><h3>What these two tools have in common</h3><p>What made me keep both wasn’t any single feature. It was the same philosophy in each:</p><ul><li><strong>Show your work.</strong> Both explain what they found and why, instead of handing you a scary number.</li><li><strong>Stay reversible.</strong> Cleanup goes to the Trash; category changes recalculate history instead of locking you in.</li><li><strong>Stay local.</strong> Neither has an account or collects telemetry, which matters a lot for tools that see your files or your daily habits.</li></ul><p>Both come from a one-person studio called AppVerz, and support messages go straight to the developer. You notice that in the small details, like the battery screen being honest about what macOS reports, or the malware scan admitting what it can’t read.</p><p>If your Mac is full and you don’t know why, or your days feel busy but not productive, both have free trials long enough to find out whether they answer your question.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63b9ff9e13bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Coding Agent Is a 40-Line Loop. Everything Hard Lives Around It.]]></title>
            <link>https://medium.com/@sumitsuthar_95414/a-coding-agent-is-a-40-line-loop-everything-hard-lives-around-it-6961a8351d0a?source=rss-b8476e9bbf13------2</link>
            <guid isPermaLink="false">https://medium.com/p/6961a8351d0a</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Sumit Suthar]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 16:35:25 GMT</pubDate>
            <atom:updated>2026-11-02T16:35:25.937Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mEOtOacjgO3GsPrVXXa3Jg.jpeg" /></figure><p>In 2023, an AI that could write a working function felt like magic. Three years later, I watch an agent open a repository I have never shown it, read the failing test, trace the bug through four files, fix it, run the suite, and open a pull request with a sensible description. Nobody typed the fix. Nobody even typed the steps.</p><p>The same machinery will sometimes delete your test directory, because it decided that was the fastest way to make the tests stop failing.</p><p>Both outcomes come from the same few mechanics. Learn those and you get more of the first kind and fewer of the second. That is why I wrote <a href="https://a.co/d/03eMpnkV">AI Agents for Software Engineers</a>. Here are seven ideas from the book that I think every engineer working with agents should know.</p><h3>1. An agent is a loop</h3><p>Strip away the branding and the definition is short: an agent gives a language model a goal and a set of tools, then runs the model in a loop, letting it decide what to do next until the goal is met or it gives up.</p><p>Here is the core of the working agent you build in Chapter 3:</p><pre>def ask_loop(question: str, max_steps: int = 5) -&gt; str:<br>    messages = [{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: question}]<br>    for step in range(max_steps):<br>        resp = client.messages.create(<br>            model=&quot;claude-sonnet-4-5&quot;, max_tokens=500,<br>            tools=TOOLS, messages=messages)<br>        messages.append({&quot;role&quot;: &quot;assistant&quot;,<br>                         &quot;content&quot;: resp.content})<br>        if resp.stop_reason != &quot;tool_use&quot;:<br>            return &quot;&quot;.join(b.text for b in resp.content<br>                            if b.type == &quot;text&quot;)<br>        results = []<br>        for block in resp.content:<br>            if block.type == &quot;tool_use&quot;:<br>                out = calculator(**block.input)<br>                results.append({&quot;type&quot;: &quot;tool_result&quot;,<br>                                &quot;tool_use_id&quot;: block.id,<br>                                &quot;content&quot;: out})<br>        messages.append({&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: results})<br>    return &quot;Gave up after too many steps.&quot;</pre><p>Ask it “What is 17 * 23 + 4?” and it makes two trips to the model. On the first, the model asks for the calculator. On the second, it reads the result, 395, and finishes. Every coding agent you have used is a variation of this, with more tools, better memory, and more safeguards.</p><p><strong>The model decides what. The loop decides whether and how many times.</strong></p><h3>2. The model never executes anything</h3><p>Tool calling is a convention. You tell the model which functions exist, it replies with a structured request, and your program runs the function and sends back the result. The model controls nothing except the text it writes.</p><p>This matters for safety. There is one line in your program where a model’s request becomes a real action, and that line belongs to you.</p><h3>3. The model is one part in five</h3><p>Most of the engineering, and most of the failures, live outside the model. Agent engineering is mostly ordinary software engineering around a very unusual function call. Your existing skills apply more than the hype suggests.</p><h3>4. The context window is the agent’s whole world</h3><p>A model remembers nothing between calls. Its memory is exactly the text you send it, every time. Even an agent’s long-term “memory” is just text your program saves to disk and loads back in.</p><p>That makes context your biggest lever on quality, and more is not better. The goal is not to fit everything in. It is to make sure the few things that matter for the next decision are present and not drowned out.</p><h3>5. The prompt is the sign on the door. The code is the lock.</h3><p>Telling a model “never modify test files” is a request it will usually honor. Usually is not good enough, so every rule that matters appears twice: once in the prompt, so the model plans around it, and once in code, so it holds when the model does not.</p><pre>def write_file(path: str, content: str) -&gt; str:<br>    if Path(path).name.startswith(&quot;test_&quot;):<br>        return &quot;error: editing test files is not allowed&quot;<br>    safe_path(path).write_text(content)<br>    return f&quot;wrote {len(content.splitlines())} lines to {path}&quot;</pre><p>If the model decides the fastest route to green is to edit the assertion, the tool refuses, and the refusal goes back to the model as text.</p><h3>6. One good run proves nothing</h3><p>An agent does not have a behavior. It has a distribution of behaviors, and a single run samples one point from it. The metric you choose changes the story.</p><p>Take an agent that passes a task 80 percent of the time. Give it three attempts with a human picking the winner, and at least one succeeds about 99 percent of the time. That is pass@k. Run it unattended three nights in a row, and the chance all three work falls to about 51 percent. That is pass^k.</p><p>Same agent, very different scores. Autonomy needs the second number.</p><h3>7. An agent is a user that follows instructions found in data</h3><p>An agent has your permissions, and it can act on instructions hidden in anything it reads: a repository file, a fetched web page, an issue comment, a dependency’s documentation. The person who wrote that text never talks to your agent. They only need to put it where your agent will eventually look. This is indirect prompt injection, and no filter fully stops it, because there is no quoting rule that makes a sentence harmless to a language model.</p><p>So assume the model can be compromised, and design like a bank. A teller is almost always honest, and the bank still has a vault, withdrawal limits, and cameras. None of those controls asks the teller to behave. For agents, that means narrow credentials, a sandbox, network egress denied by default, and human approval for anything irreversible.</p><h3>Go deeper</h3><p>These seven ideas are the outline. <a href="https://a.co/d/03eMpnkV">AI Agents for Software Engineers: Build, Orchestrate, Test, and Secure Autonomous Coding Agents</a> is the full build. It follows five parts:</p><ul><li><strong>Understand:</strong> what an agent is, how language models behave, and the agent loop</li><li><strong>Build:</strong> a real coding agent that reads a repository, runs tests, and fixes bugs</li><li><strong>Orchestrate:</strong> planning, multi-agent systems, guardrails, and humans in the loop</li><li><strong>Test:</strong> evals that actually work, debugging, observability, and cost control</li><li><strong>Secure:</strong> agent-specific threats, defense in depth, and shipping responsibly</li></ul><p>You don’t need a machine learning background. If you’re comfortable with a terminal and at least one programming language, you’re ready. Every concept starts in plain English, every listing is printed in full, and the code is MIT-licensed, so you can use it in your own projects. If you already build agents, skim the early chapters and go straight to orchestration, testing, and security, which is where I find most practitioners have gaps.</p><p>The products will change monthly. The ideas won’t. I wrote this book for every developer who was told “AI will replace you” and decided to learn how it works instead.</p><p><a href="https://a.co/d/03eMpnkV"><strong>Get AI Agents for Software Engineers on Amazon</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6961a8351d0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Being Afraid of AI Agents. Learn How They Actually Work.]]></title>
            <link>https://medium.com/@sumitsuthar_95414/stop-being-afraid-of-ai-agents-learn-how-they-actually-work-ec7de3999beb?source=rss-b8476e9bbf13------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec7de3999beb</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[book-recommendations]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[books]]></category>
            <category><![CDATA[books-and-authors]]></category>
            <dc:creator><![CDATA[Sumit Suthar]]></dc:creator>
            <pubDate>Fri, 23 Oct 2026 04:33:20 GMT</pubDate>
            <atom:updated>2026-10-23T04:33:20.763Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZcVFgmJjpMamkw1nQ4hQEQ.png" /></figure><h3>Inside AI Agents for Software Engineers, a hands-on guide to building, orchestrating, testing, and securing autonomous coding agents</h3><p>A few years ago, an AI that could write a working function felt like magic. Today, an AI agent can open a repository it has never seen, read a failing test, trace the bug through four files, fix it, run the suite, and open a pull request with a sensible description. Nobody typed the fix. Nobody even typed the steps.</p><p>Sometimes it does that brilliantly. And sometimes it deletes your test directory because it decided that was the fastest way to make the tests stop failing.</p><p>Both outcomes come from the same machinery. <strong>If you understand the machinery, you get far more of the first kind and far fewer of the second.</strong> That is the promise of my new book, <em>AI Agents for Software Engineers: Build, Orchestrate, Test, and Secure Autonomous Coding Agents</em>, now available on Amazon.</p><p>👉 <a href="https://a.co/d/07HOdDOe"><strong>Get the book on Amazon</strong></a></p><h3>Why I wrote this book</h3><p>The book is dedicated to every developer who was told “AI will replace you” and decided to learn how it works instead.</p><p>There is no shortage of agent content online. Most of it falls into one of two buckets: product tours that are out of date within a month, or research-heavy material that assumes you know what a transformer is. Working engineers are stuck in the middle, using tools they don’t fully understand and not sure when to trust them.</p><p>This book takes a different route. It skips the hype and the product reviews and teaches the <strong>durable mechanics underneath every coding agent</strong> you will ever use or build. Products change monthly. Tool calling, context windows, the agent loop, evaluation, and least privilege don’t.</p><h3>Who it’s for</h3><p>You write software for a living, or you’re learning to. You’re comfortable with a terminal, an editor, and at least one programming language. Maybe you’ve used a chat assistant for code, or tried an agent product and come away impressed, disappointed, or both.</p><p>You <strong>don’t</strong> need a machine-learning background. No neural networks, no calculus. Every concept is introduced with a plain-English comparison before the technical term, and every term is defined the first time it appears.</p><p>If you already build agents, skim the early chapters. Parts III, IV, and V (orchestration, testing, and security) are where most practitioners have gaps.</p><h3>What’s inside: five parts, sixteen chapters</h3><p>The book follows its subtitle. You build one agent, <strong>tinyagent</strong>, and grow it chapter by chapter, from a 40-line loop into a coding agent that can read a repo, run tests, and fix bugs, with guardrails, evals, and security around it.</p><h3>Part I: Understand</h3><p><em>How agents actually work, from the inside out.</em></p><ul><li><strong>What Is an AI Agent, Really?</strong> The one-sentence definition, the perceive–think–act loop, and a step-by-step trace of an agent fixing a real bug.</li><li><strong>Just Enough About Language Models.</strong> Tokens, context windows, temperature, and why the model’s statements are guesses while tool results are facts.</li><li><strong>The Agent Loop.</strong> Tool calling demystified. By the end of Chapter 3 you have a working 40-line agent.</li></ul><p>The most important lesson lands early: <strong>the model never runs anything.</strong> It only produces text that says “please run this.” Your program decides whether to comply, and that one fact shapes everything from design to security.</p><h3>Part II: Build</h3><ul><li><strong>Your First Coding Agent.</strong> A system prompt, a table of tools, and a directory the tools are confined to.</li><li><strong>Designing Tools Agents Can Use Well.</strong> A tool is an API whose only client is a language model. Good names, descriptions, and error messages fix most “the agent used the tool wrong” failures.</li><li><strong>Context Engineering.</strong> Less, better-chosen context beats more. Repo maps, search over embeddings, trimming, and caching.</li><li><strong>Memory and State.</strong> Working, episodic, and long-term memory, and why one wrong note pollutes every future run.</li></ul><h3>Part III: Orchestrate</h3><ul><li><strong>Planning and Task Decomposition.</strong> Plan-then-execute, to-do lists as state, and re-planning when a step is blocked.</li><li><strong>Multi-Agent Systems.</strong> Sub-agents, orchestrators and workers, specialist roles, and when <em>not</em> to add more agents.</li><li><strong>Workflows, Guardrails, and Humans in the Loop.</strong> Autonomy as a dial, approval gates, permission modes, and budgets.</li><li><strong>Agents in Your Development Workflow.</strong> The four homes for agents (IDE, review bot, terminal, issue-to-PR) and what each one needs.</li></ul><h3>Part IV: Test</h3><ul><li><strong>Testing Agents: Evals That Actually Work.</strong> One passing run shows an agent <em>can</em> succeed; only many runs show <em>how often</em>. Build eval suites from bugs your team already fixed.</li><li><strong>Observability, Debugging, and Cost.</strong> JSONL traces, replaying a single step, six common failure categories, and keeping cost per task under control.</li></ul><h3>Part V: Secure</h3><ul><li><strong>Threats Unique to Agents.</strong> Indirect prompt injection, data exfiltration, and risky third-party tool servers and plugins.</li><li><strong>Defense in Depth.</strong> “The prompt is advice and the dispatch point is law.” Least privilege, sandboxes, egress control, secret handling, and audit logs.</li><li><strong>Shipping Responsibly.</strong> Accountability, reviewing agent-written code, and rolling agents out to a team.</li></ul><p>Four appendices round it out: <strong>Setup</strong>, <strong>Four Checklists</strong> you can bring to a design review, a <strong>Glossary</strong>, and <strong>Further Reading</strong>.</p><h3>Ideas you’ll take away</h3><p>Each chapter closes with five takeaways. Here are a few that change how you think about agents:</p><blockquote><strong><em>“Agent engineering is mostly ordinary software engineering around a very unusual function call.”</em></strong></blockquote><blockquote><strong><em>“The model’s memory is exactly the text you send it, every time.”</em></strong><em> Managing that text is the single biggest lever on agent quality, and it’s entirely under your control.</em></blockquote><blockquote><strong><em>“Every rule that matters appears twice: once in the prompt, so the model plans around it, and once in code, so it holds when the model does not. The prompt is the sign on the door. The code is the lock.”</em></strong></blockquote><blockquote><strong><em>“Read the trace, not the summary.”</em></strong><em> The summary is what the model thinks happened. The trace is what happened.</em></blockquote><blockquote><strong><em>“Start with one agent.”</em></strong><em> Add workers only when context is the bottleneck or the steps are truly independent.</em></blockquote><h3>Built for learning by doing</h3><p>This is a practical book. Throughout, you’ll find four kinds of boxed notes:</p><ul><li><strong>Key idea:</strong> a sentence worth remembering</li><li><strong>Watch out:</strong> a common and expensive mistake</li><li><strong>Try it yourself:</strong> a short hands-on exercise</li><li><strong>Jargon:</strong> a term defined in one plain sentence</li></ul><p>Every code listing is printed in full, so there’s nothing to download. You need Python 3.10+, a terminal, an editor, and an API key (Appendix A walks you through setup). Type the code in, run it, break it, change it. All code samples are MIT-licensed, so you can use them in your own projects.</p><p>The book also tells you where to start. <strong>Building an agent?</strong> Read straight through. <strong>Evaluating an agent product for your team?</strong> Go to Chapters 10, 11, 14, and 15.</p><h3>Who should read this</h3><ul><li><strong>Backend, full-stack, and platform engineers</strong> who want to build agents into their products or internal tools</li><li><strong>Tech leads and engineering managers</strong> deciding whether, and how, to let agents touch production repositories</li><li><strong>DevOps and security engineers</strong> who need to understand the new attack surface agents create</li><li><strong>Students and early-career developers</strong> who want to understand AI agents from first principles instead of memorizing tool names</li></ul><h3>Get your copy</h3><p>If you’ve been curious about AI agents but put off by the jargon, or you’ve been using them without being sure <em>why</em> they sometimes go off the rails, this book is for you.</p><p>📘 <strong><em>AI Agents for Software Engineers: Build, Orchestrate, Test, and Secure Autonomous Coding Agents</em></strong></p><p><strong>Available now on Amazon → </strong><a href="https://a.co/d/07HOdDOe"><strong>https://a.co/d/07HOdDOe</strong></a></p><p>If you enjoy the plain-language, hands-on style, check out my other books in the same spirit, <em>Docker Simplified</em> and <em>Kubernetes Simplified</em>.</p><p>Happy building! 🚀</p><p><em>— Sumit Suthar</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec7de3999beb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build an Automated Security Scanner With Claude Code]]></title>
            <link>https://medium.com/@sumitsuthar_95414/build-an-automated-security-scanner-with-claude-code-b03779bed34b?source=rss-b8476e9bbf13------2</link>
            <guid isPermaLink="false">https://medium.com/p/b03779bed34b</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[owasp-top-10]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Sumit Suthar]]></dc:creator>
            <pubDate>Mon, 05 Oct 2026 09:47:39 GMT</pubDate>
            <atom:updated>2026-10-05T09:47:39.745Z</atom:updated>
            <content:encoded><![CDATA[<p>Static analyzers find patterns. Claude Code understands intent. Here’s how to combine both into a scanner that runs on every commit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y22VUlV_t6T2fELmg3piqw.png" /></figure><p>Most teams already run some kind of security tooling: a linter here, a dependency audit there, maybe Semgrep in CI. These tools are fast and reliable, but they share a blind spot — they match patterns. They can’t tell you that an endpoint skips the ownership check every other endpoint performs, or that a “safe” helper is called with user input three files away.</p><p>That’s exactly the kind of reasoning large language models are good at. In this guide we’ll build an automated security scanner that pairs traditional tools with <strong>Claude Code</strong>, Anthropic’s agentic coding CLI. By the end you’ll have:</p><ul><li>A reusable /scan slash command for on-demand reviews</li><li>A dedicated security-reviewer subagent</li><li>A hook that blocks secrets the moment they’re written</li><li>A headless script that produces a JSON report</li><li>A GitHub Actions workflow that fails the build on high-severity findings</li></ul><h3>The Architecture: Deterministic Tools + LLM Reasoning</h3><p>Don’t ask an LLM to do what grep does better. The scanner works in two layers:</p><ol><li><strong>Deterministic layer</strong> — Semgrep (SAST), Gitleaks (secrets), and your package manager’s audit (dependencies). Cheap, repeatable, and good at known patterns.</li><li><strong>Reasoning layer</strong> — Claude Code reads the tool output, verifies each hit against the actual code, discards false positives, and hunts for logic flaws the tools can’t see: broken access control, IDOR, missing auth, unsafe deserialization, business-logic abuse.</li></ol><p>The result is fewer, better findings — each with an explanation and a suggested fix.</p><h3>Step 1: Install the Tools</h3><pre># Claude Code<br>npm install -g @anthropic-ai/claude-code</pre><pre># Supporting scanners<br>pip install semgrep<br>brew install gitleaks jq   # or download release binaries on Linux</pre><p>Run claude once in your repo to authenticate. For CI you&#39;ll use an ANTHROPIC_API_KEY instead.</p><h3>Step 2: Give Claude Security Context With CLAUDE.md</h3><p>Claude Code automatically reads CLAUDE.md at the project root. Use it to describe your threat model so reviews are grounded in <em>your</em> system, not generic advice:</p><pre>## Security context<br>- Public REST API (Express) + Postgres via Prisma<br>- Auth: JWT in Authorization header, verified in middleware/auth.ts<br>- Every resource is tenant-scoped: queries MUST filter by req.user.orgId<br>- Secrets come from env vars only; never hardcode<br>- Treat anything under /routes as untrusted-input entry points</pre><p>That one line about tenant scoping lets Claude flag any query that forgets orgId — something no off-the-shelf rule knows about.</p><h3>Step 3: Create a /scan Slash Command</h3><p>Custom commands live in .claude/commands/ as Markdown files. Create .claude/commands/scan.md:</p><pre>---<br>description: Run a full security scan of the repo or a path<br>allowed-tools: Read, Grep, Glob, Bash(semgrep:*), Bash(gitleaks:*), Bash(npm audit:*)<br>---<br>Perform a security review of: $ARGUMENTS (default: whole repo).</pre><pre>1. Run: semgrep scan --config auto --json --quiet $ARGUMENTS<br>2. Run: gitleaks detect --no-banner --redact --report-format json --report-path /dev/stdout<br>3. Run: npm audit --json (if package.json exists)<br>4. For EVERY tool finding, open the code and confirm it is exploitable.<br>   Drop false positives and say why.<br>5. Independently review entry points for: broken access control,<br>   IDOR, injection, SSRF, auth bypass, insecure crypto, unsafe deserialization.<br>6. Report a table: severity | file:line | issue | evidence | fix.<br>Only report issues you can justify from the code. No speculation.</pre><p>Now run it from inside Claude Code:</p><pre>/scan src/routes</pre><p>The allowed-tools list matters: the command can read code and run the scanners, but can&#39;t edit files or run arbitrary shell commands.</p><p><em>Tip: Claude Code also ships with a built-in </em><em>/security-review command. It&#39;s a great starting point; the custom command lets you add your own tools, threat model, and output format.</em></p><h3>Step 4: Add a Security-Reviewer Subagent</h3><p>Subagents run in their own context window with their own instructions and tool permissions — ideal for a focused reviewer that won’t get distracted by the feature you’re building. Create .claude/agents/security-reviewer.md:</p><pre>---<br>name: security-reviewer<br>description: Reviews code changes for security vulnerabilities. Use proactively after edits to auth, routes, or data access code.<br>tools: Read, Grep, Glob, Bash<br>---<br>You are an application security engineer. Review the given changes<br>against OWASP Top 10 and this repo&#39;s CLAUDE.md security context.<br>Trace user input from entry point to sink before reporting anything.<br>Rate findings Critical/High/Medium/Low with a one-line fix each.<br>Never modify files.</pre><p>Because the description says “use proactively”, Claude will hand off to this reviewer after touching sensitive code — or you can call it directly: <em>“Use the security-reviewer agent on my last commit.”</em></p><h3>Step 5: Block Secrets in Real Time With Hooks</h3><p>Hooks are shell commands Claude Code runs at lifecycle events. A PostToolUse hook on Edit|Write lets us scan every file the moment Claude changes it. Add to .claude/settings.json:</p><pre>{<br>  &quot;hooks&quot;: {<br>    &quot;PostToolUse&quot;: [<br>      {<br>        &quot;matcher&quot;: &quot;Edit|Write&quot;,<br>        &quot;hooks&quot;: [<br>          { &quot;type&quot;: &quot;command&quot;, &quot;command&quot;: &quot;.claude/hooks/secret-scan.sh&quot; }<br>        ]<br>      }<br>    ]<br>  }<br>}</pre><p>And the hook script, .claude/hooks/secret-scan.sh:</p><pre>#!/usr/bin/env bash<br># Hook input arrives as JSON on stdin<br>FILE=$(jq -r &#39;.tool_input.file_path // empty&#39;)<br>[ -z &quot;$FILE&quot; ] || [ ! -f &quot;$FILE&quot; ] &amp;&amp; exit 0</pre><pre>if ! gitleaks detect --no-git --no-banner --redact --source &quot;$FILE&quot; &gt;/dev/null 2&gt;&amp;1; then<br>  echo &quot;Possible secret detected in $FILE. Move it to an environment variable.&quot; &gt;&amp;2<br>  exit 2   # exit code 2 feeds stderr back to Claude so it fixes the issue<br>fi<br>exit 0</pre><p>Make it executable with chmod +x. Now if Claude (or a prompt you gave it) writes an API key into code, it gets immediate feedback and corrects itself before you ever commit.</p><h3>Step 6: Run Headless and Produce a JSON Report</h3><p>Interactive use is nice, but automation needs a machine-readable result. Claude Code’s print mode (-p) runs a single prompt non-interactively. Create scripts/security-scan.sh:</p><pre>#!/usr/bin/env bash<br>set -euo pipefail<br>TARGET=${1:-.}</pre><pre>semgrep scan --config auto --json --quiet &quot;$TARGET&quot; &gt; semgrep.json || true<br>gitleaks detect --no-banner --redact --report-format json --report-path gitleaks.json || true</pre><pre>PROMPT=&quot;You are a security scanner. Read semgrep.json and gitleaks.json,<br>verify each finding in the source under $TARGET, discard false positives,<br>and look for access-control and logic flaws the tools missed.<br>Write ONLY a JSON array to security-report.json, each item:<br>{\&quot;severity\&quot;:\&quot;critical|high|medium|low\&quot;,\&quot;file\&quot;:\&quot;\&quot;,\&quot;line\&quot;:0,<br>\&quot;title\&quot;:\&quot;\&quot;,\&quot;evidence\&quot;:\&quot;\&quot;,\&quot;fix\&quot;:\&quot;\&quot;}&quot;</pre><pre>claude -p &quot;$PROMPT&quot; \<br>  --allowedTools &quot;Read,Grep,Glob,Write&quot; \<br>  --max-turns 30</pre><pre>HIGH=$(jq &#39;[.[] | select(.severity==&quot;critical&quot; or .severity==&quot;high&quot;)] | length&#39; security-report.json)<br>echo &quot;Critical/High findings: $HIGH&quot;<br>jq -r &#39;.[] | &quot;[\(.severity)] \(.file):\(.line) - \(.title)&quot;&#39; security-report.json<br>[ &quot;$HIGH&quot; -eq 0 ]   # non-zero exit fails CI</pre><p>Notice the scanners run <em>outside</em> Claude, and Claude only gets read/search/write tools. Narrow permissions keep a headless agent predictable.</p><h3>Step 7: Wire It Into GitHub Actions</h3><p>Create .github/workflows/security-scan.yml:</p><pre>name: Security Scan<br>on:<br>  pull_request:<br>  push:<br>    branches: [main]</pre><pre>jobs:<br>  scan:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v4<br>        with:<br>          fetch-depth: 0</pre><pre>      - name: Install tools<br>        run: |<br>          npm install -g @anthropic-ai/claude-code<br>          pip install semgrep<br>          curl -sSfL <a href="https://github.com/gitleaks/gitleaks/releases/download/v8.18.4/gitleaks_8.18.4_linux_x64.tar.gz">https://github.com/gitleaks/gitleaks/releases/download/v8.18.4/gitleaks_8.18.4_linux_x64.tar.gz</a> | tar xz -C /usr/local/bin gitleaks</pre><pre>      - name: Run scanner<br>        env:<br>          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}<br>        run: bash scripts/security-scan.sh</pre><pre>      - name: Upload report<br>        if: always()<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: security-report<br>          path: security-report.json</pre><p>Every PR now gets a verified security report, and the build fails if anything Critical or High shows up. If you’d rather not maintain your own workflow, Anthropic publishes an official <strong>claude-code-security-review</strong> GitHub Action that comments findings directly on pull requests.</p><h3>Step 8: Keep It Fast, Cheap, and Accurate</h3><ul><li><strong>Scan the diff, not the world.</strong> On PRs, pass changed files with git diff --name-only origin/main...HEAD. Run full-repo scans nightly.</li><li><strong>Demand evidence.</strong> Requiring a file, line, and code excerpt for every finding sharply reduces hallucinated issues.</li><li><strong>Keep a suppressions file.</strong> Add a .security-ignore.md listing accepted risks and tell Claude to respect it.</li><li><strong>Least privilege, always.</strong> Never give a CI agent Bash(*) or write access beyond the report file.</li><li><strong>Pin tool versions</strong> so results stay reproducible between runs.</li></ul><h3>What This Won’t Replace</h3><p>An LLM-assisted scanner is a force multiplier, not a pentest. It can miss issues, and it can occasionally be confidently wrong — which is why every finding includes evidence you can verify in seconds. Keep human review for critical paths, and keep your deterministic tools as the baseline. Also remember that the code you scan is sent to the model API, so check that fits your organisation’s data policies.</p><h3>Wrapping Up</h3><p>With a CLAUDE.md threat model, a /scan command, a reviewer subagent, a secret-blocking hook, and a headless CI script, you&#39;ve turned Claude Code into a security teammate that reads every change — and explains what it finds in plain language.</p><p>Start small: add the hook today, the CI job this week. You’ll be surprised what a reviewer that never gets tired catches.</p><p><em>If this was useful, follow for more practical guides on DevOps, Kubernetes, and AI-powered developer tooling.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b03779bed34b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Claude Code for OWASP Security Reviews]]></title>
            <link>https://medium.com/@sumitsuthar_95414/using-claude-code-for-owasp-security-reviews-dbd73553d095?source=rss-b8476e9bbf13------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbd73553d095</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[secure-coding]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[owasp-api-security-top-10]]></category>
            <category><![CDATA[owasp-top-10]]></category>
            <dc:creator><![CDATA[Sumit Suthar]]></dc:creator>
            <pubDate>Sun, 04 Oct 2026 09:11:10 GMT</pubDate>
            <atom:updated>2026-10-04T09:11:10.643Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nhyfvq8JsbEIm0gfAFoR3w.png" /></figure><p>Claude Code can run a full OWASP Top 10 review of your codebase in minutes, if you give it the right structure. Ask it to “check for security issues” and you get a generic list. Ask it to walk the OWASP categories against your actual data flows and you get findings with file paths, line numbers, and fixes.</p><p>In my last post I covered catching vulnerabilities before production. This one goes deeper: using the OWASP Top 10 as a checklist that Claude Code works through, category by category, and wiring that into your daily workflow and CI.</p><p>Why OWASP? It is the shared language of application security. Auditors ask for it, compliance frameworks reference it, and most real breaches map to one of its ten categories. Anchoring Claude’s review to OWASP makes the output comparable, repeatable, and easy to hand to a security team.</p><h3>The OWASP Top 10 (2025) at a glance</h3><p>The <a href="https://owasp.org/Top10/2025/">OWASP Top 10:2025</a> is the current edition. Each item below doubles as a prompt target for Claude Code.</p><ul><li><strong>A01 Broken Access Control</strong>: missing auth checks on routes, IDOR, trusting client-sent user IDs, SSRF</li><li><strong>A02 Security Misconfiguration</strong>: debug mode on, permissive CORS, default creds, verbose errors, missing security headers</li><li><strong>A03 Software Supply Chain Failures</strong>: unpinned or abandoned dependencies, known CVEs, unverified build steps</li><li><strong>A04 Cryptographic Failures</strong>: MD5/SHA1 for passwords, hardcoded keys, plain HTTP, weak randomness</li><li><strong>A05 Injection</strong>: string-built SQL, shell commands, unescaped HTML (XSS), template injection</li><li><strong>A06 Insecure Design</strong>: no rate limits, missing business-logic checks, no threat model for sensitive flows</li><li><strong>A07 Authentication Failures</strong>: weak password rules, no lockout, long-lived sessions, JWT “none” algorithm</li><li><strong>A08 Software or Data Integrity Failures</strong>: unsafe deserialization, unsigned updates, CI pulling untrusted code</li><li><strong>A09 Security Logging and Alerting Failures</strong>: auth failures not logged, secrets or PII in logs, no alerting</li><li><strong>A10 Mishandling of Exceptional Conditions</strong>: fail-open error paths, swallowed exceptions, stack traces leaked to users</li></ul><h3>Step 1: Set up the ground rules</h3><p>Start with the built-in command. Inside any repo, run:</p><pre>claude<br>&gt; /security-review</pre><p>/security-review scans your pending changes for common vulnerability classes like injection, auth flaws, and data exposure. It is the fastest way to get a baseline.</p><p>Next, teach Claude your project’s security context in CLAUDE.md so every session starts with it:</p><pre>## Security context<br>- Framework: Express + PostgreSQL (pg), React frontend<br>- Auth: JWT in httpOnly cookies, middleware in src/middleware/auth.js<br>- All DB access must go through src/db/query.js (parameterized only)<br>- Tenant isolation: every query on user data must filter by org_id<br>- Secrets come from env vars; never commit .env files<br>- Review against OWASP Top 10:2025; cite the category ID (A01–A10) for each finding</pre><p>That last line matters. It forces every finding to map to a category, which keeps reports consistent and easy to triage.</p><h3>Step 2: Review one category at a time</h3><p>One broad prompt spreads Claude’s attention thin. One category per prompt, traced through real data flows, finds far more. Here is what that looks like for four high-impact categories.</p><h4>A01 Broken Access Control</h4><pre>List every HTTP route in this repo. For each, tell me:<br>1. Which auth middleware protects it (or none)<br>2. Whether it reads a resource ID from the request<br>3. Whether it verifies the caller owns that resource<br>Output a table. Flag any route that fails 1 or 3 as A01.</pre><p>A typical catch:</p><pre>// Vulnerable: any logged-in user can read any invoice<br>app.get(&#39;/api/invoices/:id&#39;, requireAuth, async (req, res) =&gt; {<br>  const invoice = await db.query(&#39;SELECT * FROM invoices WHERE id = $1&#39;, [req.params.id]);<br>  res.json(invoice.rows[0]);<br>});</pre><pre>// Fixed: scope the query to the caller&#39;s org<br>app.get(&#39;/api/invoices/:id&#39;, requireAuth, async (req, res) =&gt; {<br>  const invoice = await db.query(<br>    &#39;SELECT * FROM invoices WHERE id = $1 AND org_id = $2&#39;,<br>    [req.params.id, req.user.orgId]<br>  );<br>  if (!invoice.rows[0]) return res.status(404).end();<br>  res.json(invoice.rows[0]);<br>});</pre><h4>A05 Injection</h4><pre>Trace every place user input (req.body, req.query, req.params, headers)<br>reaches a SQL query, shell command, file path, or HTML render.<br>Show the full path from source to sink and mark any sink that is not<br>parameterized or escaped.</pre><p>The source-to-sink framing is the key. It stops Claude from flagging safe code and makes it prove each finding.</p><h4>A04 Cryptographic Failures</h4><pre>Find all uses of hashing, encryption, random number generation, and<br>secret storage. Flag MD5/SHA1 for passwords, Math.random() for tokens,<br>hardcoded keys, and any secret that is not loaded from env or a vault.</pre><h4>A02 Security Misconfiguration</h4><pre>Review app config, Dockerfiles, and infra files (Terraform, k8s YAML).<br>Check CORS, security headers (CSP, HSTS), debug flags, default ports,<br>containers running as root, and public storage buckets.</pre><p>Repeat the pattern for the remaining categories. For A03, ask Claude to run your package manager’s audit command (npm audit, pip-audit) and explain which findings are actually reachable from your code.</p><h3>Step 3: Package it as a reusable command</h3><p>Once your prompts work, save them as a custom slash command so the whole team runs the same review. Create .claude/commands/owasp-review.md:</p><pre>---<br>description: Full OWASP Top 10:2025 review of the given path<br>argument-hint: [path]<br>---<br>Review $ARGUMENTS against the OWASP Top 10:2025.</pre><pre>For each category A01–A10:<br>1. State what you checked and which files you read<br>2. List findings with: ID, severity (Critical/High/Medium/Low),<br>   file:line, source-to-sink explanation, and a concrete fix<br>3. If nothing was found, say &quot;No findings&quot; (do not invent issues)</pre><pre>Only report issues you can point to in code. Mark anything uncertain<br>as &quot;Needs manual verification&quot;. End with a summary table by category.</pre><p>Now anyone on the team can run /owasp-review src/api and get a report in the same format.</p><p>For large repos, go one step further and define a security reviewer subagent in .claude/agents/security-reviewer.md with read-only tools (Read, Grep, Glob). Claude can then fan out one subagent per category in parallel, each with a clean context window, and merge the results. Read-only tools also guarantee the review never edits code on its own.</p><h3>Step 4: Run it on every pull request</h3><p>Manual reviews get skipped when deadlines hit. Anthropic’s <a href="https://github.com/anthropics/claude-code-security-review">claude-code-security-review</a> GitHub Action runs the review on every PR and posts findings as inline comments.</p><pre># .github/workflows/security-review.yml<br>name: Security Review<br>on:<br>  pull_request:</pre><pre>permissions:<br>  pull-requests: write<br>  contents: read</pre><pre>jobs:<br>  security:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v4<br>        with:<br>          ref: ${{ github.event.pull_request.head.sha || github.sha }}<br>          fetch-depth: 2<br>      - uses: anthropics/claude-code-security-review@main<br>        with:<br>          comment-pr: true<br>          claude-api-key: ${{ secrets.CLAUDE_API_KEY }}</pre><p>Add your API key as a repository secret named CLAUDE_API_KEY. The action reviews only the diff, so it stays fast and cheap, and it filters out common false-positive classes before commenting.</p><p>A practical split that works well:</p><ul><li><strong>Every PR:</strong> the GitHub Action on the diff</li><li><strong>Before each release:</strong> /owasp-review across the full codebase</li><li><strong>Quarterly:</strong> a full review plus a manual pass on A06 Insecure Design with your team</li></ul><h3>What Claude Code won’t do for you</h3><p>Claude Code is a strong first reviewer, not a replacement for a security program. Keep these limits in mind:</p><ul><li><strong>It sees code, not runtime.</strong> Misconfigured cloud IAM, WAF rules, or production secrets outside the repo are invisible to it. Pair it with DAST tools like OWASP ZAP.</li><li><strong>Business logic needs context.</strong> A01 and A06 bugs often depend on rules only your team knows. Write those rules into CLAUDE.md.</li><li><strong>Verify before you trust.</strong> Ask Claude to explain the exploit path for every High or Critical finding. If it can’t, treat the finding as unconfirmed.</li><li><strong>Use it alongside SAST, not instead.</strong> Semgrep, CodeQL, and dependency scanners are deterministic. Claude adds reasoning on top; together they cover more.</li><li><strong>Mind what you share.</strong> Don’t paste production secrets or customer data into prompts. Review your organization’s data policy before running it on sensitive code.</li></ul><h4>Tips that improve results</h4><ol><li>Scope tightly: one category and one module per prompt beats “review everything”</li><li>Demand evidence: file, line, and source-to-sink path for every finding</li><li>Ask for fixes as diffs, then review them like any other PR</li><li>Re-run the same command after fixing to confirm the issue is gone</li><li>Keep a SECURITY_NOTES.md of accepted risks so Claude stops re-flagging them</li></ol><h3>Wrapping up</h3><p>The recipe is simple: give Claude Code your security context, review one OWASP category at a time, save the prompts as a team command, and run it on every PR. You get a consistent, OWASP-mapped review that catches the obvious and the subtle before code ships.</p><p>Start small. Run /security-review on your next PR today, then add the /owasp-review command this week. Within a sprint, security review becomes a habit instead of a release-day scramble.</p><p>If this helped, follow for more posts on Claude Code, DevSecOps, and Kubernetes.</p><h4>References</h4><ul><li><a href="https://owasp.org/Top10/2025/">OWASP Top 10:2025</a></li><li><a href="https://github.com/anthropics/claude-code-security-review">claude-code-security-review GitHub Action</a></li><li><a href="https://docs.claude.com/en/docs/claude-code/overview">Claude Code documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbd73553d095" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Claude Code for Secure Coding: Catch Vulnerabilities Before Production]]></title>
            <link>https://medium.com/@sumitsuthar_95414/claude-code-for-secure-coding-catch-vulnerabilities-before-production-05f8443bf39d?source=rss-b8476e9bbf13------2</link>
            <guid isPermaLink="false">https://medium.com/p/05f8443bf39d</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <dc:creator><![CDATA[Sumit Suthar]]></dc:creator>
            <pubDate>Sun, 04 Oct 2026 09:04:17 GMT</pubDate>
            <atom:updated>2026-10-04T09:04:17.572Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o9GT94hT937BHcTQkbYcew.png" /></figure><p>Most security bugs aren’t exotic. They’re a string concatenated into a SQL query, a missing authorization check on one endpoint, an API key committed “just for testing.” They slip through because code review is rushed and security scanners are noisy. By the time a pentest or a bug bounty report finds them, they’re already in production.</p><p>Claude Code changes the economics of catching these early. Because it reads your whole codebase, understands context across files, and runs right in your terminal and CI, it can act like a security-minded reviewer on every change — not just the ones someone remembers to flag.</p><p>In this post I’ll walk through a practical, layered setup: on-demand reviews, project-level security rules, custom commands, CI automation, and guardrails that stop bad things before they happen.</p><h3>Why shift security left with an AI agent?</h3><p>Traditional static analysis (SAST) tools are great at pattern matching, but they struggle with intent. They’ll flag every eval while missing that your /admin/export route never checks whether the user is an admin. An LLM-based reviewer reasons about data flow and business logic, so it can explain <em>why</em> something is exploitable and propose a fix in the same breath.</p><p>The goal isn’t to replace your SAST tools, dependency scanners, or human reviewers. It’s to add a fast, context-aware layer that runs before code ever reaches them.</p><h3>Step 1: Run /security-review before every commit</h3><p>Claude Code ships with a built-in /security-review slash command. Run it inside your repo and it analyzes your pending changes for common vulnerability classes:</p><pre>cd my-app<br>claude<br>&gt; /security-review</pre><p>It looks for issues like:</p><ul><li>Injection flaws — SQL, command, NoSQL, and template injection</li><li>Authentication and authorization gaps (broken access control, IDOR)</li><li>Hardcoded secrets, tokens, and credentials</li><li>Insecure data handling and sensitive data exposure</li><li>XSS, unsafe deserialization, and weak crypto usage</li><li>Vulnerable patterns in how dependencies are used</li></ul><p>Each finding comes with an explanation and a suggested fix. The best part: you can immediately say “fix the first two issues” and Claude will make the changes in the same session.</p><h3>A real example: catching SQL injection</h3><p>Here’s the kind of code that sneaks into a Friday-afternoon PR:</p><pre>// routes/users.js<br>app.get(&quot;/users/search&quot;, async (req, res) =&gt; {<br>  const { name } = req.query;<br>  const result = await db.query(<br>    `SELECT id, email FROM users WHERE name = &#39;${name}&#39;`<br>  );<br>  res.json(result.rows);<br>});</pre><p>A security review flags this as high severity: user input flows directly into a SQL string, so a request like ?name=&#39; OR &#39;1&#39;=&#39;1 dumps every user. It also notices the route has no authentication middleware, unlike its sibling routes. The suggested fix:</p><pre>app.get(&quot;/users/search&quot;, requireAuth, async (req, res) =&gt; {<br>  const { name } = req.query;<br>  if (typeof name !== &quot;string&quot; || name.length &gt; 100) {<br>    return res.status(400).json({ error: &quot;Invalid name&quot; });<br>  }<br>  const result = await db.query(<br>    &quot;SELECT id, email FROM users WHERE name = $1&quot;,<br>    [name]<br>  );<br>  res.json(result.rows);<br>});</pre><p>Parameterized query, input validation, and the missing auth check — three fixes from one review. That cross-file awareness (“other routes use requireAuth, this one doesn&#39;t&quot;) is exactly where pattern-based scanners fall short.</p><h3>Step 2: Teach Claude your security rules with CLAUDE.md</h3><p>Every codebase has its own conventions: which ORM to use, how auth is wired, what must never be logged. Put them in a CLAUDE.md file at the root of your repo. Claude Code loads it automatically, so these rules apply both when it writes code and when it reviews it.</p><pre># Security rules for this project<br><br>- All database access goes through the Prisma client. Never build raw SQL strings.<br>- Every route under /api must use the `requireAuth` middleware unless listed in PUBLIC_ROUTES.<br>- Never log request bodies, tokens, passwords, or PII.<br>- Secrets come from environment variables only. Never hardcode keys, even in tests.<br>- Validate all external input with zod schemas in /src/schemas.<br>- Use bcrypt (cost &gt;= 12) for password hashing. Never MD5 or SHA1.<br>- File uploads: check MIME type and size, store outside the web root.</pre><p>This turns tribal knowledge into something enforced on every interaction — and new teammates benefit from it too.</p><h3>Step 3: Create a custom security command</h3><p>The built-in review is a great baseline, but you can go deeper with a custom slash command. Add a Markdown file under .claude/commands/ and it becomes a command your whole team can run.</p><p>Create .claude/commands/owasp-audit.md:</p><pre>Perform a security audit of $ARGUMENTS against the OWASP Top 10.<br><br>For each finding, report:<br>1. Severity (Critical / High / Medium / Low)<br>2. File and line number<br>3. Why it is exploitable, with a concrete attack example<br>4. A minimal code fix<br><br>Also check:<br>- Every API route enforces authentication and authorization<br>- No secrets or credentials in code or config files<br>- Dependencies in package.json with known risky usage<br><br>Only report issues you are confident about. Skip style nits.<br>Finish with a summary table sorted by severity.</pre><p>Now anyone on the team can run:</p><pre>&gt; /owasp-audit src/api/payments</pre><p>The “only report issues you are confident about” line matters. It keeps the output focused on real risks instead of a wall of maybes, which is what makes developers actually read it.</p><h3>Step 4: Automate reviews on every pull request</h3><p>Manual commands depend on people remembering to run them. To make security review unavoidable, Anthropic provides an open-source GitHub Action (anthropics/claude-code-security-review) that runs on pull requests and posts findings as inline comments.</p><pre># .github/workflows/security-review.yml<br>name: Security Review<br><br>on:<br>  pull_request:<br><br>permissions:<br>  contents: read<br>  pull-requests: write<br><br>jobs:<br>  security:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v4<br>        with:<br>          fetch-depth: 2<br>      - uses: anthropics/claude-code-security-review@main<br>        with:<br>          claude-api-key: ${{ secrets.CLAUDE_API_KEY }}<br>          comment-pr: true</pre><p>Now every PR gets a security pass before a human reviewer even opens it. Store the API key as a repository secret — never inline it in the workflow file. Check the action’s README for the current options, such as excluding directories or adding custom filtering instructions.</p><p>Prefer another CI system? Claude Code’s headless mode works anywhere you can run a shell command:</p><pre>claude -p &quot;Review the diff from origin/main for security vulnerabilities. \<br>Report only high-confidence findings with file, line, and fix.&quot; \<br>  --output-format json &gt; security-report.json</pre><p>You can parse the JSON and fail the build when critical issues appear.</p><h3>Step 5: Add guardrails with permissions and hooks</h3><p>Secure coding isn’t only about reviewing code — it’s also about making sure the agent itself operates safely. Claude Code gives you two strong controls.</p><p><strong>Permissions</strong> in .claude/settings.json let you deny access to sensitive files and dangerous commands:</p><pre>{<br>  &quot;permissions&quot;: {<br>    &quot;deny&quot;: [<br>      &quot;Read(./.env)&quot;,<br>      &quot;Read(./.env.*)&quot;,<br>      &quot;Read(./secrets/**)&quot;,<br>      &quot;Bash(curl:*)&quot;,<br>      &quot;Bash(rm -rf:*)&quot;<br>    ]<br>  }<br>}</pre><p><strong>Hooks</strong> run your own scripts at specific points in Claude’s workflow. A PreToolUse hook can inspect a file edit before it&#39;s written and block it — for example, if it contains something that looks like a secret:</p><pre>{<br>  &quot;hooks&quot;: {<br>    &quot;PreToolUse&quot;: [<br>      {<br>        &quot;matcher&quot;: &quot;Edit|Write&quot;,<br>        &quot;hooks&quot;: [<br>          { &quot;type&quot;: &quot;command&quot;, &quot;command&quot;: &quot;./scripts/check-secrets.sh&quot; }<br>        ]<br>      }<br>    ]<br>  }<br>}</pre><p>Your script can run a tool like gitleaks or a simple regex check, and exit with code 2 to block the change and tell Claude why. This means a hardcoded AWS key never even lands on disk.</p><h3>What it catches well — and where you still need humans</h3><p>In practice, Claude Code is especially strong at:</p><ul><li>Injection bugs and unsafe input handling</li><li>Missing or inconsistent auth checks across routes</li><li>Secrets and sensitive data in code or logs</li><li>Explaining a vulnerability in plain language and fixing it</li></ul><p>But keep realistic expectations:</p><ul><li><strong>It’s not deterministic.</strong> Two runs may surface slightly different findings. Treat it as an extra reviewer, not a compliance gate on its own.</li><li><strong>False positives happen.</strong> Ask Claude to justify a finding with an attack scenario; weak findings tend to fall apart.</li><li><strong>Architecture-level risks need humans.</strong> Threat modeling, infrastructure config, and business-logic abuse still deserve dedicated review.</li><li><strong>Keep your other tools.</strong> Dependency scanning (Dependabot, npm audit, Snyk), SAST, and secret scanning remain essential layers.</li></ul><h3>A simple secure-coding workflow</h3><ol><li>Write security rules into CLAUDE.md so code is generated securely from the start.</li><li>Lock down sensitive files and commands with permissions and hooks.</li><li>Run /security-review before you commit.</li><li>Use custom commands like /owasp-audit for high-risk modules (auth, payments, uploads).</li><li>Let the GitHub Action review every PR automatically.</li><li>Have humans focus on design, threat modeling, and the findings that matter most.</li></ol><h3>Final thoughts</h3><p>The cheapest vulnerability to fix is the one that never gets merged. With a few config files and one workflow, Claude Code becomes a security reviewer that never gets tired, never skips a PR, and explains its reasoning. Start with /security-review on your next change — you might be surprised by what it finds.</p><p><em>If you found this useful, follow me for more practical guides on AI-assisted development, DevOps, and building secure software.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05f8443bf39d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Token-Efficient AI Development: Build More, Spend Less]]></title>
            <link>https://medium.com/@sumitsuthar_95414/token-efficient-ai-development-build-more-spend-less-fb7261d6c58e?source=rss-b8476e9bbf13------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb7261d6c58e</guid>
            <category><![CDATA[vibe-coding-guide]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[claude-guide]]></category>
            <dc:creator><![CDATA[Sumit Suthar]]></dc:creator>
            <pubDate>Fri, 02 Oct 2026 22:09:40 GMT</pubDate>
            <atom:updated>2026-10-02T22:09:40.751Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How to cut your LLM bill without making your product any worse</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ha7kPjJM7UqBUHdLztuueA.png" /></figure><p>When you first add an LLM to a product, tokens feel almost free. You prototype, it works, you ship. Then real users arrive, and the API bill starts growing faster than your user count.</p><p>That’s the point where most teams discover that <strong>tokens are the new compute</strong>. Every word you send to a model and every word it sends back has a price, both in money and in latency. Token-efficient AI development means getting the same quality, or better, with fewer tokens.</p><p>Here’s a practical playbook.</p><h3>1. Understand where your tokens actually go</h3><p>You can’t optimize what you don’t measure. Before changing anything, log these for every request:</p><ul><li><strong>Input tokens</strong> (system prompt, history, retrieved context, tool definitions)</li><li><strong>Output tokens</strong> (these usually cost several times more than input)</li><li><strong>Cached and uncached tokens</strong></li><li><strong>Feature or endpoint name</strong>, so you know which part of your app is expensive</li></ul><p>Most teams find the same thing: a large share of their spend is input tokens they resend on every call, like long system prompts, entire chat histories and oversized retrieved documents. The user’s actual question is often under 5% of the request.</p><h3>2. Use prompt caching for anything that repeats</h3><p>If your system prompt, tool definitions or reference documents stay the same across requests, you’re paying full price to send identical text again and again.</p><p>Prompt caching fixes that. Major providers let you mark a stable prefix as cacheable. Later requests that reuse it are billed at a small fraction of the normal input price, and they respond faster.</p><p>python</p><pre>response = client.messages.create(<br>    model=&quot;claude-...&quot;,<br>    max_tokens=1024,<br>    system=[<br>        {<br>            &quot;type&quot;: &quot;text&quot;,<br>            &quot;text&quot;: LONG_SYSTEM_PROMPT_AND_DOCS,<br>            &quot;cache_control&quot;: {&quot;type&quot;: &quot;ephemeral&quot;}<br>        }<br>    ],<br>    messages=[{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: user_question}]<br>)</pre><p><strong>The key rule:</strong> put stable content first and changing content last. Caching works on prefixes, so one timestamp or user ID near the top of your prompt breaks the cache for everything after it.</p><h3>3. Route each task to the right model</h3><p>Not every request needs your most powerful model. A rough split:</p><p>TaskModel tierClassification, extraction, routing, formattingSmall and fastSummaries, standard Q&amp;A, simple code editsMid-tierMulti-step reasoning, architecture, hard debuggingFrontier</p><p>A common pattern is a <strong>cascade</strong>. A cheap model handles the request first and only escalates when it isn’t confident or a validation check fails. Since most traffic is easy, the savings add up quickly.</p><h3>4. Stop resending the whole conversation</h3><p>Chat apps often append every message to the history forever. By turn 30, each request carries the entire conversation, and cost grows roughly quadratically over a session.</p><p>Better options:</p><ul><li><strong>Sliding window:</strong> keep only the last N turns.</li><li><strong>Rolling summary:</strong> compress older turns into a short summary and keep recent turns word for word.</li><li><strong>State extraction:</strong> instead of keeping history, keep a small structured object ({&quot;user_goal&quot;: ..., &quot;decisions&quot;: [...]}).</li></ul><p>Long agent sessions need this most. Tool outputs such as file contents, search results and logs pile up quickly. Trim or summarize them once they’ve been used.</p><h3>5. Retrieve less, but retrieve better</h3><p>RAG pipelines often take the “just stuff in more chunks” approach. Twenty chunks of 500 tokens each is 10,000 tokens per query, and most of them are noise that can actually hurt answer quality.</p><ul><li>Use a <strong>reranker</strong> and send only the top 3–5 chunks.</li><li>Make chunks <strong>smaller and semantically clean</strong>.</li><li>Strip boilerplate like headers, footers, navigation text and repeated disclaimers before indexing.</li><li>Use <strong>hybrid search</strong> (keyword plus vector) so you hit the right chunk on the first try.</li></ul><p>Fewer, more relevant tokens are cheaper and usually give more accurate answers.</p><h3>6. Control output length</h3><p>Output tokens are the expensive ones, and models like to talk.</p><ul><li>Say it explicitly: <em>“Answer in at most 3 sentences”</em> or <em>“Return only the JSON.”</em></li><li>Use <strong>structured outputs or JSON schemas</strong> so the model doesn’t wrap answers in prose.</li><li>Set a sensible max_tokens for each endpoint, not one global maximum.</li><li>For code edits, ask for <strong>diffs or specific functions</strong>, not the whole file again.</li></ul><h3>7. Write tighter prompts</h3><p>Prompts tend to grow over time as people add instructions for every edge case. Review them the way you’d review code:</p><ul><li>Remove duplicate or contradictory instructions.</li><li>Replace five long examples with two good ones.</li><li>Move rarely needed instructions into a tool or a conditional branch.</li><li>Trim tool definitions. Every tool’s name, description and schema is sent on every call.</li></ul><p>A 4,000-token system prompt that becomes 1,500 tokens saves money on every request, forever.</p><h3>8. Batch work that isn’t urgent</h3><p>Nightly reports, bulk tagging, evaluations, embedding backfills and content generation don’t need real-time responses. Batch APIs from major providers typically cost about half as much as real-time calls, in exchange for results arriving within hours. If a user isn’t waiting on it, batch it.</p><h3>9. Cache at the application level too</h3><p>Before calling a model at all, check whether you’ve already answered the question:</p><ul><li><strong>Exact-match cache</strong> for repeated queries (FAQs, common lookups)</li><li><strong>Semantic cache</strong> that serves stored answers for near-duplicate questions, matched by embedding similarity</li><li><strong>Precompute</strong> outputs that change rarely, like product descriptions or category summaries</li></ul><p>The cheapest token is one you never send.</p><h3>10. Measure quality alongside cost</h3><p>Token optimization has a trap: you can cut costs while quietly making your product worse. Every change, whether a shorter prompt, a smaller model or fewer chunks, should go through an <strong>eval set</strong> of real examples with expected outputs.</p><p>Track <strong>cost per successful task</strong>, not cost per request. A cheap model that fails 30% of the time and needs retries isn’t cheap.</p><h3>A quick checklist</h3><ul><li>Logging input, output and cached tokens per feature</li><li>Stable prompt content placed first and cached</li><li>Small models handling simple tasks</li><li>Conversation history trimmed or summarized</li><li>RAG limited to the top few reranked chunks</li><li>Output length and format constrained</li><li>System prompts and tool definitions audited</li><li>Non-urgent work sent through a batch API</li><li>Application-level response caching</li><li>Eval suite guarding quality</li></ul><h3>Final thought</h3><p>Token efficiency isn’t about being stingy. It’s the same engineering discipline we already apply to database queries, network calls and bundle sizes. Teams that treat tokens as a resource to design around, rather than an afterthought, can offer cheaper plans, respond faster and scale further.</p><p>Start by measuring. The biggest savings are usually in places you aren’t looking at yet.</p><p><em>If this was useful, follow for more practical writing on building with AI.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb7261d6c58e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why More Context Can Make Claude Code Worse]]></title>
            <link>https://medium.com/@sumitsuthar_95414/why-more-context-can-make-claude-code-worse-f3e48c666bca?source=rss-b8476e9bbf13------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3e48c666bca</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[claude-context]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Sumit Suthar]]></dc:creator>
            <pubDate>Fri, 02 Oct 2026 21:16:01 GMT</pubDate>
            <atom:updated>2026-10-02T21:16:01.832Z</atom:updated>
            <content:encoded><![CDATA[<h4>Stuffing the context window feels like the responsible thing to do. Often it’s the reason your agent starts making dumb mistakes.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7JuzfCkJ8C3wycVbXqYag.png" /></figure><p>When Claude Code gets something wrong, the instinct is almost always the same: give it more. Paste the whole file. Add another paragraph to CLAUDE.md. Connect one more MCP server. Dump the logs in. Surely if the model just <em>knew everything</em>, it would get it right.</p><p>In practice, the opposite is often true. Past a certain point, every extra token you add makes the model a little less sharp. The best Claude Code users I know aren’t the ones who feed it the most context. They’re the ones who feed it the <em>right</em> context, and ruthlessly keep everything else out.</p><p>Here’s why that works, and what to do about it.</p><h3>The context window is not a hard drive</h3><p>It’s tempting to think of the context window as storage: 200K tokens (or more) of space, and as long as you’re under the limit, you’re fine. But the context window is closer to working memory. Everything in it competes for the model’s attention on every single turn.</p><p>A transformer doesn’t “look up” the relevant line in your 3,000-line file the way you’d Ctrl+F for it. It attends across everything at once. When the important instruction sits next to forty irrelevant ones, its signal gets diluted. The model still <em>can</em> find it, but the odds that it weighs it correctly go down.</p><p>Researchers have a name for this. The 2023 paper <em>“Lost in the Middle”</em> showed that language models are noticeably better at using information at the start and end of long inputs than information buried in the middle. More recently, work on what’s being called <strong>context rot</strong> has shown that model performance tends to degrade as input length grows, even on simple tasks and even well within the advertised context limit.</p><p>A long context window tells you how much the model <em>can</em> read. It doesn’t promise how well it will <em>use</em> it.</p><h3>Five ways extra context quietly hurts you</h3><p><strong>1. Important instructions get drowned out.</strong> Your CLAUDE.md started as ten crisp lines. Six months later it’s 400 lines covering every edge case anyone ever hit. Now “never edit the generated migration files” sits between a note about commit message style and a paragraph on a deprecated API. When Claude ignores a rule, the file usually isn’t too short. It’s too long.</p><p><strong>2. Stale context actively misleads.</strong> Context isn’t neutral. That plan you discussed an hour ago, the approach you abandoned, the error message from before the fix: it’s all still there, and the model treats it as current. A lot of “why did it go back to the old approach?” moments come from conversation history pulling the model toward decisions you already reversed.</p><p><strong>3. Contradictions force the model to guess.</strong> The more sources you pile in (old docs, new docs, three different README files, a Slack thread you pasted), the more likely two of them disagree. The model has to pick one, and it won’t always pick the one you meant.</p><p><strong>4. Tools are context too.</strong> Every MCP server you connect adds tool names, descriptions and schemas to the context before you’ve typed a word. Connect a handful of large servers and a meaningful chunk of your window is gone before the work starts, and the model now has dozens of tools to choose between instead of the five it actually needs.</p><p><strong>5. Noise crowds out reasoning room.</strong> Long sessions full of verbose test output, full build logs and entire file dumps leave less space for the stuff that matters: the current task, the relevant code, and the model’s own reasoning. Eventually you hit compaction, and summarization is lossy. The details that get dropped are rarely the ones you’d have chosen.</p><h3>What a “good” context actually looks like</h3><p>Think of it the way you’d brief a sharp senior engineer who just joined the project. You wouldn’t hand them the entire monorepo and every Slack thread since 2021. You’d say: here’s the goal, here are the three files that matter, here’s the one gotcha, here’s how to check your work.</p><p>That’s the target: <strong>the smallest set of high-signal tokens that makes the right outcome likely.</strong> Anthropic’s own guidance on context engineering for agents frames it in almost exactly those terms. Context is a finite resource with diminishing returns, so treat it like one.</p><h3>Practical habits that make Claude Code better</h3><p><strong>Keep CLAUDE.md short and opinionated.</strong> Put in what Claude can’t infer from the code: build and test commands, non-obvious conventions, things that have bitten you before. Leave out what it can discover by reading the repo. Review it regularly and delete aggressively. If a rule matters, state it once, clearly, near the top.</p><p><strong>Use nested CLAUDE.md files instead of one giant one.</strong> Directory-specific guidance can live in that directory, so frontend rules don’t load while you’re fixing a database script.</p><p><strong>Clear between tasks.</strong> When you finish one thing and start something unrelated, run /clear. A fresh session with a good prompt beats a long one carrying the residue of three earlier tasks.</p><p><strong>Compact on purpose, not by accident.</strong> If you need to keep going, use /compact yourself and tell it what to preserve (&quot;keep the API design decisions and the list of failing tests&quot;), rather than waiting for automatic compaction to decide for you.</p><p><strong>Point, don’t paste.</strong> Instead of dumping a whole file into the chat, reference it with @path/to/file or just tell Claude where to look. Let it read the parts it needs. Agentic search is often better than you at finding the relevant 40 lines.</p><p><strong>Trim tool output.</strong> Ask for failing tests only, not the full suite output. Pipe logs through grep or tail. A 5,000-line build log is almost never what the model needs.</p><p><strong>Be selective with MCP servers.</strong> Enable the ones relevant to the project you’re in. Run /context occasionally to see what&#39;s actually eating your window. The answer is often surprising.</p><p><strong>Delegate exploration to subagents.</strong> Subagents run in their own context window. Send one to dig through the codebase or read documentation, and you get back a summary instead of every file it opened. Your main session stays clean.</p><p><strong>Write plans to files, not chat.</strong> For larger work, have Claude write the plan to a markdown file. You can start fresh sessions that read just the plan, and the plan survives /clear, compaction and tomorrow morning.</p><h3>A quick test you can run</h3><p>Next time Claude Code makes a frustrating mistake deep into a long session, try this: /clear, write a three-sentence prompt describing exactly what you want, point it at the two files that matter, and ask again.</p><p>More often than not, the “fresh” Claude does better than the one that had an hour of context. That’s not because it knows more. It’s because it’s distracted by less.</p><h3>The takeaway</h3><p>More context feels safer, but context has a cost: diluted attention, stale assumptions, contradictions and less room to think. The skill isn’t giving Claude Code everything. It’s curating: deciding what it needs to see right now, and keeping the rest out of the way.</p><p>Treat your context window like a desk, not a warehouse. Keep it clear, keep the important thing in front of you, and you’ll be surprised how much smarter your agent gets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3e48c666bca" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>