Configure AI Remediation for Visual Studio Code

You can integrate the GitHub Copilot Chat extension for Visual Studio Code to suggest code fixes for issues identified by Klocwork.

AI suggestions may contain errors, so you should review all changes carefully before applying.

To use AI remediation feature, you will require the following:

  • An active internet connection
  • The latest version of Visual Studio Code (VSCode)
  • The latest (Undefined variable: ProductNames.VS Code) extension (installed via VSIX file)
  • A GitHub account
  • GitHub Copilot or Copilot Chat Extension (installed from Visual Studio Marketplace)
  • (Optional) An API key if using a custom large language model (LLM) instead of presets

Configure Copilot Chat

To configure Copilot Chat in your VSCode IDE:

  1. In VSCode, open Copilot Chat settings.

  2. From the drop-down, set Copilot to Agent Mode.

  3. From the drop-down, select the LLM to use. To use a custom LLM, select Manage Models..., select a provider, and enter your API key.

    Tip:  Fix accuracy is impacted by the model chosen. Based on current testing, we recommend using Claude Sonnet.

Run AI Remediation

AI remediation works for defects identified by (Undefined variable: ProductNames.Helix QAC) in VS Code. To run the AI remediation:

  1. Right-click a defect and select Fix using QAC tools.
  2. For initial requests, VS Code will ask for access to your (Undefined variable: ProductNames.Helix QAC) tools. Select Always allow each time.

The tool generates a fix based on the defect details.

Once generated, fixes are applied as diffs and displayed in the Copilot Chat window. You can use the toolbar to do the following:

  • Keep - Confirm and apply the change.
  • Undo - Revert the change in your code.
  • Previous/Next - Navigate between multiple fixes.

In the Chat window, you can also use the following additional options:

  • Bulk fix - You can correct all occurrences of the defect in your project.
  • Enhance fix - Use natural language prompts in the Chat window to refine or modify the generated fix.
  • Start a new Chat - Select this in the Chat window to begin a new session when previous context is unnecessary.

You cannot return to the proposed changes from the previous session once you start a new chat. You must choose one of the following options:

  • Keep & Continue - Apply all pending changes and start a new chat.
  • Undo & Continue - Discard all pending changes and start a new chat.
  • Cancel - Do not start a new chat; remain in the current session.