Back to skills
SKILL.md
File Operation Patterns
ASecuritySafe file operation patterns. Use when performing bulk file operations or writing deployment scripts.
- 69 stars
- 0 votes
- 0 copies
- 1 view
- Added May 27, 2026
Security analysis
93/100- Performs destructive filesystem operations
npx -y skills add Tibsfox/gsd-skill-creator --skill file-operation-patterns --agent claude-codeAre you the author of File Operation Patterns?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tibsfox-file-operation-patterns)---
name: file-operation-patterns
description: Safe file operation patterns. Use when performing bulk file operations or writing deployment scripts.
version: 1.0.0
format: 2025-10-02
triggers:
- performing bulk file operations or writing deployment scripts
updated: 2026-04-25
status: ACTIVE
---
# 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
Comments
Loading comments…