Salesforce has Agentforce agents, which assist users on the Salesforce platform, and we also have a Service agent that helps customers on the community site, among other services.
But what if a developer needs help while writing code, creating Apex classes, or building flows within Salesforce? For Salesforce developers, enabling Agentforce Vibe helps them build various solutions.
Using Agentforce Vibes, the developer asks, “Write an Apex class to calculate total order amount.” Vibe quickly gives the code, explains how it works, and even suggests improvements. This helps developers save time and write better code more efficiently.
In this article, we will learn how to create an Apex class & LWC component in Salesforce using Agentforce Vibe.
Create an Apex Class & an LWC Component in Salesforce from Agentforce Vibe
Below, I will explain how to create an Apex class and an LWC component in Salesforce from Agentforce Vibe to extend your agent’s functionality and connect custom logic with the Agentforce platform.
Let’s take an example: you want to create a data table to display Account records on the Account record page. We can achieve this by creating an Apex class to retrieve Account data and an LWC component to display it on the page in a dynamic table format.
Now, instead of creating files and writing code manually, we can use Agentforce Vibe to automatically generate the Apex class and LWC component with just a few prompts.
In the image below, you can see we have enabled the MCP server, which helps the Agentforce system connect and communicate with the Salesforce Atlas Reasoning Engine to process AI requests and responses.
We then provided the prompt to Agentforce Vibe to generate an account data table component and automatically deploy it to the Account record page for quick testing and use.

Next, you can see that the agent has automatically written the required code and is prompting to create the file.
This happens because the auto-approval feature for the agent is currently disabled, meaning it needs your confirmation before creating or modifying files.
In Agentforce Vibe, agents have advanced capabilities to generate, edit, and create files directly based on your prompts, making the development process faster and more interactive.
This functionality is not available in Agentforce for Developers, where users must manually create and manage files after the code is generated.
Here, the agent has created an Apex class to retrieve account information from the Salesforce org, allowing the component to fetch and display account data directly from the database dynamically.

After generating the Apex class and creating the file, the agent prompts you to create the meta.xml file for the Apex class.
This file is important because it defines the class’s metadata, including its API version and visibility, which enables it to be accessed by Lightning components, Flows, or other Salesforce tools.

After that, it creates the HTML file to define the user interface (UI) of the component. This file controls how the data fetched by the Apex class is displayed on the screen, such as tables, buttons, or text layouts that users see on the account record page.
Similarly, the agent will create the JavaScript file, meta.xml file, and other required component files.
Each time, it will ask for confirmation before saving the file. If you want to review or modify the generated code, you can make changes directly in the editor and then click the Save button to finalize it.

Once the Apex class and LWC component are created, Agentforce Vibe will display a “Run Command” button.
When you click on it, the Agent executes the generated code and deploys the component directly to your Salesforce org, allowing you to see the output live on the account record page without needing any manual deployment steps.

In the terminal, you can see that the component is being deployed to Salesforce, and the system has also generated a unique Deploy ID.
This ID helps you track and verify the deployment status within your Salesforce org, ensuring that the component has been successfully uploaded and activated.

Now, as you navigate to the account record page, you need to add the newly created LWC component to the page layout using the Lightning App Builder.
This allows you to display the component’s data and functionality directly on the Account record page, making it visible and accessible to end users.
To add the LWC component to the record page, open any account record, then click the gear icon and select Edit Page. This will open the Lightning Page Builder, where you can drag and drop your newly created LWC component onto the page layout.
As you can see below, the data table component has been successfully added to the account record page, displaying the related Account information directly within the page.
This allows users to view and interact with the data in real time without navigating away from the record.

In this way, we can create Apex classes and LWC components in Salesforce directly from Agentforce Vibe.
Conclusion
I hope you have got an idea about how to create an Apex class & LWC component in Salesforce using Agentforce Vibe. In this article, I have explained how the Agentforce vibe generates the code, creates files, and deploys to the Salesforce org.
You may like to read:
- Agentforce Vibes in Salesforce Tool for Developers
- Atlas Reasoning Engine in Salesforce Agentforce
- Connect Slack with Salesforce
- Deploy Agentforce Agent from Salesforce to Slack
- Create and Deploy Slack Agent From Salesforce to Slack
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.