Use Project Builder with AI coding agents
An AI coding agent such as Claude Code, Codex or Cursor writes different code each time you ask for the same thing. For one-off work that is fine. For the code your project repeats (services, components, modules, config entries) you want the same structure every time.
Project Builder splits the job. The agent decides what to build: which schematic to run and with which inputs. The schematic decides how: it is a typed, tested program, so the same inputs produce the same files, byte for byte, on every run.
Project Builder is in beta. Some commands are not implemented yet, and behavior can change between releases. The CLI commands reference lists what is available today.
Rules files vs schematics
Section titled “Rules files vs schematics”The usual way to keep an agent consistent is a rules file: AGENTS.md, CLAUDE.md or
.cursorrules. A rules file describes your conventions, and the agent tries to follow
them. Nothing checks that it did.
A schematic enforces the convention:
- Its inputs are declared in
schema.json, andbuilder executevalidates them before anything runs. - Its logic is code you can test in memory, like any other function.
- Running it twice with the same inputs gives the same result, so you review the schematic once instead of reviewing every generated file.
Keep the rules file for judgment calls. Move the patterns you repeat into schematics, and let the agent run them.
Set up your project for an agent
Section titled “Set up your project for an agent”Run builder init in your repository. Besides project-builder.json and the schematics/
folder, it writes two things for agents:
- A skill in
.claude/skills/pbuilder/:SKILL.mdroutes the agent touse.md(run a schematic),choose.md(pick one) andcreate.md(author one). - A reference block in
AGENTS.md, or inCLAUDE.mdwhen that is the file your project uses, so the agent knows the skill exists.
When the agent runs init itself, turn off the prompts and ask for JSON:
builder init --non-interactive --json --package-manager=pnpm --mcp=no .Add --dry-run to preview every planned write without touching the disk. See
builder init for every flag, and
Evaluate without adopting the SDK to try it without
changing package.json.
How an agent runs a schematic
Section titled “How an agent runs a schematic”-
Find the schematic.
builder infolists the registered collections,builder info <collection>lists its schematics, andbuilder info <collection>:<schematic>shows the inputs it accepts. -
Run it with explicit inputs.
Terminal window builder --output=json execute default:my-component --name=buttonPass every input as a flag. Prompts for sensitive inputs are refused outside a terminal, so an agent cannot rely on them.
-
Read the result. When stdout is not a terminal, the CLI writes NDJSON by default, so an agent’s shell gets machine-readable output without extra flags. Every error carries a structured code and a suggested fix.
Everything after <collection>:<schematic> is passed to the schematic as an input.
builder execute default:my-component --output=json sends --output to the schematic, not
to the CLI. See flag placement.
Exit codes
Section titled “Exit codes”The exit code tells the agent what kind of failure happened without parsing text:
| Code | Meaning |
|---|---|
| 0 | Success |
| 2 | Usage: a flag, argument or input was wrong. Fix the call and retry. |
| 3 | Config: the project’s own configuration is missing or invalid. |
| 4 | SDK: @pbuilder/sdk is missing or the version does not match. |
| 5 | Engine: the schematic failed while running. |
| 1 | Internal or not-yet-implemented. |
The full list, with every error code and its remedy, is in CLI output and errors.
When the agent should write a schematic
Section titled “When the agent should write a schematic”A schematic automates code that already works. When the agent (or you) has written the
same pattern by hand a few times and it is tested, encode it with
builder new schematic. From then on the agent runs it instead of writing it again. The
skill’s create.md covers this step.
Do not ask the agent to invent a schematic for something you have done once. See the golden rule.
Current limits
Section titled “Current limits”builder execute --dry-runis not supported by the native engine yet: it is rejected before anything runs. Review the agent’s changes withgit diffafter the run.builder add,remove,syncandvalidateare not implemented yet.--non-interactiveonbuilder executeis reserved and only prints a warning. Passing every input as a flag is what keeps a run free of prompts.