write-special-chars-ts-check
하는 일
이 스킬은 특수 문자 파일 저장 우회 방법과, 새 파일로 범위를 한정한 TypeScript 타입 검사를 결합합니다. 이미 오류가 있는 프로젝트에서 TypeScript를 쓰는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓템플릿 문자열이나 아포스트로피가 있는 TypeScript 파일이 저장되지 않을 때.
- ✓프로젝트의 오래된 오류에 막히지 않고 새 TypeScript 파일만 확인해야 할 때.
- ✓평소 TypeScript 검사 명령이 알 수 없는 오류로 실패할 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/write-special-chars-ts-check/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“이 TypeScript 파일을 저장한 다음 컴파일되는지 확인해 주실 수 있나요? 프로젝트의 오래된 오류는 무시해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 도우미 스크립트로 파일을 저장한 뒤, TypeScript 컴파일러를 직접 실행하고 새 파일에 속한 오류만 보고합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Write File Special Characters Workaround (with TypeScript Verification)
Problem
The write_file tool may fail with [ERROR] unknown error when file content
contains special characters such as:
- Apostrophes / single quotes (
') - Backticks (
`) - Template literals (
`${variable}`) common in TypeScript/JavaScript - Complex combinations of quotes and escape sequences
This is especially common when writing TypeScript, JavaScript, shell scripts, or any source file with string interpolation syntax.
Additionally, after writing TypeScript files, you need to verify they are
type-correct — but common methods like npx tsc or ./node_modules/.bin/tsc
can fail with [ERROR] unknown error due to timeout or symlink resolution
issues. The reliable method is to call the TypeScript binary directly.
Solution: Python Heredoc Workaround + Direct TSC Verification
Phase 1: Write Files via Python Heredoc
Write a small Python script to /tmp/ that uses triple-quoted strings to
embed the file content, then execute it with python3.
Step-by-Step
- Compose a Python writer script using triple-quoted strings (
"""..."""). - Write the Python script itself to
/tmp/— its content is plain enough thatwrite_filewill succeed (no problematic characters in the wrapper). - Execute the script with
run_shell:python3 /tmp/write_<name>.py
Escaping Rules Inside the Python Script
| Character | How to handle |
|---|---|
Backslash \ |
Escape as \\ |
Triple double-quote """ |
Escape as \"\"\" or use ''' strings instead |
Everything else (backticks, $, ', {}) |
No escaping needed |
Template
#!/usr/bin/env python3
content = """
<YOUR FILE CONTENT HERE>
""".lstrip("\n")
with open("/path/to/target/file.ts", "w") as f:
f.write(content)
print("File written successfully.")
Concrete Example
Suppose you need to write a TypeScript file with template literals and
apostrophes that causes write_file to fail:
Step 1 — Write the Python helper to /tmp/:
Use write_file with path /tmp/write_greeting.py and content:
#!/usr/bin/env python3
content = """
export function greet(name: string): string {
const msg = `Hello, ${name}! It's a great day.`;
console.log(`Greeting: ${msg}`);
return msg;
}
""".lstrip("\n")
with open("/app/src/greeting.ts", "w") as f:
f.write(content)
print("Written: /app/src/greeting.ts")
Step 2 — Execute the helper:
python3 /tmp/write_greeting.py
Step 3 — Verify the file was created:
cat /app/src/greeting.ts
Phase 2: TypeScript Type-Checking (Reliable Method)
After writing TypeScript files, always verify they introduce zero new type
errors. Use the direct binary path — not npx or .bin symlinks, which
are prone to timeout and path-resolution failures.
The Reliable TSC Command
node node_modules/typescript/bin/tsc --noEmit 2>&1 | grep "src/greeting.ts"
Key points:
node node_modules/typescript/bin/tsc— invokes TypeScript directly vianode, bypassing npx overhead and symlink resolution entirely.--noEmit— type-checks only; does not write output files.2>&1— merges stderr into stdout so grep can filter everything.| grep "<filename>"— filters output to only lines mentioning your newly-written file(s), so pre-existing errors in other files do not create false alarms.
Why Not npx or .bin Symlinks?
| Method | Risk |
|---|---|
npx tsc --noEmit |
Frequently returns [ERROR] unknown error (timeout, network, PATH issues) |
./node_modules/.bin/tsc --noEmit |
Symlink resolution can fail in some environments |
node node_modules/typescript/bin/tsc --noEmit |
Reliable — direct JS execution, no symlinks, no network |
Filtering for Multiple New Files
When you've written several files, pipe through a more specific grep pattern:
node node_modules/typescript/bin/tsc --noEmit 2>&1 | grep -E "src/(greeting|utils|component)\.ts"
Or use a directory prefix to catch all new files in one folder:
node node_modules/typescript/bin/tsc --noEmit 2>&1 | grep "src/myfeature/"
Interpreting the Output
- No output / empty result — grep found no errors in your new files. ✅ The files are type-correct (pre-existing errors elsewhere are unrelated).
- Lines printed — type errors exist in your new files. ❌ Fix and re-check.
Example c
자주 묻는 질문
왜 새 파일만 검사하나요?
오래된 프로젝트에는 변경과 관계없는 오류가 흔히 있어서, 걸러내면 결과가 분명해진다고 스킬은 설명합니다.
검사 명령이 실패하면 어떻게 하나요?
스킬은 TypeScript 프로그램을 직접 호출하므로, 흔한 명령 문제를 피합니다.
추가 도구가 필요한가요?
파일을 저장할 때는 Python을, TypeScript 컴파일러를 실행할 때는 Node를 사용합니다.
상세 정보
작성자의 원본 설명
Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #13095
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.