<?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 Ybmarketing on Medium]]></title>
        <description><![CDATA[Stories by Ybmarketing on Medium]]></description>
        <link>https://medium.com/@ybmarketing24?source=rss-516abdd4ba05------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*I7hv5a2eN-7N9h7n</url>
            <title>Stories by Ybmarketing on Medium</title>
            <link>https://medium.com/@ybmarketing24?source=rss-516abdd4ba05------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:31:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ybmarketing24/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How Do You Build an App That Deletes Files — Without Ever Destroying Someone’s Work?]]></title>
            <link>https://medium.com/@ybmarketing24/how-do-you-build-an-app-that-deletes-files-without-ever-destroying-someones-work-b2c189eb88f2?source=rss-516abdd4ba05------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2c189eb88f2</guid>
            <category><![CDATA[brew]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Ybmarketing]]></dc:creator>
            <pubDate>Mon, 28 Sep 2026 14:45:41 GMT</pubDate>
            <atom:updated>2026-09-28T14:49:28.536Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zKxDsvtRcqAAH7bbsK7ipw.png" /></figure><p><em>A few hard rules, enforced in code rather than in intentions.</em></p><p>Most Mac apps fail politely. A crashed editor loses your unsaved buffer; you grumble and move on. A disk cleaner that gets it wrong loses something else entirely — your conversation history with your AI agents, your custom skills, the Claude projects you’ve been curating for months. There is no Cmd+Z for a file that was never in version control.</p><p>I’ve spent the last few months building <a href="https://disktiny.com/"><strong>DiskTiny</strong></a>, a native macOS developer disk-space reclaimer (Swift 6, SwiftUI, zero dependencies). Its entire job is to find gigabytes of disposable junk — Xcode DerivedData, node_modules, Cargo target/ folders, stale simulators, Docker layers — and delete them.</p><p>That makes it the scariest category of app to build. Here is the design contract I ended up with, and why every rule in it exists.</p><h3>The problem is that the junk and your life live in the same directories</h3><p>Before writing a single line of the deletion path, I measured what’s actually on a working developer Mac (mine, September 2026):</p><p>PathSizeWhat it actually is~/Library/Application Support/Claude/vm_bundles11 GBsandbox VM images — re-downloadable, but a huge download~/.codex/sessions2.9 GB<strong>the user&#39;s agent conversation history</strong>~/.claude/skills2.3 GB<strong>the user&#39;s own skills</strong>~/.cursor/extensions1.6 GB<strong>installed extensions</strong>~/.claude/projects522 MB<strong>the user&#39;s memory files</strong></p><p>Read that table again slowly. Five directories, all sitting under tool folders, all huge. Exactly one of them is safe to delete. The other four are work the user cannot get back.</p><p>That is the entire design problem in one table: developer tool directories mix disposable cache with irreplaceable user data, often as direct siblings. Any cleaner that works at the granularity of “this tool’s folder” will eventually eat someone’s memory files.</p><p>So the safety policy isn’t a feature of DiskTiny. It’s the product. Everything else — the scanners, the UI, the licensing — is built on top of three rules.</p><h3>Rule 1: Allowlist, never denylist</h3><p>A scanner may only ever offer a path it has <strong>explicitly listed</strong>. Never a tool’s root directory. Never “everything under X except Y.”</p><p>This sounds restrictive, and it is — deliberately. Consider the two failure modes:</p><ul><li><strong>Allowlist typo:</strong> a path is missing from the list. The scanner <em>misses</em> some reclaimable space. The user gets back 40 GB instead of 41 GB and never knows.</li><li><strong>Denylist typo:</strong> a path is missing from the “never touch” list. The scanner <em>offers to delete it</em>. And someone clicks.</li></ul><p>A typo can then only ever <em>miss</em> space, never destroy data. That asymmetry is the whole point.</p><p>The obvious alternative — a global rule like “never delete anything called projects&quot; — fails in the other direction: it would also block a perfectly ordinary ~/Projects/app/node_modules, which is exactly the sort of thing a disk cleaner exists to find. Blocklists are seductive because they feel thorough. They&#39;re thorough the way a fire hose is.</p><h3>Rule 2: Discovery and deletion must be two independent mechanisms</h3><p>An allowlist on the scanner side is not enough, because software has bugs. If the <em>only</em> thing standing between ~/.claude/projects and the Trash is one scanner&#39;s if statement, then one refactor away from disaster.</p><p>So DiskTiny checks twice, in code that knows nothing about scanners:</p><ol><li><strong>Discovery:</strong> each scanner has an explicit per-tool allowlist.</li><li><strong>Deletion:</strong> TrashDeletionService consults DeletionGuard for <em>every</em> item, right before it moves anything. DeletionGuard knows nothing about which scanner produced the path — it only knows which paths are structurally forbidden.</li></ol><pre>/// `nil` when the path may be removed; otherwise why it may not.<br>public static func refusalReason(for url: URL) -&gt; String? {<br>    let target = url.standardizedFileURL<br>    let targetKey = key(target)</pre><pre>    if criticalRoots.contains(targetKey) {<br>        return &quot;system or home directory&quot;<br>    }<br>    let roots = toolRoots<br>    if roots.contains(targetKey) {<br>        return &quot;the tool&#39;s own directory — only its caches may be removed&quot;<br>    }<br>    if roots.contains(key(target.deletingLastPathComponent())),<br>       protectedChildNames.contains(target.lastPathComponent.lowercased()) {<br>        return &quot;holds your own work (\(target.lastPathComponent)), not a cache&quot;<br>    }<br>    return nil<br>}</pre><p>criticalRoots is the boring-but-essential list: the home directory itself, /System, /Library, /usr, your Documents and Desktop, and so on. toolRoots is every AI/editor tool state directory (.claude, .codex, .cursor, .warp, …) plus — importantly — <strong>everything</strong> under ~/Library/Application Support, because Application Support folders are where apps keep state, not cache. protectedChildNames are names that mean &quot;the user&#39;s own work&quot; — sessions, skills, memory, history, credentials — but <em>scoped to sit directly under a tool root</em>, so the global-projects-rule mistake from Rule 1 doesn&#39;t get repeated here.</p><p>The function returns a <em>reason</em>, not just a boolean, for a simple reason: “no” teaches nothing, but “this holds your own work (sessions), not a cache” is a sentence you can show the developer who hit it.</p><h3>The bug that justified the whole rule</h3><p>While building the guard, I found a detail that would have silently defeated it: <strong>URL equality is sensitive to a trailing slash.</strong> For Foundation, …/Claude and …/Claude/ are <em>different</em> URLs pointing at the same directory. If the guard compared URLs and some code path upstream appended a slash, the protected path simply wouldn&#39;t match the protected set. A guard that a slash can walk past is not a guard.</p><p>So the guard compares String paths — url.standardizedFileURL.path — never URLs. It&#39;s the kind of thing you can only learn by writing the test that <em>tries to walk past</em> your own defense, which is now a permanent part of the test suite.</p><h3>Rule 3: Three tiers, honestly labelled — and the honest one is the hard part</h3><p>Every item DiskTiny shows carries one of three labels:</p><p>TierPre-selected for you?The copy must say<strong>Safe</strong> — it rebuilds/re-downloads itself<strong>Caution</strong>never<em>what it is in plain words</em><strong>Protected</strong>not shown at all —</p><p>The temptation in this product category is a big “Clean!” button with everything ticked, because that’s what makes the demo screenshots impressive. DiskTiny went the other way, twice:</p><p><strong>First: nothing is ever pre-ticked.</strong> Earlier versions pre-ticked “Safe” items; I removed that. Now a tick always means the user made one, which has a subtle second benefit — the Clean button’s total can be <em>trusted</em>, no matter how the list is filtered, because it’s always exactly the sum of what the user chose.</p><p><strong>Second: “Caution” alone is not informed consent.</strong> A label that just says <em>caution</em> teaches the user nothing about the trade they’re making. The row for ~/.codex/sessions doesn&#39;t say &quot;Caution — 2.9 GB&quot;; it says this is your agent conversation history. If the cost of deletion is &quot;a large re-download,&quot; it says that. If it&#39;s &quot;state you would notice losing,&quot; it says that. The copy has to name the real consequence, because the user is the one deciding.</p><p>And because “we never delete anything ourselves” would be a lie, the README says where the product still decides: <strong>Quick Sweep</strong> in the menu bar purges every Safe item in one click with no confirmation sheet — limited to Safe, non-git-dirty items, but it is the one path where a click removes files without a review step. Shipping a deletion tool means writing down your exceptions, not pretending you don’t have any.</p><h3>One guard I’m particularly fond of: the Git-Dirty check</h3><p>Most disk cleaners treat a node_modules folder as a property of the filesystem. But it&#39;s a property of a <em>project</em> — and projects have state that matters: uncommitted work.</p><p>Before DiskTiny lists anything from a repo, it checks whether that repo has uncommitted changes to tracked files, and if so, forces every item inside it to Caution and unticks it. Git-dirty projects are never auto-selected, whatever their label.</p><p>The fun part: it does this with <strong>no </strong><strong>git subprocess</strong>. There&#39;s a small pure-Swift parser for .git/index (versions 2 and 3) that compares each tracked file&#39;s recorded size and mtime against the working tree — effectively git status --untracked-files=no, in about 120 lines, with no dependency on git being installed or on spawning a process per repo. It even has an honest blind spot, documented next to the code: a change that is fully staged and then untouched in the working tree isn&#39;t seen, and unsupported index formats (v4, SHA-256) fail <em>open</em> — reported as &quot;not dirty&quot; — so the safety tier and confirmation sheet still apply.</p><h3>The boring invariants that do the daily work</h3><p>The three rules get the essays. These get the users’ files home safe every day:</p><ul><li><strong>Trash by default.</strong> Deletion means FileManager.trashItem. Permanent deletion exists and is always a separate, explicit opt-in. Undo restores the last cleanup.</li><li><strong>Sizes are re-measured immediately before deletion</strong>, never taken from a possibly-stale scan. Files change while you review.</li><li><strong>A running tool is excluded from its own scanner.</strong> The active Xcode never appears in the Xcode list.</li><li><strong>Every scanner change must touch </strong><strong>DeletionGuard first.</strong> Adding a scanner means extending the guard <em>before</em> extending the allowlist — the review checklist enforces the ordering.</li></ul><p>None of these are clever. All of them are the difference between “we were careful” and “carefulness is not load-bearing here.”</p><h3>The philosophy, in one sentence</h3><p><strong>Safety that lives in your intentions doesn’t survive contact with a deadline. Safety that lives in your structure does.</strong></p><p>A delete-button app is really a promise: <em>the worst outcome is bounded, no matter what we got wrong.</em> That promise can’t be kept by being careful. It’s kept by making the dangerous thing unreachable through any single mistake — a typo can miss space, two independent mechanisms must both fail before data is at risk, and every label tells the truth even when the truth makes the product less impressive.</p><p>DiskTiny’s full safety policy ships in the repository as SAFETY.md — including the places where the product still makes decisions for you, stated plainly rather than marketed around. If you build anything that deletes files, I&#39;d genuinely recommend writing yours down before the next feature, not after the first incident.</p><p>The app itself is a native macOS menu bar + dashboard app (Swift 6, SwiftUI, zero third-party dependencies) that scans Xcode, Node, Cargo, Python, Docker, Gradle/Android, and package-manager caches; it’s launching soon via Developer ID + notarization and Homebrew.</p><p><em>Thanks for reading. If you’ve ever lost work to a “cleanup” tool — or built one and have a rule I should steal — I’d love to hear about it in the responses.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2c189eb88f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>