Welcome back! In our last lesson, we put all the pieces together and walked through the entire workflow, from making a design update in Figma to seeing that change go live on your deployed website. It was a huge milestone that demonstrated the power of the full design-to-deployment loop.
Now, we're going to refine that process. While regenerating the whole page works, it's not always the most efficient or safest way to make small changes.
1. What We Are Learning
Today, our learning outcome is to regenerate a section of code from an updated Figma design.
We'll focus on a more precise, "surgical" approach to updates. Instead of telling the AI to rebuild the entire page for a simple button change, you will learn how to:
- Make a targeted update in Figma.
- Get a specific link to the changed component or frame.
- Write a precise AI prompt to regenerate only the code for that specific section.
2. Why This Matters
This technique is the difference between renovating an entire house to change a light fixture and simply calling an electrician to swap it out. It's faster, less risky, and a more professional way to work.
As a designer, you know the power of components. You don't redraw a button every time you use it; you update the main component, and the changes propagate. This lesson teaches you the code equivalent of that workflow. By targeting specific sections, you maintain control, minimize the risk of the AI introducing unintended bugs elsewhere on the page, and speed up your iteration cycle dramatically.
This targeted approach is a core part of a mature AI-assisted workflow.
3. Step-by-Step Instructions
Let's say you've decided to change the main call-to-action (CTA) button on your landing page. Instead of a solid color, you want it to have an outline style.
Step 1: Make a Focused Update and Get the Link
First, you need to tell the AI exactly what changed. The best way to do this is by providing a direct link to the specific element in Figma.
- Update your component in Figma. Change the button's styling as intended (e.g., remove the fill, add a stroke).
- Select the component's frame. Make sure you've selected the frame containing only the updated button, not the entire page.
- Copy the specific link. Right-click on the selected frame, go to Copy/Paste as, and select Copy link. This link points directly to that specific element, giving the AI a very focused target.
Step 2: Write a "Surgical" AI Prompt
Now, you'll use that specific link to give the AI a very precise command. This is where you move from a broad request to a targeted instruction.
An excellent article on AI workflows provides the exact prompts for this.
From Figma to Working Prototype: An AI-Powered Workflow with ...
To understand the specific prompts for this workflow, please read the section 'Iterating on the project' in this Medium article.
Focus on the subsections titled 'Updating single component' and 'Updating tokens'. Note the prompt structure: it clearly states the action (Update), the target (Button component), and provides a specific link.
Based on that resource, your prompt in VS Code's AI chat would look something like this:
Update the main CTA Button component based on the new design from Figma. Only change the code related to this button. FIGMA_LINK: [paste your specific link here]
This prompt is powerful because it tells the AI three things:
- Action: Update.
- Target: The button component.
- Source: The specific Figma link you provided.
Step 3: Observe the AI's Targeted Change
The AI will now use the Figma Model Context Protocol (MCP) to analyze only the component you linked to and generate the corresponding HTML and CSS changes.
This short video clip demonstrates a similar workflow, where a design is updated and the AI regenerates the code to match.
How to Turn Figma Designs into Live Websites in 10 Minutes!
Watch this clip to see a visual example of how an updated Figma design can be used to regenerate code.
Watch from 01:30 to 01:48. Notice how the user pastes an updated Figma link into the chat and gives a prompt, asking the AI to apply the changes. This is the process you'll be following.
Step 4: Integrate and Verify the Changes
The AI will provide you with a new block of HTML or CSS.
- Locate the old code. Find the HTML for your button in
index.htmland its corresponding rules instyles/style.css. - Replace the old code. Carefully replace the old code with the new code generated by the AI.
- Use Source Control to review. Open the Source Control panel in VS Code. It will show you a "diff" — a side-by-side comparison of the old file (in red) and the new file (in green). This is an incredibly useful way to see exactly what the AI changed and confirm it didn't do anything unexpected.
- Verify with Live Server. Check your local preview to ensure the button has updated correctly and that nothing else on the page has broken.
4. What Could Go Wrong
- The AI regenerates more code than you asked for.
- Reason: The AI might have misinterpreted your prompt, or the specific tool you're using may not be great at "surgical" updates. Some tools are better at this than others.
- Fix: Don't use the generated code. Discard the changes using the Source Control panel in VS Code. Try again with an even more explicit prompt, like:
"ONLY generate the CSS for the button at this link. Do not touch any other code."
- The AI change introduces a bug.
- Reason: The AI might have removed a critical class name or HTML attribute when it replaced the code.
- Fix: Again, the Source Control "diff" view is your best friend. Look at what was removed and see if you can spot the issue. If not, discard the changes and try prompting again, perhaps asking the AI to be careful to preserve existing attributes.
- The specific link doesn't seem to work.
- Reason: The most common cause is that your Figma file's sharing permissions are set to private.
- Fix: In Figma, click the "Share" button and ensure that permissions are set to "Anyone with the link can view."
5. Mini Exercise
Time to practice this surgical technique.
- Open your project in both VS Code and Figma.
- In Figma, choose one small, isolated section or component (like a button, an image, or a text block).
- Make a distinct visual change to it (e.g., change a color, font size, or border radius).
- Right-click on that specific component's frame in Figma and copy the direct link.
- In VS Code, use your AI tool with a surgical prompt, providing the link and asking it to update only that one component.
- Replace the old code with the newly generated code.
- Use the Source Control panel to review the changes.
- Verify the result locally using Live Server.
You don't need to commit or deploy this change; the goal is simply to successfully perform a targeted regeneration.
6. Checklist Before Moving Ahead
- I know how to copy a direct link to a specific frame or component in Figma.
- I can write a prompt that instructs an AI to update only a specific section of code.
- I understand why this "surgical" approach is often better than regenerating an entire page.
- I have completed the exercise and successfully updated a single component in my local project using this method.
Conclusion
You've now added a crucial technique to your AI-assisted workflow. Knowing how to perform targeted updates makes the process of iterating on a design much faster and safer. You can now make changes with confidence, knowing you have fine-grained control over what the AI modifies in your codebase.
In the next lesson, we'll focus on the next step in the loop: Integrate newly generated code into the existing project files. We'll look at strategies for merging changes and using VS Code's powerful tools to manage the code the AI gives you, ensuring it fits perfectly into your project.