From magic-powers
Step 3 of instrumentation workflow — transform event candidates into concrete tracking specifications with exact code locations and property definitions. Uses mcp__Amplitude__get_event_properties, mcp__Amplitude__get_project_context.
npx claudepluginhub kienbui1995/magic-powers --plugin magic-powersThis skill uses the workspace's default tool permissions.
- After `discover-event-surfaces` has produced a candidate event list
Generates design tokens/docs from CSS/Tailwind/styled-components codebases, audits visual consistency across 10 dimensions, detects AI slop in UI.
Records polished WebM UI demo videos of web apps using Playwright with cursor overlay, natural pacing, and three-phase scripting. Activates for demo, walkthrough, screen recording, or tutorial requests.
Delivers idiomatic Kotlin patterns for null safety, immutability, sealed classes, coroutines, Flows, extensions, DSL builders, and Gradle DSL. Use when writing, reviewing, refactoring, or designing Kotlin code.
discover-event-surfaces has produced a candidate event listFor each candidate event, navigate to the relevant file and find the precise trigger point:
Trigger location rules:
page_viewed → fires in the page component's useEffect or componentDidMount, after the page rendersbutton_clicked → fires in the onClick handler of the button componentform_submitted → fires on successful form submission (after validation passes, before or after API call depending on if you want success-only)modal_opened → fires when the modal's open state becomes trueAvoid ambiguous triggers:
Use the pattern from discover-analytics-patterns. Match exactly:
// Correct — using project's analytics wrapper
import { track } from '@/analytics';
import { Events } from '@/analytics/events';
// In CheckoutConfirmation.tsx useEffect:
useEffect(() => {
track(Events.CHECKOUT_CONFIRMATION_VIEWED, {
order_id: order.id,
order_total: order.totalAmount,
payment_method: order.paymentMethod,
items_count: order.items.length,
});
}, []);
If no discover-analytics-patterns has been run, look for the pattern in the nearest existing tracking call in the same file or module.
For each property on each event, produce a complete definition:
| Property | Type | Required | Example | Description |
|---|---|---|---|---|
order_id | string | yes | "ord_abc123" | Unique order identifier from backend |
order_total | number | yes | 49.99 | Total order value in USD |
payment_method | string | yes | "credit_card" | One of: credit_card, paypal, apple_pay |
items_count | number | yes | 3 | Number of line items in order |
coupon_applied | boolean | no | true | Whether a discount code was used |
Rules for property definitions:
true means vs falseWrite a precise trigger statement:
Trigger: Fire ONCE when the checkout confirmation page renders, after the order data has loaded.
Do NOT fire: if the user arrives via direct URL without a valid order_id (guard with null check).
For async events, clarify timing:
For each event, document the edge cases that must be handled:
Common edge cases:
user_id available? If not, use anonymous IDnull or undefined → don't send the property, or send explicit null?Write the guard code:
// Guard: only fire if order data is loaded
if (!order?.id) return;
track(Events.CHECKOUT_CONFIRMATION_VIEWED, {
order_id: order.id,
// ...
});
For each event, define a test that verifies correct instrumentation:
// Test: checkout_confirmation_viewed fires correctly
describe('checkout_confirmation_viewed', () => {
it('fires when confirmation page renders with valid order', () => {
render(<CheckoutConfirmation order={mockOrder} />);
expect(mockTrack).toHaveBeenCalledWith('checkout_confirmation_viewed', {
order_id: 'ord_abc123',
order_total: 49.99,
payment_method: 'credit_card',
items_count: 3,
});
});
it('does NOT fire when order data is missing', () => {
render(<CheckoutConfirmation order={null} />);
expect(mockTrack).not.toHaveBeenCalled();
});
});
mcp__Amplitude__get_event_properties — verify that property names and types match Amplitude's existing schema for this event (if updating an existing event)mcp__Amplitude__get_project_context — get project ID and settings needed for validation, confirm the target Amplitude projectOne implementation spec per event:
## Event: <event_name>
**Trigger:** <when exactly this fires>
**File:** <src/path/to/Component.tsx>
**Location:** <function name, lifecycle hook, or handler>
### Tracking Code
```typescript
<exact code snippet>
| Property | Type | Required | Example | Description |
|---|
<test definition>
After all events: "Implementation specs ready for N events. Hand off to engineers or proceed to `add-analytics-instrumentation` for end-to-end summary."