본문으로 건너뛰기
cccskills
무료GitHub에 공개

large-file-write-via-temp-script

Recover failed writes of large files or code containing special characters by placing content in a temporary Python script. Use raw strings or Base64 encoding, then check that the output file exists and has content.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

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.

설치 방법 보기

이럴 때 유용합니다

  • Retrying writes that fail with unknown errors
  • Writing TypeScript or TSX containing template literals
  • Saving long text with Unicode or special characters
  • Using Base64 when quoted strings are difficult to embed

포함된 파일(2)

  • SKILL.md4.6 KB
  • .skill_id46 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

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_file returns [ERROR] unknown error on large payloads
  • node -e '...' with backtick template literals silently empties the target file
  • python3 -c '...' breaks on unescaped quotes or special characters
  • shell_agent may 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 use node -e or inline Python. Instead write a Python script to /tmp/write_panel.py using a triple-quoted raw string, then execute it."


Decision Guide

SituationRecommended Approach
Content has backticks / ${} template literalsApproach A (raw r""")
Content has """ sequencesApproach B (base64)
Content is binary or non-UTF-8Approach B (base64)
Delegating to shell_agentApproach C with explicit instructions
Quick small fileDirect 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

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Prepare audio stems, the separate parts of a track, for mixing by matching their durations with silence, loops, or crossfades. Verify each generated and processed file before moving to the next production step.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Match audio parts with different durations
  • Extend drums and melodic parts using suitable methods
  • Check audio specifications before mixing
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

Produce audio in separate stems, meaning individual instrument tracks, and verify each output as you go. Align track lengths with silence, loops, or crossfades, then apply effects, mix a master, and package the files.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Align instrument tracks to a reference audio file
  • Choose how to extend tracks that are too short
  • Verify audio properties after generation and effects
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

Build serverless endpoints that relay external API requests for a dashboard while keeping API keys on the server. Includes Vercel examples for input checks, caching, cross-origin access, and consistent JSON responses.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Connect a dashboard to external APIs without exposing API keys
  • Create endpoints for stock quotes and news
  • Standardize API responses and error handling
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

Produce a master track and separate audio parts through a structured Python workflow. Apply filters and reverb, export WAV files with consistent settings, package them in a ZIP archive, and check that the deliverables meet the requested specifications.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Export a master track with separate audio parts
  • Apply filters and reverb to audio
  • Check duration and format across deliverables
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

Keep document creation moving when web searches and page retrieval repeatedly fail. The skill preserves the original task, uses the model’s existing knowledge, and clearly identifies information that could not be checked against external sources.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Continue drafting after repeated web retrieval failures
  • Preserve task requirements during network errors
  • Mark information that could not be externally verified
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

When Python execution repeatedly fails in execute_code_sandbox, use a file-based alternative: save the script, run it through the shell, and capture results or errors. The guidance covers paths, imports, timeouts, structured output, and optional cleanup.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Retry Python work through the shell after repeated sandbox failures
  • Run longer tasks with an adjusted timeout
  • Execute Python work that needs multiple files or system utilities
HKUDS/OpenSpace7.8천2026년 8월 13일 업데이트

HKUDS의 스킬 모두 보기

이 스킬의 문제 신고