Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nullclaw/nullclaw/llms.txt
Use this file to discover all available pages before exploring further.
File Operations
NullClaw provides four file operation tools with strict path security and workspace scoping:file_read— Read file contentsfile_write— Write or overwrite filesfile_edit— Find and replace textfile_append— Append content to files
- Workspace scoping — operations restricted to
workspace_dirby default - Absolute path support — with explicit
allowed_pathsconfiguration - Path traversal protection —
../patterns blocked - Symlink validation — links validated after resolution
- System path blocklist — sensitive paths like
/etc/passwdrejected
file_read
Read file contents with size limits and path validation.Parameters
Relative path to the file within the workspace
Configuration
Usage
Error Cases
- File not found — Returns failure with “Failed to resolve file path”
- Path traversal — Returns “Path not allowed: contains traversal or absolute path”
- Outside workspace — Returns “Path is outside allowed areas”
- File too large — Returns “File too large: X bytes (limit: Y bytes)”
- Missing parameter — Returns “Missing ‘path’ parameter”
Absolute Path Support
To read files outside the workspace:Source
src/tools/file_read.zig:13-91
file_write
Write contents to a file with atomic temp+rename for hard link safety.Parameters
Relative path to the file within the workspace
Content to write to the file
Configuration
Usage
Behavior
- Creates parent directories — Automatically creates missing parent dirs
- Overwrites existing files — Replaces content atomically
- Preserves executable mode — On Unix, preserves file mode (e.g., 0755)
- Symlink-aware — Writes to canonical target, preserving symlink
- Hard link isolation — Uses temp+rename to avoid mutating other inodes
Atomic Write Strategy
To prevent partial writes and hard link side effects:- Create temp file
.nullclaw-write-{timestamp}-{attempt}.tmp - Write content to temp file
- Preserve file mode from existing file (if any)
- Rename temp file to target (atomic inode swap)
- Validate final path is within allowed areas
- Clean up on failure
Symlink Handling
Existing symlink:link.txt → writes to target.txt, preserves symlink
Symlink escape prevention:
escape.txt → rejected (target outside workspace)
Hard Link Safety
Without hard link protection:Source
src/tools/file_write.zig:11-222
file_edit
Find and replace the first occurrence of text in a file.Parameters
Relative path to the file within the workspace
Text to find in the file (must be non-empty)
Replacement text (can be empty to delete)
Configuration
Usage
Behavior
- First occurrence only — Replaces only the first match
- Exact match required — Text must match exactly (case-sensitive)
- Empty new_text — Deletes old_text
- Empty old_text — Rejected with “old_text must not be empty”
- No match — Returns failure “old_text not found in file”
Example: Multiple replacements
File: config.tomlSource
src/tools/file_edit.zig:13-116
file_append
Append content to the end of a file (creates file if missing).Parameters
Relative path to the file within the workspace
Content to append to the file
Configuration
Usage
Append to existing file:Behavior
- Creates file if missing — No error if file doesn’t exist
- Reads existing content — Loads existing file first
- Concatenates — Appends new content to end
- Writes atomically — Truncate+write ensures consistency
- Validates new files — Ensures created files are within allowed areas
Use Cases
Log file:Source
src/tools/file_append.zig:18-124
Path Security
workspace_only Mode
By default, all file tools are restricted toworkspace_dir:
src/main.zig→/workspace/src/main.zigdata/input.json→/workspace/data/input.json./file.txt→/workspace/file.txt
/etc/passwd→ “Absolute paths not allowed”../../../etc/passwd→ “Path not allowed: contains traversal”src/../../../etc/passwd→ “Path is outside allowed areas” (resolved)
Absolute Path Support
Withallowed_paths configuration:
src/main.zig→/workspace/src/main.zig(workspace)/data/input.json→/data/input.json(allowed_paths)/home/user/configs/app.yaml→ allowed
/etc/passwd→ “Path is outside allowed areas”/tmp/file.txt→ “Path is outside allowed areas”
Path Resolution
All paths are resolved withrealpathAlloc() to:
- Canonicalize paths (remove
.and..) - Follow symlinks to final destination
- Validate against workspace + allowed_paths
link → resolves to /etc/passwd → rejected
System Blocklist
The following paths are always blocked byisResolvedPathAllowed():
/etc/*(except on macOS where some system paths are safe)/var/run/*/sys/*/proc/*/dev/*
Null Byte Injection
Paths containing null bytes are rejected:Testing
All file tools include comprehensive test coverage insrc/tools/file_*.zig:
- Basic operations — read, write, edit, append
- Path security — traversal, symlinks, hard links
- Error cases — missing files, missing params
- Absolute paths — with/without allowed_paths
- Edge cases — empty files, empty content, UTF-8 boundaries