{"id":9079,"date":"2025-12-13T15:53:59","date_gmt":"2025-12-13T23:53:59","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=9079"},"modified":"2026-01-29T19:40:55","modified_gmt":"2026-01-30T03:40:55","slug":"ai-assisted-edits","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/documentation\/ai\/","title":{"rendered":"AI-Driven Editing And Refactoring"},"content":{"rendered":"<p>VisualGDB includes a fast AI editing engine, designed to automate the most tedious parts of C\/C++ development.<\/p>\n<h1>Contents<\/h1>\n<p><a href=\"#whentouse\">When to Use<\/a><br \/>\n<a href=\"#examples\">Real-World Examples<\/a><br \/>\n<a href=\"#starting\">Starting AI Edits<\/a><br \/>\n<a href=\"#prompts\">Writing Efficient Prompts<\/a><br \/>\n<a href=\"#tweaking\">Tweaking the Context<\/a><br \/>\n<a href=\"#steps\">Steps<\/a><br \/>\n<a href=\"#models\">Supported Models<\/a><\/p>\n<h1><a id=\"whentouse\"><\/a>When to Use<\/h1>\n<p>The AI engine excels at two main types of tasks:<\/p>\n<ul>\n<li><strong>AI-driven refactoring<\/strong>. You can quickly move common logic into separate functions\/methods or change how functions work, updating references.<\/li>\n<li><strong>Creating logic from sketches. <\/strong>You can quickly code that integrates with your existing design based on very brief prompts.<\/li>\n<\/ul>\n<p>The AI edits are not limited to these scenarios. You can always select one or more symbols, give brief instructions, and see if AI can manage it.<\/p>\n<h1><a id=\"examples\"><\/a>Real-World Examples<\/h1>\n<p>We have used our AI engine to modify an <a href=\"https:\/\/gitlab.com\/slimhazard\/picow-http-example\">open-source HTTP server<\/a> for Raspberry Pi Pico W, turning it into a simple web-controlled thermostat. Instead of creating a project from scratch, we picked a real-world open-source project, and documented every step of modifying it with AI. Checkout these tutorials for details:<\/p>\n<ol>\n<li><a href=\"https:\/\/visualgdb.com\/tutorials\/ai\/thermostat\/01-refactoring\/\">Refactoring Existing Code with AI<\/a><\/li>\n<li><a href=\"https:\/\/visualgdb.com\/tutorials\/ai\/thermostat\/02-newlogic\/\">Using AI Edits to Add New Functionality<\/a><\/li>\n<li><a href=\"https:\/\/visualgdb.com\/tutorials\/ai\/thermostat\/03-adding-similar-code\/\">Using AI Edits to Create Similar Code<\/a><\/li>\n<li><a href=\"https:\/\/visualgdb.com\/tutorials\/ai\/thermostat\/04-simplifying\/\">Using AI to Simplify C\/C++ Code<\/a><\/li>\n<\/ol>\n<h1><a id=\"starting\"><\/a>Starting AI Edits<\/h1>\n<p>VisualGDB&#8217;s AI edits are always tied to symbols, rather than files. You can initiate an AI edit by clicking the edit link next to the CodeJumps annotation on top of a symbol:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/start-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9169\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/start-1.png\" alt=\"\" width=\"1216\" height=\"247\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/start-1.png 1216w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/start-1-300x61.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/start-1-1024x208.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/start-1-768x156.png 768w\" sizes=\"(max-width: 1216px) 100vw, 1216px\" \/><\/a><\/p>\n<p>VisualGDB will automatically include all symbols referenced from the current one. E.g. <strong>err_t netinfo_handler(struct http)<\/strong> will include the definition of <strong>err_t<\/strong> and <strong>struct http<\/strong>:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/refs-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9172\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/refs-2.png\" alt=\"\" width=\"1216\" height=\"290\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/refs-2.png 1216w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/refs-2-300x72.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/refs-2-1024x244.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/refs-2-768x183.png 768w\" sizes=\"(max-width: 1216px) 100vw, 1216px\" \/><\/a><\/p>\n<p>You can control the depth of references discovery (e.g. whether to include types of all fields of <strong>struct http<\/strong>) via the depth buttons.<\/p>\n<h1><a id=\"prompts\"><\/a>Writing Efficient Prompts<\/h1>\n<p>AI can work very efficiently if you use small, concise prompts, focusing on one action at a time. E.g.:<\/p>\n<pre>+Thermostat_SetOutputValue(g_Thermostat, bool) wrapping CYW43_WL_GPIO_LED_PIN<\/pre>\n<p>This will move the code LED-related code from the current function into a separate function, will create declaration + definition of a new function, and will update the current code to call it.<\/p>\n<p>Whenever you type &#8216;@&#8217; in the prompt editor, VisualGDB will show the list of symbols visible from the current file, and all files in the project:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/alloc.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9173\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/alloc.png\" alt=\"\" width=\"929\" height=\"263\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/alloc.png 929w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/alloc-300x85.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/alloc-768x217.png 768w\" sizes=\"(max-width: 929px) 100vw, 929px\" \/><\/a>You can use it to reference existing symbols or files, e.g.:<\/p>\n<pre>+http_format_and_send() with varargs in @http_utils.c . take contentType + enum http_format_flags (ffNoCache).\r\nmeasure with sprintf, then @pvPortMalloc + send + @vPortFree<\/pre>\n<p>This prompt only took 3 seconds and produced a fully usable 60-line <a href=\"https:\/\/gitlab.com\/sysprogs-tutorials\/picow-http-example\/-\/commit\/20857876f8f0899c20e3324f8a76af4595c935e9#line_a31753634_A53\">function<\/a> on first try (see <a href=\"https:\/\/visualgdb.com\/tutorials\/ai\/thermostat\/04-simplifying\/\">this tutorial<\/a>).<\/p>\n<h1><a id=\"tweaking\"><\/a>Tweaking the Context<\/h1>\n<p>You can explicitly add individual symbols for the context window by clicking the links near the CodeJumps labels:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/include.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9175\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/include.png\" alt=\"\" width=\"1216\" height=\"505\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/include.png 1216w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/include-300x125.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/include-1024x425.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/include-768x319.png 768w\" sizes=\"(max-width: 1216px) 100vw, 1216px\" \/><\/a>The glasses icon only adds the declaration of the symbol (for classes, also declarations of all methods). The pencil icon adds the symbol body and makes it editable.<\/p>\n<p>You can add symbols at any step of the editing session. E.g. if your code contains multiple functions with duplicate functionality, you can start with editing the first one, refactor the logic into a separate function, and then add the remaining functions asking the AI to update them as well.<\/p>\n<h1><a id=\"steps\"><\/a>Steps<\/h1>\n<p>Each time you ask the AI to edit the code, it creates a separate editing step, letting you review the changes:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/step.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9176\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/step.png\" alt=\"\" width=\"931\" height=\"235\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/step.png 931w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/step-300x76.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/step-768x194.png 768w\" sizes=\"(max-width: 931px) 100vw, 931px\" \/><\/a>You can use the navigation buttons to go back and forth between the steps, or retry individual steps using the same, or a different language model.<\/p>\n<p>Steps are useful for quick refinement prompts (e.g. malloc-&gt;new[]). Just a few words are often sufficient for the language model to correct its previous output.<\/p>\n<h1><a id=\"models\"><\/a>Supported Models<\/h1>\n<p>VisualGDB supports any language model capable of completing chats. You can use any cloud service of your choice, or even run the models on your own hardware. You can configure models via <strong>Tools-&gt;VisualGDB-&gt;Manage AI models<\/strong>:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/models.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9085\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/models.png\" alt=\"\" width=\"1034\" height=\"472\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/models.png 1034w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/models-300x137.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/models-1024x467.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/12\/models-768x351.png 768w\" sizes=\"(max-width: 1034px) 100vw, 1034px\" \/><\/a>VisualGDB provides a limited number of evaluation tokens for common models. For production use, we recommend creating an account at <a href=\"https:\/\/openrouter.ai\/\">OpenRouter<\/a> that provides access to state-of-the-art models from all major vendors. You can also get limited free tokens from <a href=\"https:\/\/cloud.cerebras.ai\/\">Cerebras Cloud<\/a> or any other model provider with OpenAI-style API.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>VisualGDB includes a fast AI editing engine, designed to automate the most tedious parts of C\/C++ development. Contents When to<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[252],"tags":[254],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/9079"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=9079"}],"version-history":[{"count":9,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/9079\/revisions"}],"predecessor-version":[{"id":9178,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/9079\/revisions\/9178"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=9079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=9079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=9079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}