<?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 Sneha Maurya on Medium]]></title>
        <description><![CDATA[Stories by Sneha Maurya on Medium]]></description>
        <link>https://medium.com/@simaurya96?source=rss-9bbdb42015d7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qcgVIZrhDUF2ZicAnR9d8g.jpeg</url>
            <title>Stories by Sneha Maurya on Medium</title>
            <link>https://medium.com/@simaurya96?source=rss-9bbdb42015d7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 08:35:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@simaurya96/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[Why Autovacuum Wasn’t Enough: A Deep Dive into PostgreSQL Toast Tables, Replication Slots, and XID…]]></title>
            <link>https://medium.com/@simaurya96/why-autovacuum-wasnt-enough-a-deep-dive-into-postgresql-toast-tables-replication-slots-and-xid-5f0425a9459a?source=rss-9bbdb42015d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f0425a9459a</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Sneha Maurya]]></dc:creator>
            <pubDate>Mon, 27 Apr 2026 06:38:03 GMT</pubDate>
            <atom:updated>2026-04-27T06:38:03.258Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why Autovacuum Wasn’t Enough: A Deep Dive into PostgreSQL Toast Tables, Replication Slots, and XID Wraparound</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ad3R3MqZydOFd4Jvoy33JQ.png" /></figure><h3>The Problem</h3><p>You’re running a PostgreSQL database in production on AWS Aurora. Everything looks fine — your tables are getting autovacuumed regularly, dead tuple counts are low, and queries are fast. Then one day, you notice something alarming:</p><pre>SELECT c.oid::regclass, age(c.relfrozenxid), <br>       pg_size_pretty(pg_total_relation_size(c.oid))<br>FROM pg_class c <br>WHERE c.relkind IN (&#39;r&#39;,&#39;t&#39;) <br>ORDER BY age(c.relfrozenxid) DESC <br>LIMIT 10;</pre><pre>oid                  | age        | pg_size_pretty<br>------------------------------+------------+----------------<br> pg_toast.pg_toast_16521      | 226841519  | 8192 bytes<br> pg_toast.pg_toast_16399      | 226841519  | 8192 bytes<br> pg_toast.pg_toast_16588      | 226841519  | 8192 bytes<br> pg_toast.pg_toast_16450      | 226841519  | 8192 bytes<br> orders                       | 15234567   | 42 GB<br> order_items                  | 14123456   | 128 GB<br> order_payments               | 13987654   | 89 GB</pre><p>The toast tables have an XID age of 226 million — that’s 11% of the way to the dreaded 2-billion XID wraparound limit. Meanwhile, your actual data tables are sitting at a comfortable 15 million. What’s going on?</p><h3>Background: The Three Concepts You Need</h3><h3>1. What is Autovacuum?</h3><p>PostgreSQL uses MVCC (Multi-Version Concurrency Control). When you UPDATE or DELETE a row, the old version isn’t removed immediately — it’s marked as a “dead tuple.” Autovacuum is the background process that:</p><ul><li>Cleans up dead tuples (reclaims space)</li><li>Freezes old rows (prevents XID wraparound)</li></ul><p>Autovacuum kicks in when:</p><pre>dead tuples &gt; autovacuum_vacuum_threshold + (autovacuum_vacuum_scale_factor x live_tuples)</pre><p>For example, with default settings (threshold=50, scale_factor=0.2):</p><ul><li>A table with 1,000,000 live rows needs 200,050 dead tuples before autovacuum triggers</li><li>A table with 100 rows needs just 70 dead tuples</li></ul><p>In production, you often tune this aggressively:</p><ul><li>scale_factor = 0.001 (0.1%) means autovacuum triggers after just 1,000 dead tuples on a 1M row table</li><li>scale_factor = 0.0003 (0.03%) is even more aggressive for high-churn environments</li></ul><p>How to check your autovacuum config:</p><pre>-- Check RDS parameter group values<br>SHOW autovacuum_vacuum_scale_factor;<br>SHOW autovacuum_vacuum_threshold;</pre><pre>-- Check per-table autovacuum stats<br>SELECT relname, n_live_tup, n_dead_tup, <br>    CASE WHEN n_live_tup &gt; 0 <br>         THEN round((n_dead_tup * 100.0 / n_live_tup), 4) <br>         ELSE 0 <br>    END AS dead_pct,<br>    last_vacuum, last_autovacuum, <br>    last_analyze, last_autoanalyze, <br>    autovacuum_count, vacuum_count<br>FROM pg_stat_user_tables<br>ORDER BY n_dead_tup DESC;</pre><h3>2. What are Toast Tables?</h3><p>TOAST stands for The Oversized-Attribute Storage Technique. PostgreSQL pages are 8KB. If a row’s data exceeds ~2KB, PostgreSQL automatically moves large column values (like TEXT, JSONB, BYTEA) into a separate toast table.</p><p>Every table with large columns has a hidden toast table:</p><pre>orders (your table)<br>  └── pg_toast.pg_toast_16521 (hidden toast storage)</pre><p>You never interact with toast tables directly — PostgreSQL manages them transparently. But they ARE real tables with their own XID tracking, their own dead tuples, and their own need for vacuuming.</p><p>The key thing: Toast tables are vacuumed automatically when their parent table is vacuumed. There is no separate autovacuum trigger for toast tables. If your parent table doesn’t get vacuumed, the toast table doesn’t get vacuumed either.</p><p>But wait — what if the parent table IS being vacuumed, and the toast table XID age is STILL climbing? That’s exactly the situation we hit.</p><h3>3. What are Replication Slots?</h3><p>Logical replication slots are how PostgreSQL tracks what data has been sent to a subscriber (like a CDC pipeline). When you set up a replication slot:</p><pre>-- This is what a CDC tool (like Debezium) creates<br>SELECT * FROM pg_create_logical_replication_slot(&#39;my_cdc_slot&#39;, &#39;pgoutput&#39;);</pre><p>The slot maintains a bookmark — “I’ve sent everything up to XID 12345.” PostgreSQL cannot vacuum past this bookmarkbecause the subscriber might still need that data.</p><p>This is fine when the subscriber is active and consuming changes. But if the subscriber stops consuming (goes offline, gets misconfigured, or is simply abandoned), the slot becomes inactive — and PostgreSQL holds onto ALL changes since the slot fell behind.</p><h3>The Investigation: How We Found the Root Cause</h3><h3>Step 1: Notice the Symptom</h3><p>We were setting up a cleanup job that deletes old data from our application tables. While monitoring, we noticed toast table XID ages were dangerously high — over 226 million — while our actual tables were fine.</p><h3>Step 2: Check if Autovacuum is Running</h3><pre>SELECT relname, last_autovacuum, autovacuum_count, <br>       n_dead_tup, n_live_tup<br>FROM pg_stat_user_tables<br>WHERE relname IN (&#39;orders&#39;, &#39;order_items&#39;, &#39;order_payments&#39;)<br>ORDER BY n_dead_tup DESC;</pre><pre>relname       | last_autovacuum          | autovacuum_count | n_dead_tup | n_live_tup<br>----------------+--------------------------+------------------+------------+------------<br> orders         | 2026-04-20 09:15:23.456  | 1247             | 342        | 3712<br> order_items    | 2026-04-20 09:14:56.789  | 2891             | 12456      | 6234567<br> order_payments | 2026-04-20 09:15:01.234  | 1834             | 8901       | 4567890</pre><p>Autovacuum IS running — thousands of times! Dead tuples are low. Tables look healthy. So why are toast table XID ages so high?</p><h3>Step 3: Check if the Vacuum can FREEZE Rows</h3><p>There’s a difference between “vacuum cleaning dead tuples” and “vacuum freezing rows.” Cleaning removes dead tuples. Freezing marks old rows so their XIDs don’t count toward the 2-billion limit. Even if vacuum runs, it might not be able to freeze if something is holding back the freeze horizon.</p><pre>-- Check XID age of your tables vs toast tables<br>SELECT c.oid::regclass AS table_name, <br>       age(c.relfrozenxid) AS xid_age,<br>       round(age(c.relfrozenxid)::numeric / 2000000000 * 100, 2) AS pct_to_wraparound<br>FROM pg_class c<br>WHERE c.relnamespace = &#39;public&#39;::regnamespace <br>   OR c.oid::regclass::text LIKE &#39;pg_toast%&#39;<br>ORDER BY age(c.relfrozenxid) DESC<br>LIMIT 20;</pre><p>If toast tables have a much higher XID age than their parent tables, something is preventing the freeze specifically.</p><h3>Step 4: Check Replication Slots (The Root Cause)</h3><pre>SELECT slot_name, slot_type, active, <br>       age(catalog_xmin) AS catalog_xmin_age,<br>       pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS slot_lag<br>FROM pg_replication_slots <br>ORDER BY age(catalog_xmin) DESC;</pre><pre>slot_name          | slot_type | active | catalog_xmin_age |  slot_lag<br>-------------------------+-----------+--------+------------------+-----------<br> old_cdc_pipeline_slot   | logical   | f      | 226841519        |  45 GB<br> active_cdc_slot         | logical   | t      | 1234             |  128 KB</pre><p>There it is. An inactive replication slot (old_cdc_pipeline_slot) with a catalog_xmin age of 226 million. This slot is holding the entire database hostage:</p><ul><li>active = f means nobody is consuming from this slot</li><li>catalog_xmin_age = 226841519 means PostgreSQL cannot freeze ANY row newer than this XID</li><li>This affects ALL tables — including toast tables</li></ul><h3>Step 5: Understand Why This Happens</h3><p>Here’s the chain of events:</p><pre>1. Team A sets up CDC pipeline (Debezium) → creates replication slot &quot;old_cdc_pipeline_slot&quot;<br>2. Pipeline works fine for months<br>3. Team A migrates to new pipeline → creates new slot &quot;active_cdc_slot&quot;<br>4. Team A forgets to drop the old slot<br>5. Old slot goes inactive but keeps holding its catalog_xmin<br>6. Autovacuum runs but CANNOT freeze past the old slot&#39;s XID<br>7. Toast table XID ages climb toward 226 million<br>8. Nobody notices because the parent tables LOOK healthy (low dead tuples)</pre><p>The sneaky part: your parent tables might have low XID ages because they have enough churn for autovacuum to rewrite pages with fresh XIDs. Toast tables, which rarely change, don’t get this benefit — they’re stuck with old frozen XIDs that can’t be advanced past the replication slot’s horizon.</p><h3>The Fix</h3><h4>Immediate Fix: Drop the Inactive Slot</h4><pre>-- DANGER: Only do this if you&#39;ve confirmed the slot is truly abandoned<br>-- Check with the team that created it first!<br>SELECT pg_drop_replication_slot(&#39;old_cdc_pipeline_slot&#39;);</pre><p>After dropping the slot:</p><ol><li>Autovacuum will start freezing rows on its next pass</li><li>XID ages will gradually decrease</li><li>Toast table XID ages will come down as parent tables are vacuumed</li></ol><h4>If You Need Faster Recovery</h4><p>If XID ages are dangerously high (&gt;500 million), you might want to run a manual vacuum freeze:</p><pre>-- This freezes ALL rows in the table + its toast table<br>-- WARNING: This locks the table and can take a long time on large tables<br>VACUUM (FREEZE, ANALYZE, VERBOSE) orders;<br>VACUUM (FREEZE, ANALYZE, VERBOSE) order_items;<br>VACUUM (FREEZE, ANALYZE, VERBOSE) order_payments;</pre><p>For large tables (100GB+), this could take 30 minutes to several hours. Consider running during off-peak hours.</p><h3>Prevention: Monitoring Queries You Should Run Regularly</h3><h4>1. Replication Slot Health (Run Weekly)</h4><pre>-- Alert if any slot has catalog_xmin_age &gt; 100 million<br>SELECT slot_name, slot_type, active, <br>       age(catalog_xmin) AS catalog_xmin_age,<br>       round(age(catalog_xmin)::numeric / 2000000000 * 100, 2) AS pct_to_wraparound,<br>       pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS slot_lag<br>FROM pg_replication_slots <br>ORDER BY age(catalog_xmin) DESC;</pre><p>Red flags:</p><ul><li>active = false with high catalog_xmin_age</li><li>Any slot with pct_to_wraparound &gt; 5%</li><li>slot_lag growing over time</li></ul><h4>2. XID Age Monitoring (Run Weekly)</h4><pre>-- Check all tables including toast<br>SELECT c.oid::regclass AS table_name, <br>       age(c.relfrozenxid) AS xid_age,<br>       round(age(c.relfrozenxid)::numeric / 2000000000 * 100, 2) AS pct_to_wraparound,<br>       pg_size_pretty(pg_total_relation_size(c.oid)) AS total_size<br>FROM pg_class c <br>WHERE c.relkind IN (&#39;r&#39;, &#39;t&#39;)  -- &#39;r&#39; = regular table, &#39;t&#39; = toast table<br>ORDER BY age(c.relfrozenxid) DESC <br>LIMIT 30;</pre><p>Red flags:</p><ul><li>Any table with pct_to_wraparound &gt; 5%</li><li>Toast tables with a higher XID age than parent tables</li><li>XID ages are increasing week over week</li></ul><h4>3. Autovacuum Progress (Run During Incidents)</h4><pre>-- See what autovacuum is currently doing<br>SELECT pid, <br>       relid::regclass AS table_name, <br>       phase,<br>       heap_blks_total, <br>       heap_blks_scanned,<br>       CASE WHEN heap_blks_total &gt; 0 <br>            THEN round(heap_blks_scanned::numeric / heap_blks_total * 100, 2) <br>            ELSE 0 <br>       END AS pct_complete<br>FROM pg_stat_progress_vacuum;</pre><h4>4. Dead Tuple Monitoring (Run Daily)</h4><pre>SELECT relname, n_live_tup, n_dead_tup, <br>    CASE WHEN n_live_tup &gt; 0 <br>         THEN round((n_dead_tup * 100.0 / n_live_tup), 4) <br>         ELSE 0 <br>    END AS dead_pct,<br>    last_autovacuum, autovacuum_count<br>FROM pg_stat_user_tables<br>ORDER BY n_dead_tup DESC<br>LIMIT 20;</pre><h3>The Bigger Picture: How CDC Pipelines Interact with Autovacuum</h3><p>Many modern architectures use CDC (Change Data Capture) pipelines to stream database changes to data lakes, search engines, or event systems. Common tools:</p><ul><li>Debezium + Kafka</li><li>AWS DMS</li><li>Custom logical replication subscribers</li></ul><p>All of these use logical replication slots. The architecture typically looks like:</p><pre>PostgreSQL → Replication Slot → CDC Connector → Kafka → Data Lake</pre><p>The replication slot tells PostgreSQL: “Don’t clean up anything past this point — I might still need it.” This is essential for the pipeline to work. But it creates a dangerous coupling:</p><p>ScenarioRiskPipeline goes down for hoursSlot lag grows, WAL files accumulate on diskPipeline is replaced, but the old slot isn’t droppedXID freeze is blocked foreverPipeline can’t keep up with write volumeSame as going down — slot falls behindMultiple pipelines, one abandonedSilent XID age growth</p><h3>The pgoutput Plugin</h3><p>When you see a replication slot using pgoutput as its plugin, that&#39;s PostgreSQL&#39;s built-in logical decoding plugin. It&#39;s used by Debezium and similar tools to convert WAL (Write-Ahead Log) entries into a stream of INSERT/UPDATE/DELETE events.</p><pre>-- See what plugin each slot uses<br>SELECT slot_name, plugin, active FROM pg_replication_slots;</pre><pre>slot_name          |  plugin   | active<br>---------------------------+-----------+--------<br> active_cdc_slot           | pgoutput  | t<br> old_cdc_pipeline_slot     | pgoutput  | f</pre><h3>Quick Reference: Troubleshooting Flowchart</h3><pre>Toast table XID age is high<br>  │<br>  ├── Is autovacuum running on parent tables?<br>  │     │<br>  │     ├── NO → Check autovacuum config (scale_factor, threshold)<br>  │     │         Run: SHOW autovacuum_vacuum_scale_factor;<br>  │     │<br>  │     └── YES → Can vacuum FREEZE rows?<br>  │                 │<br>  │                 ├── Check replication slots<br>  │                 │     SELECT slot_name, active, age(catalog_xmin) <br>  │                 │     FROM pg_replication_slots;<br>  │                 │     │<br>  │                 │     ├── Inactive slot with high age → DROP IT<br>  │                 │     │   (after confirming with the owning team)<br>  │                 │     │<br>  │                 │     └── All slots active, low age → <br>  │                 │         Check autovacuum_freeze_max_age setting<br>  │                 │<br>  │                 └── No replication slots →<br>  │                     Run manual VACUUM FREEZE on affected tables<br>  │                     Check if long-running transactions are blocking</pre><h3>Key Takeaways</h3><ol><li>Autovacuum running ≠ Autovacuum freezing. Your tables can look healthy (low dead tuples, frequent autovacuum runs) while XID ages silently climb because freezing is blocked.</li><li>Toast tables are the canary. Since they change rarely, they’re the first to show XID age problems. Monitor them explicitly — don’t assume they’re fine just because the parent table is fine.</li><li>Replication slots are powerful but dangerous. An abandoned slot can silently block XID freeze for the entire database. Always have a process to identify and clean up inactive slots.</li><li>Monitor XID age, not just dead tuples. Dead tuple monitoring catches autovacuum failures. XID age monitoring catches freeze failures. You need both.</li><li>When migrating CDC pipelines, drop the old slot. This is the most common cause of this issue — a team sets up a new pipeline but forgets to clean up the old replication slot.</li><li>Don’t wait for wraparound. PostgreSQL will force a shutdown at 2 billion XIDs to prevent data corruption. At that point, you’ll need to run single-user mode vacuum on a production database. Start investigating at 5% (100 million). Take action at 10% (200 million). Treat 25% (500 million) as a P1 incident.</li></ol><p><em>This post is based on a real production investigation. Table names and data have been changed, but the queries, symptoms, and fixes are exactly what we used to diagnose and resolve the issue.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f0425a9459a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You Already Use Code.
Here’s Why You Still Need Cowork.]]></title>
            <link>https://medium.com/@simaurya96/you-already-use-code-heres-why-you-still-need-cowork-3adc83e08835?source=rss-9bbdb42015d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/3adc83e08835</guid>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[claude-cowork]]></category>
            <dc:creator><![CDATA[Sneha Maurya]]></dc:creator>
            <pubDate>Mon, 27 Apr 2026 05:53:01 GMT</pubDate>
            <atom:updated>2026-04-27T05:53:01.467Z</atom:updated>
            <content:encoded><![CDATA[<h4>Everything Cowork does, Code can do too — right? Wrong. Here’s what’s actually different, what’s genuinely better, and why smart developers are running both.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tv816qNAVQsjbxH_Ud95Hw.png" /></figure><h4>Let’s get the obvious question out of the way: “I already use Claude Code. It can access my filesystem, run shell commands, and do everything Cowork advertises. Why would I bother with another tab?”</h4><p>It’s a fair question. And on the surface, the answer seems like “you wouldn’t.” Claude Code has full terminal access, reads entire codebases, writes files, commits to Git, runs tests — it’s a powerhouse. Cowork was literally built <em>from</em> Claude Code’s architecture. Anthropic’s team even admitted they built Cowork using Code in just two weeks.</p><p>But after spending serious time with both, I can tell you: they solve different problems in your workday. And if you’re only using Code, you’re working harder than you need to on the non-coding parts of your job.</p><h3>The Honest Overlap</h3><p>Let’s not pretend these tools are worlds apart. Under the hood, they share the same agentic architecture, the same Claude intelligence, and the same Model Context Protocol (MCP) for connecting to external tools. Both can access your local filesystem. Both can run shell commands. Both can produce files, process data, and handle multi-step tasks autonomously.</p><p>If you’re a developer comfortable in the terminal, you <em>could</em> use Claude Code to organize your Downloads folder, compile a research report, or batch-rename invoices. Nothing stops you. Some developers did exactly that before Cowork existed — and that’s precisely what prompted Anthropic to build Cowork in the first place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G1QNbdc9XfVdV-ut6o0Ahg.png" /></figure><h3>What Cowork Can Do That Code Genuinely Can’t</h3><p>Here’s where it gets interesting. Despite the shared foundation, there are real capabilities in Cowork that don’t exist in Claude Code — not “harder to set up” differences, but actual features you simply cannot access from the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dEAkv4-C2_UwHoMWm_XdNw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a526MaTPD6Fpb0ROwQmXvw.png" /></figure><p>Dispatch is worth emphasizing. It’s a persistent conversation thread that lives in the Cowork tab. You message it a task, and it intelligently routes to a Cowork session or a Code session depending on the nature of the work. Development tasks route to Code. Knowledge work routes to Cowork. You get a push notification when it finishes or needs approval. If you have computer use enabled, Dispatch-spawned Code sessions can use it too.</p><h3>What Code Can Do That Cowork Can’t</h3><p>The reverse is equally important. Cowork is <em>not</em> a replacement for Code if you’re doing actual development. The terminal exists for a reason, and Code leverages it fully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vQQR0enTw1zCKM3vEo2HXg.png" /></figure><h3>The Full Comparison Matrix</h3><p>Here’s the definitive side-by-side. Bookmark this — it’ll save you from reaching for the wrong tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*8aw86mRc3DTwP6QnT6dHjQ.png" /></figure><h3>The Developer’s Case for Cowork</h3><p>Here’s the thing most developers miss: <strong>your job isn’t 100% code.</strong> You write status updates. You compile weekly summaries. You organize research. You prep for meetings. You review documents. You process expense receipts. You wrangle files across Slack, Drive, and email.</p><p>Claude Code is the best tool in the world for the coding parts of your job. But for everything else — the “surround work” that eats 30–40% of your week — Cowork is purpose-built and meaningfully faster to use than jury-rigging Code for non-coding tasks.</p><h4>Real scenarios where Cowork wins for developers:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*VD-ekqYkF_YOe8tY1OJAYQ.png" /></figure><p>Could you do all of this in Claude Code with enough MCP configuration and shell scripting? Maybe. But it would take you longer to set up, require ongoing maintenance, and burn more tokens in the process. Cowork gives you a pre-built ecosystem — connectors, plugins, scheduling, computer use — that handles these workflows out of the box.</p><h3>The Ideal Developer Setup: Both</h3><p>The smartest setup isn’t either/or — it’s both. Here’s how they complement each other:</p><p><strong>Claude Code</strong> for everything that touches your codebase: feature development, debugging, test writing, refactoring, Git operations, CI/CD, deployments. This is where Code is unmatched, and Cowork can’t compete.</p><p><strong>Cowork</strong> for everything around your codebase: research, documentation, status updates, file management, meeting prep, cross-tool workflows, recurring operational tasks. This is where Cowork’s ecosystem (connectors, plugins, scheduling, computer use, Dispatch) makes it dramatically faster.</p><p>And here’s the elegant part: <strong>Dispatch bridges both.</strong> Send a task from your phone, and Dispatch intelligently routes it — coding tasks go to a Code session, knowledge work goes to a Cowork session. You don’t even have to decide which tool to use.</p><h3>Setup Checklist for Developers</h3><p>If you’re already on Claude Code and want to add Cowork to your workflow, here’s the minimum viable setup:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*f0_wuoPyvk6YCqjwSPmb5A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*Y66f8hRO496czTEWRluoXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*UrKjZbCbLi6m-nhOpjupMw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3adc83e08835" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Review Code Written by Claude Code]]></title>
            <link>https://medium.com/@simaurya96/how-to-review-code-written-by-claude-code-34b5c551c168?source=rss-9bbdb42015d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/34b5c551c168</guid>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Sneha Maurya]]></dc:creator>
            <pubDate>Mon, 30 Mar 2026 06:50:00 GMT</pubDate>
            <atom:updated>2026-03-30T06:50:00.656Z</atom:updated>
            <content:encoded><![CDATA[<h4>The hidden best practices nobody tells you about — from the people who built the tool.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UC01V-D2-u7H1CHMjnyzkw.png" /></figure><blockquote>The new bottleneck isn’t writing code</blockquote><p>Here’s the thing nobody warned us about when AI coding tools got good: <strong>the hard part flipped.</strong></p><p>Two years ago, the bottleneck was writing code. You’d spend hours typing, debugging, Googling Stack Overflow. Now? Claude Code can write 500 lines across 8 files in 90 seconds. The code compiles. The tests pass. It looks… fine.</p><p>But is it actually good? Is it secure? Will it blow up at 2 AM on a Saturday?</p><p><strong>The bottleneck is now reviewing.</strong> And most developers are terrible at it — because they never had to review at this speed before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4x6B0NLFMit04VnwKZdmAw.png" /></figure><blockquote><em>💡 </em><strong><em>The mindset shift:</em></strong><em> Think of Claude Code as a very smart junior developer who works insanely fast but sometimes does things you wouldn’t approve in a PR. Your job is to be the senior dev reviewing the PR.</em></blockquote><h3>The 10 practices that actually matter</h3><h3>1. Use a second Claude to review the first Claude</h3><p><em>The single biggest unlock most people miss</em></p><p>This sounds weird, but it’s exactly what the Claude Code team at Anthropic does. Have one Claude draft the plan, then spin up a <strong>second session</strong> to review it “as a staff engineer.”</p><p>Separate context windows produce better results. One agent can introduce bugs that another agent (fresh context) will catch immediately.</p><pre># Session 1: Claude writes the code<br>&gt; &quot;Build an auth middleware for Express&quot;</pre><pre># Session 2: Fresh Claude reviews it<br>&gt; &quot;Review this auth middleware as a senior<br>   security engineer. Find bugs and edge cases.&quot;</pre><pre># Even better — challenge it:<br>&gt; &quot;Grill me on these changes and don&#39;t approve<br>   until you&#39;re satisfied this is production-ready&quot;</pre><p>❌ What most people do✅ What you should doReview Claude’s output in the same session. The context is polluted — it’ll defend its own choices.Open a fresh session. Paste in the code. Ask it to review as a staff engineer. Fresh context = fresh eyes.</p><h3>2. Always start with git diff, never the AI’s summary</h3><p><em>Trust the diff, not the description</em></p><p>Claude will tell you “I updated the auth middleware and added error handling.” That summary skips the 47 other lines it quietly changed. <strong>Always review with </strong><strong>git diff before committing.</strong></p><pre># Review staged changes<br>git diff --cached</pre><pre># Or compare your branch to main<br>git diff main..HEAD</pre><pre># Pro tip: Use Diffity for a visual diff<br>/diffity-diff main</pre><p>Keep PRs small — Anthropic’s own team averages <strong>118 lines per PR</strong>. One feature per PR. Always squash merge for clean history.</p><h3>3. Give Claude a way to verify itself</h3><p><em>The single highest-leverage thing you can do</em></p><p>From Anthropic’s best practices docs: if Claude can run tests and see green, it self-corrects. Without verification, it’s guessing. With verification, it’s iterating.</p><pre># Instead of this:<br>&gt; &quot;Build a payment calculator&quot;</pre><pre># Do this:<br>&gt; &quot;Build a payment calculator. Here&#39;s a test file<br>   with expected outputs. Run the tests after each<br>   change and don&#39;t stop until all pass.&quot;</pre><pre># Or even simpler:<br>&gt; &quot;Write tests first. Then implement until tests pass.&quot;</pre><blockquote><em>🎯 </em><strong><em>Why this works:</em></strong><em> Include tests, screenshots, or expected outputs with your prompt. Claude runs the feedback loop for you — writes code, runs tests, sees failures, fixes them, repeats. You review the final passing version, not every iteration.</em></blockquote><h3>4. Use /code-review — it deploys 4 agents, not one</h3><p><em>A fleet of specialized reviewers</em></p><p>Most people don’t know that /code-review doesn&#39;t just ask one Claude to read your code. It dispatches <strong>4 parallel agents</strong>, each with a different specialty:</p><p>AgentWhat it doesAgents 1 + 2Sonnet models checking CLAUDE.md complianceAgent 3Opus scanning for obvious bugs in the diffAgent 4Opus looking for security issues and incorrect logicVerificationChecks findings against actual code behavior</p><p>Findings are tagged by severity and posted as inline comments. They don’t auto-approve or block your PR.</p><h3>5. Challenge Claude, don’t babysit it</h3><p><em>The creator’s motto: don’t babysit 🚫👶</em></p><p>Boris Cherny (Claude Code’s creator) doesn’t write step-by-step instructions. He describes the outcome and challenges Claude to prove it works:</p><pre># After a mediocre first attempt:<br>&gt; &quot;Knowing everything you know now, scrap this<br>   and implement the elegant solution&quot;</pre><pre># Before merging:<br>&gt; &quot;Grill me on these changes and don&#39;t make a PR<br>   until I pass your test&quot;</pre><pre># To validate:<br>&gt; &quot;Prove to me this works — diff between main<br>   and your branch and explain every change&quot;</pre><p>You’re not micromanaging. You describe what you want, then hold it to a high bar.</p><h3>6. CLAUDE.md is your living review checklist</h3><p><em>Every mistake gets encoded so it never repeats</em></p><p>Boris’s golden rule: <strong>“Anytime we see Claude do something incorrectly, we add it to CLAUDE.md so it doesn’t repeat next time.”</strong> The file is checked into git and updated multiple times a week.</p><pre># CLAUDE.md</pre><pre>## Tech Stack<br>- Backend: Java 17, Spring Boot 3.2<br>- Database: PostgreSQL 15<br>- Testing: JUnit 5, Mockito</pre><pre>## Commands<br>- ./gradlew test         -- Run all tests<br>- ./gradlew spotlessCheck -- Lint check</pre><pre>## Code Style<br>- Constructor injection only, never field @Autowired<br>- All public methods need Javadoc<br>- No magic numbers -- use named constants</pre><pre>## Common Mistakes (add as you find them!)<br>- Use Instant not LocalDateTime for timestamps<br>- Always validate input DTOs with @Valid<br>- Catch specific exceptions, never Exception</pre><pre>## Workflow<br>- Feature branches from main<br>- Run tests before every commit<br>- One concern per PR</pre><h3>7. Use Esc Esc or /rewind — don’t fix in a polluted context</h3><p><em>Go back, don’t push forward</em></p><p>Claude goes off-track. You try to correct it. It course-corrects badly. 15 minutes later, the context is a mess and responses are getting worse.</p><p>❌ What most people do✅ What you should do”No, that’s wrong. I meant X not Y. Also fix the thing you broke in file Z.”Press Esc Esc to cancel, or /rewind to undo. Then rephrase your original prompt clearly.</p><p>Think of it like git — you wouldn’t keep committing on top of a broken commit. You’d reset and try again.</p><h3>8. Run /security-review separately</h3><p><em>Security needs a different lens than correctness</em></p><p>Claude Code has a dedicated /security-review command tuned for:</p><ul><li>Injection vulnerabilities (SQL, XSS, command injection)</li><li>Authentication and authorization flaws</li><li>Hardcoded secrets or credentials in code</li><li>Insecure data handling patterns</li></ul><p>You can also spin up a dedicated subagent: <em>“Use a subagent to review this code for security issues”</em></p><h3>9. Automate reviews on every PR</h3><p><em>Make Claude a permanent member of the review team</em></p><p>Set up Claude Code as a GitHub Action — it reviews every PR, runs security scans, and posts inline comments before a human even opens it.</p><pre># .github/workflows/claude-review.yml<br>name: Claude Code Review<br>on:<br>  pull_request:<br>    types: [opened, synchronize]</pre><pre>jobs:<br>  review:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v4<br>      - uses: anthropics/claude-code-action@v1<br>        with:<br>          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}</pre><p>You can also just comment @claude review on any PR to trigger it manually.</p><h3>10. Context management is everything</h3><p><em>Performance degrades as context fills</em></p><p>Claude’s context window holds every message, file, and command output. When full, it forgets earlier instructions and makes more mistakes.</p><pre># Compact when needed -- tell it what to keep<br>/compact focus on API changes and modified files</pre><pre># Start fresh sessions for new tasks<br># Don&#39;t keep debugging in a 200-message thread</pre><blockquote><em>⚡ </em><strong><em>Pro tip:</em></strong><em> If you do something more than once a day, turn it into a skill or command. They live in </em><em>.claude/commands/ and are checked into git.</em></blockquote><h3>The complete review flow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DYi3ZxYe8SLVz3Zb3-bvcg.png" /></figure><h4>The cheat sheet</h4><p>🔍 /code-review → 4 parallel agents audit your PR</p><p>🔒 /security-review → Dedicated security scan</p><p>⏪ /rewind → Undo Claude’s last action cleanly</p><p>⛔ Esc Esc → Cancel current operation</p><p>📦 /compact → Free up context, keep key info</p><p>📊 /diffity-diff main → Visual GitHub-style diff viewer</p><p>📝 git diff — cached → Review staged changes before commit</p><p>🏖️ /sandbox → 84% fewer permission prompts</p><h3>Final thought</h3><p>The developers who’ll thrive in the AI era aren’t the ones who prompt the best code out of Claude. They’re the ones who can <strong>review at the speed of generation.</strong></p><p>Start with three things today: use a second Claude session for reviews, add a CLAUDE.md to your project, and never merge without git diff first.</p><p><strong>Your production server at 2 AM will thank you.</strong></p><p><em>What’s your go-to trick for reviewing AI-generated code? Drop it in the comments.</em></p><p><strong>Sources:</strong></p><ul><li><a href="https://code.claude.com/docs/en/best-practices">Best Practices for Claude Code — Anthropic Docs</a></li><li><a href="https://claude.com/blog/code-review">Code Review for Claude Code — Anthropic Blog</a></li><li><a href="https://mindwiredai.com/2026/03/25/claude-code-creator-workflow-claudemd/">Boris Cherny’s Claude Code Workflow — MindwiredAI</a></li><li><a href="https://github.com/shanraisshan/claude-code-best-practice">claude-code-best-practice — GitHub</a></li><li><a href="https://www.builder.io/blog/claude-code-tips-best-practices">50 Claude Code Tips — Builder.io</a></li><li><a href="https://specterops.io/blog/2026/03/26/leveling-up-secure-code-reviews-with-claude-code/">Leveling Up Secure Code Reviews — SpecterOps</a></li><li><a href="https://towardsdatascience.com/how-to-effectively-review-claude-code-output/">How to Effectively Review Claude Code Output — Towards Data Science</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34b5c551c168" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Day Our Database Started Slowing Down (And What We Did About It)]]></title>
            <link>https://medium.com/@simaurya96/the-day-our-database-started-slowing-down-and-what-we-did-about-it-7b23b115fa1f?source=rss-9bbdb42015d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b23b115fa1f</guid>
            <category><![CDATA[garbage-collection]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Sneha Maurya]]></dc:creator>
            <pubDate>Fri, 27 Mar 2026 11:10:50 GMT</pubDate>
            <atom:updated>2026-03-27T11:10:50.417Z</atom:updated>
            <content:encoded><![CDATA[<h4>A story about PostgreSQL, invisible garbage, and the art of deleting data without breaking everything.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VjFR_cLwQ4kJNT2Cs6DU6A.png" /></figure><h3>The Slowdown Nobody Could Explain</h3><p>It started quietly.</p><p>The jobs that used to finish in 2 minutes were now taking 8. No new code had shipped. No traffic spike. No infrastructure change. Just… slowness. Creeping in like fog.</p><p>Our system — <strong>OrderFlow</strong>, an e-commerce order processing engine — had been running fine for over a year. It processed thousands of order batches every day, each one leaving behind a trail of records in PostgreSQL: order headers, line items, payment details, shipping info, fulfillment tasks. Millions of rows, accumulating month after month.</p><p>We blamed the queries first. Rewrote a few. Added an index. Nothing changed.</p><p>Then someone ran this:</p><pre>SELECT relname, n_dead_tup, n_live_tup<br>FROM pg_stat_user_tables<br>WHERE relname LIKE &#39;order%&#39;<br>ORDER BY n_dead_tup DESC;</pre><p>The results were uncomfortable.</p><pre>order_item           | 48,200,000 dead | 3,100,000 live<br>order_payment        | 31,000,000 dead | 1,800,000 live<br>warehouse_task       | 22,000,000 dead | 4,500,000 live</pre><p><strong>For every 1 live row, there were 15 dead ones.</strong> PostgreSQL was wading through a graveyard every time it ran a query.</p><h3>Why PostgreSQL Leaves Dead Bodies Behind</h3><p>Here’s something that surprises most developers the first time they hear it: <strong>when you DELETE a row in PostgreSQL, it doesn’t actually disappear.</strong></p><p>PostgreSQL uses a system called <strong>MVCC — Multi-Version Concurrency Control</strong>. The idea is clever: instead of locking a row when you update or delete it, PostgreSQL just marks the old version as “dead” and writes a new version. This means readers and writers never block each other — a huge win for performance.</p><p>But it comes with a cost. Those dead row versions — called <strong>dead tuples</strong> — sit in your table taking up space. They’re invisible to your queries, but they’re very much physically there. Every time PostgreSQL scans a table, it reads through all those dead rows too.</p><blockquote><em>🗄️ Think of it like a warehouse shelf. You cancel old orders by crossing them out on the manifest, but you never actually remove the paperwork from the shelf. Eventually the shelf is 90% cancelled orders and 10% real ones — and finding anything takes forever.</em></blockquote><p>This is <strong>table bloat</strong>. And it gets worse over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqgzrrgFS2uelQz_DLT5SA.png" /></figure><h3>Autovacuum: The Janitor That Couldn’t Keep Up</h3><p>PostgreSQL has a background process called <strong>autovacuum</strong> that’s supposed to clean up dead tuples automatically. Most of the time it works great. But autovacuum has limits:</p><ul><li>It runs on a schedule and can’t keep up with very high write/delete rates</li><li>It avoids tables under heavy load to prevent interference</li><li>It cleans up space within the table but <strong>doesn’t shrink the actual file size</strong></li><li>When tables are very large, a single vacuum pass takes a long time</li></ul><p>In our case, OrderFlow was inserting and “completing” millions of order records every week. Autovacuum was doing its best, but it was like <strong>one warehouse worker trying to clear out an entire fulfillment center after Black Friday</strong>. The dead tuples were accumulating faster than they were being removed.</p><p>The result: <strong>B-tree index bloat.</strong> PostgreSQL’s indexes also store dead tuple pointers, so the indexes were ballooning too. Every query that used an index was doing more work than it needed to.</p><h3>The Problem With Just Deleting Everything</h3><p>Our first instinct was simple: write a DELETE query, point it at old records, and fire it off.</p><pre>DELETE FROM order_item<br>WHERE created_at &lt; &#39;2024-06-01&#39;;</pre><p>We ran it in staging. It worked. Then we checked how long it took: <strong>47 minutes.</strong> And during those 47 minutes, it held locks that blocked other operations.</p><p>In production, that would have been a disaster. Customers can’t place orders while a cleanup job is hogging the database.</p><p>Here’s why bulk deletes on large tables are dangerous:</p><p><strong>1. One big transaction = one big lock.</strong> Other writes queue up waiting for it to finish. In an e-commerce system, that means order placements, payment confirmations, and shipping updates all grind to a halt.</p><p><strong>2. WAL pressure.</strong> Every deleted row gets written to PostgreSQL’s Write-Ahead Log. A massive delete generates a massive WAL spike, which can cause replication lag on read replicas.</p><p><strong>3. One giant vacuum job after.</strong> Once the big delete finishes, autovacuum has to process all those dead tuples at once — another slow, resource-intensive operation.</p><p><strong>4. If it fails halfway through,</strong> you roll back everything and start over.</p><blockquote><em>Bulk deletes feel clean. They’re not.</em></blockquote><h3>The Strategy: Small Bites, Respectfully</h3><p>The right way to delete large volumes of data from PostgreSQL is to do it in <strong>small, controlled chunks</strong> — and to respect the FK constraints that keep your data consistent.</p><p>Here’s the pattern we adopted for OrderFlow:</p><h3>1. Chunk Size Matters</h3><p>We settled on <strong>1,000 rows per transaction</strong>. Not 10,000. Not 100. One thousand.</p><ul><li>Small enough that each transaction finishes in milliseconds</li><li>Large enough that we make meaningful progress each run</li><li>Each chunk commits and releases its lock immediately</li></ul><pre>// Fetch a chunk of IDs to delete<br>List&lt;Long&gt; chunk = dao.findOrderItemIdsForBatch(batchId, 1000);</pre><pre>// Delete in one transaction — commits immediately<br>deleteOrderItemChunk(chunk);</pre><h3>2. Respect the FK Order — Always</h3><p>This one trips people up. PostgreSQL enforces foreign key constraints strictly. If you try to delete a parent row before its children, you get a constraint violation.</p><p>OrderFlow had a dependency chain like this:</p><p>The deletion order had to follow the chain <strong>bottom-up</strong>:</p><ol><li>order_payment — leaf</li><li>order_shipping — leaf</li><li>order_fulfillment_task — junction (points to both order_item and warehouse_task)</li><li>order_item — child of order_batch</li><li>order_batch — root, deleted last</li></ol><p>Skip any step and PostgreSQL throws a constraint violation and rolls back the whole transaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RHTVY0e9JR1oAFN8VrEXSg.png" /></figure><h3>3. One Batch Per Run</h3><p>Instead of trying to clean everything in one go, we designed the job to process <strong>exactly one old order batch per execution.</strong> The cron fires at 2 AM, cleans one batch fully (all its records, in chunks), and stops.</p><p>This gave us:</p><ul><li><strong>Predictable runtime</strong> — never more than 10 minutes</li><li><strong>Zero risk of runaway jobs</strong></li><li><strong>Easy blast radius control</strong> — advance the cutoff date manually when ready for more</li></ul><pre>db-cleanup:<br>  enabled: false           # flip to true when ready<br>  cutoffTimestamp: &quot;2024-06-01T00:00:00&quot;   # manually advanced<br>  chunkSize: 1000<br>  maxDurationMinutes: 10<br>  frequency: &quot;0 0 2 * * ?&quot;  # 2 AM daily</pre><h3>4. Time Cap + Failure Guard</h3><p>Two safety nets:</p><p><strong>Time cap</strong> — before processing each chunk, check if we’ve already been running for 10 minutes. If yes, stop and let the next run pick up where we left off. The batch stays in a partially-cleaned state, which is fine — we just pick the same batch next time.</p><p><strong>Consecutive failure limit</strong> — if 3 chunks in a row fail (DB error, deadlock, anything), stop immediately. Don’t keep hammering a broken state. Alert and wait for a human.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9iFdvdgh1cLzSLDBQX9-aw.png" /></figure><h3>What Happened After</h3><p>Here’s the satisfying part. After running the cleanup job for a few weeks:</p><pre>SELECT relname, n_dead_tup, n_live_tup,<br>       round(n_dead_tup::numeric / nullif(n_live_tup,0) * 100, 1) as dead_pct<br>FROM pg_stat_user_tables<br>WHERE relname LIKE &#39;order%&#39;;</pre><pre>order_item           | 180,000 dead | 2,900,000 live  | 6.2%<br>order_payment        | 92,000  dead | 1,700,000 live  | 5.4%<br>warehouse_task       | 61,000  dead | 4,200,000 live  | 1.5%</pre><p><strong>Dead tuple ratio dropped from 1500% to under 7%.</strong> Autovacuum could now easily keep up with the remaining churn.</p><p>And the jobs that were taking 8 minutes? <strong>Back to 2 minutes.</strong> No query rewrites. No new indexes. Just less garbage for PostgreSQL to wade through.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5GlzZII5BSWcYe0LubwXHA.png" /></figure><h3>The Key Lessons</h3><p><strong>1. PostgreSQL’s MVCC makes deletes invisible — until they’re not.</strong> Every DELETE leaves a dead tuple. In low-volume systems, autovacuum handles it quietly. In high-volume systems, it accumulates until it becomes a performance problem.</p><p><strong>2. Table bloat shows up as query slowness, not disk errors.</strong> You won’t get alerts. Queries just get gradually slower, and it’s hard to trace back to bloat without explicitly checking pg_stat_user_tables.</p><p><strong>3. Never delete millions of rows in one transaction.</strong> Chunk it. 1,000 rows per transaction is a good starting point. Each chunk commits immediately, releases locks, and gives autovacuum something manageable to clean up.</p><p><strong>4. FK constraints define your deletion order.</strong> Draw your ER diagram. Find the leaves. Delete bottom-up. There are no shortcuts here.</p><p><strong>5. Control the blast radius deliberately.</strong> A fixed cutoff date you advance manually is safer than a rolling retention window. It means <em>you</em> decide when to clean more — the system never surprises you.</p><p><strong>6. Let autovacuum do its job — just don’t overwhelm it.</strong> Small, regular deletes are autovacuum-friendly. One giant delete is not. Design your cleanup jobs as a partnership with autovacuum, not a replacement for it.</p><h3>The Cleanup Loop (Simplified)</h3><p>Here’s the core pattern, language-agnostic:</p><pre>every night at 2 AM:<br>  find the OLDEST incomplete order_batch older than cutoff<br>  if none found → run warehouse_task cleanup instead → done</pre><pre>  loop:<br>    if time &gt; 10 minutes → stop, resume tomorrow<br>    fetch next chunk of 1000 order_item IDs for this batch<br>    if no more records → delete the order_batch header → done</pre><pre>    in one transaction:<br>      delete order_payment WHERE order_item_uid IN (chunk)<br>      delete order_shipping WHERE order_item_uid IN (chunk)<br>      delete order_fulfillment_task WHERE order_item_uid IN (chunk)<br>      delete order_item WHERE uidpk IN (chunk)<br>    commit</pre><pre>    if 3 consecutive failures → alert + stop</pre><p>Simple. Safe. Boring in the best possible way.</p><h3>Final Thought</h3><p>The most dangerous kind of technical debt isn’t the code you wrote badly. It’s the <strong>data you forgot to clean up.</strong> It accumulates silently, causes no errors, triggers no alerts — until one day everything is just… slow.</p><p>PostgreSQL is incredibly good at handling large data. But it needs you to clean up after yourself. Give it small, regular deletions. Respect its constraints. And it’ll reward you with the performance it was always capable of.</p><p><strong>Your future on-call self will thank you.</strong></p><p><em>Have you dealt with table bloat in production? What was your wake-up moment? Drop it in the comments.</em></p><p><strong>Sources:</strong></p><ul><li><a href="https://skylinecodes.substack.com/p/postgresql-dead-tuples-mvcc-autovacuum">PostgreSQL Dead Tuples, MVCC &amp; Autovacuum — Skyline Codes</a></li><li><a href="https://www.postgresql.fastware.com/pzone/2025-03-improving-postgresql-efficiency-by-handling-dead-tuples">Improving PostgreSQL Efficiency by Handling Dead Tuples — Fastware</a></li><li><a href="https://www.percona.com/blog/basic-understanding-bloat-vacuum-postgresql-mvcc/">Basic Understanding of Bloat &amp; Vacuum in PostgreSQL — Percona</a></li><li><a href="https://cloud.google.com/blog/products/databases/deep-dive-into-postgresql-vacuum-garbage-collector">Deep Dive into PostgreSQL Vacuum — Google Cloud Blog</a></li><li><a href="https://medium.com/joor-engineering/delete-strategies-for-large-tables-using-postgres-c4e0734bb844">Delete Strategies for Large Tables Using Postgres — JOOR Engineering</a></li><li><a href="https://medium.com/@sobinsunny/database-mastery-deleting-4-million-records-from-postgresql-the-smart-way-dce9538c5e55">Deleting 4 Million Records from PostgreSQL the Smart Way — Sobin Sunny</a></li><li><a href="https://minervadb.xyz/how-do-i-delete-x-million-rows-from-postgresql-table-efficiently/">How to Delete Millions of Rows Efficiently — MinervaDB</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b23b115fa1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When Caching Fails Silently: Lessons Learned from a Spring Application]]></title>
            <link>https://medium.com/@simaurya96/when-caching-fails-silently-lessons-learned-from-a-spring-application-58236c9ffc4b?source=rss-9bbdb42015d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/58236c9ffc4b</guid>
            <dc:creator><![CDATA[Sneha Maurya]]></dc:creator>
            <pubDate>Thu, 11 Dec 2025 09:23:15 GMT</pubDate>
            <atom:updated>2026-01-12T06:52:24.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xP6i7uGrFjhUWSzYg5Z6Fg.png" /></figure><p>We once deployed a service that should have benefited massively from caching. The logic was correct, the annotations were in place, and everything worked perfectly in local testing.</p><p>But in production, something was off.Database queries continued to spike.Latency didn’t improve.And logs told us the painful truth:<br> <strong>almost every request was a cache MISS.</strong></p><p>There were no errors, no warnings — just a cache that quietly refused to work.</p><p>To understand these failures, let’s look at the implementation we started with. We had a service designed to fetch product search results. Since these results were expensive to compute, we used Spring’s @Cacheable with a custom KeyGenerator.</p><h4>The Service Implementation</h4><pre>@Service<br>public class ProductSearchService {<br>@Cacheable(<br>        cacheNames = &quot;product_search_cache&quot;, <br>        keyGenerator = &quot;searchRequestKeyGenerator&quot;, <br>        cacheManager = &quot;redisCacheManager&quot;<br>    )<br>    public List&lt;ProductResponse&gt; getAvailableProducts(SearchRequest request) {<br>        // Expensive database and filtering logic...<br>        return productRepository.findByCriteria(request);<br>    }<br>}</pre><h4>The Initial Key Generator</h4><p>We built a custom generator to create a unique key based on the user’s search criteria (like destination, currency, and category). On the surface, it looked like a standard, clean implementation:</p><pre>@Component(&quot;searchRequestKeyGenerator&quot;)<br>public class SearchRequestKeyGenerator implements KeyGenerator {    @Override<br>    public Object generate(Object target, Method method, Object... params) {<br>        // Checking if the first parameter is our SearchRequest object<br>        if (params.length &gt; 0 &amp;&amp; params[0] instanceof SearchRequest) {<br>            SearchRequest req = (SearchRequest) params[0];<br>// Constructing a composite key from relevant fields<br>            return new SearchKey(<br>                req.getNamespace(),<br>                req.getCountryCode(),<br>                req.getCurrency(),<br>                req.getCategoryType()<br>            );<br>        }<br>        // If not a SearchRequest, return null<br>        return null; <br>    }<br>    // A simple inner class to hold our composite key fields<br>    private static class SearchKey {<br>        private String namespace;<br>        private String country;<br>        private String currency;<br>        private String category;<br>        public SearchKey(String ns, String c, String curr, String cat) {<br>            this.namespace = ns;<br>            this.country = c;<br>            this.currency = curr;<br>            this.category = cat;<br>        }<br>    }<br>}</pre><p><strong>Why this code was a “Silent Failure” trap:</strong> Despite looking correct, this code contains almost every mistake .</p><p>What we discovered next became a masterclass in how caching actually works under the hood, and why even small mistakes can completely disable it.</p><h3>❌ 1. Returning null From a Key Generator</h3><p>One of the first discoveries was surprisingly simple: our custom key generator sometimes returned null.</p><h4>Why this breaks caching</h4><p>Spring interprets null as:</p><blockquote><em>“Do not cache this request.”</em></blockquote><p>Not as a valid key.<br> Not as a special case.<br> Just a silent bypass.</p><pre>return null; // ❌ never do this</pre><p>Even a small fallback like this saves the day:</p><pre>return &quot;FALLBACK_KEY&quot;; // ✔ always cacheable</pre><h3>❌ 2. Cache Keys Were Not Serializable</h3><p>In distributed environments (e.g., Redis, Hazelcast), keys <strong>must</strong> be serializable. Ours weren’t.</p><h4>Why this causes silent failures</h4><ul><li>Non-serializable keys can’t be stored or retrieved</li><li>Cache entries fail without obvious errors</li><li>Local dev works, production doesn’t</li></ul><pre>class MyKey implements Serializable { ... } // ✔ required</pre><h3>❌ 3. Missing equals() and hashCode()</h3><p>Two keys containing the same data weren’t considered equal.</p><h4>Why this breaks caching</h4><p>Caching relies on comparing keys.<br> If equality is broken:</p><ul><li>identical requests produce different keys</li><li>cache misses occur every time</li><li>memory fills with duplicate entries</li></ul><p><em>A tiny but essential implementation:</em></p><pre>@Override<br>public int hashCode() { return Objects.hash(country, type); }</pre><h3>❌ 4. Volatile Fields Sneaking Into Keys</h3><p>At one point, the key included a timestamp.</p><h4>Why this destroys hit rate</h4><p>Volatile fields → every request produces a unique key → hit rate becomes <strong>0%</strong>.</p><p><em>Bad:</em></p><pre>new Key(now()); // ❌ different each time</pre><p><em>Good:</em></p><pre>new Key(country, paymentType); // ✔ stable fields only</pre><h3>🔑 5. Key Generator Best Practices That Prevent Failure</h3><h4>✔ Always handle exceptions</h4><p>If key generation throws an exception and you don’t catch it, caching is skipped silently.</p><pre>catch (Exception e) {<br>    return &quot;ERROR_KEY&quot;; // ✔ graceful fallback<br>}</pre><h4>✔ Validate parameters</h4><p>Incorrect inputs = unpredictable keys = fragmented cache.</p><pre>if (!(params[0] instanceof RequestDto)) {<br>    return &quot;INVALID_KEY&quot;;<br>}</pre><h4>✔ Null-safe extraction avoids runtime surprises</h4><pre>String currency = req.getCurrency() != null ? req.getCurrency() : &quot;UNKNOWN&quot;;</pre><p>If not handled, null fields lead to inconsistent key generation — and more misses.</p><h3>🏗️ 6. Cache Key Design Principles That Actually Work</h3><h4>✔ Include only business-relevant stable fields</h4><p>This ensures the key reflects factors that truly affect the output.</p><pre>new MyKey(request.country(), request.methodType());</pre><h4>✔ Avoid unnecessary values</h4><p>Too many fields → too many unique keys → reduced hit rate.</p><h4>✔ Make keys readable</h4><p>A good toString() can reduce debugging time significantly.</p><h3>🐛 7. Debugging &amp; Observability: The Real Game-Changer</h3><h4>✔ Log cache misses</h4><p>Even a simple log line helps:</p><pre>Cache MISS for key={}</pre><h4>✔ Log generated keys (debug level)</h4><p>Understanding the actual key helps decode unexpected misses.</p><h4>✔ Monitor distribution</h4><p>If you see too many unique keys, your caching strategy needs adjustment.</p><h3>📊 8. Monitoring Performance: Measuring Real Impact</h3><p>Good caching should visibly improve metrics:</p><ul><li>DB queries go down</li><li>Latency improves</li><li>Hit ratio rises above 80%</li><li>Evictions and memory usage stabilize</li></ul><p>If none of these move, your cache isn’t helping — and likely isn’t working.</p><h3>🎯 Final Thoughts: Caching Is Easy to Enable, Hard to Get Right</h3><p>What we learned is simple:</p><p>Caching doesn’t fail loudly.<br> It fails <strong>silently</strong>, through a series of tiny mistakes that look harmless:</p><ul><li>returning null</li><li>forgetting Serializable</li><li>missing equals() and hashCode()</li><li>including volatile fields</li><li>not validating inputs</li></ul><p>But when we applied the right disciplines — stable keys, proper serialization, good logging, and strong key design — caching finally behaved the way we expected.</p><p><em>Caching isn’t magic. It’s engineering. When done right, it transforms systems. When done wrong, it does nothing — and tells you nothing.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58236c9ffc4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LangGraph vs LangChain: Why Agentic AI Needs a New Approach]]></title>
            <link>https://medium.com/@simaurya96/langgraph-vs-langchain-why-agentic-ai-needs-a-new-approach-fe7d1c5acdcb?source=rss-9bbdb42015d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe7d1c5acdcb</guid>
            <dc:creator><![CDATA[Sneha Maurya]]></dc:creator>
            <pubDate>Tue, 05 Aug 2025 06:43:47 GMT</pubDate>
            <atom:updated>2025-08-05T06:43:47.179Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q4WDsyU2Nm9-AVlLPBb-TA.jpeg" /></figure><h4>🎯 Introduction: The Evolution of AI Applications</h4><p>AI applications are evolving. We’re moving beyond simple, single-shot interactions to sophisticated, multi-step intelligent workflows. This shift from static chains to dynamic, decision-making agents is a fundamental change in how we build AI systems.</p><p>Let’s look at the difference:</p><p>❌ Traditional AI: Single-shot interactions</p><pre>def old_way():<br>    user_input = &quot;Help me with anxiety&quot;<br>    response = llm.invoke(user_input)<br>    return response # One-and-done, no memory, no intelligence</pre><p>✅ Agentic AI: Multi-step intelligent workflows</p><pre>def new_way():<br>    user_input = &quot;Help me with anxiety&quot;<br>    # 1. Analyze safety first<br>    # 2. Understand emotions<br>    # 3. Route to appropriate response<br>    # 4. Update memory<br>    # 5. Learn from patterns<br>    return intelligent_response</pre><p>This is where LangChain and its powerful successor, LangGraph, come into play. While LangChain gave us the fundamental building blocks, LangGraph introduces the framework for true agentic intelligence.</p><blockquote><strong>🔗LangChain = Building Blocks for AI Apps</strong></blockquote><p>LangChain is a powerful framework designed to help developers build applications with Large Language Models (LLMs). It provides a wide array of components and “chains” that link these components together in a linear sequence.</p><pre>from langchain.llms import OpenAI<br>from langchain.chains import LLMChain<br>from langchain.prompts import PromptTemplate<br><br># 🔗 LangChain: Linear chains of operations<br>prompt = PromptTemplate(template=&quot;Answer this: {question}&quot;)<br>llm = OpenAI()<br>chain = LLMChain(llm=llm, prompt=prompt)<br><br>result = chain.run(&quot;What is AI?&quot;) # Simple input → output</pre><blockquote><strong>🕸️</strong> <strong>LangGraph = Intelligent Agent Orchestration</strong></blockquote><p>LangGraph is an extension of LangChain built on top of it. It introduces a graph-based approach to defining workflows, allowing for loops, conditional branching, and persistent state management. This “graph-of-agents” model is what enables truly intelligent, multi-step reasoning.</p><pre>from langgraph.graph import StateGraph, END<br><br># 🕸️ LangGraph: Graph-based intelligent workflows<br>def create_smart_agent():<br>    workflow = StateGraph(State)<br>    <br>    # Add intelligent nodes<br>    workflow.add_node(&quot;analyze&quot;, analyze_input)<br>    workflow.add_node(&quot;decide&quot;, make_decision) <br>    workflow.add_node(&quot;respond&quot;, generate_response)<br>    workflow.add_node(&quot;remember&quot;, update_memory)<br>    <br>    # Add conditional routing (THE MAGIC!)<br>    workflow.add_conditional_edges(<br>        &quot;analyze&quot;,<br>        route_based_on_analysis,  # Intelligence happens here!<br>        {<br>            &quot;simple_question&quot;: &quot;respond&quot;,<br>            &quot;complex_problem&quot;: &quot;decide&quot;, <br>            &quot;crisis&quot;: &quot;emergency_support&quot;<br>        }<br>    )<br>    <br>    return workflow.compile()</pre><h4>🧠 Real Example: Customer Support Agent</h4><p>Imagine building a customer support agent.</p><p><strong>🔗 LangChain approach (limited):</strong></p><pre>def langchain_support(question):<br>    # This might use a pre-defined chain, but it&#39;s a linear path<br>    return llm.invoke(f&quot;Answer this support question: {question}&quot;)</pre><p>This is a simple Q&amp;A bot. It can answer a question, but it can’t adapt its behavior based on context.</p><p><strong>🕸️ LangGraph approach (intelligent):</strong></p><pre>def langgraph_support(question):<br>    # State flows through multiple intelligent nodes:<br>    # 1. classify_intent(question) -&gt; &quot;billing&quot; | &quot;technical&quot; | &quot;complaint&quot;<br>    # 2. route_to_specialist() -&gt; different handling based on classification<br>    # 3. check_user_history() -&gt; personalized response<br>    # 4. escalate_if_needed() -&gt; human handoff logic<br>    # 5. update_conversation_memory() -&gt; learn for next time<br>    pass</pre><p>This is a true agent. It can dynamically choose the best path, remember past conversations, and even escalate to a human.</p><h4><strong>🎯 Part 4: When to Use Which?</strong></h4><p><strong>🔗 Choose LangChain When: </strong>Use LangChain for simple, linear workflows like building basic chatbots or processing documents where a predictable sequence of steps is sufficient.</p><p><strong>🕸️ Choose LangGraph When: </strong>Choose LangGraph for building complex, intelligent agents that require conditional decision-making, persistent memory, and the ability to handle multi-step, non-linear problem-solving.</p><h4>🎉 Conclusion: The Future is Agentic</h4><p>LangChain gave us the essential building blocks for working with LLMs. LangGraph gives us the orchestration layer and the intelligence to connect those blocks into truly dynamic, stateful agents.</p><ul><li><strong>For simple applications</strong>, LangChain remains a powerful and efficient choice.</li><li><strong>For building intelligent, multi-step agents</strong>, LangGraph is the clear and superior path forward.</li></ul><p>Stay tuned for the next post in this series, where we’ll start building our own intelligent agent step-by-step using LangGraph!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe7d1c5acdcb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Selecting Right AI Models in Cursor]]></title>
            <link>https://medium.com/@simaurya96/selecting-right-ai-models-in-cursor-d77f34f6b6dd?source=rss-9bbdb42015d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d77f34f6b6dd</guid>
            <dc:creator><![CDATA[Sneha Maurya]]></dc:creator>
            <pubDate>Mon, 28 Jul 2025 09:05:47 GMT</pubDate>
            <atom:updated>2025-07-28T09:05:47.456Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*M6MtsQ2fM4kLB5f0.png" /><figcaption>image credit: <a href="https://www.fahimai.com/cursor-ai">https://www.fahimai.com/cursor-ai</a></figcaption></figure><p>Choosing the right AI model in Cursor can significantly impact your workflow, leading to <strong>faster output, higher quality suggestions, and optimized usage and costs</strong>. Just like working with humans, each model interprets prompts differently, and understanding these differences will help you select the best fit for your task.</p><p><em>How Models Differ</em>: Understanding Their Unique Styles</p><p>Models are trained in various ways, resulting in unique response styles. Some models are designed to “think before they code,” while others get straight to writing. Cursor supports all top-tier models, and while most can complete any task, their behavioral differences are crucial.</p><p>Here are some key dimensions to consider when distinguishing between models:</p><p>• <strong>Assertiveness</strong>: Models like gemini-2.5-pro or claude-4-sonnet are confident and make decisions with minimal prompting.</p><p>• <strong>Curiosity</strong>: Other models, such as o3 or claude-4-opus, take time to plan or ask questions to understand context more deeply.</p><p>• <strong>Context Window</strong>: Some models can process more of your codebase simultaneously, which is especially useful for large-scale tasks.</p><p><em>Model Behavior</em>: Thinking vs. Non-Thinking Models</p><p>One way to categorize models is by the initiative they take.</p><p>• <strong>Thinking Models</strong>: These models <strong>infer your intent, plan ahead, and often make decisions without needing step-by-step guidance</strong>.</p><p>◦ They are <strong>ideal for when you want the model to run with the task</strong>.</p><p>◦ They typically require <strong>less prompting</strong> but can be more opinionated.</p><p>◦ They might make bigger changes than you initially expect.</p><p>◦ Examples include claude-4-opus, gemini-2.5-pro, and o3 (which is designed for complex reasoning).</p><p>◦ Use them when you’re <strong>exploring ideas, broadly refactoring code, or need the model to act more independently</strong>. Thinking models are generally more expensive.</p><p>• <strong>Non-Thinking Models</strong>: These models <strong>wait for explicit instructions and do not infer or guess</strong>.</p><p>◦ They are <strong>ideal for precise, controlled changes</strong>.</p><p>◦ They require <strong>more prompting</strong> but behave more predictably.</p><p>◦ They are easier to guide, revise, and fine-tune.</p><p>◦ Examples include claude-4-sonnet and gpt-4.1.</p><p>◦ Use them when you <strong>need tight control, consistent behavior, or are working on well-defined tasks</strong>.</p><p>Many users also choose their preferred model based on their interaction style, with some preferring assertive models that take the lead, and others preferring models that wait for instruction. claude-4-sonnet, gemini-2.5-pro, and gpt-4.1 are all strong candidates for &quot;daily drivers,&quot; with your choice depending on how much control you desire.</p><p>How to Select the Right Model for Your Task</p><p>Cursor provides access to a curated set of high-performing models, and you can choose based on common factors like your prompting style and the task type.</p><p>1. <strong>Prompting Style</strong>:</p><p>◦ If you prefer to <strong>be in control and give clear instructions</strong>: Consider claude-4-sonnet or gpt-4.1.</p><p>◦ If you prefer to <strong>let the model take initiative</strong>: Consider claude-4-opus, gemini-2.5-pro, or o3.</p><p>2. <strong>Task Type</strong>:</p><p>◦ For <strong>directed changes</strong>: claude-4-sonnet, gemini-2.5-pro.</p><p>◦ For <strong>codebase navigation/search</strong>: gemini-2.5-pro, claude-4-opus, o3.</p><p>◦ For <strong>planning or problem-solving</strong>: claude-4-opus, gemini-2.5-pro.</p><p>◦ For <strong>complex bugs or deep reasoning</strong>: o3.</p><p>It’s important to note that o3 is specifically designed for complex, ambiguous problems. While powerful, it is also slower and more resource-intensive, making it better suited for occasional use rather than daily tasks.</p><p>Streamlining Your Workflow</p><p>• <strong>Auto-select</strong>: If you’re unsure which model to choose, the <strong>Auto option is a solid default</strong>. It keeps you in the flow by picking a reliable model from the available pool (excluding o3). Auto does not route based on task type, but serves as a safe default.</p><p>• <strong>Save What Works with Custom Modes</strong>: Once you discover effective combinations of prompts and models, you can save them as <strong>Custom Modes</strong>. This feature allows you to <strong>preselect a model, add custom instructions, and reuse the entire setup</strong> for future tasks, significantly streamlining your workflow.</p><p>Ultimately, the best model is the one that works best for you and your specific needs. Experimentation and developing your intuition about how each model “reads, thinks, and acts” will help you master model selection.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d77f34f6b6dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Meet Agentic AI ]]></title>
            <link>https://medium.com/@simaurya96/meet-agentic-ai-1fa5e311ce88?source=rss-9bbdb42015d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fa5e311ce88</guid>
            <category><![CDATA[aı]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[langchain]]></category>
            <dc:creator><![CDATA[Sneha Maurya]]></dc:creator>
            <pubDate>Sun, 06 Apr 2025 05:28:03 GMT</pubDate>
            <atom:updated>2025-04-06T05:28:03.273Z</atom:updated>
            <content:encoded><![CDATA[<p>You’ve probably heard all the AI buzz lately — chatbots, copilots, even tools that write code or create art. But now there’s a new cool kid in town: <strong>Agentic AI</strong>.</p><p>And no, it’s not a Marvel superhero (although it <em>is</em> kind of a genius).</p><p>Let’s break it down in a super simple way:<br> 💡 <strong>Agentic AI = AI that can think, plan, and <em>do</em> things for you.</strong></p><p>Sounds magical? It kinda is. Let’s dive in.</p><h3>☝️ So… What Even Is an AI Agent?</h3><p>Imagine you have a super intern.</p><p>This intern can:</p><ul><li>Understand what you want,</li><li>Think about how to do it,</li><li>Use tools (like Google, Notion, or a calculator),</li><li>And actually get it done — without you micromanaging.</li></ul><p>That’s what an <strong>AI agent</strong> does. It’s not just sitting around waiting to answer a question. It’s rolling up its sleeves, making decisions, and <em>doing stuff</em>.</p><p>For example:</p><blockquote><em>“Hey AI, summarize this 10-page PDF, find related research, and make a slide deck.”</em></blockquote><p>A regular AI model might just say: “Sure! Here’s a summary.”</p><p>But an agentic AI?<br> 👉 It reads the PDF, finds sources online, creates a plan, writes slides, and hands you a presentation.</p><h3>🧠 Wait… What Makes It Agentic?</h3><p>The magic word is: <strong>Autonomy</strong>.</p><p>Agentic AI doesn’t wait for step-by-step instructions. It:</p><ul><li><strong>Thinks for itself</strong> (kind of),</li><li><strong>Breaks big tasks into smaller steps</strong>,</li><li><strong>Remembers what it’s doing</strong>, and</li><li><strong>Loops through tasks</strong> until it gets the job done.</li></ul><p>It’s like upgrading your regular AI assistant into a mini project manager. 🧑‍💼✨</p><h3>🛠️ When Should I Use Agentic AI?</h3><p>Great question! Agentic AI shines when:</p><ul><li>The task is <strong>multi-step</strong> (not just “give me a joke”),</li><li>You need to <strong>automate something</strong>, like gathering info and sending emails,</li><li>You want the AI to <strong>use tools</strong>, like Slack, Gmail, or Notion,</li><li>You’re okay letting it “think” and act a bit on its own.</li></ul><p>But skip it when:</p><ul><li>You just need a quick, single-shot answer,</li><li>You’re working with sensitive stuff and can’t risk a rogue AI,</li><li>Speed and simplicity matter more than autonomy.</li></ul><h3>🤖 Types of AI Agents (aka Their Vibes)</h3><p>Here’s a fun breakdown of the kinds of agents out there:</p><ol><li><strong>Reactive Agents</strong> –<br> The goldfish 🐠 of AI. Acts on instinct, doesn’t remember anything.<br> Good for: Simple chatbots.</li><li><strong>Memory Agents</strong> –<br> They remember what you said earlier. Like a thoughtful barista who knows your order.<br> Good for: Customer support, conversations.</li><li><strong>Planning Agents</strong> –<br> The overachievers 📅. They love making lists and plans.<br> Good for: Research tasks, writing workflows.</li><li><strong>Tool-Using Agents</strong> –<br> The handy ones. Give them APIs or calculators and they go wild.<br> Good for: Data scraping, sending emails, generating reports.</li><li><strong>Multi-Agent Teams</strong> –<br> A squad of agents working together. One plans, one writes, one checks stuff.<br> Good for: Big tasks that need collaboration.</li></ol><h3>🚀 Real-World Use Cases (aka “Cool Stuff People Are Building”)</h3><ul><li><strong>Slack Newsletter Bot</strong>: Ask teammates for updates, format them nicely, and send a creative newsletter — automatically.</li><li><strong>AI Research Assistant</strong>: Summarizes papers, finds citations, and writes the literature review.</li><li><strong>AI Travel Planner</strong>: Picks destinations, checks flight times, and makes itineraries.</li></ul><p>The possibilities? Endless.</p><h3>✨ Final Thoughts</h3><p>Agentic AI isn’t just about making chatbots smarter — it’s about giving AI the ability to <em>act</em>, not just react. Whether it’s helping you write, plan, or build, think of it like a super assistant who gets smarter with every task.</p><p>So next time you’re stuck thinking,</p><blockquote><em>“Ugh, I wish someone could just handle this for me…”<br> Agentic AI might just be your new best friend.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fa5e311ce88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building our first NFT Marketplace ARCANE without writing single line of Solidity ]]></title>
            <link>https://medium.com/@simaurya96/building-our-first-nft-marketplace-arcane-without-writing-single-line-of-solidity-e7d8800131eb?source=rss-9bbdb42015d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7d8800131eb</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[thirdweb]]></category>
            <category><![CDATA[thirdweb-hackathon]]></category>
            <dc:creator><![CDATA[Sneha Maurya]]></dc:creator>
            <pubDate>Tue, 15 Feb 2022 17:46:37 GMT</pubDate>
            <atom:updated>2022-02-15T17:46:37.443Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="coverImage" src="https://cdn-images-1.medium.com/max/1024/0*n1buYvBu6TZDEEkd.png" /></figure><p>Gm folks! It’s 2022 😻, the year of getting ourselves in to web3. One morning we notice Hashnode dropped 2022’s first hackathon on Web 3.0 with ThirdWeb, isn’t it an amazing start for this year? Why wait for any further let’s go through what we have cooked for this Hackathon.</p><p>Before that, If you are new to web3 you must be wondering what’s Blockchain, NFT, and NFT marketplace? Don’t worry I got your back.</p><h4>⛓️ What is Blockchain?</h4><p>Well it’s hard to explain Blockchain in a one-liner but let me try</p><blockquote>Blockchain is a public database(ledger)📒 that is updated and shared across many computers(nodes) in a network.</blockquote><h4>👀 What is NFT?</h4><p>NFT stands for Non-Fungible Token. Wait it doesn’t make any sense right? I Know let me explain it when I said Non-fungible that means unique, there is no other of the same kind. bitcoin is fungible because when you trade one token for another you got the same, it’s different from the previous one. but when we say non-fungible that means if you trade one token that is totally unique in its way with another non-fungible token you got a different kind.</p><h4>🤔 What is NFT Marketplace?</h4><p>The marketplace is a common platform that acts as a market or meeting point for creators and collectors. Creators come to the marketplace and list their NFTs for sale and collectors buy those listed NFTs.</p><h4>🤷‍♀️Problem</h4><p>In past there was hardly one can verify the provenance of digital contents, like one can verify physical contents in traditional auctions that a given work of art is in fact the original one, not a replica. As we already know blockchain contains transaction history on a public ledger that is decentralized and can’t be altered, which serves the purpose of making any digital content unique in its own way. In laymen’s way, we can say tokenization of unique digital content on the blockchain is minting NFT.</p><p>We build a decentralized Marketplace app without writing a single line of solidity code, if you are thinking what’s so great about not writing solidity, let me tell you solidity is a strictly typed programming language that is used to write awesome smart contracts. It’s a newly developed language specifically writing smart contracts and deploying them on the Ethereum network. Many of us are not very comfortable in writing 👩🏼‍💻smart contract with solidity and understanding all the basic and important components for writing your own smart contract for NFT minting or for another purpose.</p><p>Then what should a person don’t want to write contracts but still want to build amazing web3 Dapps 🙇‍♂️. (🥁Drum roll, please !! ) here comes ThirdWeb.</p><p><strong>🌐thirdweb</strong></p><p>ThirdWeb is a portal that provides smart contracts, SDKs, and UI components that creators, developers, etc can integrate into their projects/apps. It’s a place where you can get all the web3 related tools and start building your awesome Dapp.</p><p>Using thirdweb SDK, project, and modules we didn’t require to pay much attention to the backend part of DApp. We only focus on integration which is totally easy for anyone who is a beginner in frontend development.</p><h4>💡Inspiration</h4><p>We got inspired by amazing NFT Marketplaces like <a href="https://opensea.io/">OpenSea</a>,<a href="https://rarible.com/">Rarible</a>.</p><h4>⚡That’s where ARCANE comes into the Play</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FmlAhhvsJ1a4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DmlAhhvsJ1a4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FmlAhhvsJ1a4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/13f7006aee556417a26f51ef89c7500e/href">https://medium.com/media/13f7006aee556417a26f51ef89c7500e/href</a></iframe><p>Well, ARCANE is an NFT marketplace where an artist can mint her/his digital content into NFT and store them on the blockchain, letting collectors purchase. <a href="https://nft-maket-place.vercel.app/">l<strong>ive demo</strong></a> We will start with having a crypto wallet. We recommend installing <a href="https://metamask.io/">Metamask</a>🦊</p><figure><img alt="Screenshot 2022-02-01 011935.png" src="https://cdn-images-1.medium.com/max/1024/0*WcE0Y_WwPYw0n-BU.png" /></figure><p>We login into thirdweb via crypto wallet, setting Mumbai as a network for creating projects and modules for our marketplace. We created NFT, Marketplace module with the current address. after setting up some permission we are ready to use our smart contracts via thirdweb SDK. Installing thirdweb SDK in Nextjs application.</p><pre>//Instantiate 3rdweb SDK<br> const rpcUrl = &quot;https://rpc-mumbai.maticvigil.com&quot;;<br> const privateKey = process.env.NEXT_PUBLIC_PRIVATE_KEY;<br><br> const wallet = new ethers.Wallet(<br>    privateKey,<br>    ethers.getDefaultProvider(rpcUrl)<br>  );<br><br>  const market = new ThirdwebSDK(wallet).getMarketplaceModule(<br>    MARKETPLACE_ADDRESS<br>  );</pre><p>Defining which module to use while minting NFT we needed the NFT module address and for listing and buying needed marketplace module address.</p><pre>// assign the smart contract address<br>const NFT_MODULE_ADDRESS = &quot;0x0C8fe5019D3B3BaC3B9e0878080C898518E02060&quot;;<br><br>// Instantiate NFT Collection module<br> const nft = new ThirdwebSDK(wallet).getNFTModule(NFT_MODULE_ADDRESS);</pre><p>it’s now time to mint your digital asset to another address</p><figure><img alt="Screenshot 2022-02-01 012019.png" src="https://cdn-images-1.medium.com/max/1024/0*5yaWGZlVH58J191N.png" /></figure><pre>// Minting the NFT asynchronously<br><br>import { ThirdwebSDK } from &quot;@3rdweb/sdk&quot;;<br>import { ethers } from &quot;ethers&quot;;<br><br>export default async function mint(req, res) {<br>  const rpcUrl = &quot;https://rpc-mumbai.maticvigil.com&quot;;<br><br>  const privateKey = process.env.NEXT_PUBLIC_PRIVATE_KEY;<br><br>  const NFT_MODULE_ADDRESS = &quot;0x0C8fe5019D3B3BaC3B9e0878080C898518E02060&quot;;<br><br>  const { account, name, decription, image } = await req.body;<br>  console.log(req.body);<br>  const wallet = new ethers.Wallet(<br>    privateKey,<br>    ethers.getDefaultProvider(rpcUrl)<br>  );<br><br>  // initialize the SDK and get the NFT Collection module<br>  const nft = new ThirdwebSDK(wallet).getNFTModule(NFT_MODULE_ADDRESS);<br>  await nft<br>    .mintTo(account, {<br>      name: name,<br>      decription: decription,<br>      image: image,<br>    })<br>    .then((metadata) =&gt; {<br>      console.log(metadata);<br>      res.send(JSON.stringify(metadata));<br>    })<br>    .catch((e) =&gt; console.log(e));<br>}</pre><p>for listing, we need both modules addresses.</p><pre>// Declaring the NFT Collection module address<br> const NFT_MODULE_ADDRESS = &quot;0x0C8fe5019D3B3BaC3B9e0878080C898518E02060&quot;;<br><br>// Declaring the MarketPlace  module address<br>  const MARKETPLACE_ADDRESS = &quot;0x229b1f789506dbea2052f8423a780b1be1c16f21&quot;;<br><br>// Initialize market module by passing in the module address<br><br>  const market = new ThirdwebSDK(wallet).getMarketplaceModule(<br>    MARKETPLACE_ADDRESS<br>  );</pre><p>you can list your minted NFT on the marketplace</p><figure><img alt="Screenshot 2022-02-01 011840.png" src="https://cdn-images-1.medium.com/max/1024/0*qa1bbc3eT1LrmA68.png" /></figure><pre>// the listingId of the listing you want to fetch data for<br>import { ThirdwebSDK } from &quot;@3rdweb/sdk&quot;;<br>import { ethers } from &quot;ethers&quot;;<br><br>export default async function list(req, res) {<br><br>  const rpcUrl = &quot;https://rpc-mumbai.maticvigil.com&quot;;<br>  const privateKey = process.env.NEXT_PUBLIC_PRIVATE_KEY;<br><br>  const NFT_MODULE_ADDRESS = &quot;0x0C8fe5019D3B3BaC3B9e0878080C898518E02060&quot;;<br>  const MARKETPLACE_ADDRESS = &quot;0x229b1f789506dbea2052f8423a780b1be1c16f21&quot;;<br> const TOKEN_ADDRESS = &quot;0x0000000000000000000000000000000000000000&quot;;  //MATIC Mumbai token address<br><br>  console.log(privateKey);<br><br>  const { tokenOffer, tokenId } = await req.body;<br><br>  console.log(req.body);<br><br>  const wallet = new ethers.Wallet(<br>    privateKey,<br>    ethers.getDefaultProvider(rpcUrl)<br>  );<br><br>  const market = new ThirdwebSDK(wallet).getMarketplaceModule(<br>    MARKETPLACE_ADDRESS<br>  );<br><br>  await market<br>    .createDirectListing({<br>      assetContractAddress: NFT_MODULE_ADDRESS,<br>      buyoutPricePerToken: ethers.utils.parseUnits(tokenOffer, 18),<br>      currencyContractAddress: TOKEN_ADDRESS,<br>      startTimeInSeconds: Math.floor(Date.now() / 1000),<br>      listingDurationInSeconds: 60 * 60 * 24,<br>      tokenId: tokenId,<br>      quantity: 1,<br>    })<br>    .then((data) =&gt; {<br>      console.log(data);<br>      res.send(JSON.stringify(data));<br>    })<br>    .catch((error) =&gt; {<br>      console.log(error);<br>    });<br>}</pre><p>🥳Woohooo!! we have minted our digital assets and listed them on the Polygon blockchain without writing any line of solidity smart contract way to go thirdweb ✨.</p><p>Now it’s time to reveal the tech-stack we have used to build this amazing marketplace 🙈</p><h4>📚 TechStack Used</h4><p><strong>Framework and Services</strong></p><ul><li><a href="https://nextjs.org/">NextJS</a> — for Frontend</li><li><a href="https://mui.com/getting-started/installation/">Material UI</a> — for styling the website</li><li><a href="https://thirdweb.com/">thirdweb</a> — for getting pre-build smart contracts</li></ul><p><strong>Libraries</strong></p><ul><li><a href="https://docs.ethers.io/v5/">ether.js</a>- for interacting with the Ethereum Blockchain and its ecosystem</li><li><a href="https://www.npmjs.com/package/axios">axios</a> — Promise based HTTP client for the browser and node.js</li><li><a href="https://docs.ipfs.io/reference/js/api/">ipfs-http-client</a> — The JavaScript HTTP RPC API client library for IPFS implementations.</li></ul><h4>👯‍♂️ Team and Collaborator</h4><p>I have been in collaboration with <a href="https://hashnode.com/@SnehaMaurya">Sneha Maurya</a> who handles backend, API/SDK integrations, and web3 related functionalities✌️.</p><h4>🚀 Deploying</h4><p>The whole app is deployed on <a href="https://nft-maket-place.vercel.app/">Vercel</a>, 🏃🏽‍♀️ go and check it out.</p><h4>🌐 Links and resources</h4><ul><li>Live demo — <a href="https://nft-maket-place.vercel.app/">ARCANE</a></li><li>Github Repository link -<a href="https://github.com/theashishmaurya/nftMaketPlace">Github-NFTMarketplace</a></li><li>connect to us on twitter — @sneha_kushw and @theashishmaurya</li></ul><h4>🤖 Future Possibilities</h4><ul><li>buying listed NFT using our custom/existing currency token form marketplace</li><li>adding royalties for minted NFTs.</li><li>adding more crypto wallets for accessing our website.</li></ul><p>This blog is posted using <a href="https://medium.com/www.blogtiple.com">Blogtiple</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7d8800131eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Begin with Solidity]]></title>
            <link>https://coinsbench.com/begin-with-solidity-7158d7238a21?source=rss-9bbdb42015d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/7158d7238a21</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Sneha Maurya]]></dc:creator>
            <pubDate>Tue, 08 Feb 2022 17:09:24 GMT</pubDate>
            <atom:updated>2022-07-20T09:38:18.346Z</atom:updated>
            <content:encoded><![CDATA[<p>gm! there. To understand what is Web3 is all about I have been learning and developing some small Dapps and trying to see through the lens of these decentralized applications. You must be wondering from where I’m getting this hands-on experience with DApp. I got you covered. <a href="https://buildspace.so/">buildspace</a> (tada!!!), they amazing DApps projects to practice and understands more about Web3 and the tools to implement it. Without any further due let’s learn to write some solidity code for your first smart contract.</p><p>“Solidity is an object-oriented, high-level language for implementing smart contracts”.</p><p>Before we jump to Solidity and language understanding let’s understand what is this Smart Contract is. Smart Contracts are programs stored on the blockchain and intended to execute automatically when predetermined conditions or agreements between two parties are met without any third-party interference.</p><figure><img alt="Build Smart contracts with.gif" src="https://cdn-images-1.medium.com/max/1024/0*Uh8c0Qlxu68vPIiu.gif" /></figure><p>If you want to deploy any smart contract on the Ethereum Blockchain network, you need to program that contract using solidity as a programming language.</p><p>Solidity is a statically-typed curly-braces language that runs on Ethereum Virtual Machine. It is highly influenced by c++, python, and javascript. It is partially designed after ECMAScript therefore you may have heard it is more similar to javascript. It follows the concept of inheritance as well.</p><p><strong>Solidity at a glance</strong></p><h4><strong>Contract Structure</strong></h4><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.7;<br><br>contract GMWorld{<br>    string private _msg;  // State variable<br><br>    function setMessage(string message) public {<br>        _msg=message;<br>    }<br><br>    function getMessage() public view returns(string){<br>        return _msg;<br>    }<br>}</pre><ul><li>the first line in the code below tells you the source code is licensed under MIT.</li></ul><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.7;</pre><ul><li>the second line is important because it tells you what version of the solidity compiler is valid to compile this file. (source code) The caret symbol (^) before the version number tells Solidity that it can use the latest build in a major version range. but it is better practice to drop the caret and tell solidity exactly what compiler version you expect. note: this version always matches with your solidity compiler, you’ll get errors if the version in your code mismatches with the version from the actual (build-in) solidity compiler.</li></ul><p>We define our smart contract by adding the <strong>contract</strong> keyword before defining the name of your contract, similar to the object-oriented programming language we define class by the <strong>class</strong> keyword. In the above code, my contract name is <strong>GMWorld</strong>.</p><p>Each contract can contain declarations of State Variables, Functions, Function Modifiers, Events, Errors, Struct Types, and Enum Types.</p><h4>State Variable:</h4><p>A variable whose value is stored in its contract storage. we can understand the state variable as a Global variable that stores the variable value in the contract storage.</p><p>As we know Solidity is a statically-typed programming language which means we need to define the type of a variable(state or local).</p><p>Data Type of state variable: Boolean Integer Address String Literals Enums</p><h4>Function Types: In solidity, we also declare a function with types that are external or internal.</h4><p><strong>external</strong> typed functions are called only outside the contract, they can’t be called from inside a contract where it is declared. (i.e f() doesn’t work in contract) <strong>internal</strong> typed functions are called only inside its contract (i.e. from within the current contract or contracts deriving from it) but not from outside the contract. <strong>public</strong> typed functions or state variables can be called publicly (from outside as well as from inside the contract). <strong>private</strong> typed functions or state variables are only visible for the contract they are defined in and not in derived contracts.</p><h4>Arrays</h4><p>Arrays can have a compile-time fixed size, or they can have a dynamic size.</p><pre>pragma solidity ^0.8.9;<br>contract MyContract {<br><br><br>      uint [] firstArr;  // Arrays in solidity with dynamic size<br>      uint [] secondArr =new unit[](4) // Arrays in solidity with fixed size<br><br>      function foo() external {   // CRUD<br><br>         // create<br>          firstArr.push(12);<br>          firstArr.push(45);<br><br>          // read<br>          console.log( firstArr[1]);<br><br>        //   update<br>          firstArr[0]=44;<br><br>          //delete<br>          delete firstArr[1];  <br>      }<br>    }</pre><h4>Structs</h4><p>Solidity provides a way to define new types in the form of structs.</p><pre>struct User{  //user defined data type<br>        address _address;<br>       string firstName;<br>       uint score;<br>    }<br>User[] users;<br><br>    function foo(string calldata _name) external{ //CRUD<br>        User memory user1=User(msg.sender,_name,0);  //create a new struct<br><br>         //read user field<br>         user1._address;<br><br>         // update<br>         user1.score =20;<br><br>         //delete<br>         delete user1;<br><br>         users.push(user1);<br><br>    }</pre><h4>Mapping Types</h4><p>Mapping type uses mapping(_KeyType =&gt; _ValueType) _VariableName the _keyType and _ValueType can be of any type built in types or user defined.</p><p>let’s take look at the code</p><pre>// SPDX-License-Identifier: GPL-3.0<br>pragma solidity &gt;=0.4.0 &lt;0.9.0;<br><br>contract MappingExample {<br>    mapping(address =&gt; uint) public balances; //key is address type and value is integer type<br><br>    function update(uint newBalance) public {<br>        balances[msg.sender] = newBalance;  //(msg.sender is address who is executing  contract)<br>    }<br>}<br><br>contract MappingUser {<br>    function f() public returns (uint) {<br>        MappingExample m = new MappingExample();<br>        m.update(100);<br>        return m.balances(address(this));<br>    }<br>}</pre><h4>Addresses</h4><p>Address type comes in two flavors, address and address payable, where it holds 20 bytes of address(address of Ethereum contract) address payable comes with additional member transfer and send if the address is payable where one can send ether to whereas only address type does not give such (ether transaction) facility.</p><p>There we go! we have completed Types in Solidity and are ready to dive in. For understanding more in-depth of each type and type conversion please go through the solidity document. <a href="https://docs.soliditylang.org/en/develop/types.html">https://docs.soliditylang.org/en/develop/types.html</a></p><p>This blog is posted using <a href="https://medium.com/www.blogtiple.com">Blogtiple</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7158d7238a21" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/begin-with-solidity-7158d7238a21">Begin with Solidity</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>