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

# Build your first plugin

> Write a CSV reader in Python or tune search ranking in Go, then certify your plugin.

Start from a working template, change what the plugin does, and check its answers with the same validators Quivr uses. The Python path turns CSV rows into searchable text. The Go path changes how search ranks results.

## Before you start

* Get a Quivr checkout. Use the Go version in its root `go.mod` and check it with `go version` from the checkout.
* For Python, check that `python3 --version` is 3.12 or later and that `python3 -m venv --help` works.
* The first build and dependency install need network access. You can run the fixtures without a Quivr server.

**1. Build the CLI**

From the root of your checkout, install `quivr` and create a temporary workspace:

```bash theme={null}
export QUIVR_REPO="$PWD"
go install ./cmd/quivr
export PATH="$(go env GOPATH)/bin:$PATH"
PLUGIN_WORK=$(mktemp -d)
cd "$PLUGIN_WORK"
```

**2. Scaffold and inspect**

`quivr plugin init` creates your project, including `quivr-plugin.yaml`. The manifest names the plugin and declares the jobs, or [Contributions](https://docs.quivr.thevibecompany.co/build/contributions.md), it can do.

> [tab] Python · CSV reader
>
> Start with the default normalizer, a plugin that turns file bytes into Parts. A Part is a named piece of content such as a title or a text passage.
>
> ```bash theme={null}
> quivr plugin init csv-rows
> cd csv-rows
> python3 -m venv .venv
> . .venv/bin/activate
> python3 -m pip install -e "$QUIVR_REPO/sdks/python" -e .
> quivr plugin inspect .
> ```
>
> The first line of the inspection report is `Plugin csv-rows 0.1.0: valid`.

> [tab] Go · Search ranking
>
> Use the retrieval scaffold. Its `default` search profile combines keyword and vector candidates. Its `composed` profile reranks results from Quivr's built-in search. Point the example module at the SDK in the same checkout as your CLI.
>
> ```bash theme={null}
> quivr plugin init harbour-rank --kind retrieval
> cd harbour-rank
> go mod edit "-replace=github.com/The-Vibe-Company/quivr/sdks/go=$QUIVR_REPO/sdks/go"
> go mod tidy
> quivr plugin inspect .
> ```
>
> The first line of the inspection report is `Plugin harbour-rank 0.1.0: valid`.

**3. Change the plugin**

> [tab] Python · CSV reader
>
> Replace `quivr-plugin.yaml` with this manifest. Its `plugin_api` range opts into signed calls, and `media_types` says it accepts CSV files.
>
> ```yaml quivr-plugin.yaml theme={null}
> id: csv-rows
> version: 0.1.0
> compatibility:
>   engine: ">=0.1.0 <0.3.0"
>   plugin_api: ">=0.14.0 <1.0.0"
> contributions:
>   normalizer:
>     media_types: [text/csv]
>     timeout_ms: 10000
> run:
>   command: [python3, -m, csv_rows]
> ```
>
> Replace `csv_rows/normalizer.py`. The SDK reads the input and verifies its size and checksum. Return one `body` Part per nonempty row, so a search hit can identify the row by its Part key.
>
> ```python csv_rows/normalizer.py theme={null}
> import csv
> import io
> from pathlib import Path
>
> from quivr_plugin import (
>     Invocation, ManifestContent, NormalizerResponse, Part, Plugin,
>     TerminalError, TextContent,
> )
>
> plugin = Plugin(Path(__file__).resolve().parent.parent / "quivr-plugin.yaml")
>
>
> @plugin.normalizer
> def normalize(invocation: Invocation) -> NormalizerResponse:
>     try:
>         text = invocation.read_input().decode("utf-8-sig")
>     except UnicodeDecodeError as exc:
>         raise TerminalError("invalid_encoding", "expected UTF-8 CSV") from exc
>
>     parts: list[Part] = []
>     for number, row in enumerate(csv.DictReader(io.StringIO(text)), start=1):
>         if number > 256:
>             raise TerminalError("too_many_rows", "expected at most 256 rows")
>         values = [f"{key}: {value}" for key, value in row.items() if key and value]
>         if values:
>             parts.append(
>                 Part(
>                     key=f"row-{number}",
>                     role="body",
>                     content=TextContent(text="\n".join(values)),
>                 )
>             )
>     if not parts:
>         raise TerminalError("empty_file", "expected at least one row of data")
>     return NormalizerResponse(manifest=ManifestContent(parts=parts))
> ```
>
> The scaffold includes fixtures and unit tests for the original Markdown handler. Remove them from this temporary example and give the new handler its own fixture.
>
> ```bash theme={null}
> rm -f fixtures/sample.json fixtures/sample.md tests/test_normalizer.py
> ```
>
> ```csv fixtures/events.csv theme={null}
> title,description
> Book fair,Local publishers present their new novels.
> Chess club,Beginners learn classic openings.
> Film night,A restored silent comedy with live piano.
> ```
>
> ```json fixtures/events.json theme={null}
> {
>   "input": {"path": "events.csv", "media_type": "text/csv"}
> }
> ```

> [tab] Go · Search ranking
>
> In `retriever.go`, change the rank constant `rrfK` from `60` to `10`. The reciprocal rank fusion formula adds `1 / (rrfK + rank)` for each candidate list that contains a hit. A smaller constant gives the top positions more weight.
>
> In `fixtures/default.json`, locate the `near_vector` list under `retrieval.order`. Move `seg_rail` to the end of that list. This fixture now puts `seg_harbour` first in both lists. Update `retrieval.expect.top` to assert the full order:
>
> ```json fixtures/default.json (excerpt) theme={null}
> ["seg_harbour", "seg_ferry", "seg_rail"]
> ```
>
> Update the fixture's description to say what it checks, then run the scaffold's Go unit tests:
>
> ```bash theme={null}
> go test ./...
> ```

**4. Run it and check the contract**

> [tab] Python · CSV reader
>
> ```bash theme={null}
> quivr plugin inspect .
> quivr plugin dev --fixture fixtures/events.json
> quivr plugin test --report contract-report.json
> ```
>
> The one-shot `dev` run prints the response and exits. Look for three Parts with keys `row-1` through `row-3` and the status line beginning `quivr plugin dev: response valid: 3 Parts`.

> [tab] Go · Search ranking
>
> ```bash theme={null}
> quivr plugin dev --startup-timeout 2m .
> ```
>
> When `dev` reports that health and discovery passed, press Ctrl+C to stop the server. Use the Contract Runner to replay retrieval fixtures. It supplies candidates to each round and compares your final ranking with the fixture's expected order.
>
> ```bash theme={null}
> quivr plugin test --startup-timeout 2m --report contract-report.json
> ```

Look for `CERTIFIED` and zero failed checks. If you see `NOT CERTIFIED`, open `contract-report.json` and look for the failing fixture and issue.

## What you built

You have a plugin project with a manifest, a changed handler, a fixture and a contract report. Each run of `plugin test` writes a fresh report. If you want to start over, create a new temporary workspace. To keep the plugin, move its project somewhere permanent before deleting the temporary folder.

[Publish and pin your plugin](https://docs.quivr.thevibecompany.co/build/test-and-publish.md) so a Quivr deployment can call it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.