Agent skill
af-sentry-expertise
Use when integrating Sentry error tracking into a project — SDK setup, webhook-driven auto-fix agents, per-project configuration, and internal integration management.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/af-sentry-expertise
SKILL.md
Sentry Integration Expertise
Directive knowledge for integrating Sentry error tracking into GainInsight projects, including SDK setup, webhook-driven auto-fix agent pipelines, and per-project configuration.
When to Use This Skill
Load this skill when:
- Setting up Sentry SDK in a new project (Next.js, Node, React, Python)
- Configuring webhook integration for auto-fix agents (Holly pipeline)
- Managing Sentry internal integrations via API
- Configuring per-project error thresholds and auto-fix settings
- Troubleshooting webhook delivery, signature verification, or agent spawning
- Querying Sentry errors or issues via API
Organisation
- Org:
gain-insight - Region: EU (Germany) —
de.sentry.io - Team:
gain-insight - Dashboard:
https://gain-insight.sentry.io
Rules (FOLLOW THESE)
API Rules
- MUST use
de.sentry.iofor all API calls — the org is EU-region hosted - MUST use PAT from Doppler (
doppler secrets get SENTRY_AUTH_TOKEN --project gi --config prd --plain) — never the MCP token - MUST NOT expose DSNs in logs — they contain ingest keys
- MUST use
sentry.io(US endpoint) for internal integration CRUD — this is a Sentry API quirk
Webhook Rules
- MUST verify HMAC-SHA256 signature using
sentry-hook-signatureheader andcrypto.timingSafeEqual() - MUST fail closed — reject webhooks when secret is unset in production (
NODE_ENV=production) - MUST deduplicate by
sentry_issue_id— use a unique partial index excluding archived agents - MUST handle race conditions — catch unique constraint violations (PostgreSQL 23505) gracefully
- SHOULD use
async fetch()for all HTTP calls in webhook handlers — neverexecFileSync('curl')
Configuration Rules
- MUST add
sentryconfig to project'sconfig_jsonwhen enabling for a new project - MUST set
enabled: trueexplicitly — missing config means disabled - SHOULD set
min_count: 1for new projects to catch errors early - SHOULD default
min_leveltoerror— onlyerrorandfatalspawn agents - MUST set
auto_fix: falsefor alert-only mode (Linear issue created but no agent spawned)
SDK Rules
- MUST install platform-specific SDK (e.g.,
@sentry/nextjs,@sentry/node,@sentry/react) - SHOULD enable Session Replay on client-side (10% normal, 100% on error)
- SHOULD follow the Andon pattern for Next.js SDK integration (see Workflows)
Quick Reference
Webhook Pipeline
Sentry Issue → Webhook (HMAC-SHA256) → Coordinator → Filter → Linear Issue → Agent Spawn
Severity Levels
| Level | Value | Default Action |
|---|---|---|
debug |
0 | Ignored |
info |
1 | Ignored |
warning |
2 | Ignored |
error |
3 | Spawn agent (if enabled) |
fatal |
4 | Spawn agent (Urgent priority) |
Unknown levels default to 0 (never trigger unless threshold is debug).
Per-Project Config Schema
{
"sentry": {
"enabled": true,
"project_slug": "my-project",
"min_level": "error",
"min_count": 1,
"auto_fix": true
}
}
Store in projects.config_json column.
Linear Priority Mapping
| Sentry Level | Linear Priority |
|---|---|
fatal |
1 (Urgent) |
error |
2 (High) |
| Other | 2 (High) |
Default Assignee
Sentry-created Linear issues are auto-assigned to Andy Davidson (4ea0cf3c-49f4-42a6-ab7d-01f2c95af853) by default. This is set via SENTRY_DEFAULT_ASSIGNEE_ID in the coordinator's watcher.ts. The createSentryLinearIssue function accepts an optional assigneeId parameter to override per-call.
Workflows
Workflow: SDK Setup (Next.js)
When: Adding Sentry to a new Next.js project
Steps:
- Install SDK:
npm install @sentry/nextjs - Create files:
next.config.ts— Wrap withwithSentryConfiginstrumentation.ts— Server/edge init with DSNinstrumentation-client.ts— Client init with replay (10% normal, 100% error)src/app/global-error.tsx— Error boundary component
- Get DSN via API:
bash
curl -s -H "Authorization: Bearer ${SENTRY_TOKEN}" \ "https://de.sentry.io/api/0/projects/gain-insight/{slug}/keys/" - Hardcode DSN in instrumentation files (not env var — it's public and baked at build time)
- Set webpack config:
org: "gain-insight",project: "{slug}" - Test: throw a test error, verify it appears in Sentry dashboard
Success criteria:
- Errors appear in Sentry dashboard within 30 seconds
- Source maps upload correctly
- Session replay captures user interactions
Workflow: Enable Webhook Auto-Fix for a Project
When: Connecting an existing Sentry project to the Holly auto-fix pipeline
Steps:
- Ensure Sentry internal integration exists with correct webhook URL
- Update project config in database:
sql
UPDATE projects SET config_json = jsonb_set( COALESCE(config_json, '{}'), '{sentry}', '{"enabled": true, "project_slug": "my-slug", "min_level": "error", "min_count": 1, "auto_fix": true}' ) WHERE project_key = 'my-project'; - Verify via dashboard status endpoint:
GET /api/sentry/status - Test with dry-run:
POST /api/sentry/test-webhookwith project slug - Verify test creates Linear issue and spawns agent (or dry-run passes all checks)
Success criteria:
- Status endpoint shows project with
enabled: true - Test webhook creates Linear issue with correct priority
- Agent spawns with
workflow_type: 'sentry-fix'
Workflow: Create Internal Integration (API)
When: Setting up the webhook receiver for the first time or rotating secrets
Steps:
- Create integration via US endpoint (Sentry API quirk):
bash
SENTRY_TOKEN=$(doppler secrets get SENTRY_AUTH_TOKEN --project gi --config prd --plain) curl -s -X POST \ -H "Authorization: Bearer ${SENTRY_TOKEN}" \ -H "Content-Type: application/json" \ -d '{ "name": "Holly Agent Integration", "scopes": ["event:read"], "events": ["issue"], "webhookUrl": "https://{coordinator-host}/webhooks/sentry", "isInternal": true, "verifyInstall": false }' \ "https://sentry.io/api/0/sentry-apps/" - Save
clientSecretfrom response asSENTRY_WEBHOOK_SECRET - Store secret in Doppler and AWS Secrets Manager
- Force-redeploy coordinator to pick up new secret
- Verify: send test webhook, expect 200 (not 401)
Success criteria:
- Integration appears in Sentry Settings > Developer Settings
- Webhook receives valid HMAC signatures
- Coordinator verifies signatures and processes events
Workflow: Troubleshoot Webhook Delivery
When: Webhooks are not being processed or returning errors
Steps:
- Check integration exists:
GET https://de.sentry.io/api/0/sentry-apps/ - Check webhook URL is correct in integration settings
- Verify ALB/proxy routing: webhook path (
/webhooks/sentry) must route to coordinator port (not API server) - Verify secret matches: compare Doppler/Secrets Manager value with integration's
clientSecret - Check coordinator logs for signature verification errors
- Send manual test with valid HMAC:
bash
SECRET="..."; BODY='{"action":"created","data":{...}}' SIG=$(echo -n "$BODY" | openssl dgst -sha256 -hmac "$SECRET" | awk '{print $2}') curl -X POST -H "Content-Type: application/json" \ -H "sentry-hook-signature: $SIG" \ -d "$BODY" "https://{coordinator-host}/webhooks/sentry" - Check response: 200 = processed, 401 = bad signature, 500 = handler error
Success criteria:
- Webhook returns 200 with
{"handled": true}or{"handled": false, "reason": "..."} - Reason messages explain filtering decisions clearly
Database Schema
Required Columns (tasks table)
ALTER TABLE tasks ADD COLUMN sentry_issue_id TEXT;
ALTER TABLE tasks ADD COLUMN sentry_event_id TEXT;
Dedup Index
CREATE UNIQUE INDEX idx_tasks_sentry_dedup
ON tasks (sentry_issue_id)
WHERE sentry_issue_id IS NOT NULL
AND agent_status NOT IN ('archived');
Prevents duplicate active agents for the same Sentry issue. Archived agents don't count.
Environment Variables
| Variable | Location | Purpose |
|---|---|---|
SENTRY_AUTH_TOKEN |
Doppler gi/prd |
Full-access PAT for API operations |
SENTRY_DSN |
Per-project Doppler | Error tracking ingest endpoint |
SENTRY_WEBHOOK_SECRET |
Doppler + AWS SM | HMAC signature verification |
Essential Reading
- Sentry Developer Docs: Internal Integrations
- Sentry Webhook Events
- af-security-expertise — Related security patterns
Remember:
- EU region =
de.sentry.iofor API, butsentry.iofor integration CRUD - Webhook secret comes from integration's
clientSecret, not a separate API key - Always verify HMAC with
timingSafeEqual— never string comparison - Fatal = Urgent priority, everything else = High
- Unknown severity levels default to 0 (safest default)
- Dedup by
sentry_issue_idwith partial unique index excluding archived agents
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?