Skip to main content

๐Ÿ“„ 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.

ParameterTypeDescription
pathstringFile path (relative to workspace)
offsetnumberStarting line number (1-based), optional
limitnumberMaximum 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.

ParameterTypeDescription
pathstringFile path
contentstringFull 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.

ParameterTypeDescription
pathstringPath of file to edit
old_stringstringOriginal string to replace (must match exactly once)
new_stringstringReplacement string

Note: old_string must appear exactly once in the file, otherwise the edit fails. Include enough surrounding context to ensure uniqueness.

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"

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โ€‹

ScenarioRecommended Tool
Code reviewfile_read + content_search
Config changesfile_read โ†’ file_edit
Log analysiscontent_search + file_read (segmented)
Document generationfile_write
Data extractionfile_read + glob_search
Batch refactoringglob_search โ†’ file_edit

Best Practicesโ€‹

Large File Strategyโ€‹

File SizeStrategy
< 50KBUse file_read to read entire file
50KB ~ 500KBUse offset + limit for segmented reading
> 500KBNever 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_read can auto-extract PDF text content (requires rag-pdf feature)
  • 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.