---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://sourcecraft.dev/portal/docs/en/code-assistant/operations/src-code-edit.md
  - https://sourcecraft.dev/portal/docs/ru/code-assistant/operations/src-code-edit.md
title: Editing code in SourceCraft Code Assistant
description: 'How to edit code using SourceCraft Code Assistant in the SourceCraft interface: autocompletion and improvement tips.'
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt


<!-- source: en/sourcecraft/operations/code-edit.md -->
# Editing code in SourceCraft Code Assistant

<!-- source: en/_includes/sourcecraft/disable-ai-features-note.md -->
{% note warning %}

SourceCraft uses the capabilities of AI models within Yandex. For this to work, some of your [organization's](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#org) data needs to be sent to Yandex.

In private organizations, you can [disable](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/disable-ai-features.md) data transfers to Yandex, but this will limit [Code Assistant](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/code-assistant.md)'s capabilities.

{% endnote %}
<!-- endsource: en/_includes/sourcecraft/disable-ai-features-note.md -->

<!-- source: en/_includes/sourcecraft/code-edition-description.md -->
Use the SourceCraft interface with built-in Code Assistant to edit your project code or [add](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/add-file-repo.md) new files and directories. You can introduce changes directly into the repository branch or through a [pull request](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#pr).
<!-- endsource: en/_includes/sourcecraft/code-edition-description.md -->

{% note tip %}

<!-- source: en/_includes/sourcecraft/spaces-tip.md -->
For full-out coding, there is a [Visual Studio Code](https://code.visualstudio.com/)-based cloud development environment called [SourceCraft Spaces](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/spaces.md) accessible via the browser.
<!-- endsource: en/_includes/sourcecraft/spaces-tip.md -->

{% endnote %}

<!-- source: en/_includes/code-assistant/about-service.md -->
Code Assistant is an AI-driven developer assistant based on [large language models (LLM)s](https://en.wikipedia.org/wiki/Large_language_model). With Code Assistant, you can optimize the code writing process and increase your performance.

The [smart autocompletion](https://sourcecraft.dev/portal/docs/en/code-assistant/concepts/index.md#autocompletion) mode enables the AI assistant to analyze the code context and come up with the most relevant suggestions for functions, cycles, conditions, and other elements.

Code Assistant also features a [chat mode](https://sourcecraft.dev/portal/docs/en/code-assistant/concepts/index.md#chat) you can use to interact with the AI assistant in the SourceCraft interface, your IDE, or [SourceCraft CLI with built-in OpenCode](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/cli-quickstart.md).

[SourceCraft Code Assistant terms of use](https://yandex.com/legal/cloud_terms_code_assistant/)
<!-- endsource: en/_includes/code-assistant/about-service.md -->

[SourceCraft Code Assistant documentation](https://sourcecraft.dev/portal/docs/en/code-assistant/index.md).

To edit code with Code Assistant:
1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M12.5 12.618c.307-.275.5-.674.5-1.118V6.977a1.5 1.5 0 0 0-.585-1.189l-3.5-2.692a1.5 1.5 0 0 0-1.83 0l-3.5 2.692A1.5 1.5 0 0 0 3 6.978V11.5A1.496 1.496 0 0 0 4.493 13H5V9.5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2V13h.507c.381-.002.73-.146.993-.382m2-1.118a3 3 0 0 1-3 3h-7a3 3 0 0 1-3-3V6.977A3 3 0 0 1 2.67 4.6l3.5-2.692a3 3 0 0 1 3.66 0l3.5 2.692a3 3 0 0 1 1.17 2.378zm-5-2A.5.5 0 0 0 9 9H7a.5.5 0 0 0-.5.5V13h3z" clip-rule="evenodd"/></svg> **Home** tab, under <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M3.999 3.5h.242c.559 0 1.049.37 1.202.907l.171.598A2.75 2.75 0 0 0 8.26 7h5.24v4a1.5 1.5 0 0 1-1.5 1.5H4A1.5 1.5 0 0 1 2.5 11V5a1.5 1.5 0 0 1 1.499-1.5m9.501 2h-1.242a1.25 1.25 0 0 1-1.201-.907l-.171-.598a3 3 0 0 0-.195-.495H12A1.5 1.5 0 0 1 13.5 5zM8.241 2H4a3 3 0 0 0-.457.035A3 3 0 0 0 2 2.764 3 3 0 0 0 1 5v6a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V5a3 3 0 0 0-3-3zM7 3.5h1.242c.559 0 1.049.37 1.202.907l.171.598q.075.261.195.495H8.26a1.25 1.25 0 0 1-1.202-.907l-.171-.598A3 3 0 0 0 6.69 3.5z" clip-rule="evenodd"/></svg> **Your craftspace**, navigate to <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M2.5 8h11v3a1.5 1.5 0 0 1-1.5 1.5H4A1.5 1.5 0 0 1 2.5 11zm10.697-1.5-1.851-2.777a.5.5 0 0 0-.416-.223H5.07a.5.5 0 0 0-.416.223L2.803 6.5zM15 7.408V11a3 3 0 0 1-3 3H4a3 3 0 0 1-3-3V7.408a3 3 0 0 1 .504-1.664l1.902-2.853A2 2 0 0 1 5.07 2h5.86a2 2 0 0 1 1.664.89l1.902 2.854A3 3 0 0 1 15 7.408M9.25 11a.75.75 0 0 0 0-1.5h-2.5a.75.75 0 0 0 0 1.5z" clip-rule="evenodd"/></svg> **Repositories**.
1. Select the repository with the code you need to edit.
1. Under <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M10.218 3.216a.75.75 0 0 0-1.436-.431l-3 10a.75.75 0 0 0 1.436.43zM4.53 4.97a.75.75 0 0 1 0 1.06L2.56 8l1.97 1.97a.75.75 0 0 1-1.06 1.06l-2.5-2.5a.75.75 0 0 1 0-1.06l2.5-2.5a.75.75 0 0 1 1.06 0m6.94 6.06a.75.75 0 0 1 0-1.06L13.44 8l-1.97-1.97a.75.75 0 0 1 1.06-1.06l2.5 2.5a.75.75 0 0 1 0 1.06l-2.5 2.5a.75.75 0 0 1-1.06 0" clip-rule="evenodd"/></svg> **Code** on the repository page, go to <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M5.312 4.909A1.25 1.25 0 1 1 3.19 3.593a1.25 1.25 0 0 1 2.123 1.316m-2.124 6.182a1.25 1.25 0 1 0 2.125 1.318 1.25 1.25 0 0 0-2.125-1.318M5 9.104V6.896a2.751 2.751 0 1 0-1.5 0v2.208A2.751 2.751 0 1 0 6.896 12.5H9.5a3 3 0 0 0 3-2.98V6.895a2.751 2.751 0 1 0-1.5 0V9.5A1.5 1.5 0 0 1 9.5 11H6.896A2.76 2.76 0 0 0 5 9.104m7.812-4.195a1.25 1.25 0 1 0-2.125-1.318 1.25 1.25 0 0 0 2.125 1.318" clip-rule="evenodd"/></svg> **Branches**.
1. Select the branch for editing.
1. Open the file that needs updates.
1. In the top-right corner, click <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M11.423 1A3.577 3.577 0 0 1 15 4.577c0 .27-.108.53-.3.722l-.528.529-1.971 1.971-5.059 5.059a3 3 0 0 1-1.533.82l-2.638.528a1 1 0 0 1-1.177-1.177l.528-2.638a3 3 0 0 1 .82-1.533l5.059-5.059 2.5-2.5c.191-.191.451-.299.722-.299m-2.31 4.009-4.91 4.91a1.5 1.5 0 0 0-.41.766l-.38 1.903 1.902-.38a1.5 1.5 0 0 0 .767-.41l4.91-4.91a2.08 2.08 0 0 0-1.88-1.88m3.098.658a3.6 3.6 0 0 0-1.878-1.879l1.28-1.28c.995.09 1.788.884 1.878 1.88z" clip-rule="evenodd"/></svg> **Edit**.
1. Start entering the text and see Code Assistant's suggestion.

    <!-- source: en/_includes/code-assistant/help-indicator-load.md -->
    When generating a suggestion, the <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="#787878" d="M12 4a8 8 0 0 1 7.89 6.7 1.53 1.53 0 0 0 1.49 1.3 1.5 1.5 0 0 0 1.48-1.75 11 11 0 0 0-21.72 0A1.5 1.5 0 0 0 2.62 12a1.53 1.53 0 0 0 1.49-1.3A8 8 0 0 1 12 4Z"><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></svg> loading icon will appear to the left of the editable code. If generation stops or there is no result, you will see the <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path fill="#787878" d="M7 14a.965.965 0 0 1-.712-.288A.972.972 0 0 1 6 13c0-.283.095-.52.288-.712A.97.97 0 0 1 7 12c.282 0 .52.096.713.288.193.192.289.43.287.712a.986.986 0 0 1-.288.713A.952.952 0 0 1 7 14ZM22 4v12.45a.968.968 0 0 1-.288.713.964.964 0 0 1-.712.287c-.25 0-.479-.083-.687-.25-.208-.167-.312-.417-.313-.75V4H7.275c-.333 0-.583-.104-.75-.312a1.071 1.071 0 0 1 0-1.375c.167-.207.417-.312.75-.313H20c.55 0 1.021.196 1.413.588.392.392.588.863.587 1.412Zm-5 7h-2.725c-.333 0-.583-.104-.75-.312a1.07 1.07 0 0 1 0-1.375c.167-.207.417-.312.75-.313H17c.283 0 .521.096.713.288.192.192.288.43.287.712 0 .283-.097.52-.288.713A.957.957 0 0 1 17 11ZM6 18l-2.3 2.3c-.317.317-.68.388-1.088.213-.409-.175-.613-.487-.612-.938V4.8l-.6-.6a.948.948 0 0 1-.275-.7.95.95 0 0 1 .275-.7.948.948 0 0 1 .7-.275.95.95 0 0 1 .7.275l18.4 18.4a.98.98 0 0 1 .288.688.925.925 0 0 1-.288.712.948.948 0 0 1-.7.275.948.948 0 0 1-.7-.275L15.15 18H6Zm1-7a.965.965 0 0 1-.712-.288A.972.972 0 0 1 6 10c0-.283.095-.52.288-.712A.97.97 0 0 1 7 9c.282 0 .52.096.713.288.193.192.289.43.287.712a.986.986 0 0 1-.288.713A.952.952 0 0 1 7 11Zm10-3h-6a.965.965 0 0 1-.712-.288A.973.973 0 0 1 10 7c0-.283.095-.52.288-.712A.97.97 0 0 1 11 6h6c.283 0 .521.096.713.288.192.192.288.43.287.712 0 .283-.097.52-.288.713A.957.957 0 0 1 17 8ZM4 6.8v10.325L5.15 16h8.05L4 6.8Z"/></svg> (no suggestion) icon.
    <!-- endsource: en/_includes/code-assistant/help-indicator-load.md -->

1. Select what to do with the suggestion:

    <!-- source: en/_includes/code-assistant/actions-with-suggestions.md -->
    * Click **Tab** to accept the suggestion.
    * To start accepting the suggestion word by word, press **Ctrl** + **→** for Windows or Linux or **Command** + **→** for macOS.
    * To discard the suggestion, press **Esc**.
    <!-- endsource: en/_includes/code-assistant/actions-with-suggestions.md -->

1. In the top-right corner, click **Commit changes**.
1. In the window that opens, configure the procedure for changes:
    * In the **Commit message** field, give a comment that will describe the changes you make.
    * Under **Commit branch**, select the branch you want to change. Create a new branch as needed.
    * Under **After commit action**, select how to make changes: via a commit or a [pull request](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#pr).
1. Confirm your changes.

    If you opted for a pull request, [finish](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/pr-create.md) creating it.

#### Useful links {#see-also}

* [Getting started with SourceCraft Code Assistant](https://sourcecraft.dev/portal/docs/en/code-assistant/index.md)
* [AI in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/code-assistant.md)
* [Code autocompletion in SourceCraft Code Assistant](https://sourcecraft.dev/portal/docs/en/code-assistant/operations/autocompletion.md)
* [Creating a pull request in a SourceCraft repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/pr-create.md)
* [AI code review of a pull request in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/ca-review.md)
* [Chat with Code Assistant in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/ca-chat.md)
* [Working in SourceCraft Spaces](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/spaces.md)
* [Downloading, copying, or getting a link to a raw file in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/raw-content.md)
<!-- endsource: en/sourcecraft/operations/code-edit.md -->