SKILL.md

  1---
  2name: layout
  3description: "Improve layout, spacing, and visual rhythm. Fixes monotonous grids, inconsistent spacing, and weak visual hierarchy. Use when the user mentions layout feeling off, spacing issues, visual hierarchy, crowded UI, alignment problems, or wanting better composition."
  4argument-hint: "[target]"
  5user-invocable: true
  6---
  7
  8Assess and improve layout and spacing that feels monotonous, crowded, or structurally weak — turning generic arrangements into intentional, rhythmic compositions.
  9
 10## MANDATORY PREPARATION
 11
 12Invoke {{command_prefix}}impeccable — it contains design principles, anti-patterns, and the **Context Gathering Protocol**. Follow the protocol before proceeding — if no design context exists yet, you MUST run {{command_prefix}}impeccable teach first.
 13
 14---
 15
 16## Assess Current Layout
 17
 18Analyze what's weak about the current spatial design:
 19
 201. **Spacing**:
 21   - Is spacing consistent or arbitrary? (Random padding/margin values)
 22   - Is all spacing the same? (Equal padding everywhere = no rhythm)
 23   - Are related elements grouped tightly, with generous space between groups?
 24
 252. **Visual hierarchy**:
 26   - Apply the squint test: blur your (metaphorical) eyes — can you still identify the most important element, second most important, and clear groupings?
 27   - Is hierarchy achieved effectively? (Space and weight alone can be enough — but is the current approach working?)
 28   - Does whitespace guide the eye to what matters?
 29
 303. **Grid & structure**:
 31   - Is there a clear underlying structure, or does the layout feel random?
 32   - Are identical card grids used everywhere? (Icon + heading + text, repeated endlessly)
 33   - Is everything centered? (Left-aligned with asymmetric layouts feels more designed, but not a hard and fast rule)
 34
 354. **Rhythm & variety**:
 36   - Does the layout have visual rhythm? (Alternating tight/generous spacing)
 37   - Is every section structured the same way? (Monotonous repetition)
 38   - Are there intentional moments of surprise or emphasis?
 39
 405. **Density**:
 41   - Is the layout too cramped? (Not enough breathing room)
 42   - Is the layout too sparse? (Excessive whitespace without purpose)
 43   - Does density match the content type? (Data-dense UIs need tighter spacing; marketing pages need more air)
 44
 45**CRITICAL**: Layout problems are often the root cause of interfaces feeling "off" even when colors and fonts are fine. Space is a design material — use it with intention.
 46
 47## Plan Layout Improvements
 48
 49Consult the [spatial design reference](reference/spatial-design.md) from the impeccable skill for detailed guidance on grids, rhythm, and container queries.
 50
 51Create a systematic plan:
 52
 53- **Spacing system**: Use a consistent scale — whether that's a framework's built-in scale (e.g., Tailwind), rem-based tokens, or a custom system. The specific values matter less than consistency.
 54- **Hierarchy strategy**: How will space communicate importance?
 55- **Layout approach**: What structure fits the content? Flex for 1D, Grid for 2D, named areas for complex page layouts.
 56- **Rhythm**: Where should spacing be tight vs generous?
 57
 58## Improve Layout Systematically
 59
 60### Establish a Spacing System
 61
 62- Use a consistent spacing scale — framework scales (Tailwind, etc.), rem-based tokens, or a custom scale all work. What matters is that values come from a defined set, not arbitrary numbers.
 63- Name tokens semantically if using custom properties: `--space-xs` through `--space-xl`, not `--spacing-8`
 64- Use `gap` for sibling spacing instead of margins — eliminates margin collapse hacks
 65- Apply `clamp()` for fluid spacing that breathes on larger screens
 66
 67### Create Visual Rhythm
 68
 69- **Tight grouping** for related elements (8-12px between siblings)
 70- **Generous separation** between distinct sections (48-96px)
 71- **Varied spacing** within sections — not every row needs the same gap
 72- **Asymmetric compositions** — break the predictable centered-content pattern when it makes sense
 73
 74### Choose the Right Layout Tool
 75
 76- **Use Flexbox for 1D layouts**: Rows of items, nav bars, button groups, card contents, most component internals. Flex is simpler and more appropriate for the majority of layout tasks.
 77- **Use Grid for 2D layouts**: Page-level structure, dashboards, data-dense interfaces, anything where rows AND columns need coordinated control.
 78- **Don't default to Grid** when Flexbox with `flex-wrap` would be simpler and more flexible.
 79- Use `repeat(auto-fit, minmax(280px, 1fr))` for responsive grids without breakpoints.
 80- Use named grid areas (`grid-template-areas`) for complex page layouts — redefine at breakpoints.
 81
 82### Break Card Grid Monotony
 83
 84- Don't default to card grids for everything — spacing and alignment create visual grouping naturally
 85- Use cards only when content is truly distinct and actionable — never nest cards inside cards
 86- Vary card sizes, span columns, or mix cards with non-card content to break repetition
 87
 88### Strengthen Visual Hierarchy
 89
 90- Use the fewest dimensions needed for clear hierarchy. Space alone can be enough — generous whitespace around an element draws the eye. Some of the most sophisticated designs achieve rhythm with just space and weight. Add color or size contrast only when simpler means aren't sufficient.
 91- Be aware of reading flow — in LTR languages, the eye naturally scans top-left to bottom-right, but primary action placement depends on context (e.g., bottom-right in dialogs, top in navigation).
 92- Create clear content groupings through proximity and separation.
 93
 94### Manage Depth & Elevation
 95
 96- Create a semantic z-index scale (dropdown → sticky → modal-backdrop → modal → toast → tooltip)
 97- Build a consistent shadow scale (sm → md → lg → xl) — shadows should be subtle
 98- Use elevation to reinforce hierarchy, not as decoration
 99
100### Optical Adjustments
101
102- If an icon looks visually off-center despite being geometrically centered, nudge it — but only if you're confident it actually looks wrong. Don't adjust speculatively.
103
104**NEVER**:
105- Use arbitrary spacing values outside your scale
106- Make all spacing equal — variety creates hierarchy
107- Wrap everything in cards — not everything needs a container
108- Nest cards inside cards — use spacing and dividers for hierarchy within
109- Use identical card grids everywhere (icon + heading + text, repeated)
110- Center everything — left-aligned with asymmetry feels more designed
111- Default to the hero metric layout (big number, small label, stats, gradient) as a template. If showing real user data, a prominent metric can work — but it should display actual data, not decorative numbers.
112- Default to CSS Grid when Flexbox would be simpler — use the simplest tool for the job
113- Use arbitrary z-index values (999, 9999) — build a semantic scale
114
115## Verify Layout Improvements
116
117- **Squint test**: Can you identify primary, secondary, and groupings with blurred vision?
118- **Rhythm**: Does the page have a satisfying beat of tight and generous spacing?
119- **Hierarchy**: Is the most important content obvious within 2 seconds?
120- **Breathing room**: Does the layout feel comfortable, not cramped or wasteful?
121- **Consistency**: Is the spacing system applied uniformly?
122- **Responsiveness**: Does the layout adapt gracefully across screen sizes?
123
124Remember: Space is the most underused design tool. A layout with the right rhythm and hierarchy can make even simple content feel polished and intentional.