Skip to content
Back to skills

File Operation Patterns

ASecurity

Safe file operation patterns. Use when performing bulk file operations or writing deployment scripts.

  • 69 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 6, 2026
ai-agentsgobash

Security analysis

A93/100
  • highPerforms destructive filesystem operations

Pro shows the line behind each finding and how to fix it

Scanned September 6, 2026

npx -y skills add Tibsfox/gsd-skill-creator --skill file-operation-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of File Operation Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for File Operation Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tibsfox-file-operation-patterns-gsd-skill-creator/badge)](https://www.skillsdirectory.com/skills/tibsfox-file-operation-patterns-gsd-skill-creator)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: file-operation-patterns
description: Safe file operation patterns. Use when performing bulk file operations or writing deployment scripts.
type: skill
category: patterns
status: stable
origin: tibsfox
modified: false
first_seen: 2026-02-07
first_path: examples/file-operation-patterns/SKILL.md
superseded_by: null
---
# File Operation Patterns

## Safe Patterns

```bash
# Create directory tree (idempotent)
mkdir -p path/to/nested/dir

# Copy preserving permissions
cp -rp src/ dst/

# Atomic write (prevents partial reads)
tmpfile=$(mktemp "${target}.XXXXXX")
echo "$content" > "$tmpfile"
mv "$tmpfile" "$target"

# Safe deletion (guard variables)
[ -n "$DIR" ] && [ "$DIR" != "/" ] && rm -rf "$DIR"

# Incremental sync
rsync -av src/ dst/
```

## Anti-Patterns

| Don't | Do |
|-------|------|
| `rm -rf $DIR` unguarded | Guard with `[ -n "$DIR" ]` |
| Write directly to target | Write to temp, then `mv` |
| Assume dir exists | `mkdir -p` first |
| Ignore permissions | `cp -p` or explicit `chmod` |

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…