Claude Code skill pack for Hex (18 skills)
Installation
Open Claude Code and run this command:
/plugin install hex-pack@claude-code-plugins-plus
Use --global to install for all projects, or --project for current project only.
What It Does
Gives Claude Code deep knowledge of Hex's public API for triggering notebook project runs, polling status, managing users, and building data pipelines. Skills cover API token authentication, project orchestration with Airflow/Dagster, scheduled runs, and the Admin API for workspace management.
Skills (18)
'Configure Hex CI/CD integration with GitHub Actions and testing.
Hex CI Integration
Overview
Set up CI/CD for Hex data analytics integrations: run unit tests with mocked project run and connection responses on every PR, trigger live Hex project runs and validate outputs on merge to main. Hex provides collaborative data notebooks with scheduled runs and API-triggered execution, so CI pipelines verify data transform logic, trigger post-deploy dashboard refreshes, and monitor run status.
GitHub Actions Workflow
# .github/workflows/hex-ci.yml
name: Hex CI
on:
pull_request:
paths: ['src/hex/**', 'tests/**']
push:
branches: [main]
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '20' }
- run: npm ci
- run: npm test -- --reporter=verbose
trigger-hex-refresh:
if: github.ref == 'refs/heads/main'
needs: unit-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '20' }
- run: npm ci
- run: npm run test:integration
env:
HEX_API_TOKEN: ${{ secrets.HEX_API_TOKEN }}
HEX_PROJECT_ID: ${{ vars.HEX_PROJECT_ID }}
Mock-Based Unit Tests
// tests/hex-service.test.ts
import { describe, it, expect, vi } from 'vitest';
import { triggerProjectRun, getRunStatus } from '../src/hex-service';
vi.mock('../src/hex-client', () => ({
HexClient: vi.fn().mockImplementation(() => ({
runProject: vi.fn().mockResolvedValue({
runId: 'run_abc123',
projectId: 'proj_xyz',
status: 'running',
startedAt: '2026-04-01T10:00:00Z',
}),
getRunStatus: vi.fn().mockResolvedValue({
runId: 'run_abc123',
status: 'completed',
elapsedMs: 4500,
outputs: { row_count: 1250, last_updated: '2026-04-01T10:00:04Z' },
}),
listProjects: vi.fn().mockResolvedValue({
projects: [{ id: 'proj_xyz', title: 'Revenue Dashboard' }],
}),
})),
}));
describe('Hex Service', () => {
it('triggers a project run and returns run ID', async () => {
const result = await triggerProjectRun('proj_xyz', { triggered_by: 'ci' });
expect(result.runId).toBe('run_abc123');
expect(result.status).toBe('running');
});
it('polls run status until complete', async () => {
const status = await getRunStatus('run_abc123');
expect(status.status).toBe('completed');
expect(status.outputs.row_count).toBe(1250);
});
});
Integration Tests
// tests/integration/hex.integration.test.ts
import { describe, it, expect } from 'vitest';
const 'Diagnose and fix Hex common errors and exceptions.
Hex Common Errors
Error Reference
401 Unauthorized
Cause: Token invalid, expired, or missing.
Fix: Regenerate token in Hex workspace settings.
403 Forbidden — Read-Only Token
Cause: Token has "Read projects" scope but RunProject requires "Run projects".
Fix: Create new token with "Run projects" scope.
404 Not Found — Project
Cause: Project ID wrong or project not published.
Fix: Verify project ID. Only published projects can be run via API.
429 Too Many Requests
Cause: RunProject is limited to 20 requests/min, 60/hr.
Fix: Queue runs with delays. See hex-rate-limits.
Run Status: ERRORED
Cause: SQL query, Python code, or connection error in the project.
Fix: Open the project in Hex UI and check the error in the run history.
Run Status: KILLED
Cause: Run exceeded timeout or was manually cancelled.
Fix: Optimize slow queries. Increase timeout in API trigger.
Quick Diagnostics
# Test token
curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer $HEX_API_TOKEN" \
https://app.hex.tech/api/v1/projects
# List recent runs for a project
curl -s -H "Authorization: Bearer $HEX_API_TOKEN" \
https://app.hex.tech/api/v1/project/PROJECT_ID/runs | python3 -m json.tool
Resources
Next Steps
For debugging, see hex-debug-bundle.
'Execute Hex primary workflow: Core Workflow A.
Hex Project Orchestration
Overview
Trigger Hex project runs from external orchestration tools (Airflow, Dagster, cron) with input parameters, status polling, and error handling. This is the primary integration pattern for embedding Hex in data pipelines.
Instructions
Step 1: Parameterized Project Runs
import 'dotenv/config';
const TOKEN = process.env.HEX_API_TOKEN!;
const BASE = 'https://app.hex.tech/api/v1';
interface RunConfig {
projectId: string;
inputParams?: Record<string, any>;
updateCache?: boolean;
killRunning?: boolean;
}
async function triggerRun(config: RunConfig) {
const response = await fetch(`${BASE}/project/${config.projectId}/run`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
inputParams: config.inputParams || {},
updateCacheResult: config.updateCache ?? true,
killRunningExecution: config.killRunning ?? false,
}),
});
if (!response.ok) throw new Error(`Trigger failed: ${response.status} ${await response.text()}`);
return response.json();
}
Step 2: Synchronous Run Helper
async function runAndWait(config: RunConfig, timeoutMs = 600000): Promise<any> {
const { runId, projectId } = await triggerRun(config);
const startTime = Date.now();
while (Date.now() - startTime < timeoutMs) {
const res = await fetch(`${BASE}/project/${projectId}/run/${runId}`, {
headers: { 'Authorization': `Bearer ${TOKEN}` },
});
const status = await res.json();
switch (status.status) {
case 'COMPLETED': return { success: true, runId, duration: Date.now() - startTime };
case 'ERRORED': throw new Error(`Run ${runId} errored: ${status.statusMessage || 'unknown'}`);
case 'KILLED': throw new Error(`Run ${runId} was killed`);
default: await new Promise(r => setTimeout(r, 5000));
}
}
throw new Error(`Run ${runId} timed out after ${timeoutMs}ms`);
}
Step 3: Pipeline Orchestration
// Run multiple Hex projects in sequence (data pipeline)
async function runPipeline(steps: RunConfig[]) {
const results = [];
for (const step of steps) {
console.log(`Running: ${step.projectId}`);
const result = await runAndWait(step);
console.log(`Completed in ${result.duration}ms`);
results.push(result);
}
return results;
}
// Example: ETL pipeline
await runPipeline([
{ projectId: 'extract-project-id', inputParams: { date: '2025-01-01' } },
{ projectId: 'transform-project-id' },
{ projectId: 'load-project-id', updateCache: true },
]);
Step 4: Cancel Long-Running Projects
async function c'Execute Hex secondary workflow: Core Workflow B.
Hex Scheduled Runs & Admin API
Overview
Configure scheduled runs and manage workspace resources via the Hex Admin API. Scheduled runs execute projects on cron-based intervals. The Admin API manages users, groups, and data connections.
Instructions
Step 1: List Project Runs
const TOKEN = process.env.HEX_API_TOKEN!;
const BASE = 'https://app.hex.tech/api/v1';
async function getProjectRuns(projectId: string) {
const response = await fetch(`${BASE}/project/${projectId}/runs`, {
headers: { 'Authorization': `Bearer ${TOKEN}` },
});
const runs = await response.json();
for (const run of runs) {
console.log(`${run.runId}: ${run.status} (${run.startTime} → ${run.endTime || 'running'})`);
}
return runs;
}
Step 2: Scheduled Runs (via Hex UI + API Trigger)
Schedules are configured in the Hex UI. For API-based scheduling, use external cron:
// cron-trigger.ts — run via cron job or CI
import cron from 'node-cron';
// Daily at 6 AM UTC
cron.schedule('0 6 * * *', async () => {
console.log('Triggering daily report...');
await triggerRun({
projectId: 'daily-report-project-id',
inputParams: { date: new Date().toISOString().split('T')[0] },
updateCache: true,
});
});
// Weekly on Monday at 9 AM
cron.schedule('0 9 * * 1', async () => {
await triggerRun({ projectId: 'weekly-summary-project-id' });
});
Step 3: User Management (Admin API)
// List workspace users
async function listUsers() {
const response = await fetch(`${BASE}/workspace/users`, {
headers: { 'Authorization': `Bearer ${TOKEN}` },
});
return response.json();
}
// List groups
async function listGroups() {
const response = await fetch(`${BASE}/workspace/groups`, {
headers: { 'Authorization': `Bearer ${TOKEN}` },
});
return response.json();
}
Step 4: Data Connection Management
// List configured data connections
async function listConnections() {
const response = await fetch(`${BASE}/workspace/connections`, {
headers: { 'Authorization': `Bearer ${TOKEN}` },
});
return response.json();
}
Scheduling Options
| Method | Intervals | Plan Required |
|---|---|---|
| Hex UI | Hourly, daily, weekly, monthly | Team+ |
| Hex UI (cron) | Any cron expression | Team+ |
| API trigger + external cron | Any schedule | Team+ |
| Airflow/Dagster integration | Any schedule | Team+ |
Resources
'Optimize Hex costs through tier selection, sampling, and usage monitoring.
Hex Cost Tuning
Overview
Hex pricing combines per-seat licensing with compute-based charges for notebook runs and data connections. Each scheduled or ad-hoc notebook execution consumes compute credits proportional to query complexity and data volume processed. Organizations running dozens of notebooks on hourly schedules — many producing identical results from unchanged data — accumulate unnecessary compute costs. Caching run results, optimizing schedules, and consolidating redundant notebooks are the highest-leverage cost reduction strategies.
Cost Breakdown
| Component | Cost Driver | Optimization |
|---|---|---|
| Seat licenses | Per-user/month (Team: $28/user) | Audit active editors quarterly; move viewers to free tier |
| Notebook runs | Compute per scheduled or manual execution | Cache results for unchanged data; extend run intervals |
| Data connections | Active warehouse/database connections | Consolidate overlapping connections; remove unused ones |
| Scheduled runs | Cron-triggered executions across all projects | Audit schedules — reduce frequency for stable data |
| API calls | Admin and Run API requests | Batch API operations; use cached results endpoint |
API Call Reduction
class HexRunOptimizer {
private resultCache = new Map<string, { data: any; timestamp: number }>();
private dataHashes = new Map<string, string>();
async runIfChanged(projectId: string, runFn: () => Promise<any>): Promise<any> {
const currentHash = await this.getSourceDataHash(projectId);
if (this.dataHashes.get(projectId) === currentHash) {
const cached = this.resultCache.get(projectId);
if (cached) return cached.data; // Source unchanged — serve cached result
}
const result = await runFn();
this.resultCache.set(projectId, { data: result, timestamp: Date.now() });
this.dataHashes.set(projectId, currentHash);
return result;
}
private async getSourceDataHash(projectId: string): Promise<string> {
const res = await fetch(`/api/v1/project/${projectId}/status`);
return (await res.json()).sourceDataHash;
}
}
Usage Monitoring
class HexCostMonitor {
private runs = new Map<string, number[]>();
private weeklyBudget = 500; // max runs per week
recordRun(projectId: string): void {
const timestamps = this.runs.get(projectId) || [];
timestamps.push(Date.now());
this.runs.set(projectId, timestamps);
}
getWeeklyReport(): { totalRuns: number; byProject: Record<string, number> } {
const weekAgo = Date.now() - 7 * 24 * 60 * 60 * 1000;
const byProject: Record<string, number> = {};
let total = 0;
'Collect Hex debug evidence for support tickets and troubleshooting.
Hex Debug Bundle
Overview
Collect Hex API connectivity status, project listing, run history, data connection health, and rate limit state into a single diagnostic archive. This bundle helps troubleshoot failed notebook runs, stale data connections, scheduled run failures, and API authentication issues.
Debug Collection Script
#!/bin/bash
set -euo pipefail
BUNDLE="debug-hex-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BUNDLE"
# Environment check
echo "=== Hex Debug Bundle ===" | tee "$BUNDLE/summary.txt"
echo "Generated: $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$BUNDLE/summary.txt"
echo "HEX_API_KEY: ${HEX_API_KEY:+[SET]}" >> "$BUNDLE/summary.txt"
# API connectivity
HTTP=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer ${HEX_API_KEY}" \
https://app.hex.tech/api/v1/projects 2>/dev/null || echo "000")
echo "API Status: HTTP $HTTP" >> "$BUNDLE/summary.txt"
# Project listing
curl -s -H "Authorization: Bearer ${HEX_API_KEY}" \
"https://app.hex.tech/api/v1/projects" \
> "$BUNDLE/projects.json" 2>&1 || true
# Recent runs (across projects)
curl -s -H "Authorization: Bearer ${HEX_API_KEY}" \
"https://app.hex.tech/api/v1/runs?limit=10" \
> "$BUNDLE/recent-runs.json" 2>&1 || true
# Data connections and rate limit headers
curl -s -D "$BUNDLE/rate-headers.txt" -H "Authorization: Bearer ${HEX_API_KEY}" \
"https://app.hex.tech/api/v1/connections" > "$BUNDLE/connections.json" 2>&1 || true
tar -czf "$BUNDLE.tar.gz" "$BUNDLE" && rm -rf "$BUNDLE"
echo "Bundle: $BUNDLE.tar.gz"
Analyzing the Bundle
tar -xzf debug-hex-*.tar.gz
cat debug-hex-*/summary.txt # Auth + connectivity
jq '.[] | {id, title, status}' debug-hex-*/projects.json # Project inventory
jq '.[] | {id, status, started_at}' debug-hex-*/recent-runs.json # Run history
jq '.[] | {name, type, status}' debug-hex-*/connections.json # Data source health
Common Issues
| Symptom | Check in Bundle | Fix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| API returns 401 | summary.txt shows HTTP 401 |
Regenerate API token in Hex workspace Settings > API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Run stuck in pending | recent-runs.json shows pending status for >5 min |
Check compute quota; cancel and re-trigger the run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Data connection failed | connections.json shows error on a source |
Re-authenticate the connection; verify DB credentials haven't expired | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Scheduled run
'Deploy Hex integrations to Vercel, Fly.
ReadWriteEditBash(vercel:*)Bash(fly:*)Bash(gcloud:*)
Hex Deploy IntegrationOverviewDeploy Hex orchestration services that trigger project runs from web endpoints or cron jobs. InstructionsVercel — On-Demand Data Refresh
Cloud Run — Scheduled Orchestrator
Resources'Create a minimal working Hex example.
ReadWriteEditBash(npm:*)Bash(curl:*)
Hex Hello WorldOverviewList projects, trigger a project run, and poll for results using the Hex API. The core workflow is: trigger a run of a published project, poll for completion, then access the results. Prerequisites
InstructionsStep 1: List Projects
Step 2: Trigger a Project Run
Step 3: Poll for Run Completion
Step 4: Complete Flow
Step 5: curl Quick Test'Install and configure Hex SDK/CLI authentication.
ReadWriteEditBash(npm:*)Bash(curl:*)Grep
Hex Install & AuthOverviewConfigure Hex API authentication using OAuth 2.0 Bearer tokens. The Hex API at Prerequisites
InstructionsStep 1: Generate API Token
Step 2: Configure Environment
Step 3: Verify Connection
Token Scopes
Error Handling
ResourcesNext StepsAfter auth, 'Configure Hex local development with hot reload and testing.
ReadWriteEditBash(npm:*)Bash(pnpm:*)Grep
Hex Local Dev LoopOverviewSet up a development workflow for Hex API orchestration with mocked API responses and testing. InstructionsStep 1: Project Structure
Step 2: Typed Hex Client
Step 3: Mocked Tests'Optimize Hex API performance with caching, batching, and connection.
ReadWriteEdit
Hex Performance TuningLatency Benchmarks
InstructionsCache Project Lists
Parallel Independent Runs
Optimize Poll Interval
Resources'Execute Hex production deployment checklist and rollback procedures.
ReadBash(curl:*)Grep
Hex Production ChecklistOverviewHex is a collaborative data analytics platform where teams build notebooks, dashboards, and scheduled data pipelines. A production integration triggers project runs, retrieves results, and monitors pipeline health via the Hex API. Failures mean stale dashboards, broken scheduled reports, or data pipelines that silently stop producing output for downstream consumers. Authentication & Secrets
API Integration
Error Handling & Resilience
Monitoring & Alerting
Validation Script'Implement Hex rate limiting, backoff, and idempotency patterns.
ReadWriteEdit
Hex Rate LimitsOverviewHex's API enforces tight limits on project run triggers (20 per minute, 60 per hour) while leaving read operations like status checks and project listing largely unthrottled. Data teams scheduling batch analytics runs or triggering parameterized notebooks from CI/CD pipelines must carefully manage the hourly cap, since a single pipeline triggering 15 projects can consume a quarter of the hourly budget. Polling run status is free, but triggering runs is the bottleneck that shapes integration architecture. Rate Limit Reference
Rate Limiter Implementation
Retry Strategy'Implement Hex reference architecture with best-practice project layout.
ReadGrep
Hex Reference ArchitectureArchitecture
Project Structure
Integration Patterns
Resources'Apply production-ready Hex SDK patterns for TypeScript and Python.
ReadWriteEdit
Hex SDK PatternsOverviewProduction patterns for Hex API: typed client, pipeline orchestration, retry logic, and Python integration. InstructionsStep 1: Run with Retry
Step 2: Python Client (hextoolkit)
Step 3: Airflow Integration
ResourcesNext StepsApply patterns in 'Apply Hex security best practices for secrets and access control.
ReadWriteGrep
Hex Security BasicsOverviewHex is a collaborative data analytics platform where notebooks query production databases, generate visualizations, and share results across teams. Security concerns center on API token management (read vs run scopes), protecting database connection credentials embedded in Hex projects, and ensuring query results containing sensitive business data are not leaked through logs or exports. A compromised run-scope token can trigger arbitrary queries against connected databases. API Key Management
Webhook Signature Verification
Input Validation
Data Protection
Security Checklist
'Analyze, plan, and execute Hex SDK upgrades with breaking change detection.
ReadWriteEditBash(npm:*)Bash(git:*)
Hex Upgrade & MigrationOverviewHex API is versioned at InstructionsCheck API Usage
Airflow Provider Updates
Resources'Implement Hex webhook signature validation and event handling.
ReadWriteEditBash(curl:*)
Hex Webhooks & EventsOverviewHex doesn't provide push webhooks. For event-driven integrations, poll run status or build your own notification system around run completions. InstructionsRun Status Polling with Callback
Notify on Completion
ResourcesReady to use hex-pack?Related Pluginssupabase-packComplete Supabase integration skill pack with 30 skills covering authentication, database, storage, realtime, edge functions, and production operations. Flagship+ tier vendor pack. vercel-packComplete Vercel integration skill pack with 30 skills covering deployments, edge functions, preview environments, performance optimization, and production operations. Flagship+ tier vendor pack. clay-packComplete Clay integration skill pack with 30 skills covering data enrichment, waterfall workflows, AI agents, and GTM automation. Flagship+ tier vendor pack. cursor-packComplete Cursor integration skill pack with 30 skills covering AI code editing, composer workflows, codebase indexing, and productivity features. Flagship+ tier vendor pack. exa-packComplete Exa integration skill pack with 30 skills covering neural search, semantic retrieval, web search API, and AI-powered discovery. Flagship+ tier vendor pack. firecrawl-packComplete Firecrawl integration skill pack with 30 skills covering web scraping, crawling, markdown conversion, and LLM-ready data extraction. Flagship+ tier vendor pack.
Tags
hexsaassdkintegration
|