Woocommerce Backend Dev

woocommerce/woocommerce/.ai/skills/woocommerce-backend-dev

作者 woocommerce40608fbc7cca無授權條款10K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Add or modify WooCommerce backend PHP code following project conventions. Use when creating new classes, methods, hooks, or modifying existing backend code. **MUST be invoked before writing any PHP unit tests.**

AI 產生的概覽

指導 WooCommerce 後端 PHP 開發,涵蓋類別、鉤子、相依性注入、資料完整性與單元測試的慣例。

功能
此技能提供在新增或修改後端 PHP 程式碼時應遵循的 WooCommerce 專案慣例。它會引導代理查閱關於檔案與程式碼實體、編碼風格、型別註解、鉤子、相依性注入、資料完整性與單元測試的參考文件。它也說明如何從 trunk 分支推導 @since 註解所需的下一個版本號。其產出是符合慣例的 PHP 程式碼與測試,而非獨立的交付檔案。
適用情境
在撰寫新的 PHP 單元測試、建立新的 PHP 類別、修改現有後端 PHP 程式碼,或新增鉤子與篩選器之前使用。它適用於必須遵循專案標準的 WooCommerce 程式碼庫內的工作。
執行需求
不含指令碼,僅為說明文件與供模型閱讀的參考文件。需要存取 WooCommerce 程式碼庫(包括 trunk 上的 includes/class-woocommerce.php),並了解 WordPress 編碼標準、PSR-4 自動載入、PHPStan 與 PHP 單元測試。

WooCommerce Backend Development

This skill provides guidance for developing WooCommerce backend PHP code according to project standards and conventions.

When to Use This Skill

ALWAYS invoke this skill before:

  • Writing new PHP unit tests (*Test.php files)
  • Creating new PHP classes
  • Modifying existing backend PHP code
  • Adding hooks or filters

Instructions

Follow WooCommerce project conventions when adding or modifying backend PHP code:

  1. Creating new code structures: See file-entities.md [blocked] for conventions on creating classes and organizing files (but for new unit test files see unit-tests.md [blocked]).
  2. Naming conventions: See code-entities.md [blocked] for naming methods, variables, and parameters
  3. Coding style: See coding-conventions.md [blocked] for general coding standards and best practices
  4. Type annotations: See type-annotations.md [blocked] for PHPStan-aware PHPDoc annotations
  5. Working with hooks: See hooks.md [blocked] for hook callback conventions and documentation
  6. Dependency injection: See dependency-injection.md [blocked] for DI container usage
  7. Data integrity: See data-integrity.md [blocked] for ensuring data integrity when performing CRUD operations
  8. Writing tests: See unit-tests.md [blocked] for unit testing conventions

Key Principles

  • Always follow WordPress Coding Standards
  • Use class methods instead of standalone functions
  • Place new internal classes in src/Internal/ by default
  • Use PSR-4 autoloading with Automattic\WooCommerce namespace
  • Write comprehensive unit tests for new functionality
  • Run linting and tests before committing changes

Version Information

To determine the next WooCommerce version number for @since annotations:

  • Read the $version property in includes/class-woocommerce.php on the trunk branch
  • Remove the -dev suffix if present
  • Example: If trunk shows 10.4.0-dev, use @since 10.4.0
  • Note: When reviewing PRs against trunk, the version in trunk is correct even if it seems "future" relative to released versions

來源與署名

來源:woocommerce/woocommerce位於.ai/skills/woocommerce-backend-dev提交40608fb

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架