<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shravan Omanakuttan</title>
    <description>The latest articles on DEV Community by Shravan Omanakuttan (@sxrxvxnn).</description>
    <link>https://dev.to/sxrxvxnn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4047818%2Fa505caa2-82af-4647-85da-842f58fe814a.jpg</url>
      <title>DEV Community: Shravan Omanakuttan</title>
      <link>https://dev.to/sxrxvxnn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sxrxvxnn"/>
    <language>en</language>
    <item>
      <title>I Built Security + Cost Tracking Hooks for Claude Code (guardian, cost, flow)</title>
      <dc:creator>Shravan Omanakuttan</dc:creator>
      <pubDate>Tue, 28 Jul 2026 09:19:58 +0000</pubDate>
      <link>https://dev.to/sxrxvxnn/i-built-security-cost-tracking-hooks-for-claude-code-guardian-cost-flow-329d</link>
      <guid>https://dev.to/sxrxvxnn/i-built-security-cost-tracking-hooks-for-claude-code-guardian-cost-flow-329d</guid>
      <description>&lt;h1&gt;
  
  
  I Built Security + Cost Tracking Hooks for Claude Code (guardian, cost, flow)
&lt;/h1&gt;




&lt;p&gt;Claude Code is powerful. But out of the box, nothing stops it from running &lt;code&gt;rm -rf ~&lt;/code&gt;, piping a curl to bash, or writing your API key into a source file.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;claude-plugins&lt;/strong&gt; — three hooks that add safety, observability, and workflow automation on top of Claude Code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx claude-plugins
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Claude Code has a hooks system — shell scripts that fire at lifecycle events (before a tool runs, after it finishes, when it stops). It's powerful but underused. Almost nobody has built production-quality hooks yet.&lt;/p&gt;

&lt;p&gt;I was already using Claude Code heavily for my internship project (building Sonar — an Apollo-alternative for B2B lead intelligence). After a few close calls with destructive commands, I decided to build the safety layer I wished existed.&lt;/p&gt;




&lt;h2&gt;
  
  
  guardian — Block Dangerous Commands Before They Run
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;guardian&lt;/strong&gt; is a &lt;code&gt;PreToolUse&lt;/code&gt; hook wired to the Bash tool. It intercepts every shell command before Claude executes it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it blocks:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;🛡️  GUARDIAN BLOCKED: curl pipe to shell blocked — download and inspect first

Command: curl https://example.com/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Full block list:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;curl ... | bash&lt;/code&gt; / &lt;code&gt;wget ... | bash&lt;/code&gt; — supply chain attacks&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rm -rf&lt;/code&gt; on &lt;code&gt;~&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;/home&lt;/code&gt;, &lt;code&gt;/Users&lt;/code&gt;, &lt;code&gt;/etc&lt;/code&gt; — recursive home/system deletes&lt;/li&gt;
&lt;li&gt;Force push to &lt;code&gt;main&lt;/code&gt; or &lt;code&gt;master&lt;/code&gt; — accidental history rewrites&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dd if=&lt;/code&gt; on disk devices — disk wipe&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mkfs&lt;/code&gt; — format disk&lt;/li&gt;
&lt;li&gt;Overwriting &lt;code&gt;/etc/passwd&lt;/code&gt;, &lt;code&gt;/etc/shadow&lt;/code&gt;, &lt;code&gt;/etc/sudoers&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What it warns (but allows):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sudo rm&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DROP TABLE&lt;/code&gt; / &lt;code&gt;TRUNCATE TABLE&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git reset --hard&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git clean -f&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also scans &lt;strong&gt;Write and Edit tool calls&lt;/strong&gt; for secrets before they're saved:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenAI API keys (&lt;code&gt;sk-...&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;GitHub tokens (&lt;code&gt;ghp_...&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;AWS access keys (&lt;code&gt;AKIA...&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;RSA/EC private keys&lt;/li&gt;
&lt;li&gt;JWT tokens (hardcoded)&lt;/li&gt;
&lt;li&gt;Google API keys&lt;/li&gt;
&lt;li&gt;Slack tokens
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="err"&gt;🛡️&lt;/span&gt;  &lt;span class="nx"&gt;GUARDIAN&lt;/span&gt; &lt;span class="nx"&gt;BLOCKED&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Secret&lt;/span&gt; &lt;span class="nx"&gt;pattern&lt;/span&gt; &lt;span class="nx"&gt;detected&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt; &lt;span class="nx"&gt;write&lt;/span&gt;

&lt;span class="nx"&gt;File&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;
&lt;span class="nx"&gt;Detected&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;OpenAI&lt;/span&gt; &lt;span class="nx"&gt;API&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;

&lt;span class="nx"&gt;Move&lt;/span&gt; &lt;span class="nx"&gt;secrets&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="nx"&gt;files&lt;/span&gt; &lt;span class="nx"&gt;and&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;VARIABLE_NAME&lt;/span&gt; &lt;span class="nx"&gt;instead&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It covers &lt;code&gt;Write&lt;/code&gt;, &lt;code&gt;Edit&lt;/code&gt;, &lt;code&gt;MultiEdit&lt;/code&gt;, and &lt;code&gt;NotebookEdit&lt;/code&gt; — every tool that can write to a file.&lt;/p&gt;




&lt;h2&gt;
  
  
  cost — Track Token Cost Per Session
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;cost&lt;/strong&gt; is a &lt;code&gt;PostToolUse&lt;/code&gt; hook that fires after every tool call and accumulates a running total.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;💰 Session: 23 tool calls · ~48,200 tokens · $0.0821 · 14min
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every session is logged to &lt;code&gt;~/.claude/cost-tracker/&lt;/code&gt; as a JSONL file. View reports anytime:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude-cost today
claude-cost all
claude-cost &lt;span class="nb"&gt;date &lt;/span&gt;2026-07-28
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Report output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;💰 Claude Cost Report — Today (2026-07-28)
──────────────────────────────────────────────────
  Tool calls:    47
  Input tokens:  ~92,400
  Output tokens: ~18,600
  Total tokens:  ~111,000
  Estimated cost: $0.5565

  By tool:
    Bash                 21 calls
    Edit                 12 calls
    Read                  8 calls
    Write                 6 calls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Token counts are estimated from input/output text length (1 token ≈ 4 chars). Not exact but close enough for tracking spend trends.&lt;/p&gt;




&lt;h2&gt;
  
  
  flow — macOS Notification When Claude Finishes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;flow&lt;/strong&gt; is a &lt;code&gt;Stop&lt;/code&gt; hook. When Claude finishes a task, you get a macOS notification with the session summary — so you can tab away and come back when it's done.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✅ Claude done — 31 tool calls · $0.0943 today
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also supports &lt;strong&gt;auto-commit&lt;/strong&gt; — set &lt;code&gt;CLAUDE_FLOW_AUTO_COMMIT=1&lt;/code&gt; and every time Claude stops, it stages and commits all changes automatically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;CLAUDE_FLOW_AUTO_COMMIT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;📦 Auto-committed: chore: update 4 files (claude-flow auto-commit)
✅ Claude done — 31 tool calls · $0.0943 today
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  How Claude Code Hooks Work
&lt;/h2&gt;

&lt;p&gt;Hooks receive JSON on stdin and exit 0 to allow or exit 2 to block (PreToolUse only):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stdin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;chunk&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stdin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stdin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;end&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;command&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tool_input&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;command&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;command&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;something-dangerous&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Blocked: reason&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// block the tool call&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// allow&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Event&lt;/th&gt;
&lt;th&gt;Fires when&lt;/th&gt;
&lt;th&gt;Can block?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PreToolUse&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Before any tool runs&lt;/td&gt;
&lt;td&gt;✅ exit 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PostToolUse&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;After any tool runs&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Stop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Claude finishes&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;UserPromptSubmit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;User sends message&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Hooks are wired in &lt;code&gt;~/.claude/settings.json&lt;/code&gt;. The installer merges safely — it never overwrites existing hooks.&lt;/p&gt;




&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx claude-plugins
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pick which plugins to install. Restart Claude Code after.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;╔══════════════════════════════════════╗
║     claude-plugins installer         ║
╚══════════════════════════════════════╝

Install [guardian] — Blocks dangerous bash commands + detects secrets? [y/N] y
  ✓ PreToolUse → guardian.js
  ✓ PreToolUse → file-guardian.js

Install [cost] — Tracks tool calls and estimates token cost? [y/N] y
  ✓ PostToolUse → cost-track.js

Install [flow] — macOS notification when Claude finishes? [y/N] y
  ✓ Stop → flow-on-stop.js

✓ Done. Restart Claude Code to activate.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To uninstall:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx claude-plugins &lt;span class="nt"&gt;--uninstall&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;Looking for contributors — especially:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows notification support for flow&lt;/li&gt;
&lt;li&gt;Slack/Discord webhook on Stop&lt;/li&gt;
&lt;li&gt;Auto git commit message generation from diff&lt;/li&gt;
&lt;li&gt;Audit log hook (log every tool call to file)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/sxrxvxnn/claude-plugins" rel="noopener noreferrer"&gt;github.com/sxrxvxnn/claude-plugins&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you use Claude Code daily, give it a try. guardian alone has already saved me from a few bad days.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Also building &lt;a href="https://github.com/sxrxvxnn/mac-ssd-toolkit" rel="noopener noreferrer"&gt;mac-ssd-toolkit&lt;/a&gt; — 27 shell scripts for using an external SSD as your Mac's primary storage.&lt;/em&gt;&lt;/p&gt;




</description>
      <category>claude</category>
      <category>security</category>
      <category>opensource</category>
      <category>devtools</category>
    </item>
    <item>
      <title>How I Freed 15GB on My 256GB MacBook and Made an External SSD My Primary Storage (With 46 Automation Scripts)</title>
      <dc:creator>Shravan Omanakuttan</dc:creator>
      <pubDate>Sun, 26 Jul 2026 10:59:55 +0000</pubDate>
      <link>https://dev.to/sxrxvxnn/how-i-freed-15gb-on-my-256gb-macbook-and-made-an-external-ssd-my-primary-storage-with-46-55i8</link>
      <guid>https://dev.to/sxrxvxnn/how-i-freed-15gb-on-my-256gb-macbook-and-made-an-external-ssd-my-primary-storage-with-46-55i8</guid>
      <description>&lt;p&gt;My MacBook's internal storage was full. Not "almost full" — &lt;strong&gt;full&lt;/strong&gt;. No more space for new projects, no room for dependencies, constant "Your disk is almost full" alerts.&lt;/p&gt;

&lt;p&gt;I had a 1TB external SSD sitting on my desk doing nothing.&lt;/p&gt;

&lt;p&gt;So I built a system to use the SSD as my Mac's primary storage — transparently, automatically, with a full terminal menu and 18 scheduled automation scripts running in the background.&lt;/p&gt;

&lt;p&gt;Here's exactly how I did it, and how you can too.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;256GB internal SSD. Here's what was eating it:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What&lt;/th&gt;
&lt;th&gt;Size&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Notion app data&lt;/td&gt;
&lt;td&gt;7.7G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Chrome cache&lt;/td&gt;
&lt;td&gt;7.4G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude desktop&lt;/td&gt;
&lt;td&gt;6.8G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OperaGX&lt;/td&gt;
&lt;td&gt;1.6G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;VS Code&lt;/td&gt;
&lt;td&gt;1.7G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Discord&lt;/td&gt;
&lt;td&gt;998M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Whisky (unused)&lt;/td&gt;
&lt;td&gt;854M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wondershare installer&lt;/td&gt;
&lt;td&gt;493M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TabNine models&lt;/td&gt;
&lt;td&gt;477M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;.rustup&lt;/code&gt; toolchain&lt;/td&gt;
&lt;td&gt;1.4G&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;.android&lt;/code&gt; SDK&lt;/td&gt;
&lt;td&gt;515M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.pub-cache&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;434M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;.nvm&lt;/code&gt; Node versions&lt;/td&gt;
&lt;td&gt;204M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;.npm&lt;/code&gt; cache&lt;/td&gt;
&lt;td&gt;460M&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That's &lt;strong&gt;~30GB&lt;/strong&gt; in things that either don't need to be on the internal drive or can be moved transparently.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Solution: SSD as Primary Storage via Symlinks
&lt;/h2&gt;

&lt;p&gt;The core idea is simple. macOS follows symlinks transparently — apps and tools have no idea they're reading from an external drive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Move Downloads to SSD&lt;/span&gt;
&lt;span class="nb"&gt;mv&lt;/span&gt; ~/Downloads /Volumes/007/Downloads
&lt;span class="nb"&gt;ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; /Volumes/007/Downloads ~/Downloads

&lt;span class="c"&gt;# Now everything that writes to ~/Downloads&lt;/span&gt;
&lt;span class="c"&gt;# actually writes to the SSD — no config changes needed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I did this for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;~/Downloads&lt;/code&gt;, &lt;code&gt;~/Documents&lt;/code&gt;, &lt;code&gt;~/Desktop&lt;/code&gt;, &lt;code&gt;~/Movies&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;All Dev projects (&lt;code&gt;leadgen-platform&lt;/code&gt;, &lt;code&gt;linkedin_automate&lt;/code&gt;, etc.)&lt;/li&gt;
&lt;li&gt;Toolchains: &lt;code&gt;.rustup&lt;/code&gt;, &lt;code&gt;.cargo&lt;/code&gt;, &lt;code&gt;.android&lt;/code&gt;, &lt;code&gt;.nvm&lt;/code&gt;, &lt;code&gt;.npm&lt;/code&gt;, &lt;code&gt;.m2&lt;/code&gt;, &lt;code&gt;.gradle&lt;/code&gt;, &lt;code&gt;.pub-cache&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Result: 36GB freed on internal. Mac went from 96% full to 68% full in one session.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Automation Layer
&lt;/h2&gt;

&lt;p&gt;Moving files manually is a one-time fix. The real value is automation. I built 27 shell scripts and wired them to macOS launchd.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;ssd&lt;/code&gt; — Terminal Menu for SSD Management
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  ╔═══════════════════════════════════════════════════════════════════════╗
  ║                      ◈  SSD TOOLS — 007  ◈                           ║
  ╚═══════════════════════════════════════════════════════════════════════╝

  ● SSD 007   899G free / 33G used       ● Mac Internal  36G free / 17G used

  STORAGE &amp;amp; SYSTEM
  ┌──────┬──────────────────────┬────────────────────────────────────────┐
  │  1   │  mount-check         │  Check SSD mount + symlink health      │
  │  2   │  cache-cleanup       │  Clear caches (Library, npm, pnpm)     │
  │  3   │  low-disk-alert      │  Check internal Mac free space         │
  │  7   │  duplicate-finder    │  Scan SSD for duplicate files          │
  │ 12   │  ssd-health          │  SSD space + fill prediction           │
  └──────┴──────────────────────┴────────────────────────────────────────┘

  DEV &amp;amp; CODE
  ┌──────┬──────────────────────┬────────────────────────────────────────┐
  │  5   │  dev-backup          │  Rsync active projects to backup       │
  │  9   │  git-status          │  Uncommitted changes across projects   │
  │ 20   │  env-backup          │  Backup all .env files                 │
  │ 25   │  focus-mode          │  Block distractions (25min)            │
  └──────┴──────────────────────┴────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;mac&lt;/code&gt; — Terminal Menu for Mac System Tools
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  ╔═══════════════════════════════════════════════════════════════════════╗
  ║                    ◈  MAC TOOLS — SHRAVAN  ◈                         ║
  ╚═══════════════════════════════════════════════════════════════════════╝

  CPU 12%   Battery 100% (charged)   Uptime 2 days
  Wifi HomeNetwork   IP 192.168.1.6

  SYSTEM        APPS           MAINTENANCE      SECURITY        POWER
  system-stats  kill-hogs      clear-caches     firewall-status caffeinate
  battery-health app-usage     brew-update      open-ports      sleep-timer
  wifi-info     startup-items  run-all-agents   lock-screen     battery-saver
  processes     force-quit     large-files      ssh-keys
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The 18 Scheduled LaunchAgents
&lt;/h2&gt;

&lt;p&gt;These run automatically via macOS launchd — no cron, no manual triggers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check what's running&lt;/span&gt;
launchctl list | &lt;span class="nb"&gt;grep &lt;/span&gt;shravan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Agent&lt;/th&gt;
&lt;th&gt;Schedule&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;dev-backup&lt;/td&gt;
&lt;td&gt;Nightly 11pm&lt;/td&gt;
&lt;td&gt;Rsync projects to SSD backup, keeps 7 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;dotfiles-backup&lt;/td&gt;
&lt;td&gt;Nightly 10:30pm&lt;/td&gt;
&lt;td&gt;Backup .zshrc, .gitconfig, SSH config&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;env-backup&lt;/td&gt;
&lt;td&gt;Nightly 10pm&lt;/td&gt;
&lt;td&gt;Backup all .env files, keeps 14 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cache-cleanup&lt;/td&gt;
&lt;td&gt;Monday 9am&lt;/td&gt;
&lt;td&gt;Clear Library/Caches, npm, pnpm&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;git-status&lt;/td&gt;
&lt;td&gt;Daily 9am&lt;/td&gt;
&lt;td&gt;Report uncommitted changes across all projects&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;dep-audit&lt;/td&gt;
&lt;td&gt;Monday 10am&lt;/td&gt;
&lt;td&gt;npm vulnerability scan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ssd-health&lt;/td&gt;
&lt;td&gt;Daily 10am&lt;/td&gt;
&lt;td&gt;Space usage + fill rate prediction&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;low-disk-alert&lt;/td&gt;
&lt;td&gt;Every hour&lt;/td&gt;
&lt;td&gt;Alert if Mac internal &amp;lt; 5GB free&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ram-monitor&lt;/td&gt;
&lt;td&gt;Every 5min&lt;/td&gt;
&lt;td&gt;Log RAM usage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;battery-logger&lt;/td&gt;
&lt;td&gt;Daily 12pm&lt;/td&gt;
&lt;td&gt;Log battery cycles + health&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Serial Lock: SSD Only Works on My Mac
&lt;/h2&gt;

&lt;p&gt;I didn't want the SSD to work if stolen. So I built a serial number lock:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/zsh&lt;/span&gt;
&lt;span class="nv"&gt;AUTHORIZED_SERIAL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"CPWY0XTG9Y"&lt;/span&gt;
&lt;span class="nv"&gt;CURRENT_SERIAL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;system_profiler SPHardwareDataType | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Serial Number"&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $NF}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$CURRENT_SERIAL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$AUTHORIZED_SERIAL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;diskutil eject disk5
  osascript &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'display alert "Unauthorized Mac. SSD ejected." as critical'&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This fires automatically via a WatchPaths LaunchAgent whenever the SSD mounts. Wrong Mac → instant eject.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Install Script
&lt;/h2&gt;

&lt;p&gt;The whole toolkit is packaged with a one-command installer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/sxrxvxnn/mac-ssd-toolkit
&lt;span class="nb"&gt;cd &lt;/span&gt;mac-ssd-toolkit
./install.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It asks for your username, SSD volume name, and project names — then configures everything, installs LaunchAgents, and adds aliases to &lt;code&gt;.zshrc&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;23GB free&lt;/td&gt;
&lt;td&gt;36GB free&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Manual backups&lt;/td&gt;
&lt;td&gt;Nightly automated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No disk monitoring&lt;/td&gt;
&lt;td&gt;Hourly alerts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scattered dotfiles&lt;/td&gt;
&lt;td&gt;Nightly backup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No SSD security&lt;/td&gt;
&lt;td&gt;Serial lock&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;The repo is open source and looking for contributors. If you have ideas for new scripts — storage tools, dev workflow automation, system monitoring — open an issue or PR.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/sxrxvxnn/mac-ssd-toolkit" rel="noopener noreferrer"&gt;github.com/sxrxvxnn/mac-ssd-toolkit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ideas already in the backlog:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git commit streak tracker&lt;/li&gt;
&lt;li&gt;Wifi speed daily logger&lt;/li&gt;
&lt;li&gt;Auto-organize Downloads by file type&lt;/li&gt;
&lt;li&gt;Monthly storage trend report&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're a Mac developer with limited internal storage, give it a try. One command and you're set up.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built while working as a BD intern at Beagle Security, building &lt;a href="https://github.com/sxrxvxnn/leadgen-platform" rel="noopener noreferrer"&gt;Sonar&lt;/a&gt; — an Apollo-style B2B intelligence platform.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>productivity</category>
      <category>terminal</category>
      <category>opensource</category>
      <category>macos</category>
    </item>
  </channel>
</rss>
