Cdrf Expert

vintasoftware/django-ai-plugins/skills/cdrf-expert

作者 vintasoftwareb8af2688d994無授權條款152 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫2 個月前更新

Expert guidance for Django REST Framework class-based views using Classy DRF (https://www.cdrf.co). Use when selecting or debugging APIView, GenericAPIView, concrete generic views, mixin combinations, or ViewSet/GenericViewSet/ModelViewSet behavior; tracing method resolution order (MRO); understanding which method to override (`create` vs `perform_create`, `update` vs `perform_update`, `destroy` vs `perform_destroy`, `get_queryset`, `get_serializer_class`); and comparing behavior across DRF versions. Do not use for function-based views, GraphQL, FastAPI/Flask, frontend work, or non-DRF backend frameworks.

AI 產生的概覽

透過 Classy DRF 參考資料,指引 Django REST Framework 類別基礎檢視的選擇、覆寫點、MRO 追蹤與版本差異。

功能
此技能會把 Django REST Framework 類別基礎檢視的問題歸類為類別選擇、生命週期追蹤、覆寫策略、MRO 除錯或版本差異等類別,然後只載入對應的參考檔案。它會引導代理查閱特定版本的 Classy DRF 頁面,以取得祖先類別、方法來源與預設屬性。最後產出建議的類別、應覆寫的方法、以方法解析順序與生命週期為依據的理由、精簡的程式碼修補或骨架,以及風險與應新增的測試。
適用情境
適用於在 APIView、GenericAPIView、具體通用檢視、mixin 或 ViewSet 之間做選擇,或判斷應覆寫 create 還是 perform_create 等鉤子時。也適合追蹤某個方法來自哪個類別,以及比較不同 DRF 版本之間的行為差異。不適用於函式基礎檢視、GraphQL、FastAPI 或 Flask、前端工作,或非 DRF 後端框架。
執行需求
需要連線至 cdrf.co 的網路存取,並在無法使用時退回 DRF 官方文件與已安裝的原始碼。使用者應提供專案的 DRF 版本,或接受明確標示的版本無關假設。此技能不含指令碼,只有參考文件。

CDRF Expert

Instructions

  1. Classify the request.

Map the user request to one or more categories:

  • Class selection (APIView vs GenericAPIView vs concrete generics vs ViewSets)
  • Lifecycle tracing (request-to-response flow)
  • Override strategy (which hook to customize)
  • MRO debugging (method came from mixin/base class)
  • Version differences (behavior changed between DRF versions)
  1. Read only the required reference file(s).

Load the minimum needed context:

  • references/class-selection-matrix.md for class selection
  • references/lifecycle-and-overrides.md for hook placement and lifecycle
  • references/mro-debugging-playbook.md for MRO/source-of-method tracing
  • references/version-check-workflow.md for DRF-version comparisons
  1. Navigate cdrf.co with version-first discipline.
  • Identify the project DRF version from user context.
  • If unknown, ask for version or provide a version-agnostic answer and explicitly mark assumptions.
  • Open the matching CDRF version namespace first (for example https://www.cdrf.co/3.16/).
  • Open the target class page and extract:
    • Ancestors and MRO
    • Available methods and source class for each method
    • Default attributes that affect behavior (queryset, serializer_class, pagination/filter backends)
  1. Choose the minimal override point.
  • Prefer narrow hooks (perform_create, perform_update, perform_destroy) before broad methods (create, update, destroy).
  • Prefer get_queryset and get_serializer_class for per-request behavior over hardcoding class attributes.
  • Keep HTTP orchestration in view methods and business/domain logic outside views.
  • Preserve DRF defaults unless the request needs behavior changes.
  1. Produce an answer grounded in method flow.

Return:

  • Recommended class
  • Method(s) to override
  • Why these methods are correct in the MRO/lifecycle
  • Concise code patch or skeleton
  • Risks/regressions and tests to add
  1. Validate before finalizing.

Check for common regressions:

  • Accidentally bypassing permission/authentication/filter/pagination hooks
  • Duplicating object-save logic between serializer and view
  • Overriding broad methods when narrow hooks are sufficient
  • Depending on methods not present in the selected DRF version

Error Handling

  1. If cdrf.co is unavailable, state that limitation and fall back to DRF official docs and installed source code.
  2. If the user cannot provide DRF version, provide a version-agnostic path and clearly mark assumptions.
  3. If multiple override points appear valid, recommend the narrowest hook first and explain tradeoffs.

Output Rules

  • Cite exact class and method names from CDRF.
  • State assumptions when DRF version is unknown.
  • Keep responses focused on DRF CBV internals and actionable code changes.

來源與署名

來源:vintasoftware/django-ai-plugins位於skills/cdrf-expert提交b8af268

授權條款: 無授權條款

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

檢舉或申請下架