---
name: file-operations-mastery
description: |
  File operation patterns for Claude Code.
  Use when reading, writing, editing, or managing files
  efficiently across large codebases.

allowed-tools:
  - Read
  - Write
  - Edit
  - Glob
---

# File Operations Mastery Skill

## Tool Selection

| Operation | Tool | Use When |
|-----------|------|----------|
| Read file | Read | Need full content |
| Find files | Glob | Pattern matching |
| Search content | Grep | Text search |
| Modify file | Edit | Targeted changes |
| Create file | Write | New files |

## Efficient Reading

### Targeted Reading

```python
# Read specific lines
Read(file_path="large.py", offset=100, limit=50)
```

### Pattern-Based Discovery

```python
# Find all test files
Glob(pattern="**/test_*.py")

# Find config files
Glob(pattern="**/*.{json,yaml,toml}")
```

## Safe Editing

### Edit Tool Best Practices

```python
# Always read first
content = Read(file_path="file.py")

# Make targeted edits
Edit(
    file_path="file.py",
    old_string="def old_function():",
    new_string="def new_function():"
)
```

### Atomic Updates

```python
# Edit small, verify each change
# Don't edit entire files at once
```

## File Discovery Patterns

```python
# Source files
Glob(pattern="src/**/*.{py,ts,js}")

# Configs
Glob(pattern="{.,}*config*")

# Tests
Glob(pattern="**/*test*/**")
```

## Best Practices

1. Read before editing
2. Use Glob for discovery
3. Make targeted edits
4. Verify changes after
5. Don't overwrite entire files
