Agent skill
typescript-rimraf-node-setup
Add, repair, audit, or standardize `rimraf`-based cleanup in Node.js/TypeScript projects with deterministic, cross-platform `package.json` scripts. Use when users ask to add or fix `clean`/`prebuild`, replace `rm -rf` or Windows delete commands (`rmdir`, `del`), clear artifacts (`dist`, `build`, `coverage`, `.cache`, `.turbo`, `*.tsbuildinfo`), enforce CI-safe script behavior, or verify cleanup reliability on Windows and Unix.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/typescript-rimraf-node-setup
SKILL.md
Rimraf Node Cleanup
Use this workflow to implement portable cleanup scripts that behave consistently across shells.
Preconditions
- Work from the project root that contains
package.json. - Keep the current package manager (
npm,pnpm, oryarn). - Check build tooling before adding redundant cleanup.
- Preserve existing script names unless the user requests a rename.
- If
package.jsonis missing, stop and ask for the correct project path instead of creating files speculatively.
Workflow
- Confirm project root and package manager deterministically:
- Detect lockfile priority:
pnpm-lock.yaml->yarn.lock->package-lock.json. - If no lockfile exists, preserve existing workflow and default install commands to
npm.
- Detect lockfile priority:
- Inspect
package.jsonscripts and list cleanup-related entries. - Identify shell-specific delete commands (
rm -rf,rmdir /s /q,del /f /q) and cleanup targets. - Decide whether a dedicated script is needed:
- If build tooling already guarantees cleanup and no standalone cleanup command is requested, keep existing behavior.
- Otherwise continue with
rimrafstandardization.
- Install
rimrafas a dev dependency only when missing:npm i -D rimrafpnpm add -D rimrafyarn add -D rimraf
- Add or update scripts using direct
rimrafcalls:- Standalone clean:
"clean": "rimraf dist" - Multi-folder clean:
"clean": "rimraf dist coverage .cache" - Prebuild hook:
"prebuild": "rimraf dist"
- Standalone clean:
- Replace shell-specific cleanup commands with equivalent
rimrafcommands. - Keep scripts minimal and deterministic:
- Do not prefix
rimrafwithnpxinsidepackage.jsonscripts. - Keep target list explicit; do not add folders that are not present or requested.
- For glob targets, use quotes in scripts when required for shell portability (for example
"*.tsbuildinfo").
- Do not prefix
- Re-open
package.jsonand verify JSON validity after edits. - If no edit is required, report a no-op result with exact reason (already portable or explicitly out of scope).
Script patterns
Use direct rimraf calls inside package.json scripts. Do not prefix script commands with npx.
Example:
{
"scripts": {
"clean": "rimraf dist coverage .cache",
"prebuild": "rimraf dist",
"build": "tsc -p tsconfig.build.json"
}
}
Use npx rimraf ... only for one-off terminal commands outside package.json scripts.
Decision rules
Use rimraf when:
- A dedicated clean step is needed.
- Multiple output folders must be removed.
- Scripts must run reliably across Windows and Unix shells.
Prefer alternatives when:
- The build tool already provides sufficient cleanup (for example,
tsupwithclean: true) and no standalone clean script is needed. - Cleanup is done in application code paths (use Node
fs.rmAPIs in code instead of package scripts).
Do not change behavior when:
- The user asks only for an audit/review and does not request edits.
- Existing scripts are already cross-platform and satisfy requested targets.
Verification
- Run the updated cleanup script (
npm run clean,pnpm run clean, oryarn clean). - If a prebuild hook is present, run the build command that depends on cleanup.
- Confirm removed folders are recreated only by the build process.
- Confirm no shell-specific delete commands remain in
package.jsonscripts. - If using glob targets, confirm arguments are quoted when required by the shell.
- Confirm
rimrafis present indevDependenciesonly once and no duplicate installer artifacts were introduced.
Additional resources
Use reference.md for CLI options, glob behavior, and the programmatic API.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?