Claude Code Skill
Presage ships a Claude Code skill that gives your AI assistant full knowledge of the library — rules, tracking, maturity, adapters. Install it and Claude will scaffold adaptive components, write rules, and wire tracking for you.
Automatic Setup (Recommended)
Section titled “Automatic Setup (Recommended)”Run a single command in your React or Vue project:
npx @presage-kit/cliThis will:
- Detect your framework (React or Vue) and package manager
- Install
@presage-kit/coreand the right adapter - Create the
.claude/skills/presage.mdskill file - Add Presage context to your
CLAUDE.md
That’s it — the /presage skill is ready to use.
Manual Setup
Section titled “Manual Setup”If you prefer to install the skill manually, create a file at .claude/skills/presage.md in your project root:
mkdir -p .claude/skillsThen paste the following content:
---name: presagedescription: Scaffold adaptive UIs with Presage — rules, tracking, maturity, React/Vue adapters---
# Presage Skill
You are an expert in the Presage adaptive UI library (@presage-kit/core, @presage-kit/react, @presage-kit/vue).
## Architecture
Presage adapts UI based on three pillars:1. **UserTraits** — static properties (role, plan, company, signupDate, custom)2. **BehavioralSignals** — auto-computed from tracked events (sessionCount, totalEvents, featureUsage, clickMap, daysSinceSignup)3. **Maturity** — auto-segmented: `'new' | 'onboarding' | 'active' | 'power' | 'dormant'`
Flow: Track Event → Recompute Signals → Evaluate Rules → Render Matching Variant
## Rules Engine
Rules are declarative JSON. Each rule targets an `adaptationId`, has a `priority` (highest wins), `conditions`, and an `action`.
```tsinterface AdaptationRule { id: string adaptationId: string priority: number conditions: ConditionGroup // { all: [...] } | { any: [...] } | { not: ... } action: AdaptationAction}```
### Condition Fields
Access user context via dot notation:- `traits.role`, `traits.plan`, `traits.company`, `traits.custom.<key>`- `signals.sessionCount`, `signals.totalEvents`, `signals.daysSinceSignup`- `signals.featureUsage.<featureId>`, `signals.clickMap.<elementId>`- `maturity` (direct, no prefix)
### 14 Operators
`eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `between`, `in`, `notIn`, `contains`, `notContains`, `exists`, `notExists`, `matches` (regex)
### Actions
- `{ type: 'show', variantId: string }` — select a variant- `{ type: 'hide' }` — hide the adaptation point- `{ type: 'reorder', order: string[] }` — reorder navigation items- `{ type: 'modify', props: Record<string, unknown> }` — pass custom props
### Boolean Logic
Nest `all` (AND), `any` (OR), `not` (negate):
```tsconditions: { all: [ { field: 'traits.plan', operator: 'eq', value: 'enterprise' }, { any: [ { field: 'maturity', operator: 'eq', value: 'active' }, { field: 'maturity', operator: 'eq', value: 'power' }, ]}, ],}```
## Client Setup
```tsimport { createAdaptiveClient, createLocalStorageDriver } from '@presage-kit/core'
const client = createAdaptiveClient({ rules: [ /* AdaptationRule[] */ ], persistence: { driver: createLocalStorageDriver('my-app') }, // Optional: maturity thresholds maturity: { newMaxSessions: 3, onboardingMaxSessions: 10, powerMinFeatures: 5, dormantDaysInactive: 14, },})```
## React Adapter
```tsximport { AdaptiveProvider, Adaptive, Variant } from '@presage-kit/react'
// Wrap app<AdaptiveProvider client={client}> <App /></AdaptiveProvider>
// Declarative component<Adaptive id="onboarding" defaultVariant="standard"> <Variant id="guided-tour"><GuidedTour /></Variant> <Variant id="standard"><StandardWelcome /></Variant></Adaptive>
// Hook (type-safe)const { selectedVariant, track } = useAdaptive('dashboard', { variants: ['simple', 'advanced'] as const, defaultVariant: 'simple',})
// Lightweight hook (variant string only)const variant = useVariant('dashboard', { variants: ['simple', 'advanced'] as const, defaultVariant: 'simple',})```
## Vue Adapter
```tsimport { AdaptivePlugin } from '@presage-kit/vue'app.use(AdaptivePlugin, { client })
// In setup()const { selectedVariant, track } = useAdaptive('dashboard', { variants: ['simple', 'advanced'] as const, defaultVariant: 'simple',})```
## Tracking
```tsclient.identify('user-123', { role: 'admin', plan: 'pro', signupDate: '2025-01-15' })client.track('feature_used', { featureId: 'export' })client.track('click', { elementId: 'settings-btn' })```
## Guidelines
- Keep rules declarative — never put adaptation logic in components- Use `priority` to handle rule conflicts (highest wins, first match)- One `adaptationId` per UI decision point- Track meaningful events only — avoid tracking every click- Use maturity for coarse segmentation, rules for fine-grained control- Functions and components should be under 40 linesOnce the skill is in place, invoke it in Claude Code:
/presageThen ask Claude to scaffold adaptive components:
/presage Add an adaptive pricing page that shows different CTAsbased on the user's plan and session count.Claude will generate the rules, the React/Vue component, and the tracking calls — following Presage conventions.
What the Skill Covers
Section titled “What the Skill Covers”| Capability | Details |
|---|---|
| Rules authoring | All 14 operators, boolean logic, priority handling |
| React components | Adaptive, Variant, AdaptiveNav, useAdaptive, useVariant |
| Vue composables | useAdaptive, useVariant, AdaptivePlugin |
| Tracking | identify, track, custom adapter pattern |
| Maturity | Auto-segmentation thresholds and overrides |
| Client setup | Persistence drivers, config options |
Next Steps
Section titled “Next Steps”- Quick Start — Build your first adaptive component
- Rules Engine — Deep dive into all operators
- React Adapter — Full component and hook reference