Reading the article reminded me of a thing that I've seen Codex do lately. Instead of writing new files using a write tool (or apply_patch) it just does this:
cat > lib/example.txt <<'EOF'
Line 1
Line 2
EOF
I don't know if Unix isn't for agents but surely they know how to use it.