writing-tsdocs

bởi medusajs

Thêm và cập nhật chú thích TypeDoc (TSDoc) vào các tệp nguồn TypeScript trong codebase Medusa. Bao gồm các loại HTTP, tuyến API, thành phần UI, mô hình dữ liệu, dịch vụ…

npx skills add https://github.com/medusajs/medusa --skill writing-tsdocs

Writing Medusa TSDocs

Adds TypeDoc (TSDoc) comments to Medusa TypeScript source files. Follows TypeDoc conventions and uses custom tags defined in www/utils/packages/typedoc-config/tsdoc.json.

Constraints

CRITICAL: Violating these produces incorrect or broken documentation.

  • Never document unexported items — only exported interfaces, types, functions, classes
  • Never add TSDocs to test files — skip *.spec.ts, *.test.ts, __tests__/
  • Never fabricate @since version numbers — only use the version passed in the prompt
  • Never remove or modify existing TSDocs — only add where missing
  • Never modify logic — only add/edit comment blocks
  • For Medusa-specific custom tags, only use those defined in tsdoc.json: @expandable, @featureFlag, @since, @apiIgnore, @schema, @tags, @version, @keep, @customNamespace, @namespaceMember

Load Reference Files When Needed

Load the reference file for the file type you're documenting before writing any TSDocs.

Path patternLoad
packages/core/types/src/http/reference/http-types.md
packages/medusa/src/api/admin/ or /store/reference/api-routes.md
packages/design-system/ui/src/components/reference/ui-components.md
packages/modules/*/src/models/reference/data-models.md
packages/core/types/src/ (non-http)reference/service-interfaces.md
packages/core/js-sdk/src/reference/service-interfaces.md
packages/core/utils/src/ (abstract providers)reference/service-interfaces.md
packages/core/workflows-sdk/src/utils/composer/reference/service-interfaces.md
packages/core/core-flows/src/ (workflows)reference/workflows-steps.md
packages/core/core-flows/src/ (steps)reference/workflows-steps.md
packages/core/utils/src/core-flows/events.tsreference/events.md

Quick Reference

TSDoc block format

/**
 * Brief description.
 */
export interface Foo {
  /**
   * The foo's ID.
   */
  id: string
}

Per-type depth guide

File typeWhat to documentKey Medusa tags
HTTP typesEvery exported interface/type + all properties@expandable on nested objects
API routesExported handlers only (minimal)@featureFlag, @since
UI componentsComponent + all propsPlain descriptions
Data modelsModel + each property@since on new items
Service interfacesEvery method in full@param, @returns, @example
JS SDKEvery public method@param, @returns, @example, @tags
ProvidersClass + every abstract method@param, @returns, @example
Workflow SDKEvery exported function@param, @returns, @example
core-flows workflowsWorkflow export + hooks@summary, @featureFlag, @since
core-flows stepsStep export + input type@featureFlag, @since, @example
EventsEvery event constant@eventPayload, @featureFlag, @since

Medusa custom tags (from www/utils/packages/typedoc-config/tsdoc.json)

TagKindUse when
@featureFlag <name>blockExport requires a feature flag to be enabled
@expandablemodifierNested object expandable in API queries
@since <version>blockExport was added in this version (prompt-provided only)
@apiIgnoremodifierExclude from API docs output
@tags <name>blockSDK categorization
@schemablockCustom schema documentation
@keepmodifierPreserve during doc generation
@customNamespaceblockAssign to custom doc namespace

Standard TypeDoc/JSDoc tags (@param, @returns, @example, @deprecated, @remarks, etc.) are always allowed.

Common Mistakes

  • Documenting unexported or private items
  • Using @since without a version being provided in the prompt
  • Writing property descriptions longer than 2 sentences
  • Adding @param/@returns to non-method exports (interfaces, types)
  • Documenting an id field without specifying what resource it belongs to

Reference Files

reference/http-types.md          - HTTP type interfaces: properties, @expandable
reference/api-routes.md          - API routes: @featureFlag, @since, minimal docs
reference/ui-components.md       - UI components: component + inline prop pattern
reference/data-models.md         - DML models: @since, property descriptions
reference/service-interfaces.md  - Methods, SDK, providers, workflow SDK: full JSDoc
reference/workflows-steps.md     - core-flows workflows and steps: @summary, hooks, @example
reference/events.md              - Event constants: @eventPayload, @featureFlag, @since

Thêm skills từ medusajs

mcloud-variables
medusajs
Thực thi các lệnh biến mcloud để liệt kê và lấy các biến môi trường cho một môi trường Cloud. Sử dụng khi kiểm tra, đọc hoặc xuất môi trường…
official
building-storefronts
medusajs
Tích hợp frontend theo SDK cho các storefront Medusa với các mẫu React Query và quy tắc gọi API quan trọng. Luôn sử dụng Medusa JS SDK cho mọi yêu cầu API—không bao giờ dùng fetch() thông thường, vì nó thiếu các header cần thiết (khóa API có thể xuất bản cho các route store, xác thực cho các route admin). Truyền các đối tượng JavaScript thuần cho các phương thức SDK; không bao giờ dùng JSON.stringify() trên các tham số body, vì SDK tự động xử lý tuần tự hóa. Sử dụng useQuery cho các yêu cầu GET và useMutation cho các yêu cầu POST/DELETE,...
official
building-admin-dashboard-customizations
medusajs
Các tiện ích mở rộng giao diện người dùng tùy chỉnh cho bảng điều khiển quản trị Medusa sử dụng Admin SDK và các thành phần giao diện Medusa. Tải kỹ năng này TRƯỚC TIÊN cho bất kỳ công việc giao diện quản trị nào (lập kế hoạch, triển khai, khám phá); máy chủ MCP chỉ cung cấp tham chiếu API, không phải mẫu thiết kế hoặc chiến lược tải dữ liệu. QUAN TRỌNG: Luôn sử dụng Medusa JS SDK cho tất cả các yêu cầu API (không bao giờ dùng fetch thông thường); tách biệt truy vấn hiển thị khỏi truy vấn modal và vô hiệu hóa dữ liệu
official
learning-medusa
medusajs
Khóa học phát triển Medusa tương tác từng bước, nơi bạn xây dựng tính năng thương hiệu trong khi học các mẫu kiến trúc. Ba bài học tiến dần (tổng cộng 2–3 giờ) bao gồm modules, workflows, API routes, module links, workflow hooks và tùy chỉnh giao diện quản trị. Kiểm tra xác nhận sau mỗi thành phần chính để đánh giá hiểu biết khái niệm, chất lượng mã và chức năng trước khi tiếp tục. Coi lỗi là cơ hội giảng dạy; gỡ lỗi cùng nhau với các câu hỏi chẩn đoán và nguyên nhân gốc rễ...
official
db-migrate
medusajs
Thực thi các migration cơ sở dữ liệu Medusa đang chờ và báo cáo kết quả. Chạy npx medusa db:migrate qua Bash để áp dụng tất cả migration đang chờ vào cơ sở dữ liệu Medusa của bạn. Báo cáo kết quả migration bao gồm số lượng migration đã áp dụng, bất kỳ lỗi nào gặp phải và xác nhận thành công. Được thiết kế cho các dự án Medusa với thiết lập npm/npx tiêu chuẩn.
official
mcloud-environments
medusajs
Thực thi các lệnh mcloud environments để liệt kê, lấy, tạo, xóa, triển khai lại hoặc kích hoạt bản dựng cho các môi trường Cloud. Sử dụng khi quản lý vòng đời môi trường,…
official
db-generate
medusajs
Tạo migrations cơ sở dữ liệu cho các module Medusa chỉ với một lệnh duy nhất. Bao bọc lệnh CLI npx medusa db:generate để tạo các tệp migration cho các module Medusa được chỉ định. Chấp nhận tên module làm đối số và báo cáo vị trí tệp migration, lỗi và các bước tiếp theo. Tự động đề xuất chạy npx medusa db:migrate sau khi tạo để áp dụng migrations.
official
mcloud-deployments
medusajs
Thực thi các lệnh mcloud deployments để liệt kê các deployment, truy xuất chi tiết deployment và tải nhật ký build. Sử dụng khi liệt kê deployment, kiểm tra deployment…
official