large-file-write-heredoc
Fungsinya
Skill ini memberi agent AI cara cadangan untuk menulis file besar saat alat penulisannya gagal dengan error tidak diketahui. Skill ini ditujukan untuk orang yang menyimpan dokumen panjang atau file kode.
Kapan dipakai
- βSaat alat tulis gagal dengan error tidak diketahui pada file besar.
- βSaat agent shell juga gagal karena konten inline terlalu besar.
- βSaat Anda memerlukan file panjang tersimpan persis seperti yang diberikan.
Link skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/large-file-write-heredoc/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βSimpan file konfigurasi panjang ini ke proyek saya. Alat tulis terus gagal karena ukurannya, jadi gunakan metode lain.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent pertama-tama mencoba alat tulis biasa. Jika gagal, agent mengirim seluruh isi file melalui heredoc Python ke dalam panggilan yang menulis file, sehingga melewati batas ukuran alat lain.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Large File Write Fallback
Problem
When writing large files (typically several KB or more), two common tools may
fail with unknown error due to internal payload size limits:
write_fileβ has a maximum content size it can handle in a single call.shell_agentβ may also hit payload limits when the task description includes large inline content.
Solution
Use run_shell with a Python heredoc pattern. This streams the file
content through stdin directly into Python's open(), bypassing the payload
constraints of the other tools.
Template
python3 - << 'EOF'
content = """<FILE CONTENTS HERE>"""
with open("<TARGET PATH>", "w") as f:
f.write(content)
EOF
Pass this as the command parameter to run_shell.
Step-by-Step Instructions
Attempt the normal write using
write_filefirst. If it succeeds, you are done.If
write_filefails (especially withunknown erroror a timeout on large content), do NOT retry withshell_agentusing inline content β it will likely fail for the same reason.Use the
run_shellheredoc fallback:- Embed the full file content inside a Python triple-quoted string.
- Specify the target path inside the
open()call. - Pass the entire block as the
commandtorun_shell.
Escape carefully inside the heredoc:
- Backslashes that should be literal in the file must be doubled (
\\). - Triple-quotes inside the content must be escaped (
\"\"\"). - The heredoc delimiter
EOFmust not appear on a line by itself inside the content (rename it toPYEOForFILEEOFif needed).
- Backslashes that should be literal in the file must be doubled (
Verify the write by following up with a
run_shellcall such as:wc -l <TARGET PATH> && head -5 <TARGET PATH>
Full Example
Suppose you need to write a large TypeScript file to
src/components/Dashboard.ts:
python3 - << 'PYEOF'
content = """import { foo } from './foo';
export interface DashboardData {
title: string;
items: string[];
}
export function createDashboard(data: DashboardData): string {
return `<div>${data.title}</div>`;
}
"""
with open("src/components/Dashboard.ts", "w") as f:
f.write(content)
PYEOF
Pass the above (without the surrounding code fence) as the command
argument to run_shell.
When to Use This Pattern
| Situation | Recommended tool |
|---|---|
| Small file (< ~2 KB) | write_file |
| Medium file, no errors yet | write_file (try first) |
Large file or write_file failed |
run_shell + Python heredoc |
shell_agent also fails on large inline content |
run_shell + Python heredoc |
Notes
- This pattern works for any text-based file (TypeScript, Python, JSON, YAML, Markdown, etc.).
- For binary files, adapt the approach to use
base64decoding inside the Python script. - The heredoc delimiter (
EOF,PYEOF,FILEEOF) can be any string not present as a standalone line in your content β choose accordingly. - This technique is also useful when content contains characters that would
need heavy shell escaping in a plain
echoorprintfapproach.
Pertanyaan umum
Mengapa penulisan biasa gagal?
Skill ini menyatakan alat tulis memiliki ukuran konten maksimum untuk satu panggilan, dan file besar bisa melebihinya.
Apa yang perlu di-escape?
Backslash dan tanda kutip di dalam isi file mungkin perlu diperhatikan agar tersimpan sesuai maksud.
Haruskah agent mencoba ulang dengan agent shell?
Skill ini meminta agar tidak, karena konten inline kemungkinan juga gagal di sana dengan alasan yang sama.
Detail
Deskripsi asli dari pembuat
Reliable fallback technique for writing large file contents when write_file and shell_agent both fail with 'unknown error' due to payload size limits β uses run_shell with a Python heredoc to bypass tool constraints.
repo: HKUDS/AgentPilot
Popularitas
- Bintang GitHub
- 7.8k
- Peringkat
- #13057
- Lisensi
- MIT
- Diperbarui
- 1/11/2026
Komentar
- β¦
Skill lain dari repositori ini
agentpilot
7.8kMembantu agent Anda meningkatkan proyek langkah demi langkah dengan menyiapkan tugas dan menjalankan loop AgentPilot yang mengusulkan, menguji, dan memberi skor pada perubahan.
openspace
7.8kMembantu agent Anda menyiapkan OpenSpace, alat yang menyimpan dan mengambil skill agent, lalu menghubungkannya ke aplikasi AI Anda melalui MCP.
rsi-arena
7.8kMembantu agent Anda menyiapkan dan menjalankan tes benchmark AI standar, seperti AIME dan Terminal-Bench, untuk membandingkan berbagai metode perbaikan.
experiment-guide
7.8kMembantu agent Anda merencanakan eksperimen kecil, membaca hasilnya, dan mencatat temuan saat menyelidiki cara memperbaiki sebuah program.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.