typescript-compile-check-resilient
Skill này làm gì
Skill này mô tả cách chạy trình biên dịch TypeScript trực tiếp và chỉ hiển thị lỗi trong các file vừa được tạo hoặc chỉnh sửa. Skill dành cho lập trình viên làm trong dự án TypeScript lớn có lỗi cũ.
Khi nào nên dùng
- ✓Khi npx hoặc lệnh TypeScript bị lỗi trong môi trường dự án của bạn.
- ✓Khi dự án đã có lỗi kiểu cũ không liên quan đến thay đổi của bạn.
- ✓Khi bạn muốn xác nhận chỉ các file mới của mình biên dịch sạch.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/typescript-compile-check-resilient/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể kiểm tra các file vừa viết có biên dịch được không, và bỏ qua lỗi cũ ở phần còn lại của dự án?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent chạy trình biên dịch TypeScript thông qua file Node của nó, rồi lọc kết quả để chỉ hiển thị lỗi trong các file mới hoặc đã thay đổi.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
TypeScript Compile-Check (Resilient) with File-Scoped Error Filtering
Use this workflow when you need to validate TypeScript changes in a project but the standard npx tsc or node_modules/.bin/tsc invocations fail due to broken symlinks, missing PATH entries, or environment issues.
When to Use This Skill
npx tscfails with "command not found" or permission errorsnode_modules/.bin/tscsymlink is broken or unresolvable- You need to validate only newly-created or task-specific files without being blocked by pre-existing compile errors in the broader codebase
Step 1 — Invoke tsc Directly via node_modules
Bypass npx and symlinks entirely by calling the TypeScript binary directly:
node_modules/typescript/bin/tsc --noEmit 2>&1; echo EXIT:$?
Why this works: The tsc CLI entry point is a plain Node.js script at node_modules/typescript/bin/tsc. It does not depend on symlinks or PATH resolution. The --noEmit flag checks types without writing output files. Capturing EXIT:$? lets you programmatically detect success (EXIT:0) vs failure (EXIT:1 or higher).
If the project uses a custom tsconfig, specify it explicitly:
node_modules/typescript/bin/tsc --noEmit --project tsconfig.json 2>&1; echo EXIT:$?
Step 2 — Filter Output to Task-Specific Files Only
When a legacy codebase has pre-existing errors, the full tsc output will be noisy and may cause false negatives. Pipe through grep to isolate errors from only the files you created or modified:
node_modules/typescript/bin/tsc --noEmit 2>&1 \
| grep -E "(file-pattern)" ; echo EXIT:${PIPESTATUS[0]}
Examples
Single new file:
node_modules/typescript/bin/tsc --noEmit 2>&1 \
| grep -E "settings-store\.ts"
Multiple new files (pipe-delimited pattern):
node_modules/typescript/bin/tsc --noEmit 2>&1 \
| grep -E "(settings-keys|settings-store|preferences|SettingsModal)"
All files in a specific directory:
node_modules/typescript/bin/tsc --noEmit 2>&1 \
| grep -E "src/features/my-feature/"
Check: no output = no errors in your files (success).
Step 3 — Capture Exit Code Correctly Through a Pipe
When grepping, the shell exit code reflects grep, not tsc. Use ${PIPESTATUS[0]} (bash) to recover the original tsc exit code:
node_modules/typescript/bin/tsc --noEmit 2>&1 \
| grep -E "(my-file-pattern)"; echo "TSC_EXIT:${PIPESTATUS[0]}"
Or store errors explicitly:
TSC_OUTPUT=$(node_modules/typescript/bin/tsc --noEmit 2>&1)
TSC_EXIT=$?
echo "$TSC_OUTPUT" | grep -E "(settings-keys|settings-store|preferences|SettingsModal)"
echo "TSC_EXIT:$TSC_EXIT"
The second approach (storing output in a variable) is the most reliable since $? is captured before the pipe.
Step 4 — Interpret Results
| Condition | Meaning |
|---|---|
TSC_EXIT:0, no grep output |
✅ Full project clean, your files are fine |
TSC_EXIT:1, no grep output |
✅ Your files are fine; pre-existing errors elsewhere (acceptable) |
TSC_EXIT:1, grep output present |
❌ Your files have errors — fix them |
TSC_EXIT:2 |
❌ tsc configuration error (bad tsconfig, missing typescript package) |
Fallback: Verify TypeScript Is Installed
If node_modules/typescript/bin/tsc does not exist:
# Check if typescript is installed
ls node_modules/typescript/bin/tsc 2>/dev/null || echo "TypeScript not installed"
# Install if needed
npm install --save-dev typescript
# or
yarn add --dev typescript
Full Example
# Store full tsc output and exit code
TSC_OUTPUT=$(node_modules/typescript/bin/tsc --noEmit 2>&1)
TSC_EXIT=$?
# Show only errors in newly-created files
NEW_FILE_ERRORS=$(echo "$TSC_OUTPUT" | grep -E "(settings-keys|settings-store|preferences|SettingsModal)")
if [ -z "$NEW_FILE_ERRORS" ]; then
echo "✅ No TypeScript errors in new files (TSC_EXIT:$TSC_EXIT)"
else
echo "❌ TypeScript errors in new files:"
echo "$NEW_FILE_ERRORS"
exit 1
fi
Notes
- This technique is safe for CI and local environments alike.
- The direct
node_modules/typescript/bin/tscpath works on macOS, Linux, and Windows (vianode node_modules/typescript/bin/tscon Windows CMD). - On Windows, replace the bash script with:
node node_modules/typescript/bin/tsc --noEmit - Always prefer
--noEmitfor validation-only checks to avoid side effects.
Câu hỏi thường gặp
Vì sao chạy trình biên dịch trực tiếp?
Chạy qua file Node giúp tránh các lỗi về liên kết và đường dẫn lệnh có thể làm hỏng lệnh thông thường.
Tôi có thể dùng một file cấu hình cụ thể không?
Có. Kiểm tra có thể trỏ tới file cấu hình của dự án để dùng đúng thiết lập.
Làm sao agent biết kiểm tra đã đạt?
Lệnh in ra mã thoát, và mã này bằng không khi không có lỗi.
Chi tiết
Mô tả gốc của tác giả
TypeScript compile-checking in projects where npx and node_modules/.bin symlinks fail, with a filtering technique to isolate errors from only newly-created or task-specific files — ignoring pre-existing legacy errors.
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #13084
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.