Skip to main content

safe-file-writing

Safe ways to edit/overwrite files in Hermes Agent. Avoids file corruption from write_file on large files and Excel file locks.

소스 정보

저장소
crimsonblazezero/Zero-Tools
최근 소스 활동
2026년 8월 3일 15:27
감지된 SKILL.md 언어
영어
스타
0
포크
0

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
safe-file-writing
description
Safe ways to edit/overwrite files in Hermes Agent. Avoids file corruption from write_file on large files and Excel file locks.
tags
["file","write","patch","safe-editing"]
# Safe File Writing ## ⚠️ Never Use write_file for Large Files When editing or overwriting scripts >400 lines, **always use `patch` instead of `write_file`**. `write_file` truncates long content silently, producing corrupt but compilable-looking files. ## Safe Editing Patterns ### Pattern 1: Patch Only (Preferred) ```bash # Only modify the exact lines you need to change patch --path scripts/weekly_report.py \ --old "old line" \ --new "new line" ``` ### Pattern 2: Import and Run When you need to generate output without risking the source file: ```python # Create a small wrapper script import sys sys.path.insert(0, 'scripts') from weekly_report import * # Use existing functions directly build_excel(wk_m, mo_m, fb_agg, wt, mt, 'output.xlsx') ``` ### Pattern 3: Backup First If you absolutely must rewrite: 1. Copy original first 2. Write new content 3. Verify compilation before deleting backup ## Excel File Locks `.xlsx` files locked by Excel → openpyxl raises PermissionError. **Fix:** Write to a new filename like `xxx_v19_new.xlsx`, never overwrite the open file.
GitHub에서 보기