Syncing Tools
The Pillar CLI scans your codebase for usePillarTool, injectPillarTool, and defineTool calls, then syncs them to Pillar's backend. This enables the AI to discover and suggest tools to users.
The scanner uses AST parsing — no barrel file needed. See Setting Up Tools for how to define tools.
Prerequisites
Before syncing, you need:
- A Project Slug — Your unique identifier (e.g.,
acme-corp) - A Secret Token — For authenticating sync requests
Get both from the Pillar admin dashboard: Tools → Configure Sync
Quick Start
# Set your credentialsexport PILLAR_SLUG="your-agent-slug"export PILLAR_SECRET="your-secret-token"# Scan and sync your actionsnpx pillar-cli sync --scan ./src
Watch mode re-syncs automatically when you save a file:
npx pillar-cli sync --scan ./src --watch
Compare local tools against what's deployed:
npx pillar-cli sync status --scan ./src
See the CLI Reference for all sync options.
Environment Variables
Required
| Variable | Description |
|---|---|
PILLAR_SLUG | Your project slug (e.g., acme-corp) |
PILLAR_SECRET | Secret token for authentication |
Optional
| Variable | Default | Description |
|---|---|---|
PILLAR_API_URL | https://help-api.trypillar.com | API URL (override for custom deployments) |
PILLAR_PLATFORM | web | Platform: web, ios, android, desktop |
PILLAR_VERSION | From package.json | App version (semver or git SHA) |
GIT_SHA | Auto-detected | Git commit SHA for traceability |
CLI Arguments
| Argument | Description |
|---|---|
--scan <dir> | Directory to scan for tools (default: ./src) |
--watch | Re-sync on file changes |
--force | Sync even if manifest is unchanged |
--local | Use localhost:8003 as the API URL |
--help | Show help message |
Local Development
Use the --local flag to sync against a local Pillar backend:
# Sync against local Pillar backend (localhost:8003)PILLAR_SLUG=my-app PILLAR_SECRET=dev-secret \npx pillar-cli sync --scan ./src --local
CI/CD Integration
GitHub Actions
# .github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Sync Pillar actions
env:
PILLAR_SLUG: ${{ secrets.PILLAR_SLUG }}
PILLAR_SECRET: ${{ secrets.PILLAR_SECRET }}
GIT_SHA: ${{ github.sha }}
run: npx pillar-cli sync --scan ./src
- name: Deploy
run: npm run deploy
Store PILLAR_SLUG and PILLAR_SECRET as GitHub repository secrets.
GitLab CI
# .gitlab-ci.yml
stages:
- build
- sync
- deploy
build:
stage: build
script:
- npm ci
- npm run build
sync-pillar:
stage: sync
script:
- npx pillar-cli sync --scan ./src
variables:
PILLAR_SLUG: $PILLAR_SLUG
PILLAR_SECRET: $PILLAR_SECRET
GIT_SHA: $CI_COMMIT_SHA
deploy:
stage: deploy
script:
- npm run deploy
Generic CI
#!/bin/bashset -e# Build your appnpm cinpm run build# Sync actions to Pillarexport PILLAR_SLUG="${PILLAR_SLUG}"export PILLAR_SECRET="${PILLAR_SECRET}"export GIT_SHA="${CI_COMMIT_SHA:-$(git rev-parse HEAD)}"npx pillar-cli sync --scan ./src# Deploy your appnpm run deploy
How Sync Works
- Scan — The CLI uses TypeScript's compiler API to find
usePillarTool,injectPillarTool, anddefineToolcalls - Extract — Tool metadata (name, description, type, inputSchema, etc.) is extracted from the AST
- Build Manifest — Creates a versioned manifest with platform info
- Upload — Sends the manifest to Pillar's API
- Process — Backend processes tools asynchronously (creates, updates, deletes)
- Complete — CLI polls for completion and reports results
What Gets Synced
The scanner extracts these fields from your tool definitions:
name— Tool identifierdescription— Used for AI matchingtype— Tool type (navigate, trigger_tool, query, etc.)inputSchema— For data extraction from user queriesexamples— Example phrases that trigger the toolautoRun— Whether to auto-execute without confirmationautoComplete— Whether the tool completes immediately
The execute function stays in your code — only metadata is synced.
Response Statuses
| Status | Description |
|---|---|
unchanged | Manifest matches existing deployment (no-op) |
accepted | Job queued for processing |
created | Deployment created (synchronous mode) |
Debugging
Enable debug mode to write the manifest to disk:
# Enable debug mode to write manifest to diskPILLAR_DEBUG=1 PILLAR_SLUG=my-app PILLAR_SECRET=xxx \npx pillar-cli sync --scan ./src# Check the generated manifestcat actions-manifest.json
This creates actions-manifest.json in your project root.
Version Tracking
Each sync creates a versioned deployment. The CLI tracks:
- Version — From
PILLAR_VERSIONorpackage.json - Git SHA — From
GIT_SHAor auto-detected from git - Platform — From
PILLAR_PLATFORM - Timestamp — When the sync occurred
This enables rollback and audit tracking in the Pillar dashboard.
Best Practices
Sync on Deploy
Always sync tools as part of your deployment pipeline to keep tools in sync with your app:
#!/bin/bash# deploy.sh - Run as part of your deployment# Build the appnpm run build# Sync actions before deployingnpx pillar-cli sync --scan ./src# Deploy (e.g., to Vercel, AWS, etc.)vercel deploy --prod
Use Environment-Specific Slugs
For staging/production environments, use different project slugs:
# Staging environmentPILLAR_SLUG=myapp-staging PILLAR_SECRET=$STAGING_SECRET \npx pillar-cli sync --scan ./src# Production environmentPILLAR_SLUG=myapp-production PILLAR_SECRET=$PROD_SECRET \npx pillar-cli sync --scan ./src
Organize Tools by Feature
Group related tools in dedicated files for better organization:
src/
hooks/ # React / Vue composables
usePillarTools.ts
useNavigationTools.ts
useAdminTools.ts
tools/ # Angular components or Vanilla JS modules
pillar-tools.component.ts
navigation-tools.component.ts
admin-tools.component.ts
Migrating from pillar-sync
If you're using the older npx pillar-sync command from @pillar-ai/sdk, replace it with:
npx pillar-cli sync --scan ./src
The old command continues to work but won't receive new features. The CLI adds watch mode, status comparison, force sync, and config file support.
Next Steps
- Learn how to define tools with
usePillarTool/injectPillarTool - Set up context to enable tool filtering
- See the full CLI Reference for all commands
- View sync history in the Pillar admin dashboard