/gridkit:grid-alignfrom gridkit
Audits UI against a layout grid (columns, gutters, margins, baseline rhythm, spacing scale, breakpoints) and optionally fixes code to snap to it. Works on SwiftUI/UIKit iOS apps and web apps (CSS, Tailwind, CSS-in-JS, React).
Ships in gridkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Bring an existing app's layout onto a chosen grid: define the spec → audit (code + screenshots) → report → optionally apply fixes → re-audit.
Everything is measured, not eyeballed. The bundled scripts resolve the grid to exact numbers per viewport, collect real element frames from the running app, and flag what is off and by how much. Your judgment goes into telling intentional deviations from mistakes, tracing findings to source, and choosing the idiomatic fix.
$SKILL below means this skill's directory (the folder holding this file). Scripts need only python3, plus node + Playwright for web screenshots and Xcode for iOS.
| Script | What it does |
|---|---|
scripts/gridspec.py | List presets, write .gridkit/spec.json, resolve the grid for a viewport (column x-positions, span widths, rhythm, key lines), check values against the spacing scale |
scripts/scan_spacing.py | Static scan for literal spacing off the scale: SwiftUI/UIKit, CSS/SCSS, JSX styles, Tailwind classes, spacing tokens |
scripts/web_capture.mjs | Web: per route × width — collect frames, audit, save raw + annotated screenshots |
scripts/collect_frames.js / annotate_page.js | The in-page halves of the above, usable from any browser tool |
assets/GridAuditFrames.swift | iOS: XCUITest that dumps accessibility frames + screenshot per screen |
scripts/audit_frames.py | Audits a frames JSON against the spec → numbered findings (md/json) |
scripts/annotate.swift | Draws grid + numbered findings onto any screenshot (macOS) |
All output goes in .gridkit/ in the user's project: spec.json (commit it) and audit/ (suggest adding .gridkit/audit/ to .gitignore).
Package.swift/*.xcodeproj with SwiftUI or UIKit; package.json (React/Vue/Svelte/plain), Tailwind (tailwindcss dependency, @theme, tailwind.config.*), CSS modules, styled-components. A repo can hold both, so audit each separately with its own spec (.gridkit/spec.ios.json, .gridkit/spec.web.json)..gridkit/spec.json, a GridKit JSON (brand-grid.json, GridKit.shared.load, initialPreset=, .apply(preset:)), spacing tokens (enum Spacing, --space-*, Tailwind spacing/--spacing), container widths, breakpoints. Existing tokens tell you the de-facto system even when nobody wrote it down.import GridKit, gridkit-react). It isn't required, but with it the user can see the same grid live while you work.If a spec already exists, show its resolved numbers and confirm it's still the target. Otherwise, build one with the user:
python3 $SKILL/scripts/gridspec.py presets --platform web # or ios
Ask (AskUserQuestion, one round, recommended option first, based on what Phase 0 found):
swiss-12-column for most web, four-column-mobile or ios-standard for phone apps, asymmetric-editorial/modular-* for content-heavy layouts), their existing GridKit JSON, or custom numbers.hero-split has one), 4 or 8, or the body line height for reading layouts. Don't drop it unless the user asks: without it, vertical gaps are only checked against the spacing scale, and line heights and text baselines aren't checked at all.Ask about margin, gutter or max-width overrides afterwards, and only if the preset doesn't fit (e.g. their site caps content at 1200px).
Then write and adjust the spec:
python3 $SKILL/scripts/gridspec.py init --platform web --preset swiss-12-column --spacing-base 8 # --rhythm 4 to override the preset's
python3 $SKILL/scripts/gridspec.py resolve # every target in the spec
The full format is in references/spec-format.md. Show the user a small table of the resolved grid per target (variant, column count, column width, gutter, content span, rows, baseline rhythm), so you both agree on the numbers before anything gets flagged.
Run all three passes. They catch different things.
python3 $SKILL/scripts/scan_spacing.py --spec .gridkit/spec.json src/ # or the app's Sources/
This lists every literal spacing value that's off the scale, with file:line and the nearest on-scale value. The histogram at the top matters most: one value used 40 times (say 12 → 16) usually has a single root cause, such as a token, a shared component, or a Tailwind class pattern.
Web. The dev server must be running. Start it in the background if it isn't, then:
node $SKILL/scripts/web_capture.mjs --spec .gridkit/spec.json --url http://localhost:5173 --routes /,/pricing
Playwright comes from the project, or from PLAYWRIGHT_DIR. If neither has it, ask before installing anything. Either add it as a dev dependency, or install it outside the project: npm i --prefix ~/.cache/gridkit-align playwright && npx --prefix ~/.cache/gridkit-align playwright install chromium, then run with PLAYWRIGHT_DIR=~/.cache/gridkit-align. If a browser MCP (Claude in Chrome or the built-in browser) is available instead, do the same steps by hand. Resize to each target width. Evaluate collect_frames.js and save the result as <name>.frames.json. Run audit_frames.py --format json. Evaluate (annotate_page.js source)(auditJson), then take a screenshot.
iOS. Choose the path that fits the project:
assets/GridAuditFrames.swift into the UI test target (create a UI test target if there is none, after asking). Edit testCaptureScreens to navigate to each screen under audit, then run it with TEST_RUNNER_GRID_AUDIT_OUT="$PWD/.gridkit/audit" xcodebuild test … -only-testing:<UITests>/GridAuditFrames (see the header of the file). Then for each capture:
python3 $SKILL/scripts/audit_frames.py --spec .gridkit/spec.json .gridkit/audit/[email protected] --format json > .gridkit/audit/[email protected]
swift $SKILL/scripts/annotate.swift .gridkit/audit/[email protected] .gridkit/audit/[email protected] .gridkit/audit/[email protected]
GridKit.shared.apply(configuration:) from a DEBUG launch argument, or .gridKit(.enabled(activation: .manual)) + show(). Capture with xcrun simctl io booted screenshot .gridkit/audit/home.png and inspect it. Without GridKit, annotate a plain simulator screenshot with annotate.swift and a geometry-only audit JSON (audit_frames.py on a frames file with an empty elements list).device-interaction skill is available, it can drive navigation and return the UI hierarchy with frames. Convert that into the frames format (references/frames-format.md).Open every *.annotated.png with the Read tool and compare it against its *.audit.md. For each finding:
ignore list, so re-audits stay clean.Severity: error (overflow, content inside the margins) > warn (near-miss column edges, off-scale spacing, off-rhythm gaps and line heights, text baselines that drifted off the baseline grid, near-miss key and row lines) > info (font sizes off the type scale). Each web audit also states how many text blocks sit on the baseline grid. Quote it in the report, since it's the clearest measure of vertical rhythm. Checks and tuning are explained in references/frames-format.md.
Write .gridkit/audit/REPORT.md with these sections:
Summarize the report in chat (scorecard + top root causes) and link the annotated screenshots. If the user may share it, offer to publish the report as an artifact. Then ask how to proceed: apply everything, apply selected groups, or stop at the report. Never modify code before this answer.
Platform playbooks with idiomatic fixes for each finding type: references/swiftui-fixes.md and references/css-fixes.md. Rules:
enum GridSpec / Spacing in Swift; CSS custom properties or the Tailwind theme on the web) with values generated from the spec, then point code at them. Don't scatter new literals, even on-scale ones.containerRelativeFrame(count:span:spacing:), Grid/LazyVGrid, and a custom Layout on iOS. Use CSS Grid with grid-column: span n, subgrid, and gap on the web. Avoid hard-coded widths and .offset/position: relative nudges.swift build / xcodebuild build, npm run build / tsc --noEmit), so a regression points at one group.Re-run Phase 2 with the same spec, targets and routes. Then report:
ignore), or items the user chose not to fix.Remaining real findings mean the work isn't done. Say so plainly rather than rounding the result up.
assets/GridAuditFrames.swift (opens in a new tab)assets/GridSpec.swift (opens in a new tab)assets/grid.css (opens in a new tab)assets/presets.json (opens in a new tab)references/css-fixes.md (opens in a new tab)references/frames-format.md (opens in a new tab)references/spec-format.md (opens in a new tab)references/swiftui-fixes.md (opens in a new tab)scripts/annotate.swift (opens in a new tab)scripts/annotate_page.js (opens in a new tab)scripts/audit_frames.py (opens in a new tab)scripts/collect_frames.js (opens in a new tab)scripts/gridspec.py (opens in a new tab)scripts/scan_spacing.py (opens in a new tab)scripts/web_capture.mjs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub acrosa/gridkit --plugin gridkit