How I force Copilot to write deterministic React UI (using a custom Markdown Skill) #189283
Replies: 2 comments 4 replies
-
|
Hey @MegaByteMark, this is a really clever approach and the timing is great because I've been wrestling with the exact same problem. The flakiness you're describing with natural language UI prompts is real. I've noticed that the more specific the layout constraint (things like "card centered, checkbox left-aligned, link right-aligned on the same row"), the worse natural language gets, because the model is inferring spatial relationships from text rather than parsing a structure. Your DSL sidesteps that entirely by making layout syntactically unambiguous. The ||| COLUMN ||| / === ROW === nesting is especially smart, it maps almost 1:1 to Flexbox/Grid mental models, so there's no translation loss. A few questions / thoughts: On the design-system.md file, are you storing raw Tailwind class mappings in there (e.g. primary-button: bg-blue-600 rounded-xl font-bold), or is it more semantic/token-based? Curious how opinionated the schema is. On alternatives considered, did you look at anything like Storybook's CSF format or a JSON schema approach before landing on Markdown? Just curious why Markdown won out (my guess: it's the most token-efficient + human-readable combo). Going to try dropping this into a project this weekend. The repo structure looks clean. Nice work making it installable as a single skill file drop-in, that's the right distribution model for this kind of thing. |
Beta Was this translation helpful? Give feedback.
-
|
This nails the core problem: natural language is ambiguous, and LLMs amplify that ambiguity. Your DSL works because it gives the model typed, scoped structure instead of a blob of English to interpret. The I ran into the same insight from the prompt side. Not UI wireframes, but general prompts. Role instructions, constraints, output format, examples... when they're all mixed in one text block, the model guesses which part matters most. Structure fixes that. I've been building flompt around this idea. It decomposes prompts into 12 typed semantic blocks (role, constraints, output format, chain of thought, etc.) on a visual canvas, then compiles them to Claude-optimized XML. Same principle as your DSL: give the model unambiguous boundaries between different types of instructions. Curious if you've thought about extending the Markdown-UI approach beyond layout. Things like accessibility constraints or interaction states could be their own typed blocks in the spec. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
General
Copilot Feature Area
Copilot Agent Mode
Body
Hi,
I've been heavily using Copilot's Agent mode to scaffold frontend code, particularly React which I'm relatively new to. It’s amazing, but I found that writing natural language prompts for complex UI layouts ("make a login page with a card in the middle and a dark button") was too flaky. Sometimes it hallucinates, totally misses constraints, or generates spaghetti CSS that doesn't match the theme I'm trying to implement.
I wanted a way to give Copilot strict "wireframes" it could actually understand. Figma is too token-heavy, paired with the fact LLM's don't have eyeballs so its doing its best guess of pixel math to work out how things should be arranged, and trying to explain intricate layout in English is equally cumbersome.
So I built an open-source intermediate representation which I've called the Markdown-UI DSL.
I packaged it as a Copilot Custom Skill that you can just drop into .github/skills/markdown-ui-agent/SKILL.md.
Once installed, you can write dumb-simple .ui.md files like this:
Why this works so well with Copilot Agent Mode:
If you are trying to implement true "Spec-Driven Development" (SDD) using Copilot agents, you might find this really useful.
I wrote up a quick 2-minute installation guide in the repo here: https://github.com/MegaByteMark/markdown-ui-dsl
Would love to know how you guys handle UI design prompting with Copilot and if you find this DSL useful!
Beta Was this translation helpful? Give feedback.
All reactions