rushstack-best-practices

โดย microsoft

ให้แนวทางปฏิบัติที่ดีที่สุดและคำแนะนำสำหรับการทำงานกับ Rush monorepos ใช้เมื่อผู้ใช้กำลังทำงานในที่เก็บที่ใช้ Rush เป็นฐาน ถามเกี่ยวกับคำสั่ง Rush…

npx skills add https://github.com/microsoft/rushstack --skill rushstack-best-practices

Rushstack Best Practices

This skill provides essential best practices for working with Rush monorepos. Following these guidelines ensures efficient dependency management, optimal build performance, and proper command usage.

Important Guidelines

When encountering unclear issues or questions:

  1. Never make assumptions - If unsure about Rush behavior, configuration, or commands
  2. Search official resources first - Check documentation and existing issues before guessing
  3. Provide accurate information - Base responses on verified sources, not assumptions
  4. Ask for clarification - When the problem description is ambiguous or incomplete

Core Principles

  1. Always use Rush commands - Avoid npm/pnpm/yarn directly in a Rush monorepo
  2. Use rushx for single projects - Like npm run, but Rush-aware
  3. rush install vs update - install for CI, update after changes
  4. rush build vs rebuild - build for incremental, rebuild for clean
  5. Projects at 2 levels - Standard: apps/, libraries/, tools/
  6. Selection flags reduce scope - Use --to, --from, --impacted-by
  7. Build cache is automatic - Configure output folders to enable
  8. Subspace for large repos - Isolate dependencies when needed

Project Selection Best Practices

When running commands like install, update, build, rebuild, etc., by default all projects under the entire repository are processed. Use these selection flags to improve efficiency:

--to

Select specified project and all its dependencies.

  • Build specific project and its dependencies
  • Ensure complete dependency chain build
rush build --to @my-company/my-project
rush build --to my-project  # If project name is unique
rush build --to .            # Use current directory's project

--to-except

Select all dependencies of specified project, but not the project itself.

  • Update project dependencies without processing project itself
  • Pre-build dependencies
rush build --to-except @my-company/my-project

--from

Select specified project and all its downstream dependencies.

  • Validate changes' impact on downstream projects
  • Build all projects affected by specific project
rush build --from @my-company/my-library

--impacted-by

Select projects that might be affected by specified project changes, excluding dependencies.

  • Quick test of project change impacts
  • Use when dependency status is already correct
rush build --impacted-by @my-company/my-library

--impacted-by-except

Similar to --impacted-by, but excludes specified project itself.

  • Project itself has been manually built
  • Only need to test downstream impacts
rush build --impacted-by-except @my-company/my-library

--only

Only select specified project, completely ignore dependency relationships.

  • Dependency status is known to be correct
  • Combine with other selection parameters
rush build --only @my-company/my-project
rush build --impacted-by projectA --only projectB

Command Usage Guidelines

Command Tool Selection

Choose the correct command tool based on different scenarios:

  1. rush command - Execute operations affecting the entire repository or multiple projects

    • Strict parameter validation and documentation
    • Support for global and batch commands
    • Suitable for standardized workflows
    • Use cases: Dependency installation, building, publishing
  2. rushx command - Execute specific scripts for a single project

    • Similar to npm run or pnpm run
    • Uses Rush version selector for toolchain consistency
    • Prepares shell environment based on Rush configuration
    • Use cases: Running project-specific build scripts, tests, dev servers
  3. rush-pnpm command - Replace direct use of pnpm in Rush repository

    • Sets correct PNPM workspace context
    • Supports Rush-specific enhancements
    • Provides compatibility checks with Rush
    • Use cases: When direct PNPM commands are needed

Install vs Update

CommandBehaviorWhen to Use
rush updateUpdates shrinkwrap, installs new dependenciesAfter cloning, after git pull, after modifying package.json
rush installRead-only install from existing shrinkwrapCI/CD pipelines, ensuring version consistency

Build vs Rebuild

CommandBehaviorWhen to Use
rush buildIncremental build, only changed projectsDaily development, quick validation
rush rebuildClean build all projectsComplete rebuild needed, investigating issues

Dependency Management

Package Manager Selection

Choose in rush.json:

{
  "pnpmVersion": "8.x.x"     // Preferred - efficient, strict
  // "npmVersion": "8.x.x"   // Alternative
  // "yarnVersion": "1.x.x"  // Alternative
}

Version Constraints

Configure in common/config/subspaces/<subspace>/common-versions.json:

{
  "preferredVersions": {
    "react": "17.0.2",
    "typescript": "~4.5.0"
  },
  "implicitlyPreferredVersions": true,
  "allowedAlternativeVersions": {
    "typescript": ["~4.5.0", "~4.6.0"]
  }
}

Adding/Removing Dependencies

Always use Rush commands, not npm/pnpm directly:

rush add -p lodash --dev      # Add dev dependency
rush add -p react --exact     # Add exact version
rush remove -p lodash         # Remove dependency

Build Cache Configuration

Configure in <project>/config/rush-project.json:

{
  "operationSettings": [
    {
      "operationName": "build",
      "outputFolderNames": ["lib", "dist"],
      "disableBuildCacheForOperation": false,
      "dependsOnEnvVars": ["MY_ENV_VAR"]
    }
  ]
}

Cache Behavior:

  • Cache stored in common/temp/build-cache
  • Invalidated by: source changes, dependency changes, env vars, command params
  • Parallel builds supported via enableParallelism

Troubleshooting

Dependency Issues

  • Avoid npm, pnpm, yarn - use Rush commands
  • Run rush purge to clean environment
  • Run rush update --recheck to force dependency check

Build Issues

  • Use rush rebuild to skip cache
  • Check rushx build output for specific errors
  • Use --verbose for detailed logs

Performance Issues

  • Use selection flags (--to, --from, etc.) to reduce scope
  • Enable build cache in rush-project.json
  • Consider subspace for very large monorepos

Subspace for Large Monorepos

What is Subspace:

  • Allows multiple PNPM lock files in one Rush monorepo
  • Enables independent dependency management per team/project group
  • Reduces risk from dependency updates
  • Improves install/update performance

When to Use:

  • Large monorepos (50+ projects)
  • Multiple teams with different dependency needs
  • Conflicting version requirements
  • Need for faster dependency operations

Official Resources

Documentation & References

Official Websites:

Search Existing Issues:

When to Search vs. Ask

Search these resources first when:

  • Encountering error messages
  • Unsure about configuration options
  • Looking for examples or tutorials
  • Need to understand Rush behavior

Ask the user for clarification when:

  • The specific use case is unclear
  • Multiple approaches are possible
  • Context is missing to provide accurate guidance
  • The issue might be environment-specific

Detailed References

For expanded information on specific domains, see:

  • references/core-commands.md - Detailed command reference
  • references/project-configuration.md - Configuration file specifications
  • references/dependency-management.md - Advanced dependency patterns
  • references/build-system.md - Build optimization and caching
  • references/subspace.md - Subspace setup and usage

Skills เพิ่มเติมจาก microsoft

oss-growth
microsoft
บุคลิกภาพนักเติบโตโอเอสเอส
official
microsoft-foundry
microsoft
ปรับใช้ ประเมิน และจัดการ Foundry agents แบบครบวงจร: สร้าง Docker, push ไปยัง ACR, สร้าง hosted/prompt agent, เริ่ม container, batch eval, continuous eval, เวิร์กโฟลว์ prompt optimizer, agent.yaml, จัดชุดข้อมูลจาก traces ใช้สำหรับ: ปรับใช้ agent ไปยัง Foundry, hosted agent, สร้าง agent, เรียกใช้ agent, ประเมิน agent, รัน batch eval, continuous eval, การตรวจสอบต่อเนื่อง, สถานะ continuous eval, ปรับแต่ง prompt, ปรับปรุง prompt, prompt optimizer, ปรับแต่งคำแนะนำ agent, ปรับปรุง agent...
officialdevelopmentdevops
azure-ai
microsoft
ใช้สำหรับ Azure AI: ค้นหา, คำพูด, OpenAI, การประมวลผลเอกสารอัจฉริยะ ช่วยในการค้นหา, การค้นหาแบบเวกเตอร์/ไฮบริด, การแปลงคำพูดเป็นข้อความ, การแปลงข้อความเป็นคำพูด, การถอดเสียง, OCR เมื่อ: การค้นหา AI, การค้นหาคำถาม, การค้นหาแบบเวกเตอร์, การค้นหาแบบไฮบริด, การค้นหาเชิงความหมาย, การแปลงคำพูดเป็นข้อความ, การแปลงข้อความเป็นคำพูด, การถอดเสียง, OCR, แปลงข้อความเป็นคำพูด
officialdevelopmentapi
azure-deploy
microsoft
ดำเนินการปรับใช้ Azure สำหรับแอปพลิเคชันที่เตรียมไว้แล้วซึ่งมีไฟล์ .azure/deployment-plan.md และไฟล์โครงสร้างพื้นฐานอยู่แล้ว ห้ามใช้ทักษะนี้เมื่อผู้ใช้ขอสร้างแอปพลิเคชันใหม่ ให้ใช้ azure-prepare แทน ทักษะนี้รันคำสั่ง azd up, azd deploy, terraform apply และ az deployment พร้อมการกู้คืนข้อผิดพลาดในตัว ต้องมี .azure/deployment-plan.md จาก azure-prepare และสถานะที่ตรวจสอบแล้วจาก azure-validate เมื่อ: "run azd up", "run azd deploy", "execute deployment",...
officialdevopsaws
azure-storage
microsoft
บริการ Azure Storage รวมถึง Blob Storage, File Shares, Queue Storage, Table Storage และ Data Lake ตอบคำถามเกี่ยวกับระดับการเข้าถึงพื้นที่จัดเก็บ (hot, cool, cold, archive) ว่าเมื่อใดควรใช้แต่ละระดับ และการเปรียบเทียบระดับ ให้บริการจัดเก็บวัตถุ, แชร์ไฟล์ SMB, การส่งข้อความแบบอะซิงโครนัส, NoSQL key-value และการวิเคราะห์ข้อมูลขนาดใหญ่ รวมถึงการจัดการวงจรชีวิต ใช้สำหรับ: blob storage, file shares, queue storage, table storage, data lake, อัปโหลดไฟล์, ดาวน์โหลด blobs, storage accounts, access tiers,...
officialdevelopmentdatabase
azure-diagnostics
microsoft
ดีบักปัญหาการผลิตบน Azure โดยใช้ AppLens, Azure Monitor, สถานะทรัพยากร และการจัดลำดับความสำคัญอย่างปลอดภัย เมื่อ: ดีบักปัญหาการผลิต, แก้ไขปัญหาแอปบริการ, แอปบริการ CPU สูง, แอปบริการล้มเหลวในการปรับใช้, แก้ไขปัญหาคอนเทนเนอร์แอป, แก้ไขปัญหาฟังก์ชัน, แก้ไขปัญหา AKS, kubectl ไม่สามารถเชื่อมต่อ, kube-system/CoreDNS ล้มเหลว, pod รอ, crashloop, node ไม่พร้อม, การอัปเกรดล้มเหลว, วิเคราะห์บันทึก, KQL, ข้อมูลเชิงลึก, การดึงอิมเมจล้มเหลว, ปัญหาการเริ่มต้นเย็น, การตรวจสอบสถานะล้มเหลว,...
officialdevopsdevelopment
azure-prepare
microsoft
เตรียมแอปพลิเคชัน Azure สำหรับการปรับใช้ (infra Bicep/Terraform, azure.yaml, Dockerfiles) ใช้สำหรับสร้าง/ปรับปรุงให้ทันสมัย หรือสร้าง+ปรับใช้ ไม่ใช่สำหรับการย้ายข้ามคลาวด์ (ใช้ azure-cloud-migrate) ห้ามใช้สำหรับ: แอป copilot-sdk (ใช้ azure-hosted-copilot-sdk) เมื่อ: "สร้างแอป", "สร้างเว็บแอป", "สร้าง API", "สร้าง HTTP API แบบไร้เซิร์ฟเวอร์", "สร้างฟรอนต์เอนด์", "สร้างแบ็กเอนด์", "สร้างบริการ", "ปรับปรุงแอปพลิเคชันให้ทันสมัย", "อัปเดตแอปพลิเคชัน", "เพิ่มการรับรองความถูกต้อง", "เพิ่มการแคช", "โฮสต์บน Azure", "สร้างและ...
officialdevelopmentdevops
azure-validate
microsoft
การตรวจสอบความพร้อมก่อนการปรับใช้สำหรับ Azure ตรวจสอบเชิงลึกเกี่ยวกับการกำหนดค่า โครงสร้างพื้นฐาน (Bicep หรือ Terraform) การกำหนดบทบาท RBAC สิทธิ์ของ managed identity และข้อกำหนดเบื้องต้นก่อนการปรับใช้ เมื่อ: ตรวจสอบแอปของฉัน ตรวจสอบความพร้อมในการปรับใช้ เรียกใช้การตรวจสอบก่อนดำเนินการ ยืนยันการกำหนดค่า ตรวจสอบว่าพร้อมปรับใช้หรือไม่ ตรวจสอบ azure.yaml ตรวจสอบ Bicep ทดสอบก่อนปรับใช้ แก้ไขข้อผิดพลาดในการปรับใช้ ตรวจสอบ Azure Functions ตรวจสอบ function app ตรวจสอบ serverless...
officialdevopstesting