scopes

scopes is a cursor rule for Cursor from getsentry/sentry-java. It costs 7 tokens per session (1,710 once invoked), scanned A, original, MIT.

Guidance for managing scopes in the Sentry Java SDK. A scope stores data attached to captured events, such as context, and can be inherited for a particular part of an application’s work.

In plain words
What is it for?
Use it when changing event context, managing scope lifecycles, working with threads or requests, or migrating older Hub-based code.
Why use it?
It helps developers control which context is attached to which events and understand the transition from the older Hub API to scopes.

Cursor rule for Cursor

About the project

getsentry/sentry-java is a Java and Android software development kit for sending application errors, events, and diagnostic information to Sentry. It is used by developers working with Java, Android, Kotlin, and other JVM-based applications to monitor software behavior. The catalogue rules, skills, instructions, and setting support workflows around this SDK.

getsentry/sentry-java · 1,349 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/getsentry/sentry-java/scopes
Clone the repo
git clone --depth 1 https://github.com/getsentry/sentry-java

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for scopes

README.md
[![agentmods](https://agentmods.dev/badge/rules/getsentry/sentry-java/scopes.svg)](https://agentmods.dev/rules/getsentry/sentry-java/scopes)
Your own site
<a href="https://agentmods.dev/rules/getsentry/sentry-java/scopes"><img src="https://agentmods.dev/badge/rules/getsentry/sentry-java/scopes.svg" alt="Measured on agentmods" height="20"></a>
Per session 7 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,710 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00007 $0.01710
Opus 5 $0.00003 $0.00855
Sonnet 5 $0.00001 $0.00342
Haiku 4.5 $0.00001 $0.00171

Measured yesterday against content hash fbb2cb6076b3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

scopes scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/scopes.mdc · 127 lines

How it starts

The opening of the file, as written. The whole thing — 127 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Java SDK Hubs and Scopes

Scopes

Scopes implements IScopes and manages three Scope instances, global, isolation and current scope. For some data, all three Scope instances are combined, for others, a certain one is used exclusively and for some we look at each scope in a certain order and use the data of the first scope that has the data set. This logic is contained in CombinedScopeView. Data itself is stored on Scope instances. Scopes also has a parent field, linking the Scopes it was forked off of and a creator String, explaining why it was forked.

Hub

Up until major version 7 of the Java SDK the IHub interface was a central part of the SDK. In major version 8 we replaced the IHub interface with IScopes. IHub has been deprecated. While there is some bridging code in place to allow for easier migration, we are planning to remove it in an upcoming major.

Scope Types

We have introduced some new Scope types in the SDK, allowing for better control over what data is attached where. Previously there was a stack of scopes that was pushed and popped. Instead we now fork scopes for a given lifecycle and then restore the previous scopes. Since Hub is gone, it is also never cloned anymore. Separation of data now happens through the different scope types while making it easier to manipulate exactly what you need without having to attach data at the right time to have it apply where wanted.

Global Scope

Global scope is attached to all events created by the SDK. It can also be modified before Sentry.init has been called. It can be manipulated using Sentry.configureScope(ScopeType.GLOBAL, (scope) -> { ... }).

Global scope can be retrieved from Scopes via getGlobalScope. It can also be retrieved directly via Sentry.getGlobalScope.

Isolation Scope

Isolation scope can be used e.g. to attach data to all events that come up while handling an incoming request. It can also be used for other isolation purposes. It can be manipulated using Sentry.configureScope(ScopeType.ISOLATION, (scope) -> { ... }). The SDK automatically forks isolation scope in certain cases like incoming requests, CRON jobs, Spring @Async and more.

Read the full file on GitHub · 127 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 127 lines · 7 tokens per session scan A fbb2cb6076b3

Subscribe to this mod's changes

scopes is a cursor rule published in the GitHub repository getsentry/sentry-java (1,349 stars, last pushed today), licensed MIT. It adds 7 tokens to every session and 1,710 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.