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

# ocx build

> Reference for the ocx build command — build a registry from source files

## Usage

```bash theme={null}
ocx build [path] [options]
```

## Description

Build a registry from source files. This command validates the `registry.jsonc` manifest, generates the `index.json` and component packument files, and copies raw component files into the output directory. Intended for registry authors who want to publish their own components.

## Arguments

| Argument | Required | Description                                            |
| -------- | -------- | ------------------------------------------------------ |
| `path`   | No       | Registry source directory (default: current directory) |

## Flags

| Flag                | Shorthand | Default           | Description                                                                     |
| ------------------- | --------- | ----------------- | ------------------------------------------------------------------------------- |
| `--out <dir>`       |           | `./dist`          | Output directory                                                                |
| `--dry-run`         |           | `false`           | Validate and show what would be built                                           |
| `--show-validation` |           | `false`           | Run full validation before build; show detailed validation output in human mode |
| `--cwd <path>`      |           | Current directory | Working directory                                                               |
| `--json`            |           | `false`           | Output as JSON                                                                  |
| `--quiet`           | `-q`      | `false`           | Suppress output                                                                 |

## Examples

### Build Registry in Current Directory

```bash theme={null}
ocx build
```

### Build from a Specific Directory

```bash theme={null}
ocx build ./my-registry
```

### Specify Output Directory

```bash theme={null}
ocx build --out ./public
```

### Validate Without Building

```bash theme={null}
ocx build --dry-run
```

### Show Validation Breakdown Before Build

```bash theme={null}
ocx build --show-validation
```

When `--show-validation` is set, OCX always runs validation checks before building.

* In human mode, it prints per-check validation results.
* With `--json` or `--quiet`, validation still runs, but presentation follows those flags.

## Output

```bash theme={null}
$ ocx build
Building registry...
Built 5 components to dist

$ ocx build --json
{
  "success": true,
  "data": {
    "components": 5,
    "output": "/path/to/dist"
  }
}
```

## Source Structure

The build command expects a `registry.jsonc` file in the source directory:

```
my-registry/
  registry.jsonc        # Registry manifest
  files/
    agents/
      my-agent.md       # Agent definition
    plugins/
      my-plugin.ts      # Plugin file
    skills/
      my-skill/
        SKILL.md        # Skill definition
```

## Errors

| Error        | Cause                                     | Solution                         |
| ------------ | ----------------------------------------- | -------------------------------- |
| Build errors | Invalid `registry.jsonc` or missing files | Check error messages for details |

## See Also

* [Creating Registries](/docs/registries/create) — Full guide for registry authors.
* [Registry Protocol](/docs/registries/protocol) — Technical specification for registry HTTP APIs.
* [CLI Reference](/docs/cli/commands) — All commands.
