home / skills / sounder25 / google-antigravity-skills-library / 04_clean_artifacts

04_clean_artifacts skill

/04_clean_artifacts

This skill safely removes build artifacts like bin and obj, respects gitignore, and frees disk space while avoiding source deletion.

npx playbooks add skill sounder25/google-antigravity-skills-library --skill 04_clean_artifacts

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
1.2 KB
---
name: Clean Build Artifacts
description: Removes ignored build artifacts (bin, obj, node_modules) to reclaim space and fix ghost build errors. Safely respects .gitignore.
version: 1.0.0
author: Antigravity Skills Library
created: 2026-01-15
leverage_score: 4/5
---

# SKILL-004: Clean Build Artifacts

## Overview

Build artifacts can accumulate and cause subtle build errors or disk bloat. This skill "deep cleans" a workspace by removing generated folders that match standard patterns.

## Trigger Phrases

- `clean artifacts`
- `clean build`
- `wipe bin obj`
- `reset workspace`

## Inputs

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `--target` | string[] | No | `bin`,`obj`,`node_modules` | Folders to remove |
| `--dry-run` | switch | No | False | List what would be deleted |

## Outputs

1. Console log of deleted paths.
2. Space reclaimed summary.

## Safety/QA Checks

1. **Git Check:** Uses `git clean -fdX` if possible (safest).
2. **Explicit List:** If not git, only deletes explicit target list (`bin`, `obj`).
3. **No Source Code:** Never deletes `.cs`, `.py`, etc.

## Implementation

See `clean_artifacts.ps1`.

Overview

This skill removes ignored build artifacts (bin, obj, node_modules) to reclaim disk space and resolve ghost build errors. It performs a safe, workspace-wide cleanup that respects .gitignore and avoids removing source files. The operation supports dry-run mode and reports the deleted paths and space reclaimed.

How this skill works

The skill first prefers a git-based safe removal using git clean -fdX when the repository is available. If git is not usable, it falls back to deleting only explicit target folders (default: bin, obj, node_modules) and never removes source code files. It logs every candidate path, supports a dry run for review, and summarizes reclaimed space after completion.

When to use it

  • After switching branches or pulling large merges to remove stale build outputs
  • When encountering inexplicable build errors that persist after rebuilds
  • To free disk space in developer workspaces or CI agents
  • Before creating a clean snapshot or packaging a project
  • As part of a recovery step when CI jobs report inconsistent artifacts

Best practices

  • Run with --dry-run first to verify what will be deleted
  • Prefer running inside a git repository so git clean -fdX can be used safely
  • Limit targets to known build folders; avoid adding generic patterns
  • Review console logs immediately after execution to confirm expected deletions
  • Automate in CI only when you can restore or reproduce important artifacts from source

Example use cases

  • Developer runs clean artifacts after switching feature branches to remove old bin/obj files that cause linker errors
  • CI job executes the skill on a fresh agent to ensure no leftover node_modules distort dependency resolution
  • Workspace maintenance task reclaims tens of GBs from cached build outputs before a disk quota warning
  • Troubleshooting step: run dry-run to list stale folders before committing to deletion

FAQ

Will this delete my source files?

No. The skill is designed never to delete source code file types and prefers git clean -fdX, which removes only untracked ignored files.

What if my repository has no git metadata?

The skill falls back to deleting only explicitly listed target folders (default: bin, obj, node_modules) and logs each removal for review.