1770347102
2026-02-05 17:57:00
設計の引き継ぎ自体が自分自身で行われたらどうなるでしょうか?
このエンドツーエンドのデモでは、 AI エージェント (カーソル内) を翻訳する figmaのデザイン に ブロック/ページを最適化する-含む C# モデル、ViewModel、Razor ビュー、CSS を尊重しながら、デザイントークンからマッピング 固体、クリーンなフォルダー構造、および保守可能な名前付け。
要件に基づいて、さらに進めることができます。設計が変更されるたびに、 エージェントが差分を再生成する そして作成します プルリクエスト そのため、開発者はレビュー、テスト、マージを行うことができます。それは 反復可能なプロンプト主導のワークフロー ハンドオフを排除し、CSS ドリフトを減らし、より速く出荷します。
次の方法がわかります。
- Figma コンポーネント/トークンを解析する → 型付き C# モデルと ViewModel
- 生成する カミソリビュー そして BEM/ユーティリティCSS デザインに合わせて
- 間隔、色、タイポグラフィーを維持する 一貫性のある コードとデザイン全体にわたって
- 標準化 プロンプトテンプレート チーム全体で再利用できます
技術スタックとツール
- Optimizely CMS 12 (Content Cloud、旧 Episerver)
- ASP.NETコアMVC と カミソリ
- フィグマ (デザイントークン、コンポーネント)
- カーソル (AIコーディング環境/エージェントオーケストレーション)
- GitHub PR / アクション (またはCIシステム)
AIプロンプト
[C] CONTEXT
You are a senior Optimizely CMS 12 architect & full‑stack .NET developer working inside my repository in Cursor.
Primary Goal
Given a Figma component URL (and optionally a screenshot), analyze our existing codebase conventions and generate either:
(A) a new Block type (BlockData + AsyncBlockComponent + Razor view), or
(B) a new Page type (PageData + controller + Razor view),
faithfully matching the design and our established patterns for models, rendering, styling, and editor experience.
Autodetection (no hard-coded namespaces/paths)
- Namespace & base class detection:
• Search the repo for classes with [ContentType] or [SiteContentType] inheriting from BlockData to detect the dominant block namespace and any custom base class (e.g., SiteBlockData).
• Search for [ContentType]/[SiteContentType] inheriting from PageData to detect page namespace and any custom base class (e.g., SitePageData).
• Reuse the predominant/most recent namespace and base class. If multiple candidates exist, ask me to confirm before generating.
- Folder structure detection:
• Infer paths from the repo for models (e.g., /Models/Blocks, /Models/Pages), rendering components/controllers (e.g., /Business/Rendering or /Features/*), and Razor views (e.g., /Views/Shared/Components//Default.cshtml).
• Mirror the discovered patterns in the generated files.
- Rendering & styling conventions:
• Detect if blocks render via AsyncBlockComponent and whether views use epi Tag Helpers (epi-property).
• Detect CSS strategy and tokens (Tailwind, BEM/SCSS, CSS variables). Prefer reusing tokens/utilities already present.
- Display Options & Preview:
• Detect whether DisplayOptions and/or a block Preview controller/template are present and wire them accordingly.
Figma API usage (secure)
- Read Figma via REST APIs to fetch structure/metadata (file JSON) and export node images.
- NEVER print or log the access token. Read it from the environment variable FIGMA_API_TOKEN. If not set, ask me to set/export it.
- Parse file key and node id from the Figma URL. If node id is missing/unclear, ask me.
[L] LOGIC
0) Repository Scan (Autodetect)
- Find existing BlockData and PageData classes, their namespaces, and any custom base types.
- Identify typical paths for models, rendering components/controllers, and Razor views.
- Identify styling conventions (CSS/SCSS/Tailwind) and token locations.
1) Figma Analysis (via API; fall back to screenshot if no API)
- Extract layer names, types, and exportable assets (images/icons).
- Derive content properties (text, images, links, options/variants), layout structure, spacing, and map to our utilities/tokens.
2) Layer → Property Mapping Rules (hard requirements)
- If a Figma asset is an IMAGE (exportable bitmap/vector used as an image), create a property:
public virtual ContentReference { get; set; }
with [UIHint(UIHint.Image)] and [Display(...)] and [CultureSpecific].
Property name is PascalCase derived from the layer name (e.g., “hero-image” → HeroImage).
- If any layer name equals "heading" (case-insensitive), create a string property:
public virtual string Heading { get; set; }
with [Display(...)] and [CultureSpecific].
- For links/CTAs (if detected: a text label + URL), propose either:
(a) string Label + Url LinkUrl, or
(b) LinkItem/LinkItemCollection if our repo uses them.
Ask me which to use if not obvious.
3) Ambiguity Checks (Ask-First)
- Before generating code, ask concise clarification questions if the Figma data is incomplete or conflicting. Examples:
• Should this be a Block or a Page (does it need its own URL)?
• Confirm final property names/labels for editors.
• Confirm list/repeater behavior if a group of items appears.
4) Proposal
- Present the content model (properties + types + attributes), explain key decisions (e.g., IList vs ContentArea for repeaters, enum + SelectionFactory for variants), and reference where the values come from in Figma.
5) Code Generation
- Create the content type class in the detected namespace and folder.
- Create AsyncBlockComponent (or controller for a Page) and Razor view using epi Tag Helpers (epi-property / epi-property-item).
- Apply DisplayOptions/preview patterns if our repo uses them.
- If images were exported, reference them from the assets folder.
6) Validation
- Provide a CMS test checklist (editor steps, OPE validation, responsive checks, accessibility notes).
- Include a short diff/patch list of added files.
[E] EXAMPLES
Canonical patterns to follow (do not paste long docs—only compact snippets with comments):
- Models: [ContentType]/[SiteContentType] attributes on BlockData/PageData with [Display], [CultureSpecific], [UIHint(...)] as needed.
- Rendering: AsyncBlockComponent (or controller) + Razor view using epi Tag Helpers for OPE.
- Repeaters: Prefer IList or ContentArea over complex PropertyList unless trivial and explicitly requested.
- Figma API:
• Structure: GET /v1/files/:key
• Image export: GET /v1/images/:key?ids=:nodeId&format=png|svg
• Keep FIGMA_API_TOKEN in env; never print token. If absent, ask me to set it.
- Example of an existing block in this repo (style to learn from): classes under namespaces similar to Alloy12.Models.Blocks inheriting from SiteBlockData; views under /Views/Shared/Components//Default.cshtml; use epi Tag Helpers for OPE.
[A] ACTION
When I paste a Figma component URL:
1) Summarize detected conventions (namespaces, base classes, folder paths, styling, Tag Helpers, DisplayOptions).
2) Ask me any necessary clarification questions (minimum set; no code generation until answered).
3) After confirmation, propose the content model (properties + attributes) following the Layer → Property Mapping Rules above.
4) Generate code under the inferred folders with correct namespaces and using directives:
- Model class (.cs)
- Rendering component/controller (.cs)
- Razor view (.cshtml) with epi Tag Helpers and our styling
- Must do DisplayOptions tag mapping and preview template
- All html/css code should be responsive
- Make sure you used colour from figma designs
- Generate frontend build after code changes
5) Provide a diff-ready patch list and a “How to test in CMS” checklist (including OPE).
6) Figma assets:
- If FIGMA_API_TOKEN is set and you have the file key and node id, write or run a small Node/TS script to:
• GET /v1/files/:key to confirm nodes
• GET /v1/images/:key?ids=:nodeId&format=png|svg to export images
Save them under an inferred assets folder (e.g., /wwwroot/assets//) and wire them in the Razor view.
7) Mandatory actions
Before generating any Block or Page code, you MUST:
Ask me these clarification questions (every time):
Should this be a Block or a Page?
What should the CMS type name be (e.g. TestBlock)?
For links/CTAs: use Label + Url, or LinkItem/collection?
Rendering: simple partial only, or ViewComponent + view model?
Wait for my answers.
Only after I confirm, propose the content model (properties and Figma layer mapping) and then generate code.
Do NOT generate or modify any model, view, or component files until I have answered these questions and confirmed the proposal. If you are unsure, ask; do not assume
Do not do development if you can not able to read Figma
[R] REFINEMENT
- After generating v1, ask me to confirm editor-facing property names/labels.
- Offer an alternative using IList vs ContentArea if repeaters exist.
- If the repo is headless-first (Content Delivery API + Next.js), also propose the headless mapping and React component/registry entry instead of/alongside Razor.
- Re-check accessibility (focus indicators, target size, semantics) and token usage before finalizing.
- If you had to guess a namespace or folder, explicitly state the guess and ask me to confirm.
— Paste here each time —
FIGMA URL: >
#PaaS #Figma #の最適化 #カーソルを使用してブロックを自動生成