Set Up an Agent
An agent builds correctly with OPERATOR when it has two things: a short set of rules and a component index that are always in front of it, and a way to look up the rest at the moment it needs it. oprt init provides the first, and the lookup commands the second.
Write the instructions
Run this once in the project:
pnpm exec oprt initIt writes a block into AGENTS.md, between <!-- OPERATOR:START --> and <!-- OPERATOR:END -->: the house rules as "use this, not that" pairs, one line per component saying what it is for, the recipes, and the commands that print the rest. The block is about 10 KB. Whatever else the file holds is kept.
Name an agent to write the file it reads:
| Option | File |
|---|---|
none, or --agent codex | AGENTS.md |
--agent claude | CLAUDE.md |
--agent cursor | .cursor/rules/operator.mdc, with alwaysApply: true |
--agent all | all three |
--path <file> | the file you name, inside the project |
After upgrading OPERATOR, oprt upgrade refreshes the block; running init again does the same, and replaces only its block. --dry-run previews, and --remove takes the block out. oprt doctor reports a block that is missing or was written by an older version.
The instruction file is the place for this because an agent reads it on every turn without being asked. A document it has to decide to open is opened less often than it is needed.
Look things up
The block tells the agent to use these instead of guessing. Each prints the facts for the installed version.
pnpm exec oprt search "table with selection"
pnpm exec oprt component DataGrid --dense
pnpm exec oprt component --listsearch <need>ranks the components and recipes that answer a need, and follows redirects: "go to another page" leads toLink, becauseButtonis not for that.component <Name>prints one component: what it is for, what to use instead, every prop, what each option value is for, its nesting rules and its example.--denseis the short form for an agent; without it the full descriptions are included. Several names can be given at once.component --listprints every component in one line each, parts under their parent.
--dense is the short form for people and for agents. With --json it is a compact form of the same data: no component description and one sentence per prop, with every constraint kept (each option's values and default, what each value is for, what is required, the nesting rules, the slots and the example). "dense": true says which form came back.
The answer every command gives
Every command takes --json, list and add included, and answers in one envelope:
{
"apiVersion": 2,
"type": "search",
"identity": {
"cli_version": "0.2.0",
"contract_version": "0.2.1",
"contract_digest": "sha256:1872c9cd…",
"schema_version": 2
},
"data": { "query": "table with selection", "matchCount": 4, "results": [] }
}type says what data holds: check, search, component.detail, component.batch, component.list, doctor, init, add or list (and instructions, from the MCP get_instructions tool). identity keeps four things apart, because they change on their own schedules:
| Field | What it is |
|---|---|
cli_version | The oprt program, the @oprt/cli package version. |
contract_version | The version of @oprt/react that the contract describes. |
contract_digest | sha256: and the hash of dist/contract.json, so two answers with one digest read one contract. shasum -a 256 on that file gives the same. |
schema_version | The version of this result format. It rises when a field is removed or changes meaning; adding a field does not raise it. apiVersion is the same number. |
Version 2 of the format replaced doctor's typescript field with parser, and a check's parser now names the bundled parser (@babel/parser, source bundled) where version 1 named the project's TypeScript.
A failure is { apiVersion, error, code, suggestions, identity }. The code is stable: a caller branches on it, never on the wording. suggestions holds the nearest valid names. The library exports a JSON Schema for every answer and for the failure (RESULT_SCHEMAS).
Is it ready? oprt doctor
pnpm exec oprt doctorDoctor says, one operation at a time, whether it can run here. Lookups (search, component, list) read the contract that ships inside oprt, so they always can. Code checking reads code with a parser that also ships inside oprt, so it is ready in any project, whatever TypeScript the project has (or has not): doctor names the parser and its version. Checking is blocked only if that file is missing or fails its own probe (a damaged install), with a reason (parser_missing or parser_unusable) and the fix, and a blocked check is a failed doctor (exit 1), not a footnote.
"operations": {
"lookup": { "status": "ready", "contract_version": "0.3.0", "message": "…" },
"check_code": {
"status": "ready",
"parser": { "name": "@babel/parser", "version": "8.0.8", "source": "bundled" },
"message": "…"
}
}Other ways in
The same content, from the same source, for agents that work differently.
Model Context Protocol. oprt mcp serves search, get_component, list_components, get_instructions and check_code on stdin and stdout. Every tool declares an outputSchema and returns the envelope above as its structured result, with a short text block beside it, so a client never has to parse prose. The declared schema is a summary of the answer (its fields and their types, the values a status can take, what an answer must have), so the whole tool list stays near 5.4 KB; the full JSON Schemas, which every answer is also tested against, are exported by the library as RESULT_SCHEMAS. A check that finds problems in the code is a successful call: the findings are in the result. A call that could not run (a wrong argument, an unknown component, a parser that cannot be loaded) is an error result (isError) carrying the failure, with its code. Arguments are checked against the advertised schemas before a tool runs: search's limit is a whole number from 1 to 50, dense is true or false, and an unknown argument is refused by name. The server's version (serverInfo.version) is the oprt program's; the contract's version and digest are in identity. For Claude Code, in .mcp.json:
{
"mcpServers": {
"oprt": { "command": "pnpm", "args": ["exec", "oprt", "mcp"] }
}
}Plain pages. This site serves /llms.txt, an index for agents; /llms/instructions.md, the block as a page; and one plain page per component, such as /llms/components/button.md.
A skill. skills/oprt/SKILL.md in the repository is a short method for agents that load skills: find, read, write, check. It holds no component facts of its own; it sends the agent to the commands.
Where it all comes from
One source feeds every one of these: each component's manifest (what it accepts) and packages/manifest/scripts/guidance.mjs (when to choose it, and what each option is for). The build fails when a component has no guidance or a note names a value its prop no longer takes, so none of them can describe a component the library does not ship. See Extending the Manifest.