{"name":"manage-workspace-storage","title":"Manage workspace storage","description":"Keep agent context small and retire disposable build and test files after verification. Check a context budget and volume headroom, give each run a project-owned scratch directory, preserve evidence, and reclaim disk space within a checked scope. Use when .context keeps growing, old worktrees or test artifacts fill a shared disk, or a large build needs a storage preflight and cleanup.","compatibility":"The workflow works wherever the agent can inspect local files and disk usage. The bundled guard and scratch helper require Node.js 22 or newer on macOS or Linux. Git is needed only to inspect or retire Git worktrees. The helper makes no network requests.","allowedTools":"Read Grep Glob Bash","license":"MIT","kind":"requestOnly","useWhen":"a project needs to bound scratch storage, prevent context growth, or audit and retire local artifacts","group":"workflow","lifecycle":"release","version":"1.0.0","author":"crissmoldovan","install":["npx skills add crissmoldovan/agent-skills --skill manage-workspace-storage"],"asks":["Use manage-workspace-storage before the browser suite. Check the target volume, keep .context small, and clean up this run's scratch after retaining its result.","Tell me what filled this project's disk and which files are safe to remove."],"commands":[],"documents":[{"path":"references/commands.md","slug":"commands","title":"Guard and cleanup commands","body":"# Guard and cleanup commands\n\nRun the bundled helper from the installed skill directory with Node.js 22 or newer. Set\n`PROJECT` to the project directory. Set `SCRATCH_ROOT` to a dedicated, existing directory\nyou own outside the project on the volume receiving bulk writes. Give it permissions\nthat disallow group or other writes. The helper keeps one active or unretired run per\nscratch root. Set `REQUIRED_FREE_MIB` to the measured or estimated peak plus any project reserve.\n\n```bash\nnode scripts/workspace-storage.mjs guard --project \"$PROJECT\" \\\n  --volume \"$SCRATCH_ROOT\" --min-free-mib \"$REQUIRED_FREE_MIB\"\nnode scripts/workspace-storage.mjs start --project \"$PROJECT\" \\\n  --scratch-root \"$SCRATCH_ROOT\" --min-free-mib \"$REQUIRED_FREE_MIB\"\n```\n\n`guard` is read-only. It fails with exit status 1 if available bytes are below the supplied\nminimum or .context exceeds the first limit reached. The defaults are 128 MiB of\nregular-file logical size and 10,000 directory entries. Use `--context-max-mib` or\n`--context-max-entries` to supply the project's own budget. A successful check prints\nbyte counts and the inspected paths as JSON. `--volume` defaults to the project path.\nGuard checks the given volume at the time of the call. Invoke it separately for other\nvolumes that receive writes. A periodic check or preflight is only active where a caller\nactually runs it.\n\n`start` runs the same guard and creates a private run directory containing a `work`\ndirectory and an ownership record. It prints `run` and `work` as JSON. Set `RUN` to the\nreported run path and direct disposable output into `work`. Keep durable evidence outside\nthe run. For dependency caches, Git worktrees, and other state with a manager, use the\nmanager's own configuration and removal commands.\n\n```bash\nnode scripts/workspace-storage.mjs cleanup --project \"$PROJECT\" --run \"$RUN\"\n```\n\nThe preview prints the run path, logical bytes, and entry count. Cleanup accepts only a\nrun the helper created for this project. It refuses symlinked roots, mismatched ownership\nrecords, mounts, and nested Git metadata. It does not follow symlinks during removal.\n\nOnce the original writer and dependent jobs are terminal and all required evidence reads\nback, apply the previewed removal within the authorized scope. `--closed` records the\ncaller's confirmation. The helper has no access to the run's process or evidence system.\n\n```bash\nnode scripts/workspace-storage.mjs cleanup --project \"$PROJECT\" --run \"$RUN\" --apply --closed\n```\n\nThe result verifies the path is absent and prints available bytes before and after.\nIf deletion fails partway through, inspect the same run again. Retire any remaining\nGit checkout through Git and resolve the reported issue before retrying. Keep the\nsame project and run identity. Run paths are unique. If an abrupt exit leaves an empty\nreservation directory or an incomplete run without an ownership record, first verify no\nhelper or job still owns it. Inspect the residue and remove only the confirmed empty\nreservation or explicitly reviewed residue. The helper does not sweep old scratch roots or\nremove unmarked files from a shared directory.\n\nThe onboarding metadata marks this skill as request-only for project recommendations.\nThe installed skill remains discoverable by its description.\n","bodyHtml":"<h2 id=\"guard-and-cleanup-commands\">Guard and cleanup commands</h2>\n<p>Run the bundled helper from the installed skill directory with Node.js 22 or newer. Set\n<code>PROJECT</code> to the project directory. Set <code>SCRATCH_ROOT</code> to a dedicated, existing directory\nyou own outside the project on the volume receiving bulk writes. Give it permissions\nthat disallow group or other writes. The helper keeps one active or unretired run per\nscratch root. Set <code>REQUIRED_FREE_MIB</code> to the measured or estimated peak plus any project reserve.</p>\n<pre><code class=\"language-bash\">node scripts/workspace-storage.mjs guard --project &quot;$PROJECT&quot; \\\n  --volume &quot;$SCRATCH_ROOT&quot; --min-free-mib &quot;$REQUIRED_FREE_MIB&quot;\nnode scripts/workspace-storage.mjs start --project &quot;$PROJECT&quot; \\\n  --scratch-root &quot;$SCRATCH_ROOT&quot; --min-free-mib &quot;$REQUIRED_FREE_MIB&quot;\n</code></pre>\n<p><code>guard</code> is read-only. It fails with exit status 1 if available bytes are below the supplied\nminimum or .context exceeds the first limit reached. The defaults are 128 MiB of\nregular-file logical size and 10,000 directory entries. Use <code>--context-max-mib</code> or\n<code>--context-max-entries</code> to supply the project&#39;s own budget. A successful check prints\nbyte counts and the inspected paths as JSON. <code>--volume</code> defaults to the project path.\nGuard checks the given volume at the time of the call. Invoke it separately for other\nvolumes that receive writes. A periodic check or preflight is only active where a caller\nactually runs it.</p>\n<p><code>start</code> runs the same guard and creates a private run directory containing a <code>work</code>\ndirectory and an ownership record. It prints <code>run</code> and <code>work</code> as JSON. Set <code>RUN</code> to the\nreported run path and direct disposable output into <code>work</code>. Keep durable evidence outside\nthe run. For dependency caches, Git worktrees, and other state with a manager, use the\nmanager&#39;s own configuration and removal commands.</p>\n<pre><code class=\"language-bash\">node scripts/workspace-storage.mjs cleanup --project &quot;$PROJECT&quot; --run &quot;$RUN&quot;\n</code></pre>\n<p>The preview prints the run path, logical bytes, and entry count. Cleanup accepts only a\nrun the helper created for this project. It refuses symlinked roots, mismatched ownership\nrecords, mounts, and nested Git metadata. It does not follow symlinks during removal.</p>\n<p>Once the original writer and dependent jobs are terminal and all required evidence reads\nback, apply the previewed removal within the authorized scope. <code>--closed</code> records the\ncaller&#39;s confirmation. The helper has no access to the run&#39;s process or evidence system.</p>\n<pre><code class=\"language-bash\">node scripts/workspace-storage.mjs cleanup --project &quot;$PROJECT&quot; --run &quot;$RUN&quot; --apply --closed\n</code></pre>\n<p>The result verifies the path is absent and prints available bytes before and after.\nIf deletion fails partway through, inspect the same run again. Retire any remaining\nGit checkout through Git and resolve the reported issue before retrying. Keep the\nsame project and run identity. Run paths are unique. If an abrupt exit leaves an empty\nreservation directory or an incomplete run without an ownership record, first verify no\nhelper or job still owns it. Inspect the residue and remove only the confirmed empty\nreservation or explicitly reviewed residue. The helper does not sweep old scratch roots or\nremove unmarked files from a shared directory.</p>\n<p>The onboarding metadata marks this skill as request-only for project recommendations.\nThe installed skill remains discoverable by its description.</p>\n","words":485}],"body":"# Manage workspace storage\n\nAn interrupted run needs a checkpoint. A finished run needs evidence. Neither needs a second\ncheckout sitting beside its logs for the rest of the project. Keep a compact record in context\nand give large, disposable outputs a location and an end of life before creating them.\n\n## When to Use\n\n- A build, browser suite, native test, or packaging run creates large temporary files.\n- A project keeps cloning worktrees, reinstalling dependencies, or retaining build output.\n- A user asks what filled the disk, what can be recovered, or which project owns a directory.\n\n`derive-codebase-context` owns the documentation agents load. `isolated-change-validation` owns\nthe proof required to accept a change. `work-in-external-repo` owns selecting another checkout.\nUse this skill for the storage those workflows consume and leave behind.\n\n## Prerequisites\n\n1. **Name the project, affected volumes, and scope.** Decide which locations the run owns and\n   where its required evidence will live. Read-only inspection and deletion have separate scope.\n   **Complete when:** the project and paths come from the actual workspace, and the run has\n   no reason to write to another project's directory.\n\n## Procedure\n\n1. **Measure what already exists.** Start with available bytes on the volumes the run uses and\n   an allocated-size breakdown of the named directory, using a bounded top-level inventory.\n   For suspected shared use, check Git worktree registrations, links and mounts, and open or\n   known in-flight operations. A folder name is a lead about ownership. Files kept by another\n   checkout, a container, or a running job need their owner resolved.\n   **Complete when:** the baseline and largest contributors are recorded, with uncertainties\n   where the evidence does not establish ownership or recoverability.\n\n2. **Keep context small and give disposable output a home.** Use .context for decisions,\n   current pointers, checksums, and short status records. Send builds, dependencies, fixtures,\n   databases, worktree copies, and bulk logs to project-owned scratch or their appropriate\n   managed store. Put required originals in the project's approved durable location.\n   Pick the headroom from the actual build and its peak scratch usage. Invoke the guard before\n   and after heavy stages on each volume they write to. Use it as a preflight command in a\n   recurring workflow where it needs to stop a launch. Correct the storage plan if it refuses.\n   **Complete when:** the run has its scratch path, evidence destination, and applicable storage\n   budget, and the preflight passes.\n\n3. **Retain what you need to resume or verify.** Check the original operation and its dependent\n   processes through terminal status. Keep exact source identity, a concise result or failure,\n   and only the logs, outputs, and rollback material required by policy or evidence. Read back the\n   retained bytes or confirm the exact revision in the authoritative remote. Keep unpublished\n   changes, unique originals, and active runs until their disposition is established. A time\n   limit expiring does not establish that a run ended.\n   **Complete when:** the verified evidence and any live or unresolved paths are recorded outside\n   the disposable run.\n\n4. **Retire the run with a named scope.** Preview the owned scratch run, confirm it is closed and\n   its evidence is safe, and apply cleanup within the authorized paths. Use Git to remove linked\n   worktrees so their registrations are retired with the files. A legacy directory needs its\n   own inventory, ownership and recovery checks. Leave shared caches, other projects, and\n   ambiguous files in place while those checks are unresolved.\n   **Complete when:** the removed paths and any Git registrations are absent, retained evidence\n   still reads back, and volume free space is measured again.\n\nSee [the guard and cleanup commands](references/commands.md) to wire the helper into a run.\nIt can remove the scratch directory it creates. Existing workspaces require the scoped review\nabove.\n\n## Usage Examples\n\n```text\nUse manage-workspace-storage before the browser suite. Check the target volume, keep .context small, and clean up this run's scratch after retaining its result.\n```\n\n```text\nTell me what filled this project's disk and which files are safe to remove.\n```\n\n## What it looks like\n\nA short closeout names the closed run, its preserved source and evidence, the removed paths,\nthe measured before and after free bytes, and any paths that still need a decision.\n\n## Pitfalls\n\n- A clean worktree can still contain ignored evidence or dependency links. Check both before\n  removing it.\n- A second copy can share blocks with the first. Directory size and newly available bytes\n  measure different things.\n- A path being old, ignored, or named cache says little about whether another run depends on it.\n- Increasing a limit hides the symptom until the volume fills again. Find what wrote the bytes\n  and change where that output goes or when it is retired.\n\n## Verification\n\n- [ ] Context and volume budgets were checked against the paths receiving writes.\n- [ ] Required evidence is readable outside the disposable run.\n- [ ] Remaining or removed paths match the agreed scope.\n- [ ] The storage gain is reported as a measured difference in free bytes.\n","bodyHtml":"<h2 id=\"manage-workspace-storage\">Manage workspace storage</h2>\n<p>An interrupted run needs a checkpoint. A finished run needs evidence. Neither needs a second\ncheckout sitting beside its logs for the rest of the project. Keep a compact record in context\nand give large, disposable outputs a location and an end of life before creating them.</p>\n<h3 id=\"when-to-use\">When to Use</h3>\n<ul>\n<li>A build, browser suite, native test, or packaging run creates large temporary files.</li>\n<li>A project keeps cloning worktrees, reinstalling dependencies, or retaining build output.</li>\n<li>A user asks what filled the disk, what can be recovered, or which project owns a directory.</li>\n</ul>\n<p><code>derive-codebase-context</code> owns the documentation agents load. <code>isolated-change-validation</code> owns\nthe proof required to accept a change. <code>work-in-external-repo</code> owns selecting another checkout.\nUse this skill for the storage those workflows consume and leave behind.</p>\n<h3 id=\"prerequisites\">Prerequisites</h3>\n<ol>\n<li><strong>Name the project, affected volumes, and scope.</strong> Decide which locations the run owns and\nwhere its required evidence will live. Read-only inspection and deletion have separate scope.\n<strong>Complete when:</strong> the project and paths come from the actual workspace, and the run has\nno reason to write to another project&#39;s directory.</li>\n</ol>\n<h3 id=\"procedure\">Procedure</h3>\n<ol>\n<li><p><strong>Measure what already exists.</strong> Start with available bytes on the volumes the run uses and\nan allocated-size breakdown of the named directory, using a bounded top-level inventory.\nFor suspected shared use, check Git worktree registrations, links and mounts, and open or\nknown in-flight operations. A folder name is a lead about ownership. Files kept by another\ncheckout, a container, or a running job need their owner resolved.\n<strong>Complete when:</strong> the baseline and largest contributors are recorded, with uncertainties\nwhere the evidence does not establish ownership or recoverability.</p>\n</li>\n<li><p><strong>Keep context small and give disposable output a home.</strong> Use .context for decisions,\ncurrent pointers, checksums, and short status records. Send builds, dependencies, fixtures,\ndatabases, worktree copies, and bulk logs to project-owned scratch or their appropriate\nmanaged store. Put required originals in the project&#39;s approved durable location.\nPick the headroom from the actual build and its peak scratch usage. Invoke the guard before\nand after heavy stages on each volume they write to. Use it as a preflight command in a\nrecurring workflow where it needs to stop a launch. Correct the storage plan if it refuses.\n<strong>Complete when:</strong> the run has its scratch path, evidence destination, and applicable storage\nbudget, and the preflight passes.</p>\n</li>\n<li><p><strong>Retain what you need to resume or verify.</strong> Check the original operation and its dependent\nprocesses through terminal status. Keep exact source identity, a concise result or failure,\nand only the logs, outputs, and rollback material required by policy or evidence. Read back the\nretained bytes or confirm the exact revision in the authoritative remote. Keep unpublished\nchanges, unique originals, and active runs until their disposition is established. A time\nlimit expiring does not establish that a run ended.\n<strong>Complete when:</strong> the verified evidence and any live or unresolved paths are recorded outside\nthe disposable run.</p>\n</li>\n<li><p><strong>Retire the run with a named scope.</strong> Preview the owned scratch run, confirm it is closed and\nits evidence is safe, and apply cleanup within the authorized paths. Use Git to remove linked\nworktrees so their registrations are retired with the files. A legacy directory needs its\nown inventory, ownership and recovery checks. Leave shared caches, other projects, and\nambiguous files in place while those checks are unresolved.\n<strong>Complete when:</strong> the removed paths and any Git registrations are absent, retained evidence\nstill reads back, and volume free space is measured again.</p>\n</li>\n</ol>\n<p>See <a href=\"references/commands.md\">the guard and cleanup commands</a> to wire the helper into a run.\nIt can remove the scratch directory it creates. Existing workspaces require the scoped review\nabove.</p>\n<h3 id=\"usage-examples\">Usage Examples</h3>\n<pre><code class=\"language-text\">Use manage-workspace-storage before the browser suite. Check the target volume, keep .context small, and clean up this run&#39;s scratch after retaining its result.\n</code></pre>\n<pre><code class=\"language-text\">Tell me what filled this project&#39;s disk and which files are safe to remove.\n</code></pre>\n<h3 id=\"what-it-looks-like\">What it looks like</h3>\n<p>A short closeout names the closed run, its preserved source and evidence, the removed paths,\nthe measured before and after free bytes, and any paths that still need a decision.</p>\n<h3 id=\"pitfalls\">Pitfalls</h3>\n<ul>\n<li>A clean worktree can still contain ignored evidence or dependency links. Check both before\nremoving it.</li>\n<li>A second copy can share blocks with the first. Directory size and newly available bytes\nmeasure different things.</li>\n<li>A path being old, ignored, or named cache says little about whether another run depends on it.</li>\n<li>Increasing a limit hides the symptom until the volume fills again. Find what wrote the bytes\nand change where that output goes or when it is retired.</li>\n</ul>\n<h3 id=\"verification\">Verification</h3>\n<ul>\n<li><input disabled=\"\" type=\"checkbox\"> Context and volume budgets were checked against the paths receiving writes.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Required evidence is readable outside the disposable run.</li>\n<li><input disabled=\"\" type=\"checkbox\"> Remaining or removed paths match the agreed scope.</li>\n<li><input disabled=\"\" type=\"checkbox\"> The storage gain is reported as a measured difference in free bytes.</li>\n</ul>\n","outline":["When to Use","Prerequisites","Procedure","Usage Examples","What it looks like","Pitfalls","Verification"],"words":823}
