CodePinion Labs/codepinion_sentry_skill Public

This skill connects to Sentry or GlitchTip via an authentication key to automatically collect, resolve, and open pull requests for project issues. Once connected, it identifies errors, applies the necessary fixes, and generates a PR for your review.

1 branch
codepinion_sentry_skill
README

codepinion_sentry_skill

Connects AI coding agents to your GlitchTip (or Sentry) error tracker. Two parts, sharing one stdlib-only API client:

  1. An interactive skill — ask Claude Code, Codex, Gemini CLI, or Antigravity "any new errors?" or "dig into issue 393", and it reads the issue, stack trace and breadcrumbs itself instead of you pasting a crash report in.
  2. An autonomous watcher — a Celery Beat service that polls GlitchTip every ~2 minutes and, for each new issue, runs a headless coding agent in your repo to investigate and fix it. By default it only ever pushes bugfix/<slug> branches for you to review; pushing straight to your dev branch is an explicit per-project opt-in.

GlitchTip is Sentry-API-compatible for the subset used here (issues, an issue's latest event, comments, resolve/ignore), so the same client works against a real Sentry org — just point it at a different --api-url/--org.

AI agents working on this repo: read AGENTS.md first.


Quick start: the interactive skill (≈5 minutes)

Requirements: Python 3.12+. Nothing to pip install.

1. Install it for your agent

AgentInstallConfirm
Claude Codeln -s "$(pwd)/skills/glitchtip" ~/.claude/skills/glitchtiptype /glitchtip in a new session
Codexcodex/install.shrestart Codex, invoke with $glitchtip
Gemini CLIgemini-extension/install.shgemini extensions list
Antigravityantigravity/install.shagy plugin list

Run these from the repo root. The Claude Code symlink points at your working copy, so later edits to skills/glitchtip/ take effect without reinstalling. The other installers copy files, so re-run them after pulling changes. Details per agent are below.

2. Create a GlitchTip auth token

In GlitchTip: Profile → Auth Tokens → Create. For read-only use, give it org:read, project:read and event:read. Add event:write only if you want the agent to be able to resolve/ignore issues (it still only does that when you explicitly ask).

3. Store the credentials — in your own terminal, not in an AI chat

read -rs GT_TOKEN        # paste the token, press Enter (input is hidden)
python3 skills/glitchtip/scripts/glitchtip.py configure --env prod \
  --api-url https://glitchtip.example.com --org <org-slug> --token "$GT_TOKEN"
unset GT_TOKEN
  • --env prod is just a label for this connection; configure several (e.g. prod, sentry) and switch with --env NAME. The last one configured becomes the default.
  • The org slug is the first path segment of your GlitchTip URLs (https://glitchtip.example.com/<org-slug>/issues).
  • Saved to ~/.glitchtip/claude-code.json, mode 0600. The client never prints the token back.

4. Check it works

python3 skills/glitchtip/scripts/glitchtip.py check
# [prod] OK — reached https://glitchtip.example.com as org '<org-slug>'.

5. Use it

Open your agent in the codebase the errors come from, and ask naturally:

  • "Any new errors in GlitchTip?"
  • "What's crashing in production?"
  • "Why are the backups failing? Look at issue 393." (or paste an issue URL)

The agent lists/reads issues, then investigates the cause in the code you have open. It will not resolve or ignore anything unless you ask for that specific action.

Using the CLI directly

The client is a normal CLI too:

GT="python3 skills/glitchtip/scripts/glitchtip.py"
$GT envs                                             # configured connections (* = default)
$GT list-issues --status unresolved --environment production --limit 20
$GT list-issues --service code-be --query "OOM"
$GT list-issues --status unresolved --project prod --all   # every match, all pages
$GT triage                                           # unresolved issues grouped by likely root cause
$GT get-issue 393                                    # header, tags, extras, exception, app frames, breadcrumbs
$GT get-issue 393 --all-frames --all-crumbs          # nothing hidden
$GT --env sentry get-issue 12 --json                 # raw issue + latest event
$GT comments 393
$GT resolve 393                                      # writes; also: ignore, unresolve
$GT api --path "/api/0/organizations/<org>/issues/?limit=5"   # any endpoint

Full command reference: skills/glitchtip/reference.md. list-issues is org-wide: it returns issues from every project in the org unless you pass --project.

  • Each line shows the issue's project in parentheses. The leading [env] is only the name of your configured connection.
  • A last line ending in MORE MATCH means the list was cut at --limit. Use --all to see everything.
  • triage groups same-cause issues (same project, exception type and masked title) so a big backlog reads as a short list of problems. Treat the grouping as a starting point.

The autonomous watcher

Why it exists: an AI session's own scheduler stops when the session closes. The watcher is a standalone Celery app meant to run on something always-on (e.g. wherever your product's Celery workers already run), not a laptop that sleeps.

For quick, read-only monitoring instead, you don't need the watcher: in Claude Code run e.g. /loop 15m check glitchtip for new unresolved issues and summarise anything new. It stops when the session ends and never changes code.

What it does, per poll

  1. Takes a lock so only one poll runs at a time, and resets any run left half-finished by a crashed worker.
  2. For each configured project — only if it has been seeded — fetches every unresolved issue matching that project's environment/service tags (all pages, so a new issue can't be missed).
  3. For each issue it hasn't finished with, and only if the repo checkout is clean: claims it, builds a prompt (watcher/rulebook.md + the issue exactly as get-issue shows it — tags, extras, exception, app frames, trimmed breadcrumbs — + this project's push mode + the exact pause-gate command) and runs the project's agent CLI headless in that checkout (claude -p, codex exec, or agy run -p), with a 30-minute timeout. At most 25 runs start per poll (CODEPINION_SENTRY_MAX_RUNS_PER_POLL); the rest wait for the next poll.
  4. The rulebook makes that agent find the root cause, write a regression test, lint, rebase and retest, then run the pause gate. What it pushes depends on the mode.
  5. Every run's full stdout/stderr is saved to watcher/runs/<project>-<issue>-<time>.log.

Before you start: prerequisites on the watcher host

  • Python 3.12+, git, and a reachable broker (Redis by default).
  • The agent CLI each project uses (claude / codex / agy), installed and logged in.
  • A dedicated, clean checkout of each project's repo, with credentials that can push branches.
  • Headless permissions. A headless agent can't answer permission prompts, so the target repo must pre-allow what the rulebook needs (editing files, running tests/linters, git commit/rebase/push) — e.g. for Claude Code, allow rules in that repo's .claude/settings.json. Without this, runs will stop at the first prompt. Check the first few run logs to confirm.

1. Install

python3 -m venv watcher/.venv
source watcher/.venv/bin/activate
pip install -r watcher/requirements.txt

2. Configure

Copy config/example.codepinion-sentry.json to ~/.codepinion-sentry/config.json (or point CODEPINION_SENTRY_CONFIG at it) and add one entry per repo:

keymeaning
nameunique project name, used in logs and state
repo_pathabsolute path to the watcher's checkout of the repo
glitchtip.base_url / org_slugyour GlitchTip instance and org
glitchtip.token_envname of the env var holding the token — the token is never in this file
glitchtip.environment_tag / service_tagoptional filters on the issues' environment/service tags
cliclaude (default), codex, or agy
dev_branchbranch fixes are based on (and pushed to in auto_push); default dev
modereport_only (default) or auto_push — see push modes
pause_pathsextra regexes (validated at load) for paths that always stop a run. They add to the built-in list (billing/, accounts/, code_k8s, migrations/, anything with auth/permission) and can never remove from it

Check your tag filters match real data before relying on them, e.g. glitchtip.py list-issues --status unresolved --environment production --service code-be.

3. Seed each project (required)

Seeding marks every issue that is unresolved right now as already seen, so the watcher only works on issues that appear afterwards. Without it the whole backlog would look new. The watcher refuses to poll an unseeded project.

export GLITCHTIP_TOKEN_CODEBE=...          # every token_env named in your config
python3 -m watcher.seed --dry-run          # lists what would be marked; writes nothing
python3 -m watcher.seed                    # all projects, or: --project <name>

Run from the repo root, with the same environment variables as the worker. Re-running is safe: issues the watcher already tracks keep their state (but anything new since the last poll is marked seen too).

4. Run

export GLITCHTIP_TOKEN_CODEBE=...
export CODEPINION_SENTRY_BROKER_URL=redis://localhost:6379/0
celery -A watcher.celery_app worker --beat --loglevel=INFO

Watch a few real cycles and read the run logs before leaving it unattended.

Push modes

  • report_only (default) — the agent does the full fix and test on a bugfix/<slug> branch and pushes only that branch. Its summary starts with WOULD AUTO-PUSH: yes or WOULD AUTO-PUSH: no — <reason>. Read those verdicts in watcher/runs/ for a while; once the "yes" fixes are ones you'd have merged as-is, switch that project to auto_push. Report-only is an instruction to the agent, not a hard block, so the watcher also compares the remote dev branch before and after each run and logs codepinion_sentry_dev_moved_during_report_only_run if it moved (a teammate pushing at the same time also triggers it).
  • auto_push — fixes that pass every gate are pushed straight to dev_branch. Runs that hit a pause rule, need a product decision, are really features, or hit a rebase conflict still stop and push a bugfix/<slug> branch with a summary.

Retries, overlap, and dirty checkouts

  • Exit 0 → the issue is done. Non-zero exit, timeout, or a worker that died mid-run → failed, retried on later polls up to 3 attempts, then logged as codepinion_sentry_giving_up and left for a human.
  • One poll at a time per host (a file lock next to the state DB). This is single-host, like the SQLite state; multiple hosts would need a shared lock and shared state.
  • An issue is never started on a checkout with uncommitted changes; it's skipped with codepinion_sentry_skipped_dirty_checkout (no attempt used) until the repo is clean.

Inspecting and resetting state

State lives in ~/.codepinion-sentry/state.sqlite3 (override with CODEPINION_SENTRY_STATE):

sqlite3 ~/.codepinion-sentry/state.sqlite3 'select * from handled_issues order by updated_at desc limit 20'
sqlite3 ~/.codepinion-sentry/state.sqlite3 'select * from seeded_projects'
# make the watcher retry one issue from scratch:
sqlite3 ~/.codepinion-sentry/state.sqlite3 "delete from handled_issues where project='codepinion-be' and issue_id='393'"

status is one of in_progress, done, failed, seeded.

Environment variables

variabledefaultpurpose
CODEPINION_SENTRY_CONFIG~/.codepinion-sentry/config.jsonwatcher config
CODEPINION_SENTRY_STATE~/.codepinion-sentry/state.sqlite3state DB (lock file sits next to it)
CODEPINION_SENTRY_BROKER_URLredis://localhost:6379/0Celery broker
CODEPINION_SENTRY_RESULT_BACKENDthe broker URLCelery result backend
CODEPINION_SENTRY_POLL_SECONDS120poll interval
CODEPINION_SENTRY_MAX_RUNS_PER_POLL25max agent runs one poll starts; the rest wait for the next poll

Troubleshooting

symptomcause / fix
Unknown environment 'X'run configure for it, or check glitchtip.py envs
Token rejected (exit 2)token expired/revoked or missing a scope — create a new one and re-run configure --token
check fails with "Could not reach"wrong --api-url (use the base URL, no /api/...), or no network
list is empty but GlitchTip shows issuesyour --environment/--service filter doesn't match the issues' tags
watcher logs project_not_seededrun python3 -m watcher.seed --project <name>
watcher logs skipped_dirty_checkouta previous run left changes in the checkout — inspect, then clean it
runs end immediately / do nothinglook in watcher/runs/; usually the agent CLI isn't logged in or tool permissions aren't pre-allowed

Repository layout

skills/glitchtip/             canonical skill — the ONLY place the skill is edited
  SKILL.md                    instructions the agent reads
  reference.md                every command, endpoint and env var
  scripts/glitchtip.py        stdlib-only GlitchTip/Sentry client (also a CLI)
  scripts/test_glitchtip.py
antigravity/                  generated copy of the skill + installer (tools/sync_variants.py)
codex/                        Codex installer, its own short SKILL.md, AGENTS.md block
gemini-extension/             Gemini CLI extension manifest, GEMINI.md, installer
watcher/                      the autonomous watcher (Celery app)
  celery_app.py               Celery app + beat schedule
  tasks.py                    the poll task: lock, seed check, claim, run, record outcome
  issues.py                   fetching issues (shared by tasks and seed; no Celery import)
  runner.py                   prompt building, headless CLI invocation, git helpers
  state.py                    SQLite state: claims, outcomes, seeding, poll lock
  seed.py                     `python3 -m watcher.seed`
  config.py                   config loading + validation
  pause_rules.py              path denylist; also the CLI gate the agent runs
  rulebook.md                 instructions given to every headless run
  test_*.py
config/                       example watcher config
tools/sync_variants.py        keeps antigravity/ in sync with skills/glitchtip/
.codepinion/workflows/        CI on CodePinion Actions: both test suites + the sync check

Installer details

  • Codex — codex/install.sh copies glitchtip.py and reference.md to ~/.codex/glitchtip/, installs the skill under ~/.codex/skills/glitchtip/, and adds a clearly delimited block to ~/.codex/AGENTS.md. It respects CODEX_HOME, is safe to re-run, replaces only its own block, and refuses to touch a file with malformed or duplicate markers.
  • Gemini CLI — gemini-extension/install.sh assembles the extension (copying in the current glitchtip.py and reference.md) and runs gemini extensions install.
  • Antigravity — antigravity/install.sh assembles the plugin (same SKILL.md as Claude Code), runs agy plugin validate, then agy plugin install.

All installers take the client from skills/glitchtip/scripts/, so there's one copy of the code.

Development

Tests use only the standard library (unittest) and need no network, broker, or agent CLI — Celery is stubbed where needed. Run everything from the repo root:

for t in skills/glitchtip/scripts/test_glitchtip.py watcher/test_*.py; do python3 "$t" || break; done
python3 tools/sync_variants.py             # after any change under skills/glitchtip/
python3 tools/sync_variants.py --check     # exits 1 if antigravity/ has drifted

Contributor and AI-agent conventions are in AGENTS.md.

License

Licensed under the Apache License, Version 2.0. See NOTICE. The Apache license covers this code; it does not grant the right to use the CodePinion name or logo, and this project is not affiliated with GlitchTip or Sentry.

About

This skill connects to Sentry or GlitchTip via an authentication key to automatically collect, resolve, and open pull requests for project issues. Once connected, it identifies errors, applies the necessary fixes, and generates a PR for your review.

1 branch
Apache-2.0
Updated 1 day ago
Contributors

Languages

Python98.3%
Shell1.7%

Clone

https://api.codepinion.co.ke/git/codepinion-labs/codepinion_sentry_skill.git
git clone https://api.codepinion.co.ke/git/codepinion-labs/codepinion_sentry_skill.git