Einstein for Developers (Beta) is an AI-powered code generation tool designed to enhance your productivity with Apex and LWC development. It’s an extension that you can install for Visual Studio Code and Code Builder, it works with any org, and it’s completely free. Using Einstein for Developers can be a real game-changer for developers, as it multiplies your productivity, helps you learn, and enables you to complete work much faster.

In a previous post about Einstein for Developers, we shared the details of how to install the extension, how it works behind the scenes contextualizing the prompts with your org metadata, and how prompt-based generation works. This post covers the latest — and super useful — features that have been incorporated into the tool, including a large language model (LLM), the new configuration panel, inline auto-completion for Apex and LWC, and test case generation for Apex.

Internal implementation changes

Powered by generative AI, Einstein for Developers uses an LLM to generate recommended code based on your prompts and what you type. With version 0.47.0 of Einstein for Developers, we’ve switched to using two new LLMs, both still part of the CodeGen family. We use a smaller, lighter-weight model for inline autocomplete and a larger, more compute-intensive model for natural language to code generation, resulting in an overall improved experience and results.

Our all-new data usage policy states that customer prompts and responses are not used to train our internal LLM. This highly-anticipated update ensures the extension doesn’t use your data or code to train CodeGen and you can use it safely in your environments.

Easier activation and the new configuration panel

The extension is now installed by default with the Salesforce Extension Pack (Expanded) for Visual Studio Code. It’s also installed by default in Code Builder.

Once installed, Einstein for Developers is now much easier to configure. Previously, you had to navigate to the org, activate the feature from there, and then control its capabilities through the IDE settings. Now, you can simply click a status bar icon from your IDE to open a configuration menu. From this menu, you can activate and deactivate the extension, toggle its capabilities, configure keyboard shortcuts to work with it in a more agile way, check its status, explore the documentation, and more.

status bar icon on IDE bottom bar

Configuration panel

Inline auto-completion recommendations

Inline auto-completion gives you recommendations while you type your code. It works both for Apex and LWC code — yes, LWC (HTML, CSS, and JavaScript generation) is supported too! It can show you multiple recommendations at once, and there’s a toolbar that appears where you can navigate through them and accept the ones that you like. On top of all that, the extension passes the files that you have opened in the IDE to the LLM, so that it can create better suggestions that follow your own coding style and conventions.

Inline recommendation showing two possible suggestions and the toolbar to accept them

In addition, thanks to the last version using a larger LLM, now Einstein can return longer suggestions with inline autocomplete. You can control whether it returns shorter or longer suggestions via a setting. Note that with longer completions you’ll likely see slightly higher latency.

Einstein for Developers autocompletion length setting

Test case generation

How much time do you spend writing Apex tests? Einstein for Developers can also help you write tests (limited to Apex tests for now). This is how it works: Right-click the Apex method for which you want to generate a test, and select “Einstein: Generate a Test.”

Menu that opens upon right-click from which you can generate a test

If there’s a test class with the same name as the file plus the “Test” keyword appended at the end, Einstein for Developers automatically detects that it’s the class where it should create the test. In any other case, it asks you which test class to use.

Einstein for Developers prompting the user to select a test file for the newly generated test

Then it shows you the tests that already exist within your project. It’s important to select the tests that apply to the Apex method under test, so that they can be fed as additional context to the LLM. This ensures that Einstein for Developers doesn’t duplicate a test you may already have in your project.

Einstein for Developers prompting you to select which test methods to use in the generation

Finally, it creates the tests for you. You can then accept the result, clear it, or try again.

accept - try again - clear menu with a generated test

Note that the more complex the method being tested, the more difficult it will be for the LLM to come up with a good result. In any case, it will at least provide a good skeleton and starting point for you to complete, saving you a lot of time.

Conclusion

Now that you know more about all the great innovations that have been incorporated into Einstein for Developers recently — including using a larger LLM for better results, inline autocompletion recommendations, and test generation — I encourage you to try the extension in Visual Studio Code or Code Builder today and see how these improvements can help you become a much more productive (and happier!) developer.

Stay tuned, as much more is coming, such as a code explanations feature, and more support for LWC code.

Resources

About the author

Alba Rivas works as a Principal Developer Advocate at Salesforce. You can follow her on Twitter or LinkedIn.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS