Loading...
Loading...
Add observability to any repo: Sentry (errors), PostHog (analytics), Helicone (LLM costs). Auto-detects language/framework. Creates Sentry project via MCP. Installs SDKs, writes config, updates .env.example, opens PR. Supports: Next.js, Node/Express/Hono, Go, Python, Swift, Rust, React Native.
npx skill4agent add phrazzld/claude-config instrument-repoSENTRY_ORG=misty-step
SENTRY_TEAM=misty-step
POSTHOG_PROJECT_ID=293836
POSTHOG_HOST=https://us.i.posthog.com# Language detection
[ -f package.json ] && echo "typescript"
[ -f go.mod ] && echo "go"
[ -f pyproject.toml ] || [ -f setup.py ] && echo "python"
[ -f Package.swift ] && echo "swift"
[ -f Cargo.toml ] && echo "rust"
# Framework detection (TypeScript)
grep -q '"next"' package.json 2>/dev/null && echo "nextjs"
grep -q '"hono"' package.json 2>/dev/null && echo "hono"
grep -q '"express"' package.json 2>/dev/null && echo "express"
grep -q '"react-native"' package.json 2>/dev/null && echo "react-native"
# LLM usage detection (for Helicone)
grep -rq '@ai-sdk\|openai\|anthropic\|@google/genai' package.json src/ lib/ app/ 2>/dev/null && echo "has-llm"
grep -rq 'openai\|anthropic\|langchain' *.go cmd/ internal/ 2>/dev/null && echo "has-llm"
grep -rq 'openai\|anthropic\|langchain' *.py src/ 2>/dev/null && echo "has-llm"
# Existing instrumentation
grep -q '@sentry' package.json 2>/dev/null && echo "has-sentry"
grep -q 'posthog' package.json 2>/dev/null && echo "has-posthog"
grep -rq 'helicone' src/ lib/ app/ 2>/dev/null && echo "has-helicone"1. cd ~/Development/$REPO
2. Detect language, framework, LLM usage, existing instrumentation
3. git fetch origin && git checkout -b infra/observability origin/main (or master)
4. Create Sentry project if needed → mcp__sentry__create_project
5. Install packages (language-specific)
6. Write/update config files from templates
7. Update .env.example
8. Typecheck/build to verify
9. git add <specific files> && git commit
10. git push -u origin infra/observability
11. gh pr create with structured body| Condition | Sentry | PostHog | Helicone |
|---|---|---|---|
| Any app/service | YES | — | — |
| User-facing web app | YES | YES | — |
| Has LLM SDK imports | YES | maybe | YES |
| CLI tool | YES | NO | maybe |
| GitHub Action / lib | NO | NO | NO |
tracesSampleRate: 0.1 # 10% of transactions
replaysSessionSampleRate: 0 # Don't record sessions by default
replaysOnErrorSampleRate: 1.0 # Always replay on errortemplates/nextjs/sentry.client.config.tssentry.server.config.tssentry.edge.config.tsinstrumentation.tslib/sentry.tscomponents/posthog-provider.tsxcomponents/posthog-pageview.tsxlib/posthog.tspnpm add @sentry/nextjs posthog-js posthog-nodewithSentryConfig()next.config.ts/ingestnext.config.tsasync rewrites() {
return [
{ source: "/ingest/static/:path*", destination: "https://us-assets.i.posthog.com/static/:path*" },
{ source: "/ingest/:path*", destination: "https://us.i.posthog.com/:path*" },
{ source: "/ingest/decide", destination: "https://us.i.posthog.com/decide" },
];
},templates/node/lib/sentry.tspnpm add @sentry/nodeSentry.setupExpressErrorHandler(app)onErrortemplates/go/internal/observability/sentry.gogo get github.com/getsentry/sentry-gotemplates/python/observability.pypip install sentry-sdkpyproject.tomltemplates/swift/SentrySetup.swifthttps://github.com/getsentry/sentry-cocoahttps://github.com/PostHog/posthog-iostemplates/rust/src/sentry_init.rssentry = "0.35"Cargo.tomltemplates/react-native/pnpm add @sentry/react-native posthog-react-nativetemplates/helicone/lib/ai-provider.tsbaseURLfeat: add observability (Sentry [+ PostHog] [+ Helicone])
- Sentry: error tracking with PII-safe defaults
[- PostHog: product analytics with privacy masking]
[- Helicone: LLM cost tracking via gateway proxy]
- Updated .env.example with required variables## Summary
Add production observability to {repo}.
## Changes
- Sentry error tracking (DSN: `{dsn}`)
- PII scrubbing (emails, IPs, sensitive headers)
- Environment-aware (production/preview/development)
- Traces sample rate: 10%
[- PostHog product analytics
- Pageview tracking via `/ingest` proxy rewrite
- Privacy: `respect_dnt: true`, manual pageview capture]
[- Helicone LLM cost tracking
- Proxied through gateway for cost/latency monitoring
- Tagged with product name and environment]
- Updated `.env.example` with all required variables
## Required Env Vars
| Variable | Where | Value |
|----------|-------|-------|
| `NEXT_PUBLIC_SENTRY_DSN` | Vercel | `{dsn}` |
| `SENTRY_AUTH_TOKEN` | Vercel + GH Actions | org-level token |
[| `NEXT_PUBLIC_POSTHOG_KEY` | Vercel | project API key |]
[| `HELICONE_API_KEY` | Vercel (server) | Helicone API key |]
## Test Plan
- [ ] `pnpm build` passes
- [ ] Deploy to preview → check Sentry for test error
- [ ] Set env vars on Vercel production
[- [ ] Verify PostHog Live Events after deploy]
[- [ ] Verify Helicone dashboard shows tagged requests]| Variable | Scope | Notes |
|---|---|---|
| Per-project | Unique per Sentry project |
| Per-project (server-only) | Same DSN, no NEXT_PUBLIC prefix |
| Shared | For source map uploads |
| | Hardcode in config |
| Per-project | Matches Sentry project slug |
| Shared | PostHog project API key |
| | Via rewrite proxy |
| Shared (server-only) | Never expose client-side |
--audittracesSampleRate: 1sendDefaultPii: true/ingestrespect_dnt: true