large-file-write-via-temp-script
O que ela faz
Esta skill mostra ao agente de IA como salvar arquivos grandes que contêm caracteres complicados, como crases, template literals ou emojis. É para desenvolvedores que salvam arquivos TypeScript, TSX ou semelhantes que falham quando passados em linha.
Quando usar
- ✓Quando o conteúdo do arquivo inclui crases, template literals com chaves ou emojis que quebram comandos em linha.
- ✓Quando as tentativas de gravação em linha falham com erros desconhecidos ou esvaziam o arquivo sem aviso.
- ✓Quando um arquivo TypeScript ou TSX grande precisa ser salvo exatamente como escrito.
Link da skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/large-file-write-via-temp-script/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Salve este componente TSX no meu projeto. Ele tem crases e template literals, e as gravações em linha continuam quebrando.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente grava um pequeno script auxiliar em Python em um arquivo temporário. O conteúdo do arquivo fica dentro de uma string bruta nesse script, então os caracteres especiais são mantidos, e o agente executa o auxiliar para gravar o arquivo de destino.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do GitHub.
Large File Write via Temp Script
Problem
Writing large files — especially TypeScript, TSX, or any content containing
Unicode emoji, backticks, ${} template literals, or multi-line heredoc
conflicts — can silently fail or truncate content when passed inline.
Failure modes observed:
write_filereturns[ERROR] unknown erroron large payloadsnode -e '...'with backtick template literals silently empties the target filepython3 -c '...'breaks on unescaped quotes or special charactersshell_agentmay time out or fail when the inline content is too large
Solution: Write a Python Script to a Temp File First
Instead of passing file content inline, write a small Python helper script to
/tmp/write_task.py (or similar), then execute it. The helper script holds
the target file content as a raw Python string or via base64 decoding.
Approach A — Python Triple-Quoted String (preferred for readability)
Use write_file or a heredoc to create the helper, then run it:
# Step 1: Write the helper script to /tmp
cat > /tmp/write_task.py << 'PYEOF'
import pathlib
content = r"""
// Your TypeScript / file content goes here
// Backticks `like this`, ${template} literals, and emoji 🎉 are all safe
export const MyComponent = () => {
const msg = `Hello, world!`;
return <div>{msg}</div>;
};
"""
pathlib.Path("/path/to/target/file.ts").write_text(content.lstrip("\n"), encoding="utf-8")
print("Written successfully.")
PYEOF
# Step 2: Execute the helper
python3 /tmp/write_task.py
Why
r"""? A raw triple-quoted string avoids all backslash escaping issues. The only content that cannot appear verbatim is"""itself — if needed, split the string or escape that sequence only.
Approach B — Base64-Encoded Content (most robust for binary/complex content)
When the content contains """ or other Python string edge cases:
# Step 1: Base64-encode your content (done once, outside the target system)
# python3 -c "import base64; print(base64.b64encode(open('file.ts').read().encode()).decode())"
# Step 2: Embed the base64 blob in the helper script
cat > /tmp/write_task.py << 'PYEOF'
import base64, pathlib
b64 = (
"aW1wb3J0IFJlYWN0IGZyb20gJ3JlYWN0JzsKCmV4cG9ydCBjb25zdCBNeUNvbXBvbmVudCA9"
"ICgpID0+IHsKICByZXR1cm4gPGRpdj5IZWxsbzwvZGl2PjsKfTsK"
# ... more lines if needed
)
content = base64.b64decode(b64).decode("utf-8")
pathlib.Path("/path/to/target/file.ts").write_text(content, encoding="utf-8")
print(f"Written {len(content)} bytes successfully.")
PYEOF
python3 /tmp/write_task.py
Approach C — shell_agent Delegation (simplest for agents)
Ask shell_agent to perform the write using the temp-script pattern:
"Write the following TypeScript content to
/src/components/MyPanel.ts. Do NOT usenode -eor inline Python. Instead write a Python script to/tmp/write_panel.pyusing a triple-quoted raw string, then execute it."
Decision Guide
| Situation | Recommended Approach |
|---|---|
Content has backticks / ${} template literals |
Approach A (raw r""") |
Content has """ sequences |
Approach B (base64) |
| Content is binary or non-UTF-8 | Approach B (base64) |
| Delegating to shell_agent | Approach C with explicit instructions |
| Quick small file | Direct write_file (no workaround needed) |
Anti-Patterns to Avoid
# ❌ DANGEROUS — backtick template literals will break node -e
node -e "const fs = require('fs'); fs.writeFileSync('out.ts', \`${content}\`);"
# ❌ FRAGILE — breaks on unescaped quotes and special characters
python3 -c "open('out.ts','w').write('${content}')"
# ❌ UNRELIABLE for large payloads — may silently truncate
echo "${large_content}" > out.ts
Verification Step
Always verify the write succeeded:
# Check file exists and has non-zero size
python3 -c "
import pathlib
p = pathlib.Path('/path/to/target/file.ts')
assert p.exists() and p.stat().st_size > 0, f'Write failed: {p}'
print(f'OK — {p.stat().st_size} bytes written to {p}')
"
Notes
- The temp script approach works for any file type:
.ts,.tsx,.js,.json,.md,.py, etc. - Always
lstrip("\n")the triple-quoted string to avoid a leading blank line. - For very large files (>50 KB), prefer base64 to avoid any risk of heredoc conflicts.
- Clean up temp scripts after use:
rm /tmp/write_task.py
Perguntas frequentes
Por que a gravação em linha quebra?
A skill diz que crases, template literals e aspas podem ser cortados ou alterados quando passados em linha.
O que é uma string bruta?
É uma string do Python que mantém barras invertidas e caracteres especiais exatamente como foram digitados.
Onde fica o script auxiliar?
A skill usa um local temporário, como /tmp, mas um caminho temporário semelhante também pode ser usado.
Detalhes
Descrição original do autor
Reliable fallback technique for writing large or special-character-heavy file content when inline write_file or shell_agent calls fail with unknown errors — uses a Python helper script written to a temp file to avoid escaping and truncation pitfalls.
repo: HKUDS/AgentPilot
Popularidade
- Estrelas no GitHub
- 7,8 mil
- Posição no ranking
- #13059
- Licença
- MIT
- Atualizada em
- 01/11/2026
Comentários
- …
Mais skills deste repositório
agentpilot
7,8 milAjuda seu agente a melhorar um projeto passo a passo, preparando uma tarefa e executando o ciclo do AgentPilot, que propõe, testa e pontua mudanças.
openspace
7,8 milAjuda seu agente a configurar o OpenSpace, uma ferramenta que armazena e busca skills de agentes, e a conectá-la ao seu app de IA pelo MCP.
rsi-arena
7,8 milAjuda seu agente a configurar e rodar testes padrão de benchmark de IA, como AIME e Terminal-Bench, para comparar diferentes métodos de melhoria.
experiment-guide
7,8 milAjuda seu agente a planejar pequenos experimentos, ler seus resultados e registrar descobertas enquanto investiga como melhorar um programa.
Skills parecidas
diffs
394 milPermite que seu agente gere um diff real e compartilhável das edições, como link de visualização ou arquivo de imagem, em vez de um resumo escrito à mão.
coding-agent
394 milAjuda seu agente a passar um trabalho grande de programação para o Codex, Claude Code ou OpenCode em segundo plano e acompanhar o andamento.
gh-issues
394 milAjuda seu agente a encontrar issues do GitHub, escolher quais resolver e abrir pull requests com correções, acompanhando os comentários de revisão.