buildx-cli
v1.8.43
Published
CLI tool for BuildX API with authentication and schema synchronization
Readme
BuildX CLI
A command-line interface tool for BuildX API with authentication, project management, and schema synchronization capabilities.
Features
- 🔐 Authentication Management: Secure login/logout with token validation
- 📁 Project Management: List, set default, and manage multiple projects
- 🔄 Schema Synchronization: Pull and push collections/types as code
- ⚡ Function Synchronization: Pull and push function source files as code
- ⚙️ Configuration Management: Store settings or use environment variables
- 🎯 Interactive CLI: User-friendly command-line interface with prompts
Installation
Using npx (Recommended)
npx buildx-cli --helpGlobal Installation
npm install -g buildx-cliLocal Development
git clone <repository-url>
cd buildx-cli
yarn install
yarn build
yarn start --helpQuick Start
Configure API settings:
npx buildx-cli config:setupAuthenticate:
npx buildx-cli auth:loginList projects:
npx buildx-cli projects:listPull schema:
npx buildx-cli schema:pull --project-id <project-id>Pull function code:
npx buildx-cli function:pull --project-id <project-id>Pull AI functions:
npx buildx-cli ai-function:pull --project-id <project-id>Pull templates:
npx buildx-cli template:pull --project-id <project-id>
Configuration
Method 1: Interactive Setup
npx buildx-cli config:setupMethod 2: Environment Variables
Set these environment variables or add them to a .env file:
BUILDX_API_ENDPOINT=https://api.example.com
BUILDX_API_KEY=your-api-key
BUILDX_PROJECT_ID=your-default-project-idSupported aliases (auto-resolved):
NEXT_PUBLIC_API_ENDPOINT=
NEXT_PUBLIC_API_KEY=
NEXT_PUBLIC_BUILDX_PROJECT_ID=
NEXT_PUBLIC_BUILDX_API_ENDPOINT=
NEXT_PUBLIC_BUILDX_API_KEY=
BUILDX_API_ENDPOINT=
BUILDX_API_KEY=
BUILDX_PROJECT_ID=Resolution priority is strict-first:
- Endpoint:
BUILDX_API_ENDPOINT->NEXT_PUBLIC_BUILDX_API_ENDPOINT->NEXT_PUBLIC_API_ENDPOINT - API key:
BUILDX_API_KEY->NEXT_PUBLIC_BUILDX_API_KEY->NEXT_PUBLIC_API_KEY - Project ID:
BUILDX_PROJECT_ID->NEXT_PUBLIC_BUILDX_PROJECT_ID
When running config:setup, CLI auto-detects these values and asks for confirmation before using them.
Method 3: Command Line Options
npx buildx-cli config:setup --endpoint https://api.example.com --api-key your-api-keyPer-command endpoint override:
- Many commands support
-u, --api-url <url>. --api-urloverrides only the current command request target.- Saved config is not changed.
- API key and auth are still resolved from existing config/env.
View Current Configuration
npx buildx-cli config:showClear Configuration
npx buildx-cli config:clearCommands
Authentication
auth:login
Logs in with token or username/password interactively.
npx buildx-cli auth:loginBrowser-session login (uses your existing Studio login):
npx buildx-cli auth:login --browserThe CLI will show a verification code. Open the verification page in any browser/device, sign in, and enter that code.
Token login (useful when authenticating from another machine):
npx buildx-cli auth:login --token <your-token>auth:logout
Clears stored authentication.
npx buildx-cli auth:logoutauth:status
Shows current auth state and user details (if available).
npx buildx-cli auth:statusProjects
projects:list
Lists available projects for the authenticated account.
npx buildx-cli projects:listFilter by product key (project.product.key):
npx buildx-cli projects:list --product-key approvalprojects:set-default <project-id>
Sets default project used by commands when --project-id is not provided.
npx buildx-cli projects:set-default hello-worldprojects:current
Shows currently selected default project.
npx buildx-cli projects:currentprojects:metadata:get
Get project metadata (default path: metadata.product_constants), optionally export to JSON file.
npx buildx-cli projects:metadata:get --project-id hello-world
npx buildx-cli projects:metadata:get --project-id hello-world --path product_constants --output ./project-metadata.jsonprojects:metadata:update
Update project metadata constants + optional locale fields.
# set constants
npx buildx-cli projects:metadata:update --project-id hello-world --set API_BASE_PATH=/v1 --set FEATURE_FLAG_X=on
# import constants from JSON object
npx buildx-cli projects:metadata:update --project-id hello-world --import ./metadata.json
# replace all constants then import
npx buildx-cli projects:metadata:update --project-id hello-world --replace --import ./metadata.json
# unset keys
npx buildx-cli projects:metadata:update --project-id hello-world --unset FEATURE_FLAG_X
# update locale together
npx buildx-cli projects:metadata:update --project-id hello-world --default-language en-US --timezone Asia/BangkokNotes:
- Metadata key format is enforced:
A-Z0-9_ - Duplicate keys in
--setare rejected
projects:locale:validate
Validate locale format before saving.
npx buildx-cli projects:locale:validate --default-language en-US --timezone UTCproject:init
Initialize a new Buildx project and optional app scaffold.
Modes:
plain: creates standalone project viaPOST /projects.product: triesPOST /product/:product_key/projects, then falls back toplainwhen product creation is denied (for example non-root auth).
Key options:
-i, --interactive: prompt for missing options (recommended for first-time setup)--project-id <id>: target project ID (required unless interactive prompt is used)--name <name>: project name (required unless interactive prompt is used)--description <text>: project description (optional)--product-key <key>: enable product mode first, with fallback to plain mode--app <none|next|expo|react>: app scaffold target (defaultnone)--react-stack <vite|next|expo-web>: required when--app react--out-dir <path>: output workspace directory (default./<project-id>)--overwrite: allow writing into non-empty output directory--use-existing: allow using existingproject_idwithout creating a new backend project--dry-run: compute output without writing files or calling APIs--json: print machine-readable result
Examples:
# backend only (plain mode)
npx buildx-cli project:init --project-id hello-world --name "Hello World"
# interactive guided mode
npx buildx-cli project:init --interactive
# product mode first, fallback to plain when not allowed
npx buildx-cli project:init --project-id hello-world --name "Hello World" --product-key approval
# backend + Next.js app
npx buildx-cli project:init --project-id hello-world --name "Hello World" --app next
# backend + Expo app
npx buildx-cli project:init --project-id hello-world --name "Hello World" --app expo
# existing backend project id (reuse backend, scaffold local files)
npx buildx-cli project:init --project-id hello-world --name "Hello World" --app next --use-existingExisting project behavior:
- CLI checks existing project IDs before create.
- If
project_idalready exists:- interactive mode asks for confirmation to continue with existing backend.
- with
--use-existing, CLI skips confirmation and continues directly. - with
--jsonand no--use-existing, CLI exits with error (no interactive prompt in JSON mode).
Next.js starter behavior (--app next):
- public/private route split remains (
app/(public)andapp/(private)). - root app shell includes a reusable navbar.
- includes built-in theme mode setup (
light|dark|system) with toggle. - includes built-in locale setup (
en|th) with selector. - default web UI stack is HeroUI (
@heroui/react) as primary component framework. - generated provider wiring does not import/wrap
HeroUIProvider(compatibility with current HeroUI export surface). - generated auth wiring supports dual mode:
buildxmode (root auth API, no project scope)projectmode (project-scoped auth API with project id)automode (uses project id only when provided)
- starter card layout uses
CardContent(notCardBody) for current HeroUI package compatibility. - auth screens use shared UI pack components without forcing full-screen background, so page/layout background is controlled by the generated app.
Expo starter behavior (--app expo):
- scaffold base runs
npx create-expo-app@latest(TypeScript template) first. - dependency install step now follows detected package manager from user agent/lockfile (
pnpm,yarn,bun,npm) instead of forcingnpm install. - mobile-first scaffold with HeroUI Native (
heroui-native) provider and starter controls. - starter provider defaults disable animated-style helper noise for custom-style scaffolds:
isAnimatedStyleActive={false}config.devInfo.stylingPrinciples=false
- starter uses
SafeAreaViewfromreact-native-safe-area-context(not deprecatedreact-nativeexport). - includes required
heroui-nativepeer dependencies:uniwind,tailwind-merge,tailwind-variants,react-native-gesture-handler,@gorhom/bottom-sheet. - includes
react-native-workletsdependency required by currentreact-native-reanimatedchain. - keeps auth state split (public/private view) and uses shared Buildx auth provider wiring.
- generated auth wiring supports dual mode (
buildx|project|auto) with project-id forwarding on auth actions. - includes starter auth flows on mobile:
- sign-in (username/password)
- sign-up (name/email/tel support)
- EOTP request + verify
- forgot/reset password
- private change-password form
- after Buildx dependency rewiring, CLI runs install to ensure added packages are available immediately.
- CLI also runs
expo installfor native compatibility packages (react-native-reanimated,react-native-safe-area-context,react-native-screens,react-native-svg,react-native-worklets,react-native-gesture-handler,@gorhom/bottom-sheet) to align with Expo SDK expectations. - generated Expo app includes
global.csssetup for Uniwind + HeroUI Native styles and wraps app withGestureHandlerRootView. - generated
global.cssincludes fallback static theme tokens for HeroUI Native hover color variables to avoid Uniwind missing-variable warnings in minimal starter usage.
project:add-pack
Add Buildx pack dependencies into an existing project package.
Key options:
--pack <ui-packs|sdk>: pack to install--version <version>: optional version override--dir <path>: target project directory (default current directory)--manager <bun|pnpm|npm|yarn>: force package manager--json: print machine-readable result
Examples:
# add UI packs with default version
npx buildx-cli project:add-pack --pack ui-packs
# add sdk in specific directory with pnpm
npx buildx-cli project:add-pack --pack sdk --manager pnpm --dir ./my-projectGenerated auth-aware structure:
- Next.js scaffold source:
project:init --app nextrunsnpx create-next-app@latestfirst (TypeScript + App Router)- then applies Buildx auth/public-private route wiring and maintenance scripts
- then runs dependency install to ensure added Buildx/HeroUI packages are present before first
dev
- Next.js template uses route groups for separation:
app/(public)/...(sign-in/sign-up/forgot-password)app/(private)/...(protected dashboard)- rewrites root
app/layout.tsxand starter shell to include provider wiring (auth + theme + locale) - starter root
app/page.tsxincludes genericDashboard,Sign in, andSign uplinks with usage description
- Expo template uses auth-state route split in
App.tsx:project:init --app exporunsnpx create-expo-app@latestfirst- public screen tree for unauthenticated users
- private screen tree for authenticated users
- mobile-first baseline with
heroui-nativeprovider
- Generated auth mode env defaults:
NEXT_PUBLIC_BUILDX_AUTH_MODE/EXPO_PUBLIC_BUILDX_AUTH_MODE/VITE_BUILDX_AUTH_MODE(default:auto)NEXT_PUBLIC_BUILDX_PROJECT_ID/EXPO_PUBLIC_BUILDX_PROJECT_ID/VITE_BUILDX_PROJECT_IDused as default project scope inprojectmode- in
projectmode, generated auth forms passprojectIdexplicitly to auth actions - in
buildxmode, generated auth provider forces root scope (no project id)
- Scaffold layout is single-level:
- app package files are generated at workspace root (no
apps/webnesting) buildx/artifacts are generated at root level alongside app files
- app package files are generated at workspace root (no
UI package dependency resolution:
- generated apps depend on package from env
BUILDX_UI_PACKS_PACKAGE - default package name is
buildx-react-ui-packs - default package version/tag is
latest(override viaBUILDX_UI_PACKS_VERSION) - set a scoped package before seeding when unscoped npm name is unavailable:
BUILDX_UI_PACKS_PACKAGE=@your-scope/buildx-react-ui-packs npx buildx-cli project:init ...
Notes:
- Next scaffold requires npm registry connectivity for
create-next-app. - Use
--dry-runto preview file plan without running scaffold commands. - After backend bootstrap,
project:initautomatically runs initial pull via CLI:schema:pull --target-dir <workspace>/buildx/generatedfunction:pull --target-dir <workspace>/buildxai-function:pull --target-dir <workspace>/buildx/ai-functionstemplate:pull --target-dir <workspace>/buildx/templatesso starter artifact docs/structure are available immediately.
- Generated projects are package-manager agnostic (no forced
packageManagerlock in generatedpackage.json). - Next
app/globals.cssis normalized with Tailwind@sourceto include UI pack classes fromnode_modules(prevents missing utilities likegrid-cols-2from shared components). - Next starter includes
@heroui/reactby default. - Expo starter includes
heroui-nativeby default.
Standard Artifact Guideline
Use this as the standard workflow for project artifacts after project:init.
Scope and location:
- schema artifacts:
buildx/generated/* - function artifacts:
buildx/functions/* - AI function artifacts:
buildx/ai-functions/* - template artifacts:
buildx/templates/*
Initial sync baseline:
project:initauto-pulls all artifact groups (schema,function,ai-function,template).
Daily standard loop (recommended):
- Pull latest remote artifacts first.
- Edit local files.
- Diff against remote.
- Push with
--dry-run. - Push for real after review.
# 1) pull latest (all artifact groups)
npx buildx-cli schema:pull --project-id <project-id>
npx buildx-cli function:pull --project-id <project-id>
npx buildx-cli ai-function:pull --project-id <project-id>
npx buildx-cli template:pull --project-id <project-id>
# 2) diff before push
npx buildx-cli schema:diff --project-id <project-id> --details
npx buildx-cli function:diff --project-id <project-id>
npx buildx-cli ai-function:diff --project-id <project-id>
npx buildx-cli template:diff --project-id <project-id>
# 3) dry-run push
npx buildx-cli schema:push --project-id <project-id> --dry-run
npx buildx-cli function:push --project-id <project-id> --dry-run
npx buildx-cli ai-function:push --project-id <project-id> --dry-run
npx buildx-cli template:push --project-id <project-id> --dry-run
# 4) push for real
npx buildx-cli schema:push --project-id <project-id>
npx buildx-cli function:push --project-id <project-id>
npx buildx-cli ai-function:push --project-id <project-id>
npx buildx-cli template:push --project-id <project-id>Users
user:list
Lists users in project scope.
npx buildx-cli user:list --project-id hello-worlduser:create
Creates a user in project scope.
npx buildx-cli user:create --project-id hello-world --username demo --password secret --name "Demo User" --email [email protected]Data Commands
data:list <collection-id>
List documents from a collection.
npx buildx-cli data:list employees --project-id hello-world --limit 20 --sort '{"createdAt":-1}'data:get <collection-id> <document-id>
Get one document by ID.
npx buildx-cli data:get employees 65fabc... --project-id hello-worlddata:create <collection-id>
Create one document from JSON.
npx buildx-cli data:create employees --project-id hello-world --data '{"name":"Alice","email":"[email protected]"}'data:update <collection-id> <document-id>
Update one document from JSON.
npx buildx-cli data:update employees 65fabc... --project-id hello-world --data '{"name":"Alice Updated"}'data:delete <collection-id> <document-id>
Delete one document.
npx buildx-cli data:delete employees 65fabc... --project-id hello-worlddata:export <collection-id>
Export collection data to JSON file.
npx buildx-cli data:export employees --project-id hello-world --output ./employees.json --filter '{"status":"active"}'data:import <collection-id>
Import JSON array into a collection.
npx buildx-cli data:import employees --project-id hello-world --input ./employees.json
npx buildx-cli data:import employees --project-id hello-world --input ./employees.json --mode upsert
npx buildx-cli data:import employees --project-id hello-world --input ./employees.json --mode upsert --upsert-key email
npx buildx-cli data:import employees --project-id hello-world --input ./employees.json --mode upsert --upsert-key tenant_id,employee_codeSchema Commands
schema:pull
Pulls schema artifacts from remote and writes local files.
Writes:
types.tscollections.json(unless--skip-collections-code)collections.manifest.jsonSCHEMA_AS_CODE.md(generated usage guide for human/AI collaborators)
Source-of-truth behavior:
collections.jsonis pulled from remote/project/:project_id/collectionspayload directly (with only lightweight normalization for internal keys).- CLI does not reconstruct
collections.jsonfromtypes.tsduringschema:pull. - runtime cache payload under
form_schema.*.propertiesScheme.schemais excluded from pull/push sync artifacts. - embedded
Object/List/Rowarray children are sanitized during pull normalization (invalid child entries without a stablenameare removed from exportedcollections.json). - collection-level
configurationsis preserved for push/pull sync (includingconfigurations.soft_delete.*values).
System-managed fields:
- when
timestamps: true, pulledtypes.tsincludescreatedAt/updatedAt(BxDateTime) - when
auditable: true, pulledtypes.tsincludescreatedBy/updatedBy(BxAuth) - these fields are excluded from collections sync payloads (won't be pushed back)
Key options:
-p, --project-id <id>: project to sync from-t, --target-dir <path>: base output directory (recommended)-o, --output <path>: custom types path (when no--target-dir)--collections-file <path>: custom collections JSON path (when no--target-dir)--filter <pattern...>: include only matching collection IDs--include-buildx: includebuildx_*collections--skip-collections-code: skip collections JSON/manifest output--no-annotate-types: disable@bx.*annotations injection into pulledtypes.ts--dry-run: print full file content previews without writing files-f, --force: overwrite even if local file drift is detected
npx buildx-cli schema:pull --project-id hello-world --target-dir ./.sandbox/buildx-cli
npx buildx-cli schema:pull --project-id hello-world --dry-runschema:sync is still available as a compatibility alias (deprecated).
schema:push
Pushes local collections.json back to remote project.
Reads:
collections.jsoncollections.manifest.json(for drift checks)
Behavior:
- validates minimum shape (
collection_id,form_schema) - validates nested embedded field schema recursively:
Object/List/RowrequirepropertiesScheme.children- array children must be object items with non-empty
name - nested children are validated transitively
- compares local checksum vs remote checksum
- skips remote-drift conflicts unless
--force - excludes system-managed fields (
createdAt,updatedAt,createdBy,updatedBy) from push - preserves collection-level runtime
configurationsfromcollections.json(for example soft-delete settings underconfigurations.soft_delete)
Key options:
-p, --project-id <id>--product-key <key>push to all projects whereproject.product.keymatches (cannot be used with--project-id)-t, --target-dir <path>--collections-file <path>(when no--target-dir)--filter <pattern...>--dry-run-f, --force
npx buildx-cli schema:push --project-id hello-world --target-dir ./.sandbox/buildx-cli --dry-run
npx buildx-cli schema:push --product-key approval --target-dir ./.sandbox/buildx-cli --dry-runschema:types:convert
Converts a local types.ts file into collections JSON first, so you can review before push.
Reads:
types.ts(or--types-file)- optional base
collections.jsonto preserve metadata (used when present)
Writes:
collections.json(or--collections-file)
Key options:
-t, --target-dir <path>--types-file <path>--collections-file <path>--base-collections-file <path>--no-allow-lossy(strict mode: require base metadata file)--filter <pattern...>--dry-run
Field annotations (JSDoc in types.ts) are supported:
@bx.title <text>@bx.description <text>@bx.requiredor@bx.required false@bx.ref <collection_id_or_enum_key>@bx.choices value1:Label 1|value2:Label 2(forChoices/MultipleChoices)@bx.type <SchemaType>(force schema field type, useful for unions)@bx.default <json>@bx.format <json_or_string>@bx.validate <json_or_string>@bx.props <json-object>(merge custom keys intopropertiesScheme)
Required behavior:
- converter does not auto-assume
required: truefrom non-optional TypeScript syntax by default. - use
@bx.required(or@bx.required false) for explicit required control. - converter output is validated with the same recursive schema rules used by
schema:pushbefore writingcollections.json.
System-managed fields:
createdAt,updatedAt,createdBy,updatedByintypes.tsare ignored by convert output and never synced back
Embedded object fidelity:
- inline object/list members are restored as structured
children(not collapsed toitem: Text). - nested relation refs are normalized to collection IDs (for example
Partial<Workflows>->workflows). - when merging with base
collections.json, nested child metadata is preserved by child name when possible. - dynamic object/list fallback stays as
BxObject/BxListat type layer andObject/Listin collection schema layer. - dynamic mixed fallback uses
BxMixedat type layer andMixedin collection schema layer. - temporary compatibility:
string[]/BxText[]converts toMultipleChoicesinstead of genericList. schema:pullannotation style:- emits multiline JSDoc tags for readability
- emits
@bx.typeonly for lossy relation kinds (ReverseReference,ReverseReferences,Virtual) - enforces remote
Mixedfields toBxMixed(notBxText) from source-of-truthcollectionspayload
Example:
export type Employees = {
/** @bx.title Employment status @bx.choices active:Active|on_leave:On Leave */
status?: BxChoices;
/** @bx.required */
employee_id?: BxText;
/** @bx.ref departments @bx.title Department */
department?: Partial<Departments> | BxDataObject;
};npx buildx-cli schema:types:convert --target-dir ./.sandbox/buildx-cli --dry-run
npx buildx-cli schema:types:convert --target-dir ./.sandbox/buildx-cli
npx buildx-cli schema:push --collections-file ./.sandbox/buildx-cli/collections.json --project-id hello-world --dry-runschema:list
Lists remote collections.
Key options:
-p, --project-id <id>--filter <pattern...>--include-buildx
npx buildx-cli schema:list --project-id hello-world --filter "user*"schema:diff
Diffs local collections against remote by collection_id.
Reads:
- local
collections.json
Output markers:
= same~ changed+ local-only- remote-only
Key options:
-p, --project-id <id>-t, --target-dir <path>--collections-file <path>(when no--target-dir)--filter <pattern...>--include-buildx
npx buildx-cli schema:diff --project-id hello-world --target-dir ./.sandbox/buildx-cliFunction Commands
function:pull
Pulls function context schema and function source code from remote.
Writes:
function-context.d.tsfunctions/*.tsfunctions/functions.manifest.jsonFUNCTION_AS_CODE.md(generated usage guide for human/AI collaborators)
Behavior:
- writes a compact
function-context.d.tsby default (use--full-contextto keep full remote schema) - preserves remote function code as-is by default (safe with existing runtime)
- optional
--module-wrapcan normalize arrow-function code into module format (export default) for local tooling - stores manifest checksums using deterministic source checksum parity (normalized
CRLF -> LFand trim) so local/remote comparisons stay stable - skips overwriting local edited files unless
--force - supports dry-run file content previews
Key options:
-p, --project-id <id>-t, --target-dir <path>--context-output <path>(when no--target-dir)--functions-dir <path>(when no--target-dir)--filter <pattern...>--full-context--module-wrap--no-validate-code--no-lint--dry-run-f, --force
npx buildx-cli function:pull --project-id hello-world --target-dir ./.sandbox/buildx-cli
npx buildx-cli function:pull --project-id hello-world --dry-runfunction:sync is still available as a compatibility alias (deprecated).
function:push
Pushes local function source files back to remote.
Reads:
functions/*.tsfunctions/functions.manifest.json
Behavior:
- checks remote drift against manifest baseline
- uses deterministic source checksum parity between local and remote source
- skips push when local source is unchanged from remote source checksum
- validates local function code compatibility before push (can bypass via
--no-validate-code) - runs basic syntax lint before push (can bypass via
--no-lint) - skips conflicts unless
--force
Key options:
-p, --project-id <id>--product-key <key>push to all projects whereproject.product.keymatches (cannot be used with--project-id)-t, --target-dir <path>--functions-dir <path>(when no--target-dir)-n, --name <function-name>for a single function--filter <pattern...>--no-validate-code--no-lint--dry-run-f, --force
npx buildx-cli function:push --project-id hello-world --target-dir ./.sandbox/buildx-cli --dry-run
npx buildx-cli function:push --product-key approval --target-dir ./.sandbox/buildx-cli --dry-runfunction:list
Lists remote function names.
Key options:
-p, --project-id <id>--filter <pattern...>
npx buildx-cli function:list --project-id hello-world --filter "send*"function:diff
Diffs local function sources against remote.
Reads:
- local
functions/*.ts functions/functions.manifest.json
Output markers:
= same~ changed+ local-missing- remote-missing! remote-drift
Comparison behavior:
- computes deterministic source checksums on normalized content (
CRLF -> LF, trim) for both local and remote sources - prints git-like unified patch blocks in default output for changed/missing functions
Key options:
-p, --project-id <id>-t, --target-dir <path>--functions-dir <path>(when no--target-dir)-n, --name <function-name>--filter <pattern...>--no-patch(show summary/status only)
npx buildx-cli function:diff --project-id hello-world --target-dir ./.sandbox/buildx-clifunction:revisions <function-name>
Lists function revisions and shows which revision is live plus alias mapping.
Key options:
-p, --project-id <id>-u, --api-url <url>--json
npx buildx-cli function:revisions process-order --project-id hello-worldfunction:publish <function-name> [revision]
Publishes a revision to alias (default alias: live). If revision is omitted, CLI publishes the latest revision.
Key options:
-p, --project-id <id>-u, --api-url <url>--alias <alias>(default:live)
npx buildx-cli function:publish process-order --project-id hello-world
npx buildx-cli function:publish process-order r12 --project-id hello-world
npx buildx-cli function:publish process-order 12 --project-id hello-world --alias stableBest practices:
- Use aliases as stable pointers for environments/traffic, not raw revision numbers in app code.
- Revision identifier is system-managed (
r1,r2, ...). You cannot set revision id manually. - If you want deployment traceability by git commit, use git hash as an alias (for example:
a1b2c3d4->r42). - Recommended alias convention:
live: production trafficstable: last known good releasecanary: limited rollout / verification
- Typical release flow:
- Save function in Studio/CLI (creates new revision automatically)
- Validate with
function:invoke --revision rN - Promote by alias:
function:alias:set <fn> canary rN - Promote to production:
function:publish <fn> rN --alias live - Fast rollback:
function:alias:set <fn> live <previous-revision>
- For routine publish operations, run
function:publish <fn>without revision to move the latest revision tolive. - Keep revision IDs immutable and treat alias changes as deployment events (track in release notes/ops logs).
- Use
function:revisions <fn>to list revision id, checksum (short), and alias mapping in one place.
Git-hash alias example:
# Point alias named by git hash to a revision
npx buildx-cli function:alias:set process-order a1b2c3d4 r42 --project-id hello-world
# Publish latest revision to a git-hash alias
npx buildx-cli function:publish process-order --project-id hello-world --alias a1b2c3d4
# Inspect mapping + checksum
npx buildx-cli function:revisions process-order --project-id hello-worldfunction:alias:set <function-name> <alias> <revision>
Sets alias pointer directly to a revision.
Key options:
-p, --project-id <id>-u, --api-url <url>
npx buildx-cli function:alias:set process-order canary r15 --project-id hello-worldAI Function Commands
ai-function:pull
Pulls AI function rows from buildx_ai_functions (fallback compatibility: buildx_ai_function).
Writes:
buildx/ai-functions/functions.jsonbuildx/ai-functions/functions.manifest.json
Key options:
-p, --project-id <id>-t, --target-dir <path>--data-file <path>(when no--target-dir)--manifest-file <path>(when no--target-dir)--filter <pattern...>--dry-run
npx buildx-cli ai-function:pull --project-id hello-world
npx buildx-cli ai-function:pull --project-id hello-world --target-dir ./.sandbox/buildx-cliai-function:push
Pushes local AI function JSON back to buildx_ai_functions (fallback compatibility: buildx_ai_function).
Reads:
buildx/ai-functions/functions.jsonbuildx/ai-functions/functions.manifest.json(for drift detection)
Behavior:
- checks remote drift against local manifest baseline
- supports push-by-name and wildcard filter
- skips missing remote row unless
--allow-create
Key options:
-p, --project-id <id>-t, --target-dir <path>--data-file <path>(when no--target-dir)--manifest-file <path>(when no--target-dir)-n, --name <function-name>--filter <pattern...>--allow-create--dry-run-f, --force
npx buildx-cli ai-function:push --project-id hello-world --dry-run
npx buildx-cli ai-function:push --project-id hello-world --name summarize_order --forceai-function:diff
Diffs local AI functions against remote collection.
Output markers:
= same~ changed+ local-only- remote-only! remote-drift
npx buildx-cli ai-function:diff --project-id hello-worldTemplate Commands
template:pull
Pulls templates from buildx_templates.
Writes:
buildx/templates/templates.jsonbuildx/templates/templates.manifest.json
npx buildx-cli template:pull --project-id hello-worldtemplate:push
Pushes local templates JSON back to buildx_templates.
Reads:
buildx/templates/templates.jsonbuildx/templates/templates.manifest.json(for drift detection)
npx buildx-cli template:push --project-id hello-world --dry-runtemplate:diff
Diffs local templates against remote buildx_templates.
npx buildx-cli template:diff --project-id hello-worldfunction:invoke <function-name>
Invokes function with optional revision or alias.
Key options:
-p, --project-id <id>-u, --api-url <url>-X, --method <method>--revision <revision>--alias <alias>--data <json>--data-file <path>
npx buildx-cli function:invoke process-order --project-id hello-world --alias live --data '{"order_id":"A001"}'
npx buildx-cli function:invoke process-order --project-id hello-world --revision r12 --data-file ./payload.jsonConfiguration Commands
config:setup
Interactive API configuration (endpoint, api key).
npx buildx-cli config:setupconfig:show
Displays current resolved configuration (use this to inspect configured API endpoint).
npx buildx-cli config:showconfig:clear
Clears all saved CLI configuration.
npx buildx-cli config:clearConfiguration Sources
The CLI checks for configuration in this order:
- Stored Configuration (via
config:setup) - Environment Variables (
BUILDX_API_ENDPOINT,BUILDX_API_KEY) .envFile (in current directory)
Configuration File Location
- Global config:
~/.config/buildx-cli-nodejs/config.json
Environment Variables
BUILDX_API_ENDPOINT- Your API endpoint URLBUILDX_API_KEY- Your API keyBUILDX_PROJECT_ID- Default project ID (optional)NEXT_PUBLIC_BUILDX_API_ENDPOINT- Alias for API endpointNEXT_PUBLIC_API_ENDPOINT- Alias for API endpointNEXT_PUBLIC_BUILDX_API_KEY- Alias for API keyNEXT_PUBLIC_API_KEY- Alias for API keyNEXT_PUBLIC_BUILDX_PROJECT_ID- Alias for default project ID
API Endpoints
The CLI interacts with the following API endpoints:
POST /auth/login- User authenticationGET /auth/me- Get current user infoGET /projects- List user projectsGET /project/:project_id/collections/schema- Fetch project schema typesGET /project/:project_id/collections- Fetch collections as codePOST /project/:project_id/collections- Upsert collectionGET /project/:project_id/functions/context/schema/info- Fetch function context schema infoGET /project/:project_id/functions- List functionsGET /project/:project_id/functions/:function_name- Fetch function sourcePOST /project/:project_id/functions/:function_name- Upsert function sourceGET /project/:project_id/functions/:function_name/revisions- List function revisionsPOST /project/:project_id/functions/:function_name/revisions/:revision/publish- Publish function revisionPUT /project/:project_id/functions/:function_name/aliases/:alias- Update function aliasPOST /project/:project_id/functions/run/:function_name- Invoke function
CLI Output Formats (All Commands)
Detailed command-by-command examples (normal + --json): see OUTPUT_EXAMPLES.md.
General rules:
- Success output is human-readable by default unless command has explicit JSON mode.
- Error output is plain text:
Error: <message>and exits non-zero. - Commands with
--jsonprint JSON to stdout for automation. - Commands that return documents (
data:list/get/create/update/delete) are already JSON by default.
Authentication
auth:login:- default: human-readable status lines
--json:{ success, method, username, tokenMasked, expiresAt }
auth:logout:- default: human-readable confirmation
--json:{ success, authenticated }
auth:status:- default: human-readable session summary
--json:{ success, authenticated, user?, tokenMasked?, expiresAt? }
Projects
projects:list:- default: human-readable list
--json:{ success, projects[], total, defaultProjectId }
projects:set-default:- default: human-readable confirmation
--json:{ success, defaultProjectId, project }
projects:current:- default: human-readable summary
--json:{ success, defaultProject }
projects:metadata:get: prints pretty JSON for selected metadata path.--output <file>writes JSON file and prints success line.
projects:metadata:update:- default: human-readable summary (
default_language,timezone, key count) --json: updated project payload JSON--dry-run: payload JSON only
- default: human-readable summary (
projects:locale:validate: success line + JSON validation result.
Configuration
config:setup:- default: interactive + human-readable summary
--json:{ success, api: { endpoint, apiKeyMasked } }
config:show:- default: human-readable configuration report
--json: structured config payload (api,auth,projects,sync,configPath,envSources)
config:clear:- default: human-readable confirmation
--json:{ success, cleared }
Users
user:list:- default: tab-separated table (
id,username,name,email) + total --json: raw users array JSON
- default: tab-separated table (
user:create:- default: human-readable confirmation
--json: created user JSON
Schema
schema:pull/schema:sync:- default: file write summary
--dry-run: file preview blocks (JSON/text)--json:{ success, command, project_id, output, dryRun }
schema:push:- default: per-collection lines +
pushed/skippedsummary --json:{ success, pushed, skipped, results[] }
- default: per-collection lines +
schema:list:- default: one
collection_idper line + total --json:{ success, total, collections[] }
- default: one
schema:diffmarkers:= same~ changed+ local-only- remote-only--json:{ success, summary, results[] }
schema:types:convert:- default: conversion summary + output path
--dry-run: generated JSON preview--json:{ success, dryRun, output, collections_count, warnings[] }
Functions
function:pull/function:sync:- default: file write summary
--dry-run: context/source/manifest preview blocks--json:{ success, command, project_id, output, dryRun }
function:push:- default: per-function lines +
pushed/skippedsummary --dry-run: would-push + manifest preview--json:{ success, pushed, skipped, results[] }
- default: per-function lines +
function:list:- default: one function name per line + total
--json:{ success, total, functions[] }
function:logs:- default:
timestamp status messagelines + shown count --json: raw log rows JSON
- default:
function:diffmarkers:= same~ changed+ local-missing- remote-missing! remote-drift--json:{ success, summary, results[] }
function:revisions:- default: one line per revision with
- live marker (
[live]) revision+revision_id- short checksum (
source_checksumfirst 12 chars) createdAt- alias mapping (
aliases=...)
- live marker (
--json: array entries with keys:revisionrevision_idchecksumcreatedAtlivealiases
- default: one line per revision with
function:publish:- default: confirmation + live revision + aliases object
[revision]omitted => auto uses latest revision--json:{ success, function, publishedRevision, alias, live_revision_id, aliases }
function:alias:set:- default: confirmation line with alias target
--json:{ success, function, alias, revision, aliases }
function:invoke:- object/array response: pretty JSON
- text response: plain text
--raw: raw response output
Data
data:list: pretty JSON response.data:get: pretty JSON response.data:create: pretty JSON response.data:update: pretty JSON response.data:delete: pretty JSON response.data:export: writes JSON file + summary line.--json:{ success, collection_id, project_id, count, output }
data:import:- default: summary (
created,updated) --dry-run: simulated summary lines--json: structured import result (success,collection_id,project_id,mode,batch,dryRun,created,updated,match?)
- default: summary (
Revision/Alias Definition (Important)
- Function revision is system-managed and immutable (
r1,r2, ...). - You cannot set custom revision id (for example git hash) as revision.
- If you need git-traceable deployment labels, use alias names as git hash values.
- Example:
function:alias:set process-order a1b2c3d4 r42function:revisions process-order(to inspect mapping + checksum)
Development
Project Structure
src/
├── commands/ # CLI commands
│ ├── auth/ # Authentication commands
│ ├── config/ # Configuration commands
│ ├── projects/ # Project management commands
│ └── sync.ts # Schema synchronization
├── services/ # Business logic services
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
├── config/ # Configuration management
└── index.ts # Main entry pointAvailable Scripts
yarn build # Build the project
yarn dev # Run in development mode
yarn start # Run built version
yarn test # Run tests
yarn lint # Run linter
yarn format # Format codeBuilding
yarn buildDevelopment Mode
yarn devExamples
CI/CD Pipeline
# Set environment variables
export BUILDX_API_ENDPOINT=https://api.example.com
export BUILDX_API_KEY=$CI_API_KEY
export BUILDX_PROJECT_ID=$CI_PROJECT_ID
# Run schema pull
npx buildx-cli schema:pull --project-id $BUILDX_PROJECT_ID --output ./src/types/api.tsLocal Development
# Setup once
npx buildx-cli config:setup
# Use regularly
npx buildx-cli projects:list
npx buildx-cli schema:pull --project-id my-project
npx buildx-cli function:pull --project-id my-projectMonorepo Local Shortcuts (No Publish)
From monorepo root:
yarn cli:build
yarn cli --helpIsolated test output:
yarn cli -- schema:pull --project-id my-project --target-dir ./.sandbox/buildx-cli
yarn cli -- function:pull --project-id my-project --target-dir ./.sandbox/buildx-cliContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
License
MIT License - see LICENSE file for details.
