Skillpedia
برمجة عامة48k · #6189

windows-shell-reliability

ما الذي تفعله

تساعد هذه المهارة في تشغيل الأوامر على Windows دون أخطاء. تعلّم كيفية التعامل مع مسارات الملفات التي تحتوي على مسافات، واستخدام الترميز الصحيح للنص، وتجنب المزالق الشائعة عند تشغيل البرامج.

متى تستخدمها

  • ✓عند إنشاء برامج تعمل على Windows أو إصلاحها.
  • ✓عندما تفشل الأوامر بسبب أسماء ملفات تحتوي على مسافات.
  • ✓إذا ظهر نص المخرجات بأحرف غريبة.

رابط المهارة

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

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/windows-shell-reliability/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“كيف أشغّل برنامجاً موجوداً في مجلد اسمه يحتوي على مسافة؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

تعلّم المهارة وضع علامات تنصيص حول مسارات الملفات التي تحتوي على مسافات، واستخدام أوامر Windows محددة لتجنب أخطاء الترميز أو مشكلات البرامج.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

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.
الأسئلة الشائعة

لماذا علامات التنصيص مهمة للمسارات؟

لأن Windows قد يفسّر المسافة على أنها نهاية اسم وبداية آخر، فيسبب أخطاء.

ما هو الترميز (text encoding)؟

هو طريقة تمثيل الحاسوب للأحرف. استخدام ترميز خاطئ قد يجعل الحروف المميزة والرموز تظهر بشكل غير صحيح.

هل يمكنني استخدام أوامر مثل «del» أو «copy»؟

نعم، لكن PowerShell يوفر أوامر أكثر أماناً ووضوحاً مثل «Remove-Item» و«Copy-Item»، وهي مفضلة في السكريبتات.

التفاصيل

الوصف الأصلي من المؤلف

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

repo: sickn33/agentic-awesome-skills

الشعبية

نجوم GitHub
48k
الترتيب
#6189
الترخيص
MIT
آخر تحديث
15‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة