---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/code-edit.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/code-edit.md
  - href: en/sourcecraft/operations/code-edit.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
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


# Editing code in SourceCraft Code Assistant

<!-- 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 ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select the repository with the code you need to edit.
1. Under ![image](../../_assets/console-icons/code.svg) **Code** on the repository page, go to ![image](../../_assets/console-icons/code-trunk.svg) **Branches**.
1. Select the branch for editing.
1. Open the file that needs updates.
1. In the top-right corner, click ![image](../../_assets/console-icons/pencil.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 ![image](../../_assets/code-assistant/loading.svg) loading icon will appear to the left of the editable code. If generation stops or there is no result, you will see the ![image](../../_assets/code-assistant/chat_crossed.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)
