返回 Skill 列表
extension
分类: 开发与工程无需 API Key

update-text-file

更新或修改任何目录中的文本文件(诗歌、文档、笔记等)。当用户要求编辑、更新、修改、修订或重写一个文本文件、诗歌、文档或类似内容时,使用此技能。支持添加新内容、扩展现有文本或替换文件内容,同时保留原始位置。

person作者: jakexiaohubgithub

Update Text File

Input Parameters

| Parameter | Required | Description | Example | |-----------|----------|-------------|---------| | file_path | Yes | Path to the text file to update | ~/Downloads/poem.txt | | update_type | No | Type of update: 'add' (append content), 'expand' (add to existing), 'replace' (full rewrite), or 'edit' (modify specific sections) | expand | | new_content | Yes | The new or additional content to write to the file | With wisdom guiding every choice... |

Procedure

  1. Locate the target file using find command with common text file extensions (.txt, .md, .doc, etc.) or search by filename pattern
  2. Display current file contents using cat to understand what needs to be updated
  3. Ask user for clarification on desired changes if not explicitly provided (use ask_user)
  4. Write updated content to the file using cat > {{FILE_PATH}} << 'EOF' syntax, preserving the original file location
  5. Verify the update by displaying the new file contents with cat {{FILE_PATH}}
  6. Confirm successful update to the user with a summary of changes made

Output

Updated text file saved to original location with confirmation message showing what was changed. File contents displayed to user for verification.

Reference Commands

find {{DIRECTORY}} -maxdepth 2 -type f \( -name "*.txt" -o -name "*.md" \)
cat {{FILE_PATH}}
cat > {{FILE_PATH}} << 'EOF'
{{NEW_CONTENT}}
EOF

Example

update the poem in my Downloads folder
edit the notes file and add more details
revise the document with new content
modify the text file to include additional paragraphs
update the markdown file in my home directory

Notes

  • Always display the original file contents before making changes to understand context
  • Use heredoc syntax (cat > file << 'EOF') to safely write multi-line content
  • Preserve the original file location and path
  • Verify changes by displaying updated contents after writing
  • Ask for clarification if update intent is ambiguous