🎁 Get the FREE AI Skills Starter Guide β€” Subscribe β†’
BytesAgainBytesAgain
πŸ¦€ ClawHub

File Writer

by @ykaixu

Safely write or update large files over 5000 bytes by reading, incrementally editing small sections, verifying each change, and using fallback recovery methods.

Versionv1.0.0
Installs11
⚑ When to Use
TriggerAction
- Updating existing files with significant changes
- Modifying specific sections of large files
- Previous write operations were truncated
- Need to ensure file integrity
πŸ’‘ Examples

Example 1: Adding Section to Large File

Step 1: Read file to find insertion point
read /path/to/large-file.md --offset 50 --limit 10

Step 2: Use edit to add new section edit: file_path: /path/to/large-file.md oldText: "## Existing Section\n\nContent here" newText: "## Existing Section\n\nContent here\n\n## New Section\n\nNew content"

Step 3: Verify read /path/to/large-file.md --offset 50 --limit 20

Example 2: Creating Large New File

Step 1: Create basic structure
write:
  file_path: /path/to/new-file.md
  content: "# Title\n\n## Section 1\n\nContent 1"

Step 2: Add sections incrementally edit: file_path: /path/to/new-file.md oldText: "Content 1" newText: "Content 1\n\n## Section 2\n\nContent 2"

Step 3: Verify wc -l /path/to/new-file.md

Example 3: Replacing Large Section

Step 1: Read file to find exact text
read /path/to/file.md

Step 2: Use unique markers edit: file_path: /path/to/file.md oldText: "\n[old content]\n" newText: "\n[new content]\n"

Step 3: Verify read /path/to/file.md | grep "new content"

πŸ“‹ Tips & Best Practices

1. Always read before editing - Understand current state 2. Use edit for modifications - More precise than write 3. Keep changes small - Under 500 bytes per edit 4. Verify after each operation - Don't batch operations 5. Use unique markers - For complex modifications 6. Create backups - For critical files 7. Handle errors gracefully - Provide recovery strategies 8. Test incrementally - Verify each step

View on ClawHub
TERMINAL
clawhub install file-writer

πŸ§ͺ Use this skill with your agent

Most visitors already have an agent. Pick your environment, install or copy the workflow, then run the smoke-test prompt above.

πŸ” Can't find the right skill?

Search 60,000+ AI agent skills β€” free, no login needed.

Search Skills β†’