MANDATORY: Read Samples Before Implementation
STOP — you MUST read ALL of the following before writing ANY code:
Samples (in the SAME folder as this SKILL.md):
view-entity-sample.razorview-entity-sample.cs
Target component and project files:
- The target
.razorand.razor.cs - Related project files: DTOs, enums
Design and styling context (search the project — these are NOT in the SKILL.md folder):
design.md— search for this file anywhere in the project; read it in full if found; if absent, note the absence and continue without design contextux-tokens.css,ux-base.css,ux-components.css— read from the project'swwwrootfolder if present; note any that are absent
If any sample file (items 1–2) cannot be accessed: stop immediately, confirm the SKILL.md folder location, retry from that location, and if still inaccessible report which file is missing. Do not proceed with partial implementation or approximation.
If items 5–6 are not found: note the absence and continue — they are reference context, not blocking.
MANDATORY: Match Sample Layout (Visual Structure)
When a sample exists, you MUST match the sample's visual structure, not only its data-loading behavior.
Required process:
- Reuse the sample's top-level component layout (hero header + main card) unless the user explicitly requests otherwise.
- If the sample uses shared utility classes (e.g.
ux-gradient-primary,ux-fade-in-up), verify they exist by grepping for the class name as a substring (e.g.ux-gradient-primary) across all CSS files underwwwroot(includingux-tokens.css,ux-base.css, andux-components.css). CSS utility classes are often defined as compound selectors (e.g..mud-paper.ux-gradient-primary), so search for the class name alone, not the full selector. If the class name appears anywhere in any CSS file, it exists and must be used.
Required baseline layout (when supported by the target app):
- A hero header using
MudPaperwithClass="pa-4 mb-4 ux-gradient-primary"andElevation="0" - A main content card using
MudCardwithClass="ux-fade-in-up"andStyle="animation-delay: 0.1s"
Forbidden:
- Replacing the hero header with a different structure (e.g.
MudCardHeader) unless explicitly requested - Dropping the sample's utility classes when they exist in the target project
Preserve Existing Implementation
Use for: Read-only view or detail entity pages in Blazor with MudBlazor
Do NOT use for: Add or edit forms, search pages, dialogs, or non-Blazor projects
Source of truth: Existing .razor.cs file defines data loading, service calls, navigation, and the DTO structure
You MUST NOT:
- Modify existing backend methods such as
LoadEntity()orLoadEntityAsync() - Change service calls or their parameters
- Add, rename, or remove DTO properties
- Invent fields or services not present in the backing class
- Rewrite existing C# functionality
- Put C# logic in the
.razorfile using@code - Render editable inputs — this page is read-only
1. Data Loading
Load data through existing lifecycle methods and backing methods such as OnInitializedAsync(), OnParametersSetAsync(), or explicit load methods already present in .razor.cs.
Show a loading indicator while the data object is null, using the same pattern as the sample (MudProgressCircular inside a centered MudStack).
Do not display entity content until the data object is non-null.
2. Map DTO Properties to Read-Only Display
Render all scalar DTO properties as labeled read-only fields using MudText:
| Property Type | Display |
|---------------|---------|
| String / number | MudText Typo="Typo.body1" with MudText Typo="Typo.overline" label above |
| Boolean / status | MudChip with conditional Color and Variant |
| Enum | Resolved display label (not raw integer) in MudChip or MudText |
| Nullable object | Conditional section rendered only when non-null |
| Collection | Iterated with @foreach, each item in a MudPaper card |
Chip rules:
- Use
T="string"on everyMudChip - Match
Colorsemantics:Color.Successfor positive/active,Color.DefaultorColor.Errorfor inactive/negative - Match
Variantsemantics:Variant.Filledfor active,Variant.Outlinedfor inactive or neutral
Enum rules:
- Locate the real enum definition before referencing it
- Use verified member names only — never copy from sample code without confirming they match the target enum
3. Nullable Object Sections
Render optional nested objects inside an @if guard matching the existing null check in the backing class.
Do not render nested fields outside their guard block.
4. Child Collections
Render child collections with @foreach inside a guarded @if block.
- When the collection has items, render each in a
MudPaperwithClass="pa-3 ux-inner-panel"andElevation="0"usingMudGrid— do not useOutlined="true"or hardcode aStyleborder-radius - When the collection is empty or null, render a
MudTextfallback message usingColor.Secondary - Never use
forloops with index variables for read-only collections —@foreachis correct here
5. Navigation Actions
Render navigation buttons at the bottom of the card in a right-aligned MudStack:
- Render an Edit button only when a matching edit route or method exists in
.razor.cs - Always render a Back button that calls the existing
Cancel()or equivalent navigation method - Never invent navigation methods or routes
Button placement:
- Use
Justify="Justify.FlexEnd"onMudStack Row="true",Spacing="2",AlignItems="AlignItems.Center"
6. Styling
- Prefer shared utility styles first
- Keep component-specific styles minimal
- Never modify existing shared styles, variables, or theme values
- Match the sample layout without introducing unnecessary wrappers
- If the sample uses shared utility classes (for example
ux-gradient-primary,ux-fade-in-up), verify they exist in the target app's styles (usually underwwwroot) and reuse them
Design and styling context
Apply the design token and CSS utility context from the files you read in the mandatory phase. Use var(--token) for all inline Style= attributes — never hardcode hex values. Verify utility classes (e.g. ux-fade-in-up, ux-gradient-primary) exist before applying. The design context informs styling choices only — it does not override layout structure.
Definition of Done
- [ ] All properties displayed in
.razorexist on the DTO returned by the backing class - [ ] No
@codeblock was introduced in.razor - [ ] No editable inputs (e.g.
MudTextField,MudSelect) were rendered - [ ] Data is loaded through existing lifecycle or backing methods only
- [ ] A loading state is shown while the data object is null
- [ ] Nullable object sections are guarded by
@ifmatching existing backing logic - [ ] Child collections use
@foreachwith an empty-state fallback message - [ ] Enum values were verified against the real enum definition before use
- [ ] Navigation buttons call only existing methods or use existing routes
- [ ] Shared styles were preserved and component styling remained minimal
- [ ] Sample visual structure was matched (hero header + main card)
- [ ] Sample utility classes were verified to exist in the target project and reused when available