andrewyng/context-hub/new-project

Claude Code and agent skill by andrewyng/context-hub

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Build a new AI agent with Olakai monitoring from scratch — project setup, SDK integration, KPI configuration, and end-to-end validation

Install

npx vskill@latest install andrewyng/context-hub/new-project

SKILL.md

The same SKILL.md was published earlier as andrewyng/context-hub/new-project.

Build a New AI Agent Project with Olakai

This skill guides you through creating a new AI agent that is fully integrated with Olakai for analytics, KPI tracking, and governance.

Prerequisites

Before starting, ensure:

  1. Olakai CLI installed: npm install -g olakai-cli
  2. CLI authenticated: olakai login
  3. API key for SDK (generated per-agent via CLI — see Step 2.2)

Why Custom KPIs Are Essential

Olakai's core value is tracking business-specific KPIs for your AI agents. Without KPIs, you're tracking events without gaining actionable insights.

What you can measure with KPIs:

  • Business outcomes (items processed, success rates, revenue impact)
  • Operational data (step counts, retry rates, execution time)
  • Quality indicators (error rates, user satisfaction signals)

Without KPIs configured:

  • No dashboard KPIs beyond basic token counts
  • No aggregated performance views
  • No alerting thresholds
  • No ROI calculations
Every agent should have 2-4 KPIs that answer: "How do I know this agent is performing well?"
KPIs created here belong to this specific agent only. If you later create additional agents, each one needs its own KPI definitions — KPIs cannot be shared or reused across agents.

Understanding the customData to KPI Pipeline

Before diving into implementation, understand how data flows through Olakai:

SDK customData → CustomDataConfig (Schema) → Context Variable → KPI Formula → kpiData
How It Works
  1. customData (SDK): Raw JSON you send with each event
  2. CustomDataConfig (Platform): Schema defining which fields are processed
  3. Context Variables: CustomDataConfig fields become available for formulas
  4. KPI Formula: Expression that computes a value (e.g., SuccessRate * 100)
  5. kpiData (Response): Computed KPI values returned with each event
Critical Rules
RuleConsequence
Only CustomDataConfig fields become variablesUnregistered customData fields are NOT usable in KPIs
Formula evaluation is case-insensitivestepCount, STEPCOUNT, StepCount all work in formulas
NUMBER configs need numeric valuesDon't send "5" (string), send 5 (number)
KPIs are unique per agentEach KPI belongs to exactly one agent — create separately for each
Built-in Context Variables (Always Available)
VariableTypeDescription
PromptstringThe prompt text sent to the LLM
ResponsestringThe LLM response text
Documents countnumberNumber of attached documents
PII detectedbooleanWhether PII was detected
PHI detectedbooleanWhether PHI was detected
CODE detectedbooleanWhether code was detected
SECRET detectedbooleanWhether secrets were detected

Step 1: Design the Agent Architecture

1.1 Determine Agent Type

Agentic AI (Multi-step autonomous workflows):

  • Research agents, document processors, data pipelines
  • Track as SINGLE events aggregating all internal LLM calls
  • Focus on workflow-level KPIs (total tokens, total time, success/failure)

Assistive AI (Interactive chatbots/copilots):

  • Customer support agents, coding assistants, Q&A systems
  • Track EACH interaction as separate events
  • Focus on conversation-level KPIs (per-message tokens, response quality)
1.2 Design Your KPI Schema (CRITICAL)

Design your KPIs BEFORE writing any SDK code. This ensures only meaningful data is sent and tracked.

Step A: Identify Business Questions

What do stakeholders need to know about this agent?

  • "How many items does it process per run?"
  • "What's the success/failure rate?"
  • "How efficient is each execution?"
Step B: Map Questions to Data Fields
Business QuestionField NameTypeKPI FormulaAggregation
ThroughputItemsProcessedNUMBERItemsProcessedSUM
ReliabilitySuccessRateNUMBERSuccessRate * 100AVERAGE
Error countSuccessRateNUMBERIF(SuccessRate < 1, 1, 0)SUM
CorrelationExecutionIdSTRING(for filtering only)-
Step C: Plan Your customData Structure
typescript
// ONLY include fields you'll register as CustomDataConfigs
customData: {
// Business KPIs
ItemsProcessed: number, // Count of items handled
SuccessRate: number, // 0-1 success ratio
// Performance KPIs
StepCount: number, // Number of workflow steps
// Identification (for filtering, not KPIs)
ExecutionId: string, // Correlation ID
}
IMPORTANT: Only include fields you will register as CustomDataConfigs. Unregistered fields are stored but cannot be used in KPIs.
What NOT to Include in customData

The Olakai platform automatically tracks these — do NOT duplicate them:

Already TrackedWhereDon't Send As customData
Session IDMain payloadsessionId
Agent IDAPI key associationagentId
User emailuserEmail parameteremail, userEmail
TimestampEvent metadatatimestamp, createdAt
Request timerequestTime parameterduration, latency
Token counttokens parametertokenCount
ModelAuto-detectedmodel, modelName
ProviderClient configprovider

customData is ONLY for:

  1. KPI variables — Fields you'll use in formula calculations
  2. Tagging/filtering — Fields you'll filter by in queries

Step 2: Configure Olakai Platform

2.1 Create a Workflow (Required)
Every agent MUST belong to a workflow, even if it's the only agent in that workflow.
bash
olakai workflows create --name "Your Workflow Name" --json
# Output: { "id": "wfl_xxx...", "name": "Your Workflow Name" }
2.2 Create the Agent in Olakai
bash
olakai agents create \
--name "Your Agent Name" \
--description "What this agent does" \
--workflow WORKFLOW_ID \
--with-api-key \
--json
# Returns agent details including apiKey:
# {
# "id": "cmkbteqn501kyjy4yu6p6xrrx",
# "name": "Your Agent Name",
# "workflowId": "wfl_xxx...",
# "apiKey": "sk_agent_xxxxx..." <-- Use this in your SDK
# }

Agent-Workflow Hierarchy:

Workflow: "Customer Support Pipeline"
├── Agent: "Ticket Classifier"
├── Agent: "Response Generator"
└── Agent: "Quality Checker"
Workflow: "Document Processing"
└── Agent: "Document Summarizer" ← single-agent workflows are valid
2.3 Create Custom Data Configurations (BEFORE Writing SDK Code)
This step MUST be completed before Step 3 (SDK Integration). Only fields registered here can be used in KPI formulas.
ONLY create configs for data you'll use in KPIs or for filtering. Don't create configs for data already tracked automatically.
bash
# For numeric fields (can be used in KPI calculations)
olakai custom-data create --agent-id YOUR_AGENT_ID --name "ItemsProcessed" --type NUMBER
olakai custom-data create --agent-id YOUR_AGENT_ID --name "SuccessRate" --type NUMBER
olakai custom-data create --agent-id YOUR_AGENT_ID --name "StepCount" --type NUMBER
# For string fields (for filtering/grouping, not calculations)
olakai custom-data create --agent-id YOUR_AGENT_ID --name "ExecutionId" --type STRING
# Verify all configs are created
olakai custom-data list --agent-id YOUR_AGENT_ID
2.4 Create KPI Definitions
Quick Start with Templates

Instead of writing formulas from scratch, use predefined classifier templates:

bash
# List available templates
olakai kpis templates
# Create a classifier KPI from a template
olakai kpis create --name "User Satisfaction" \
--calculator-id classifier --template-id sentiment_scorer \
--scope CHAT --agent-id $AGENT_ID
# Create a time-saved estimator
olakai kpis create --name "Time Saved" \
--calculator-id classifier --template-id time_saved_estimator \
--scope CHAT --agent-id $AGENT_ID
Custom Formula KPIs
bash
# Variable passthrough
olakai kpis create \
--name "Items Processed" \
--agent-id YOUR_AGENT_ID \
--calculator-id formula \
--formula "ItemsProcessed" \
--unit "items" \
--aggregation SUM
# Percentage calculation
olakai kpis create \
--name "Success Rate" \
--agent-id YOUR_AGENT_ID \
--calculator-id formula \
--formula "SuccessRate * 100" \
--unit "%" \
--aggregation AVERAGE
# Conditional counting
olakai kpis create \
--name "Error Count" \
--agent-id YOUR_AGENT_ID \
--calculator-id formula \
--formula "IF(SuccessRate < 1, 1, 0)" \
--unit "errors" \
--aggregation SUM
# Validate formulas before creating
olakai kpis validate --formula "ItemsProcessed" --agent-id YOUR_AGENT_ID

Step 3: Implement SDK Integration

3.1 TypeScript Implementation

Install dependencies:

bash
npm install @olakai/sdk openai

Initialize and track:

typescript
import { olakaiConfig, olakai } from "@olakai/sdk";
import OpenAI from "openai";
// Initialize Olakai
olakaiConfig({
apiKey: process.env.OLAKAI_API_KEY!,
debug: process.env.NODE_ENV === "development",
});
// Create LLM client
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
// Use wrapped client — monitoring happens automatically
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: userPrompt }],
});

Agentic workflow with manual event tracking:

`taskExecutionId` — Cross-Agent Task Correlation. Generate ONE taskExecutionId per task and share it across all agents in a multi-agent workflow. This links events from different agents into a single logical task for analytics.
typescript
async function runAgent(input: string): Promise<string> {
const startTime = Date.now();
const executionId = crypto.randomUUID();
const taskExecutionId = crypto.randomUUID();
let totalTokens = 0;
let stepCount = 0;
let itemsProcessed = 0;
try {
// Step 1: Planning
stepCount++;
const plan = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: `Plan: ${input}` }],
});
totalTokens += plan.usage?.total_tokens ?? 0;
// Step 2: Process items
const items = parseItems(plan.choices[0].message.content);
for (const item of items) {
stepCount++;
const result = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: `Process: ${item}` }],
});
totalTokens += result.usage?.total_tokens ?? 0;
itemsProcessed++;
}
// Step 3: Summarize
stepCount++;
const summary = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Summarize results" }],
});
totalTokens += summary.usage?.total_tokens ?? 0;
const finalResponse = summary.choices[0].message.content ?? "";
// Track the complete workflow as a single event
// Only send fields that have CustomDataConfigs (from Step 2.3)
olakai("event", "ai_activity", {
prompt: input,
response: finalResponse,
tokens: totalTokens,
requestTime: Date.now() - startTime,
taskExecutionId,
task: "Data Processing & Analysis",
customData: {
ExecutionId: executionId,
StepCount: stepCount,
ItemsProcessed: itemsProcessed,
SuccessRate: 1.0,
},
});

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/andrewyng/context-hub/new-project/badge)](https://verified-skill.com/skills/andrewyng/context-hub/new-project)

Something wrong with this skill or its page? Tell us.