npx skills add ...
npx skills add launchdarkly/agent-skills --skill custom-metrics
Create, track, retrieve, update, and delete custom business metrics for configs. Covers full lifecycle: define metric kinds via API, emit events via SDK, and query results.
This repo is now called launchdarkly/ai-tooling. Both names install the same content, but the install count here only covers this one.
npx skills add launchdarkly/agent-skills --skill custom-metrics
Full lifecycle management of custom business metrics: create metric definitions via API, track events via SDK, retrieve metric data, and manage metrics programmatically.
sdk)writer role for metric managementbuilt-in-metrics)Before prompting the user for an API key, try to detect it automatically:
~/.claude/config.json and look for mcpServers.launchdarkly.env.LAUNCHDARKLY_API_KEYLAUNCHDARKLY_API_KEY, LAUNCHDARKLY_API_TOKEN, or LD_API_KEY| Step | Method | Purpose |
|---|---|---|
| 1. Create | API | Define metric in LaunchDarkly |
| 2. Track | SDK | Send events to the metric |
| 3. Get | API | Retrieve metric definition/data |
| 4. Update | API | Modify metric properties |
| 5. Delete | API | Remove metric |
Required fields for numeric custom metrics:
successCriteria - Must be one of: "HigherThanBaseline", "LowerThanBaseline"unit - e.g., "count", "percent", "milliseconds"The API will return 400 Bad Request if these are missing for numeric metrics.
Metric Kinds:
custom - Track any event (most common for agent metrics)pageview - Track page viewsclick - Track click eventsSuccess Criteria (for numeric metrics):
HigherThanBaseline - Higher values are better (e.g., revenue, satisfaction)LowerThanBaseline - Lower values are better (e.g., errors, latency)Common Units:
count - Generic countmilliseconds - Time durationpercent - Percentage valuesdollars - CurrencyOnce the metric is created, track events using the SDK:
isNumeric=True for aggregationcreate_metric() and ld_client.track()ld_client.flush() (await in Node) before close(). Trailing events are at risk of being lost otherwise, in short-lived scripts and long-running services alike. This is not a serverless-only rule; it applies to any process that exits.Custom metrics appear in:
get_metric() or list_metrics()sdk - SDK setupbuilt-in-metrics - Built-in agent metrics (tokens, duration, cost)online-evals - Quality metrics via judges