moesniper
Escape-proof precision file editor for LLM agents. All content is hex-encoded to guarantee zero shell corruption. Edits are applied via line-range splicing with atomic writes and automatic backups.
Install
Usage
# Replace lines 10-12 with hex-decoded content
# Delete lines 5-8
# Batch operations from a manifest file
# Undo last edit (restores backup)
Flags
| Flag | Description |
|---|---|
--dry-run |
Preview changes without writing |
--json |
Output machine-readable JSON |
--help |
Show full usage (including LLM agent guide) |
LLM Agent Workflow
# 1. Find the lines you want to edit (using ix)
# 2. Encode your replacement content
| |
# Output: 666e206d61696e2829207b7d
# 3. Dry-run to preview (safe - never modifies files)
# 4. Apply the edit
# 5. Undo if something went wrong
Hex Encoding
All replacement content must be hex-encoded. This prevents shell mangling of special characters.
# Encode your text
|
# Output: 757365207065746772617068
# Decode a hex string
|
Manifest Format
A manifest is a JSON array of operations applied bottom-up (highest line first) so line numbers in the original file stay valid:
start/end: 1-indexed line range (inclusive)hex: replacement content (hex-encoded)delete: set totrueto delete the range (no hex needed)
Run: sniper target_file.rs --manifest ops.json
JSON Output
Backups
Every edit automatically creates a backup in .sniper/:
.sniper/
file.rs.1712345678 # timestamped backup
Undo restores the most recent backup: sniper file.rs --undo
License
MIT