9. Design ↔ code workflows
Trigger: "Design from Code…" on a file in the Explorer, the AI panel with a file attached, or Claude Code with the ui-designer-from-code skill.
Esta página está em inglês; a tradução está a caminho.
9.1 From code (AI-7)#
Trigger: “Design from Code…” on a file in the Explorer, the AI panel with a file attached, or Claude Code with
the ui-designer-from-code skill.
- The agent reads the component and what it uses (Read, Grep, Glob; allowed in the panel).
- It maps code components to design components through the code map (
get_code_connect_map) andsearch_design_system; it finds the font and tokens in the repository. - If the page is running (a dev-server URL in the prompt, 0.8), it captures it as a reference frame beside
the build. In a terminal session that is
generate_figma_design(EXP-6). In the panel the agent cannot call it (network, refused under--proposal, §5.1): the panel itself offers “Capture page…” before the run, which the user confirms with the URL in view, and the capture is attached as an image. - It builds the frames with the design loop (§4), compares with the capture or an attached screenshot, fixes, and deletes the capture.
- The proposal shows the new frames; the summary lists code components without a design counterpart.
9.2 To code (AI-8)#
Trigger: “Implement with Claude” on a frame or component, or Claude Code with ui-designer-to-code.
get_design_context(withclientFrameworks/clientLanguagesfrom the repository),get_variable_defs, the code map, and the project’s conventions (CLAUDE.md, existing components).- Missing code-map entries are proposed (
get_code_connect_suggestions) and, on confirmation, written (add_code_connect_map). - Code is written in a scratch copy, never in the workspace directly (AI-14): the panel creates a git
worktree of the repository in the run folder (or, outside git, a copy of the target folder) and runs
Claude there with
--allowedTools "mcp__ui-designer__*,Read,Grep,Glob,Edit,Write",Bashstill disallowed, the same settings override (Read deny rules, hooks off) andud mcp --allowlist as §6.3,Edit/Writeconfined to the scratch copy by a deny rule on every other path. Type checks and tests are not run by the agent in the panel; the user runs them. - When the run ends, the panel lists the changed files and opens VS Code’s diff editor per file. Apply
copies the changes into the workspace with a
WorkspaceEdit(undoable in each editor); Discard deletes the scratch copy. Code-map entries written in step 2 are part of the design proposal and follow its Accept/Discard.
In a terminal session the user’s own Claude Code permissions apply instead; the skill still asks the agent to show the diff before writing.
9.3 Review (AI-9)#
Trigger: “Review Design” on a frame, page or flow, or Claude Code with ui-designer-review.
get_metadata,ud system,get_screenshot,ud_lint, the review scripts.- Each finding becomes a comment (
ud_run comment.addwith node, category, severity) in the proposal. - Fixes for mechanical findings are prepared as separate
use_figmacalls with the descriptionfix: <finding id>, so the change list can group them. - The panel shows findings in a list beside the comments, each with its fix (if any). Accept offers “comments only” or “comments and selected fixes”.