Chuyển đến nội dung
Skillpedia
Lập trình chung48k · #6189

windows-shell-reliability

Skill này làm gì

Công cụ này giúp chạy lệnh trên Windows mà không gặp lỗi. Nó hướng dẫn cách xử lý đường dẫn tệp có khoảng trắng, dùng mã hóa văn bản đúng và tránh các lỗi thường gặp khi chạy chương trình.

Khi nào nên dùng

  • ✓Khi tạo hoặc sửa chương trình chạy trên Windows.
  • ✓Khi lệnh bị lỗi do tên tệp có khoảng trắng.
  • ✓Khi văn bản đầu ra của lệnh hiện ký tự lạ.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/windows-shell-reliability/SKILL.md

Sao 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

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/windows-shell-reliability/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm sao để chạy một chương trình nằm trong thư mục có khoảng trắng trong tên?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ hướng dẫn đặt dấu ngoặc kép quanh đường dẫn có khoảng trắng và dùng các lệnh Windows cụ thể để tránh lỗi mã hóa hoặc lỗi chương trình.

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.

Windows Shell Reliability Patterns

Best practices for running commands on Windows via PowerShell and CMD.

When to Use

Use this skill when developing or debugging scripts and automation that run on Windows systems, especially when involving file paths, character encoding, or standard CLI tools.


1. Encoding & Redirection

CRITICAL: Redirection Differences Across PowerShell Versions

Older Windows PowerShell releases can rewrite native-command output in ways that break later processing. PowerShell 7.4+ preserves the byte stream when redirecting stdout, so only apply the UTF-8 conversion workaround when you are dealing with older shell behavior or a log file that is already unreadable.

Problem Symptom Solution
dotnet > log.txt view_file fails in older Windows PowerShell `Get-Content log.txt
npm run > log.txt Need a UTF-8 text log with errors included `npm run ... 2>&1

Rule: Prefer native redirection as-is on PowerShell 7.4+, and use explicit UTF-8 conversion only when older Windows PowerShell redirection produces an unreadable log.


2. Handling Paths & Spaces

CRITICAL: Quoting

Windows paths often contain spaces.

❌ Wrong ✅ Correct
dotnet build src/my project/file.fsproj dotnet build "src/my project/file.fsproj"
& C:\Path With Spaces\bin.exe & "C:\Path With Spaces\bin.exe"

Rule: Always quote absolute and relative paths that may contain spaces.

The Call Operator (&)

In PowerShell, if an executable path starts with a quote, you MUST use the & operator.

Pattern:

& "C:\Program Files\dotnet\dotnet.exe" build ...

3. Common Binary & Cmdlet Pitfalls

Action ❌ CMD Style ✅ PowerShell Choice
Delete del /f /q file Remove-Item -Force file
Copy copy a b Copy-Item a b
Move move a b Move-Item a b
Make Dir mkdir folder New-Item -ItemType Directory -Path folder

Tip: Using CLI aliases like ls, cat, and cp in PowerShell is usually fine, but using full cmdlets in scripts is more robust.


4. Dotnet CLI Reliability

Build Speed & Consistency

Context Command Why
Fast Iteration dotnet build --no-restore Skips redundant nuget restore.
Clean Build dotnet build --no-incremental Ensures no stale artifacts.
Background Start-Process dotnet -ArgumentList 'run' -RedirectStandardOutput output.txt -RedirectStandardError error.txt Launches the app without blocking the shell and keeps logs.

5. Environment Variables

Shell Syntax
PowerShell $env:VARIABLE_NAME
CMD %VARIABLE_NAME%

6. Long Paths

Windows has a 260-character path limit by default.

Fix: If you hit long path errors, use the extended path prefix: \\?\C:\Very\Long\Path\...


7. Troubleshooting Shell Errors

Error Likely Cause Fix
The term 'xxx' is not recognized Path not in $env:PATH Use absolute path or fix PATH.
Access to the path is denied File in use or permissions Stop process or run as Admin.
Encoding mismatch Older shell redirection rewrote the output Re-export the file as UTF-8 or capture with `2>&1

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Câu hỏi thường gặp

Vì sao dấu ngoặc kép quan trọng với đường dẫn?

Vì Windows có thể hiểu khoảng trắng là kết thúc của một tên và bắt đầu của tên khác, gây lỗi.

Mã hóa văn bản là gì?

Đó là cách máy tính biểu diễn các ký tự. Dùng sai mã hóa có thể làm dấu và ký tự đặc biệt hiển thị sai.

Tôi có thể dùng các lệnh như ‘del’ hoặc ‘copy’ không?

Có, nhưng PowerShell có các cmdlet an toàn và rõ ràng hơn như ‘Remove-Item’ và ‘Copy-Item’, phù hợp hơn trong script.

Chi tiết

Mô tả gốc của tác giả

Reliable command execution on Windows: paths, encoding, and common binary pitfalls.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#6189
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự