30/11/2024

Using Codestral in VS Code - Part 1

This is a part of the series of article where I explain how I learning AI code assistance in VS Code.

You can read the first article here. It explains how you connect Codestral to VS Code.

Ok, now we have connected Codestral to VS Code, lets see how we can use it to assist my coding. In this part I'm going to ask Codestral to write a whole program for me and probably small edit. To simplicity I'm going to use .Net Core console application and ask Codestral to create a snake game in C#.

Get project created

First let's get project created for our game in VS Code. Open a folder and create a new folder called "SnakeGageCodestral" (or any preferred name).

Then open the terminal in VS Code and create console project by running following command:

dotnet new console

That will create the basic structure with Program.cs file in it.


Open the Program.cs and clear any code in it.


Get AI Assistance

Open "Continue" extension. Select your AI modal (in this case we are using Codestral) and ask the question from AI.

You can use a prompt like this: Can you create a snake game in .Net Core console project in C sharp?



Codestral will be more helpful than you think and will also include steps to create project also, but we are intrested in code section. Choose that section (step 4 in below example) and apply it.


This will get updated in Program.cs file.
Check for any obvious compile time errors and if there are you can get assistance from AI by just putting the error message in chat box.

Mine was ok and next step is to run it. Use following command on VS Code terminal.

dotnet run

Mine worked ok.



Editing using AI

Though it worked first time. Snake was running too fast. I wanted to slow it down. So I asked AI assistance to make a edit. It has suggested the line that I should edit as per screen shot below.


That's it. We will have look at more features later.

No comments:

Post a Comment

Azure Map Routing

Azure map, replace earlier mapping technology provided by Microsoft which was called "Bing Maps". Recently I had chance to look in...