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

# PR Duplicate Command

> CLI reference for the pr-duplicate command

# PR Duplicate Command

Detect duplicate pull requests using semantic search across your issues and PR collections.

## Syntax

```bash theme={null}
simili pr-duplicate [OPTIONS]
```

## Options

| Option        | Short | Type   | Description                                   | Default               |
| ------------- | ----- | ------ | --------------------------------------------- | --------------------- |
| `--repo`      |       | string | Repository (`owner/name`)                     | Required              |
| `--number`    | `-n`  | number | PR number to check                            | Required              |
| `--top-k`     |       | number | Maximum candidates to return                  | 5                     |
| `--threshold` |       | number | Minimum similarity score (0.0-1.0)            | 0.65                  |
| `--token`     |       | string | GitHub token (falls back to `GITHUB_TOKEN`)   | -                     |
| `--config`    | `-c`  | file   | Path to configuration file                    | `.github/simili.yaml` |
| `--dry-run`   |       | bool   | Skip Qdrant search (returns empty candidates) | false                 |
| `--help`      | `-h`  | bool   | Show help message                             | -                     |

## Examples

### Check PR for duplicates

```bash theme={null}
simili pr-duplicate --repo owner/repo --number 42
```

### Adjust similarity threshold

```bash theme={null}
simili pr-duplicate --repo owner/repo --number 42 --threshold 0.80
```

### Return more candidates

```bash theme={null}
simili pr-duplicate --repo owner/repo --number 42 --top-k 10
```

### Dry-run mode

```bash theme={null}
simili pr-duplicate --repo owner/repo --number 42 --dry-run
```

## How it works

1. Fetches PR details and changed file paths from GitHub
2. Embeds the PR content: `Title: ...\n\nBody: ...\n\nChanged Files:\n- path/a`
3. Searches both the `collection` (issues) and `pr_collection` (PRs) in Qdrant
4. Deduplicates and sorts candidates by similarity score
5. Optionally runs an LLM-based duplicate verdict on the top-3 issue candidates
6. Returns a JSON result with candidates and duplicate assessment

## Output

```json theme={null}
{
  "pr": {
    "repo": "owner/repo",
    "number": 42,
    "title": "Fix authentication timeout"
  },
  "candidates": [
    {
      "type": "issue",
      "number": 123,
      "title": "Login session expires unexpectedly",
      "score": 0.92,
      "url": "https://github.com/owner/repo/issues/123"
    },
    {
      "type": "pull_request",
      "number": 38,
      "title": "Fix session expiry in auth middleware",
      "score": 0.88,
      "url": "https://github.com/owner/repo/pull/38"
    }
  ],
  "duplicate_detected": true,
  "duplicate_of": 38,
  "confidence": 0.91,
  "reasoning": "PR #38 addresses the same auth timeout issue with an identical fix approach."
}
```

## Configuration

To enable a dedicated PR collection, set `qdrant.pr_collection` in your config:

```yaml theme={null}
qdrant:
  url: "${QDRANT_URL}"
  api_key: "${QDRANT_API_KEY}"
  collection: "my-issues"
  pr_collection: "my-prs"   # PRs indexed here
```

If `pr_collection` is not set, PRs are stored alongside issues in the main `collection`.

## Indexing PRs first

Before running `pr-duplicate`, make sure PRs are indexed:

```bash theme={null}
simili index --repo owner/repo --include-prs=true
```

## GitHub Actions integration

Run PR duplicate check on every PR:

```yaml theme={null}
name: Simili PR Duplicate Check

on:
  pull_request:
    types: [opened, edited, reopened]

jobs:
  pr-duplicate:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
      contents: read
    steps:
      - uses: actions/checkout@v4

      - uses: similigh/simili-bot@v0.2.0
        with:
          command: "pr-duplicate"
          config_path: ".github/simili.yaml"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          QDRANT_URL: ${{ secrets.QDRANT_URL }}
          QDRANT_API_KEY: ${{ secrets.QDRANT_API_KEY }}
          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
```

## Next steps

<CardGroup cols={2}>
  <Card title="Index command" href="/reference/cli/index-command">
    Index issues and PRs first
  </Card>

  <Card title="Configuration schema" href="/reference/config-schema">
    Configure PR collection
  </Card>
</CardGroup>
