layout-grid
Skill17 starsChanged 11 days agoMITView on GitHub
Grid and alignment rules for a WinUI 3 app, with three checks that catch misalignment (a lint for off-grid numbers in XAML and C#, a layout probe that measures real bounds in snapshot mode, and a grid overlay). Use when building or reviewing a custom page, card, row, form, or dialog, after every build that touched layout, or when the user says something looks misaligned, crooked, cramped, or unevenly spaced.
4 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- Stijnus/dsh-rev-engedited, first seen Nov 8, 2026
- daveebbelaar/bamaedited, first seen Nov 1, 2026
- miovrag/claude-skillstheir own version, first seen Jun 12, 2026
- launchapp-dev/animus-clitheir own version, first seen Mar 15, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- daveebbelaar/bama★ 1.7k35% same
- Stijnus/dsh-rev-eng★ 145% same
Wrote their own version · 2
- launchapp-dev/animus-cli★ 39same name
- miovrag/claude-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- agent-cliSkill
- csharp-winuiSkill
- improve-architectureSkill
- os-integrationsSkill
- performanceSkill
- app-iconSkill
- design-from-appSkill
- design-kitSkill
- design-systemSkill
- ux-designSkill
- windows-designSkill
- cloneSkill
- researchSkill
- user-storiesSkill
- build-and-verifySkill
- distributeSkill
- improve-loopSkill
- test-windows-appSkill
- app-briefSkill
- bawaSkill
- new-windows-appSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Every margin, padding, spacing, and size comes from Space.xaml in XAML ({StaticResource SpaceLg}) and Space in code (Space.Lg): Xs 4, Sm 8, …
- Distinctive: line 52
Run it after every build that touched pages:
- Distinctive: line 102
Never overlaps another probe in its area.
- Distinctive: line 110
When a check fails and the cause is not clear, draw the grid over the window:
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Layout grid
Agents guess numbers. A guessed Margin="13" looks almost right and makes
the whole app feel slightly off. This skill replaces guessing with one
scale and three checks that fail when something is off. Windows itself
lays out on a 4 epx grid, so the scale matches every WinUI control.
The template has everything in place: src/<App>/UI/Space.xaml,
UI/Grid.cs, and tools/. For an app made before this skill, copy those
two files, tools/grid-lint.ps1, and tools/check-layout.ps1 from the
new-windows-app skill's template, and the GridProbes.Write line from
its Snapshot.cs.
The rules
- Every margin, padding, spacing, and size comes from
Space.xamlin XAML ({StaticResource SpaceLg}) andSpacein code (Space.Lg):Xs 4,Sm 8,Md 12,Lg 16,Xl 24,Xxl 36,Section 48. Raw numbers are 0, 1, 2, or a multiple of 4. - Pages have 36 epx side margins (
PageMargin). Cards pad 16 (CardPadding). Related controls sit 8 apart, cards 16 apart in a row and 4 apart in a stack of settings cards, groups 24 to 32, sections 48. - Each column has one leading edge. Titles, text, cards, and buttons in a column start on the same x. Indent on purpose, by a step of the scale.
- Let containers do the aligning:
- Rows and columns of values:
GridwithRowSpacingandColumnSpacing. - A stack:
StackPanelwithSpacing, never a margin on each child. - A label above a control: the control's own
Header. - A setting:
SettingsCard, which aligns icon, text, and control. - Numbers in a column:
FontFeaturestabular figures or a fixed column, right aligned. - An icon with text: a horizontal
StackPanelwithSpacing8 or 12, both centered vertically.
- Rows and columns of values:
- Dialogs keep
ContentDialog's own width. Fixed widths for columns are multiples of 4 (ListColumnWidth320). Controls take their height from WinUI, never a fixedHeight. - Nested corners are concentric: inner radius = outer radius - padding.
RenderTransformwith aTranslateTransformandCanvas.Leftmove a view after layout, so nothing lines up with it. Use them only for motion and drag previews, withgrid: ok <why>in a comment on the line.- Long text trims with its full value in a tooltip. Nothing clips.
Check 1: lint the code
Run it after every build that touched pages:
tools/grid-lint.ps1
# src\Tasks\Pages\TodayPage.xaml:14: off grid (10): <StackPanel Margin="10,0,0,0">
# FAIL grid-lint: 1 lines off the gridFix each line with a token. Silence a line on purpose with
<!-- grid: ok <why> --> or // grid: ok <why> on the same line.
Check 2: probe the real layout
Mark what you lay out yourself: the page, its sections, cards, rows in a
card, dialog content. NavigationView, ListView rows, SettingsCard,
and CommandBar align themselves and need no probes.
<StackPanel Padding="{StaticResource PageMargin}" Spacing="{StaticResource SpaceXl}"
ui:GridArea.Name="page" ui:GridArea.Inset="{StaticResource SpaceXxl}">
<Grid ui:GridProbe.Area="page" ui:GridProbe.Name="header"> ... </Grid>
<local:StatsRow ui:GridProbe.Area="page" ui:GridProbe.Name="stats" />
<Border Style="{StaticResource CardStyle}" ui:GridProbe.Area="page" ui:GridProbe.Name="card" />
</StackPanel>ui:GridArea marks a container and its inset. ui:GridProbe marks a view
in it. Probes with the same Edge (default lead) must share one leading
edge. Set ui:GridProbe.Edge="" for views that sit side by side.
Probe a row, not the text in it. A title centered against a taller command bar has a bottom edge that is not on any grid line, while the row is.
Snapshot mode writes a <page>-<mode>-layout.json next to every PNG,
with positions in epx and the display scale. Check them:
tools/check-layout.ps1
# PASS all-light-layout.json: 2 probes in 1 areas
# FAIL today-light-layout.json
# - edge page/lead has 2 leading edges: header 356.8, stats 360.8It checks that every probe:
- Starts on a whole physical pixel, so its edges stay sharp.
- Starts a multiple of 4 epx from its area's edge.
- Stays inside its area's inset on both sides.
- Shares one leading edge with the others on its edge.
- Sits a multiple of 4 epx below the probe above it.
- Never overlaps another probe in its area.
At 125% or 150% display scale WinUI snaps edges to physical pixels, so a 36 epx margin can measure 36.8. Every comparison allows one physical pixel; a real misalignment is larger.
Check 3: look at the grid
When a check fails and the cause is not clear, draw the grid over the window:
tools/snap.ps1 -Grid -Pages todayThe PNGs show an 8 epx grid, each area in blue with its inset dashed, and each probe in pink with its name. Open them with the Read tool.
Fix a failure
| Message | Usual cause | Fix |
| starts 23 epx into page | a raw margin on one child | remove it, use the panel's Spacing or Padding token |
| 2 leading edges | a centered panel, or one child with extra margin | HorizontalAlignment="Stretch" or Left on the children |
| gap 10 epx | Spacing="10", or a margin on top of Spacing | one token, on the panel |
| gap 29.2 epx between a title and a list | the probe sits on centered text | probe the row that holds the text |
| not inside its 36 epx inset | a missing PageMargin, or a fixed width wider than the parent | Padding="{StaticResource PageMargin}", MaxWidth instead of Width |
| overlap | a TranslateTransform, Canvas.Left, or a fixed height | remove it, let the panel size the view |
| ScrollViewer's child sets MaxWidth | the page column sits straight in the ScrollViewer, which places it by its desired width: maximized, it slides off the right edge | a <Grid> between the ScrollViewer and the column |
| between physical pixels | a fractional number, or UseLayoutRounding="False" | a whole number from Space, layout rounding on |
Done when tools/grid-lint.ps1 passes, tools/check-layout.ps1 passes on
the layout files of every page you touched, and every custom page and
card has a ui:GridArea with probes on its main parts.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

