PAIPAI

@pai/cli

Generate a typed client folder from a server PAI contract, and compile skill folders.

pai generate client writes a typed HTTP client folder from a server InferPaiContract export. Use it when the frontend cannot import type from the server package. pai generate skills compiles skill folders.

Import

pnpm add -D @pai/cli
pnpm exec pai generate client \
  --source server/pai.ts \
  --type AppPai \
  --out-dir web/src/generated/pai \
  --name Pai

Signature

pai generate client --source <file> --type <Export> --out-dir <dir> --name <Stem> [--check]

Parameters

--source: string

TypeScript file that exports the app.

--type: string

Exported contract alias (AppPai).

--out-dir: string

Generated folder.

--name: string

API stem (Pai, createPaiClient, …).

--check?: flag

Exit non-zero when the folder is stale.

Agent bindings derive their export names from agent IDs. When IDs produce the same name, suffixes are assigned in case-sensitive agent-ID order: support becomes SupportAgent, while support-agent becomes SupportAgent2. After adding, removing, or renaming colliding IDs, check the agent IDs in the generated client.ts before reusing those imports.

pai generate skills

pai generate skills compiles a directory of Agent Skills folders into one module for defineSkills(). Every child directory must be a skill holding SKILL.md, apart from the output directory and the others listed in Skill folder rules; top-level files are ignored.

pnpm exec pai generate skills --dir server/skills [--out <file>] [--check | --watch]

--dir: string

Directory whose child directories are skills.

--out?: string

Output module. Defaults to <dir>/generated/index.ts.

--check?: flag

Write nothing, and exit non-zero when the module is missing or stale, or any skill has a warning.

--watch?: flag

Generate, then regenerate whenever a skill changes, until stopped. Cannot be combined with --check.

Every problem is printed with its file, and nothing is written while any skill is invalid. See Skill folder rules; generateSkills() is the same step as a Node API. pai install-skills is unrelated: it installs a developer skill for coding agents.

Learn more

On this page