# Publishing

Because contracts live in your client applications, publishing and sharing contracts require maintaining a separate `package.json` specifically for your contracts. This lets you publish **only** your contracts to an npm registry.

## Private APIs

If you're working with a private API, it's recommended that you use either [private package](https://www.npmjs.com/features), or something else like [Gemfury](https://gemfury.com/) to keep your contracts private. If you're completely opposed to either of those options, you also have the option of using your github repo as your contract package.

## Distributing Contracts

The **Rivet** CLI helps manage your contracts with an npm registry. There are 4 CLI commands that you should be aware of. All of these commands are expected to be run from your consumer application root directory (along side your `package.json` that requires `rivet`)

### `rivet compile`

Compiles your javascript contract files into JSON Schema files, for distribution.

### `rivet watch`

Watches contracts for change to files, and compiles changes to JSON Schema files, for distribution.

### `rivet version <version|major|minor|patch>`

Bumps the contracts version, and writes the new version to the contracts' `package.json`. It will also create a version commit and tag.

### `rivet publish`

Publishes your contracts package to the registry.

> Note: Only use this, if you are using an npm registry to host your contracts.

## Importing Contracts


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rivet.itg.sh/contracts/publishing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
