Skip to main content

AI Agent Integration

Sentry CLI is designed to work seamlessly with AI coding agents, providing structured JSON output and predictable behavior for automated debugging workflows.

Overview

AI agents can use Sentry CLI to:
  • Fetch issue details for debugging context
  • Analyze error patterns across projects
  • Get AI-powered explanations via Sentry’s Seer AI
  • Generate fix plans for common errors
  • Monitor deployment health automatically

Agent Skills

Sentry CLI provides a skill file for AI agents that documents all commands, flags, and JSON output schemas.

Installation

The skill file is automatically installed when you set up Sentry CLI:
1

Install Sentry CLI

2

Run Setup

This automatically installs agent skills to:
  • Claude Desktop: ~/.config/claude/skills/sentry-cli/SKILL.md
3

Verify Installation

Check if the skill file exists:

Manual Installation

If auto-detection doesn’t work, manually copy the skill file:

Skill File Contents

The skill file (SKILL.md) contains:
  • Complete command reference with all flags
  • JSON output schemas for every command
  • Authentication patterns
  • Usage examples and best practices
  • Error handling guidance

Supported AI Agents

Claude Desktop

Claude Desktop (Sonnet, Opus) supports the Sentry CLI skill natively. Setup:
1

Install Sentry CLI

2

Authenticate

3

Use in Claude

Ask Claude to help with Sentry issues:
“Fetch the top 5 unresolved errors from my-org/my-project and explain the most frequent one”
Example Prompts:
  • “Show me all critical issues in production from the last 24 hours”
  • “Analyze the top 3 issues by user impact and suggest fixes”
  • “Get the AI explanation for issue MYAPP-2J”
  • “List all unresolved TypeError issues”

Cursor

Cursor can use Sentry CLI via terminal commands in its agent mode. Setup:
  1. Install Sentry CLI globally
  2. Authenticate with sentry auth login
  3. Use Cursor’s terminal integration:
Cursor Rules: Add to .cursorrules in your project:
.cursorrules

GitHub Copilot

GitHub Copilot can suggest Sentry CLI commands when you add comments:
Copilot will suggest code to parse the JSON output.

Custom Agents

Build custom agents using the Sentry CLI as a tool:

JSON Output for Agents

All Sentry CLI commands support --json for structured output.

Issue List

Output Schema:

Issue View

Output Schema:

AI Explanation

Output Schema:

Fix Plan

Output Schema:

Authentication for Agents

AI agents need authentication to access Sentry data.

Environment Variable

The simplest method for agents is using SENTRY_AUTH_TOKEN:
1

Create Auth Token

Go to Settings → Account → API → Auth Tokens in Sentry
2

Set Environment Variable

Add to your shell profile (~/.bashrc, ~/.zshrc) for persistence
3

Test

OAuth (Interactive)

For interactive sessions, use OAuth:
The token is stored in ~/.sentry/config.db and automatically used by agents.

Agent Workflows

1. Automated Debugging

Agent fetches issue, gets explanation, suggests fix:

2. Error Pattern Analysis

Agent identifies patterns across issues:

3. Deployment Health Check

Agent verifies deployment health:

4. Code Review Assistant

Agent checks if PR fixes known issues:

Best Practices

1. Use JSON Output Always

Agents should always parse JSON:
Never parse human-readable output.

2. Handle Errors Gracefully

Check exit codes:

3. Rate Limiting

Implement backoff for rate limits:

4. Cache Results

Avoid redundant API calls:

5. Limit Scope

Use filters to reduce data:

Example Agent Implementations

Claude Desktop Agent

Prompt:
“You are a debugging assistant with access to Sentry CLI. When I ask about errors:
  1. Use sentry issue list to fetch relevant issues
  2. Parse JSON output to analyze patterns
  3. Use sentry issue explain for AI explanations
  4. Use sentry issue plan for fix suggestions
  5. Provide code examples for fixes
Always use --json flag and parse with jq.”

Python Agent

debugging_agent.py

Troubleshooting

Skill File Not Found

If your agent can’t find the skill file:

Authentication Issues

If agent commands fail with auth errors:

JSON Parsing Errors

If JSON output is invalid:

Next Steps

CI/CD Integration

Automate Sentry checks in your pipeline

Scripting Guide

Build custom automation scripts