typescript-compile-check-resilient-fallback
Skill này làm gì
Skill này giải thích cách kiểm tra lỗi trong code TypeScript khi lệnh thông thường không chạy được. Nó mô tả đường dẫn dự phòng và cách phân biệt lỗi thật trong code với lỗi thiết lập. Skill dành cho lập trình viên làm dự án TypeScript.
Khi nào nên dùng
- ✓Khi lệnh kiểm tra TypeScript thông thường báo lỗi không liên quan đến code của bạn.
- ✓Khi bạn cần biết thay đổi của mình có biên dịch được trước khi hoàn thành hay không.
- ✓Khi bạn muốn tách lỗi kiểu thật khỏi sự cố công cụ hoặc môi trường.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/typescript-compile-check-resilient-fallback/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 thay đổi TypeScript của tôi có biên dịch được không, ngay cả khi lệnh kiểm tra thông thường không chạy?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent chạy kiểm tra chuẩn trước. Nếu chính công cụ bị lỗi, nó dùng phương án dự phòng, rồi phân loại lỗi code thật và lỗi thiết lập.
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 Fallback
Use this workflow whenever you need to verify that TypeScript files compile
cleanly after creating or modifying them, especially in environments where
npx or direct ./node_modules/.bin/tsc invocations may return unexpected
errors.
Step 1 — Attempt Primary Invocation
Run the compile check with run_shell using the standard approach:
npx tsc --noEmit
or, if you already know the project root:
./node_modules/.bin/tsc --noEmit
Evaluate the result:
- If it exits cleanly (exit code 0, no unexpected output) → done.
- If it exits with TypeScript diagnostic errors → proceed to Step 3.
- If it exits with an unknown / tool-level error (e.g.,
npxnot found, permission denied, spawn error, unclear non-zero exit unrelated to TS diagnostics) → proceed to Step 2.
Step 2 — Fallback via shell_agent
When the primary invocation fails with an unknown error, delegate to
shell_agent so it can resolve environment issues automatically:
Task: "From the project directory
<PROJECT_DIR>, runnode node_modules/typescript/bin/tsc --noEmitand report all TypeScript diagnostic errors."
Example shell_agent task string:
From /path/to/project, run:
node node_modules/typescript/bin/tsc --noEmit
Capture the full stdout/stderr output and return it.
shell_agent will handle PATH issues, working-directory changes, and
retry on transient failures automatically.
Step 3 — Filter Pre-Existing Errors
TypeScript projects frequently have pre-existing errors in files you did not touch. To avoid false regressions:
- Identify the baseline error count for the project (e.g., determined at task start or documented in task context). A common baseline is 11 pre-existing errors in unrelated files.
- Collect the full diagnostic list from tsc output.
- Filter to keep only errors whose file path matches a file you created or modified in this task.
- Evaluate:
- Zero errors in your new/modified files → ✅ no regression introduced.
- One or more errors in your new/modified files → ❌ fix them before proceeding.
Filtering heuristic (pseudocode)
all_errors = parse_tsc_output(tsc_stdout)
my_files = [list of files created/modified in this task]
new_errors = [e for e in all_errors if e.file in my_files]
if len(new_errors) == 0:
print("✅ No new TypeScript errors introduced.")
else:
for err in new_errors:
print(f"❌ {err.file}:{err.line} — {err.message}")
raise Exception("Fix TypeScript errors before continuing.")
Step 4 — Fix and Re-Run
If new errors are found:
- Fix the errors in your file(s).
- Repeat from Step 1.
Decision Tree Summary
run_shell: npx tsc --noEmit
│
├─ clean exit ──────────────────────────────► ✅ Done
│
├─ TS diagnostic errors ────────────────────► Step 3 (filter)
│
└─ unknown/tool error
│
└─ shell_agent: node .../tsc --noEmit
│
├─ TS diagnostic errors ────► Step 3 (filter)
└─ clean exit ──────────────► ✅ Done
Notes
- Always run tsc from the project root (where
tsconfig.jsonlives). - The
node node_modules/typescript/bin/tscinvocation is the most portable fallback because it bypassesnpx, shell PATH lookups, and binary permission issues entirely. - When the baseline error count is unknown, run tsc before making any changes and record the count; that becomes your baseline.
- Only report/act on errors in files you own; never attempt to fix pre-existing errors in third-party or unrelated project files unless explicitly asked.
Câu hỏi thường gặp
Phương án dự phòng là gì?
Nếu lệnh thông thường lỗi vì lý do không liên quan đến code, agent nhờ một công cụ hỗ trợ chạy kiểm tra theo cách khác.
Làm sao agent biết một lỗi là thật?
Lỗi thật đi kèm thông báo chẩn đoán của TypeScript, còn lỗi công cụ thì không có.
Cách này có thay đổi code của tôi không?
Không. Kiểm tra chỉ đọc code và báo cáo lỗi.
Chi tiết
Mô tả gốc của tác giả
A resilient workflow for running TypeScript compile checks (tsc --noEmit) that falls back gracefully when npx or direct binary invocations fail, and distinguishes pre-existing errors from newly introduced ones.
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #13083
- 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á.