pillar-best-practices

Best practices for integrating the Pillar SDK and CLI into web applications. Use when adding an AI assistant panel, setting up Pillar with the CLI, syncing tools, managing knowledge sources, or designing tool workflows.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "pillar-best-practices" with this command: npx skills add pillarhq/pillar-skills/pillarhq-pillar-skills-pillar-best-practices

Pillar SDK & CLI Best Practices

Best practices for integrating the Pillar SDK and CLI into web applications. Covers project setup with the CLI, tool syncing, knowledge source management, and SDK integration patterns.

When to Apply

Reference these guidelines when:

  • Setting up Pillar in a new project (pillar init)
  • Syncing tools to the Pillar backend (pillar sync)
  • Managing knowledge sources (pillar knowledge)
  • Diagnosing integration issues (pillar doctor)
  • Adding Pillar SDK to a React or Next.js project
  • Setting up PillarProvider in your app
  • Defining tools for the AI assistant to discover and call
  • Creating tool handlers to execute user requests
  • Designing multi-tool workflows for agentic operations

Essential Rules

CLI

PriorityRuleDescription
CRITICALcli-setupUse pillar init to scaffold a project — handles framework detection, SDK install, credentials, and first sync
HIGHcli-syncUse pillar sync --scan to push tool definitions; use --watch in development and CI for deploys
HIGHcli-knowledgeUse pillar knowledge to manage docs and help content the copilot uses to answer questions

SDK

PriorityRuleDescription
CRITICALsetup-providerAlways wrap your app with PillarProvider
CRITICALsetup-nextjsNext.js App Router requires a 'use client' wrapper
CRITICALschema-compatibilityinputSchema must follow cross-model formatting rules (arrays need items, no type unions)
HIGHtool-descriptionsWrite specific, AI-matchable descriptions and keep tools focused
HIGHtool-return-valuesReturn flat data from execute -- never { success: true } without the actual data
HIGHtool-handlersUse centralized handlers with proper cleanup
HIGHguidance-fieldUse the guidance field for agent-facing disambiguation and prerequisites
HIGHworkflow-patternsDesign multi-tool workflows using the distributed guidance pattern
HIGHtool-overlap-auditAudit existing tools for overlap before creating new ones
HIGHcodebase-verificationVerify API shapes against the actual codebase -- never guess
HIGHform-queue-patternFor form-opening tools, defer completion until user submits; queue multiple forms for sequential execution

Quick Reference — CLI

1. Project Setup (CRITICAL)

Install and initialize Pillar in one command:

npx pillar-cli init

This detects your framework, installs the SDK, generates a provider wrapper and starter tools, creates credentials, syncs tools, and sets up knowledge sources. See rules/cli-setup.md.

If you already have a product key:

npx pillar-cli init --product-key your-slug

2. Tool Syncing (HIGH)

Push tool definitions to the backend:

pillar sync --scan ./src          # one-time sync
pillar sync --scan ./src --watch  # re-sync on file changes
pillar sync status --scan ./src   # compare local vs remote

In CI/CD:

npx pillar-cli sync --scan ./src

Set PILLAR_SLUG and PILLAR_SECRET as environment variables. See rules/cli-sync.md.

3. Knowledge Sources (HIGH)

Add docs and help content the copilot uses to answer questions:

pillar knowledge add https://docs.myapp.com
pillar knowledge list
pillar knowledge status
pillar knowledge sync <source-id>
pillar knowledge remove <source-id>

See rules/cli-knowledge.md.

4. Diagnostics

Verify the integration is healthy:

pillar doctor

Checks product key, sync secret, SDK version, tool sync status, knowledge sources, and embed config reachability.

5. Testing

Test the copilot without starting your app:

pillar chat "how do I export data?"   # single question
pillar chat                            # interactive session

6. Authentication

pillar auth login     # opens browser to authenticate
pillar auth status    # check current session
pillar auth logout    # clear credentials

Credentials are stored in ~/.pillar/config.json.

Quick Reference — SDK

7. Provider Setup (CRITICAL)

Always wrap your app with PillarProvider:

import { PillarProvider } from '@pillar-ai/react';

<PillarProvider productKey="your-product-key">
  {children}
</PillarProvider>

8. Next.js App Router (CRITICAL)

Create a client wrapper component:

// providers/PillarSDKProvider.tsx
'use client';

import { PillarProvider } from '@pillar-ai/react';

export function PillarSDKProvider({ children }: { children: React.ReactNode }) {
  return (
    <PillarProvider productKey={process.env.NEXT_PUBLIC_PILLAR_PRODUCT_KEY!}>
      {children}
    </PillarProvider>
  );
}

9. Tool Descriptions (HIGH)

Write specific descriptions the AI can match:

// Good - specific and includes context
description: 'Navigate to billing settings. Suggest when user asks about payments, invoices, or subscription.'

// Bad - too generic
description: 'Go to billing'

10. Tool Registration (HIGH)

In React components, use the usePillarTool hook — it auto-registers on mount and cleans up on unmount:

import { usePillarTool } from '@pillar-ai/react';

usePillarTool({
  name: 'create_dashboard',
  description: 'Create a new empty dashboard.',
  guidance: 'First step in dashboard workflow. Returns dashboard_uid needed by create_*_panel tools.',
  type: 'trigger_tool',
  autoRun: true,
  inputSchema: { type: 'object', properties: { title: { type: 'string' } }, required: ['title'] },
  execute: async (data) => {
    const result = await api.createDashboard(data.title);
    return { uid: result.uid };
  },
});

Outside React (or for imperative registration), use pillar.defineTool() with the same schema shape. It returns an unsubscribe function for cleanup.

Sync tools after defining them: pillar sync --scan ./src

11. Guidance Field (HIGH)

Use guidance for agent-facing instructions that help the LLM choose and chain tools:

get_available_datasources: {
  description: 'Get datasources available for creating visualizations.',
  guidance: 'Call BEFORE creating dashboards or panels. If zero results, ask user to create one.',
}

12. Audit for Overlap (HIGH)

Before creating a new tool, search existing tools for semantic overlap:

// Found existing: save_dashboard handles "create a dashboard"
// Don't create a second create_dashboard -- extend or disambiguate instead

13. Decompose Large Tools (HIGH)

Prefer smaller tools with tight schemas over one large tool with many modes:

// Instead of one "manage_user" with an operation enum,
// split into focused tools:
invite_user: { description: 'Invite a new user by email', type: 'trigger_tool' }
remove_user: { description: 'Remove a user from the org', type: 'trigger_tool' }
change_user_role: { description: 'Change a user role', type: 'trigger_tool' }

How to Use

Read individual rule files for detailed explanations and code examples:

rules/cli-setup.md
rules/cli-sync.md
rules/cli-knowledge.md
rules/setup-provider.md
rules/setup-nextjs.md
rules/tool-descriptions.md
rules/tool-handlers.md
rules/schema-compatibility.md
rules/guidance-field.md
rules/workflow-patterns.md
rules/tool-overlap-audit.md
rules/codebase-verification.md
rules/form-queue-pattern.md

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

webmcp

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

openclaw-version-monitor

监控 OpenClaw GitHub 版本更新,获取最新版本发布说明,翻译成中文, 并推送到 Telegram 和 Feishu。用于:(1) 定时检查版本更新 (2) 推送版本更新通知 (3) 生成中文版发布说明

Archived SourceRecently Updated
Coding

ask-claude

Delegate a task to Claude Code CLI and immediately report the result back in chat. Supports persistent sessions with full context memory. Safe execution: no data exfiltration, no external calls, file operations confined to workspace. Use when the user asks to run Claude, delegate a coding task, continue a previous Claude session, or any task benefiting from Claude Code's tools (file editing, code analysis, bash, etc.).

Archived SourceRecently Updated
Coding

ai-dating

This skill enables dating and matchmaking workflows. Use it when a user asks to make friends, find a partner, run matchmaking, or provide dating preferences/profile updates. The skill should execute `dating-cli` commands to complete profile setup, task creation/update, match checking, contact reveal, and review.

Archived SourceRecently Updated