> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qodo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Similar code

<Badge color="outline-provider" size="sm" shape="pill" icon="github">GitHub</Badge>

<Warning>
  **Git Integration (formerly Qodo Merge)** – AI code review agents for pull requests. This documentation describes the Qodo v1 experience. For the Qodo v2 documentation, click [here.](/code-review)
</Warning>

The similar code tool retrieves the most similar code components from inside the organization's codebase, or from open-source code.

## How to use the `similar code` tool

**Manual usage**

Comment on the PR:

```bash theme={null}
/find_similar_component COMPONENT_NAME
```

Where `COMPONENT_NAME` is the name of a code component in the PR (class, method, function).

You can set a specific class or file where the component will be taken from:

```bash theme={null}
/find_similar_component COMPONENT_NAME --pr_find_similar_component.file=FILE_NAME
```

**Automatic usage**

To run the tool automatically, use the [`analyze`](/v1/tools/tools-list/analyze) tool. On a PR, comment:

```bash theme={null}
/analyze
```

For the components you want to find similar code, click the `similar` checkbox.

<Frame>
  <img src="https://mintcdn.com/qodo/uIkZ6kAWHm6WXqrW/images/v1/image-193.png?fit=max&auto=format&n=uIkZ6kAWHm6WXqrW&q=85&s=846b54fa012787c191d31965c73e6b3f" alt="" width="933" height="764" data-path="images/v1/image-193.png" />
</Frame>

You can search for similar code within your organization's codebase or globally, across open-source projects. Each result includes the matching code and its license information.

<Frame>
  <img src="https://mintcdn.com/qodo/uIkZ6kAWHm6WXqrW/images/v1/image-194.png?fit=max&auto=format&n=uIkZ6kAWHm6WXqrW&q=85&s=0c7101a2f98101f8bd7587911854e48d" alt="" width="831" height="901" data-path="images/v1/image-194.png" />
</Frame>

### Search results

Each search result includes:

* `extracted keywords`: Keywords identified in your code. Clicking the link to view the keywords and adjust the search if needed.
* `search context`: The context in which the tool looks for similar code, either inside your organization's repositories or across public open-source projects (Global).
* `similar code`: Matching code snippets found in the selected search context. Click the link to open the code component in the relevant file.
* `relevant repositories`: Open-source repos that contain code related to your component and its keywords.

## Configuration options

Configure the `similar code` tool by setting configurations under the `pr_find_similar_component` part in your [configuration file](/v1/configuration/configuration-file/).

| Possible configurations | Default value | What they do                                                                         |
| :---------------------- | :------------ | :----------------------------------------------------------------------------------- |
| `search_from_org`       | `false`       | If set to true, the tool will search for similar code in the organization's codebase |
| `number_of_keywords`    | `5`           | Number of keywords to use for the search.                                            |
| `number_of_results`     | `5`           | The maximum number of results to present                                             |

## Example usage

**Global Search** for a method called `chat_completion`:

<Frame>
  <img src="https://mintcdn.com/qodo/uIkZ6kAWHm6WXqrW/images/v1/image-195.png?fit=max&auto=format&n=uIkZ6kAWHm6WXqrW&q=85&s=b03cc5fd237fc67845b7531fbd2107cf" alt="" width="831" height="901" data-path="images/v1/image-195.png" />
</Frame>

Search result link example:

<Frame>
  <img src="https://mintcdn.com/qodo/uIkZ6kAWHm6WXqrW/images/v1/image-196.png?fit=max&auto=format&n=uIkZ6kAWHm6WXqrW&q=85&s=9cd16ec52e0bc8c48f93205e3a6e464e" alt="" width="1217" height="744" data-path="images/v1/image-196.png" />
</Frame>

**Organization Search**:

<Frame>
  <img src="https://mintcdn.com/qodo/uIkZ6kAWHm6WXqrW/images/v1/image-197.png?fit=max&auto=format&n=uIkZ6kAWHm6WXqrW&q=85&s=64dcca986832ab2198efed05ffed0823" alt="" width="937" height="755" data-path="images/v1/image-197.png" />
</Frame>
