file-operation-patterns

Automate safe file operations with idempotent creation, atomic writes, and safe deletion.

69|9|Updated Jan 30, 2026
One-click install
npx skills add https://github.com/Tibsfox/gsd-skill-creator --skill file-operation-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: file-operation-patterns
Source: https://github.com/Tibsfox/gsd-skill-creator/tree/main/examples/skills/file-operation-patterns
Command: npx skills add https://github.com/Tibsfox/gsd-skill-creator --skill file-operation-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Safe file system operation patterns help avoid data loss and errors during bulk file operations, directory management, and deployment tasks.

Core Features & Use Cases

  • Directory Creation: Use mkdir -p and pre-checks to ensure idempotent creation.
  • Copying: Preserve attributes or use rsync for large copies.
  • Moving / Renaming: Atomic rename where possible; copy then remove across filesystems.
  • Atomic Writes: Write to a temp file, then move to target to prevent partial reads.
  • Safe Deletion: Dry-run before deleting, use trash when available, guard against dangerous rm.
  • Anti-Patterns: Common mistakes to avoid during scripting.

Quick Start

Apply the safe file operation patterns to a bulk copy in a deployment script.

Frequently Asked Questions about file-operation-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I ensure safe file operations during bulk directory management in shell scripts?

Atomic writes prevent partial reads by writing to a temporary file first, then moving it to the final target location. This mechanism ensures that reading processes never access incomplete data during file system operations.

What is the best way to handle safe deletion of files in deployment scripts?

Safe deletion in deployment scripts is best handled by performing a dry-run before deleting, using trash when available, and guarding against dangerous rm commands. These safe patterns prevent accidental data loss.

How do I copy large files robustly while preserving attributes in a CLI workflow?

To copy large files robustly in a CLI workflow, preserve file attributes or use rsync for large copies. These robust copy patterns ensure data integrity and prevent corruption during extensive file transfers.

Can I achieve idempotent directory creation across different filesystems?

Idempotent directory creation is achieved by using mkdir -p with pre-checks, ensuring directories are created safely without errors on repeated runs. For moving across filesystems, use copy then remove patterns.

What are common anti-patterns to avoid when automating file system operations?

Common anti-patterns in file system operations include unsafe rm commands, non-atomic writes causing partial reads, and lacking dry-run checks before deletion. Avoiding these mistakes prevents data loss and script errors.