agentleFS
whinstudiowhinstudio/skills/cmp-design-to-code/SKILL.md

cmp-design-to-code

Skill0 starsChanged 3 days agoMITView on GitHub

Use when building or adjusting UI from a provided design in this Compose Multiplatform app — the exported design boards under design/ (dc.html files and canvas.json), the fonts and icons Compass prepared, a mockup or a screenshot — or when a screen must match its design more closely. Measure first, map every value to a theme token, build exactly what is shown, then check each value against the design.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 3 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Search design/ recursively.

    line 13
  2. Distinctive:

    Read every board of the screen you are building, all states included, before writing code.

    line 29
  3. Very specific:

    Write a value table in your working notes, not in a file: element → value → source (read or estimated) → token or component.

    line 32
  4. Very specific:

    Put the design's type scale into Typography(...): size, line height, weight and letter spacing per role.

    line 100
  5. Very specific:

    Do not hard-code the board frame.

    line 114
  6. Distinctive:

    Every size, colour and font in the diff traces to a table row, read or marked estimated.

    line 134
  7. Distinctive:

    No pixel measurement with scripts.

    line 142
  8. Very specific:

    Do not open the design URL.

    line 144
  9. Very specific:

    Do not ask questions. Choose the closest reading of the design and list it under Assumptions.

    line 148

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Design to code

The design is the specification. Read values from it; never eyeball them. Code rules are in cmp-code-rules, screen structure in cmp-feature.

1. What is in design/

Search design/ recursively; the boards may sit in a subfolder such as design/project/.

FileWhat it is
*.dc.htmlOne board per screen and state. Inline style attributes hold exact values: px sizes, hex colours, font family, weight, line height, letter spacing, radius, gaps.
canvas.jsonThe board list: file name, title (usually Screen · state) and frame size. Use it to pair screens with their states. A board that shows the flow between screens tells you the navigation.
a style-guide boardColour tokens and the type scale, when the design has one. Read it first.
fonts/<family>_<weight>.ttfThe design's fonts, already downloaded (for example figtree_600.ttf).
icons/<id>.xmlAndroid vector drawables, drawn black; tint them. License in icons/LICENSE-icons.txt.
sounds/Sound effects, when the app has them.
artifact-url.txtWhere the design was published. Do not open it: it needs a login.

The <link> to Google Fonts and support.js in the HTML are for the browser; ignore them.

2. Extract

  • Read every board of the screen you are building, all states included, before writing code.
  • Machine-readable values (HTML, CSS, SVG, token files) are exact. Values taken from an image (a screenshot, a mockup) are estimates.
  • Write a value table in your working notes, not in a file: element → value → source (read or estimated) → token or component. The code must follow the table; the table is what you check against at the end.

CSS to Compose. The board frame (for example 390 × 844) is a phone in dp, so 1 CSS px = 1 dp and font px = sp.

CSSCompose
width: 390px; height: 844px on the board rootthe frame, never code it: fillMaxSize()
padding: 52px 20px 14px (top, right/left, bottom)padding(start = 20.dp, top = 52.dp, end = 20.dp, bottom = 14.dp)
display: flex; flex-direction: column; gap: 8pxColumn(verticalArrangement = Arrangement.spacedBy(8.dp))
display: flex (row), gap: 12pxRow(horizontalArrangement = Arrangement.spacedBy(12.dp))
justify-content: space-betweenArrangement.SpaceBetween
align-items: centerverticalAlignment = Alignment.CenterVertically (Row), horizontalAlignment = Alignment.CenterHorizontally (Column)
flex: 1Modifier.weight(1f)
width: 100%fillMaxWidth()
font-size: 15px; line-height: 22px; letter-spacing: 0.4pxfontSize = 15.sp, lineHeight = 22.sp, letterSpacing = 0.4.sp
font-weight: 400 / 500 / 600 / 700FontWeight.Normal / Medium / SemiBold / Bold
color: #9E2F45Color(0xFF9E2F45), defined in the theme
rgba(255,255,255,0.16)Color.White.copy(alpha = 0.16f)
border-radius: 20px / 999pxRoundedCornerShape(20.dp) / CircleShape
border: 1px solid #E8DCD3Modifier.border(1.dp, color, shape)
box-shadow: ...Modifier.shadow(elevation, shape); an estimate, mark it
opacity: 0.6Modifier.alpha(0.6f)
aria-hidden="true"decorative: contentDescription = null

3. Clarify

  • The board titles name the states (content, empty, loading, error, dialog). Each board becomes a UI state; cmp-code-rules requires loading, empty and error even when the design leaves one out.
  • Interactive session: ask about what the design does not show (a missing state, overflow of long text, what a tap does).
  • A choice the design leaves open and you must make (a derived state's colours): if cmp-design-rules is installed, follow it; the design's own values always win.
  • Headless run: derive a missing state from the boards that exist (same header, spacing and colours) and list it under Assumptions. Never fill a gap with your own "improvement".
  • The design's sample data (names, counts, prices) is sample data. Show real or fake data from the data layer, not the design's numbers hard-coded in the UI.

4. Ground in the theme

  • Find the project's theme first. shared/.../AppTheme.kt exists: the project was generated from the release that added it or later. MainScreen already wraps the app in AppTheme { … }; never add a second MaterialTheme or theme composable around the Scaffold.
    • With Theming: the palette (CustomColorsPalette, OnLightColorsPalette, OnDarkColorsPalette) and KtTheme are in core/designsystem/.../theme/. KtTheme provides LocalColorsPalette and maps the palette to MaterialTheme.colorScheme (background/surface, onBackground/onSurface, onSurfaceVariant, primary, onPrimary, outline) in colorSchemeFor; AppTheme.kt applies the user's Light/Dark/System choice through it. Add the design's colours to the palette class and both palettes, map them in colorSchemeFor when a Material role fits, and put typography and shapes into KtTheme's MaterialTheme(...) call.
    • Without Theming: AppTheme.kt is a plain MaterialTheme that follows the system with Material's baseline light and dark schemes. Put the colour scheme, typography and shapes there (lightColorScheme(primary = …)); a dark scheme only when the design shows one ("One colour mode shown" below). A design with one colour mode: use its scheme in both branches of AppTheme (or drop the isSystemInDarkTheme() branch), and set window_background in both themes.xml files (next bullet) to that scheme's background, or delete values-night/themes.xml. Otherwise a dark-mode device shows Material's dark scheme, or a dark launch window before a light app.
    • With or without Theming: window_background in androidApp/src/main/res/values/themes.xml (light) and values-night/themes.xml (dark) is the Android window shown before the first frame. When you change the theme's background colour, update it in both files.
  • Projects without AppTheme.kt: use core/designsystem's palette (package darkmode) when the project was generated with it, or a theme package that already exists. Otherwise create one in core/presentation under a theme package: colours, typography and a theme composable that wraps MaterialTheme, applied once in shared/.../MainScreen.kt around the Scaffold (add implementation(projects.core.presentation) to shared/build.gradle.kts if it is missing). Name each file after the one type it declares.
  • Colours: every measured colour becomes a named token in the theme. Map it to a MaterialTheme.colorScheme role when one fits (primary, background, surface, onSurface, error, outline). Colours with no role go into a small @Immutable data class provided through a CompositionLocal. Composables read tokens; no bare Color(0x...) under ui/. detekt's MagicNumber exempts the theme package, not ui/ (hex colours in a when under ui/ were reported in a measured run).
  • One colour mode shown in the design: use it and list that under Assumptions. Do not invent a dark palette.
  • Fonts: copy the needed files from design/fonts/ into src/commonMain/composeResources/font/ of the theme module (core/designsystem with KtTheme, shared with a plain AppTheme.kt, else the module above). That module needs androidResources.enable = true (cmp-feature, references/screen.md, "Resources"), or the Android app falls back to the system font while every gate stays green. Build the family in a @Composable function, because org.jetbrains.compose.resources.Font is composable:
@Composable
fun figtreeFamily(): FontFamily = FontFamily(
    Font(Res.font.figtree_400, FontWeight.Normal),
    Font(Res.font.figtree_600, FontWeight.SemiBold)
)

Put the design's type scale into Typography(...): size, line height, weight and letter spacing per role. Components use MaterialTheme.typography.x, not ad-hoc TextStyles.

  • Icons: copy the ones the screen uses from design/icons/ into composeResources/drawable/ of the module that shows them, and draw them with Icon(painterResource(Res.drawable.<id>), contentDescription = ..., tint = ...). Material icons are not on the classpath.
  • Texts shown in the design become string resources in every UI language (cmp-code-rules, section 11).
  • Reuse components the project already has before writing new ones.

5. Build one to one

  • Apply the table's values exactly. Add nothing the design does not show: no extra animation, shadow, gradient, divider or "nicer" spacing.
  • Do not hard-code the board frame. Express proportions with weight, fillMaxWidth(fraction) and Arrangement.spacedBy; fixed sizes only for things that are fixed by nature (icons, avatars, button heights). The app runs on phones of many sizes on Android and iOS.
  • Boards usually draw no status bar, but their first element often has a large top padding (around 44 to 60 px) that stands in for it. The generated MainScreen passes its Scaffold padding to the NavHost, so every screen already starts below the status bar. Do not add that space a second time: keep only the part that is real spacing and mark it as estimated.
  • Spacing written once inside a composable may stay inline (20.dp); values repeated across screens become theme tokens.

6. Verify

  • Headless run: go through the table and find each value in the code (grep for the hex value or the token). Every row is used, or its absence is listed. Then run the gates (cmp-gates). The visual comparison happens on the walkthrough video Compass records afterwards.
  • Interactive session: run the app, take a screenshot of each state and compare it with its board row by row. List what still differs.

Done when

  • Every size, colour and font in the diff traces to a table row, read or marked estimated.
  • Nothing appears that the design does not show; every state board has a matching UI state.
  • The design's fonts and icons are used; no system font where the design names a family.
  • Modules that received fonts or drawables enable Android resources.
  • The final summary lists remaining differences, estimates and assumptions.

Headless runs

  • No pixel measurement with scripts. Open images with the Read tool and mark every value taken from an image as estimated.
  • Do not open the design URL; it needs a login this session does not have. Everything needed is under design/.
  • There is no internet: if a font family is not in design/fonts/, use the theme's default and say so under Assumptions.
  • Do not ask questions. Choose the closest reading of the design and list it under Assumptions.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.