๐ File Operations
๐ค Who it's for: Developers / data wranglers
โฑ๏ธ Read time: ~5 minutes
๐ก In one line: AI reads, writes, searches, and batch-edits files directly โ search big files first, confirm before edit, all safe and controllable.
YingClaw provides full read, write, edit, and search capabilities for files, covering everyday development and operations scenarios.
Core Toolsโ
file_read โ Read Fileโ
Read any text file, with support for segmented reading and automatic PDF extraction.
| Parameter | Type | Description |
|---|---|---|
path | string | File path (relative to workspace) |
offset | number | Starting line number (1-based), optional |
limit | number | Maximum lines to read, optional |
# Read entire file
file_read path="config.toml"
# Read in segments (start at line 100, read 50 lines)
file_read path="app.log" offset=100 limit=50
file_write โ Write/Create Fileโ
Create a new file or overwrite an existing one. Parent directories are created automatically.
| Parameter | Type | Description |
|---|---|---|
path | string | File path |
content | string | Full content to write |
# Create README.md
file_write path="docs/guide.md" content="# User Guide\n\n..."
file_edit โ Precise Replacementโ
Find a unique matching string in a file and replace it with new content.
| Parameter | Type | Description |
|---|---|---|
path | string | Path of file to edit |
old_string | string | Original string to replace (must match exactly once) |
new_string | string | Replacement string |
Note:
old_stringmust appear exactly once in the file, otherwise the edit fails. Include enough surrounding context to ensure uniqueness.
glob_search โ File Searchโ
Match file paths by glob pattern.
# Search all Rust source files
glob_search pattern="**/*.rs"
# Search module files under src
glob_search pattern="src/**/mod.rs"
content_search โ Content Searchโ
Search file contents using regex, powered by ripgrep.
# Search for 'useState' in all .ts files
content_search pattern="useState" include="*.ts"
# Search and show match counts
content_search pattern="TODO" output_mode="count"
Use Casesโ
| Scenario | Recommended Tool |
|---|---|
| Code review | file_read + content_search |
| Config changes | file_read โ file_edit |
| Log analysis | content_search + file_read (segmented) |
| Document generation | file_write |
| Data extraction | file_read + glob_search |
| Batch refactoring | glob_search โ file_edit |
Best Practicesโ
Large File Strategyโ
| File Size | Strategy |
|---|---|
| < 50KB | Use file_read to read entire file |
| 50KB ~ 500KB | Use offset + limit for segmented reading |
| > 500KB | Never read in full, use content_search for key content only |
Search First, Then Deep Readโ
For large projects: use glob_search to locate target files, then content_search to find key lines, and finally file_read for precise reading.
Read Before Editingโ
Always file_read to confirm current content before editing. Construct a precise old_string to avoid accidental changes.
Special Format Supportโ
- PDF files:
file_readcan auto-extract PDF text content (requiresrag-pdffeature) - Code files: Auto-detect language and preserve syntax highlighting context
- Config files: Structured reading for JSON / YAML / TOML formats
Next Stepsโ
Master file operations, then learn about ๐ง Memory System to let YingClaw remember your preferences.