agentleFS
SentryKnown publishergetsentry/sentry-java/.cursor/rules/api.mdc

sentry-java / rules

Cursor rule1.4k starsChanged 7 months agoMITView on GitHub

Public API surface, binary compatibility, and common classes to modify

Trending

Quiet this year.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the getsentry/sentry-java repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about getsentry/sentry-java

The biggest 5 of 18 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 18

Talked about on GitHub (18 times).

On GitHub · 18

13 more on GitHub

The file

We split this api.mdc into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never edit .api files manually: Run ./gradlew apiDump to regenerate them.

    line 11
  2. Distinctive:

    When adding a new method that users can call (e.g.

    line 50
  3. Very specific:

    Add serialization/deserialization in the relevant data class or create a new one implementing JsonSerializable and JsonDeserializer

    line 70
  4. Very specific:

    Write tests for all implementations, especially Scope, Scopes, SentryTest, and any new data classes

    line 73

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
api.mdc
---
alwaysApply: false
description: Public API surface, binary compatibility, and common classes to modify
---
# Java SDK Public API

## API Compatibility

Public API is tracked via `.api` files generated by the [Binary Compatibility Validator](https://github.com/Kotlin/binary-compatibility-validator) Gradle plugin. Each module has its own file at `<module>/api/<module>.api`.

- **Never edit `.api` files manually.** Run `./gradlew apiDump` to regenerate them.
- `./gradlew check` validates current code against `.api` files and fails on unintended changes.
- `@ApiStatus.Internal` marks classes/methods as internal — they still appear in `.api` files but are not part of the public contract.
- `@ApiStatus.Experimental` marks API that may change in future versions.

## Key Public API Classes

### Entry Point

`Sentry` (`sentry` module) is the static entry point. Most public API methods on `Sentry` delegate to `getCurrentScopes()`. When adding a new method to `Sentry`, it typically calls through to `IScopes`.

### Interfaces

| Interface | Description |
|-----------|-------------|
| `IScope` | Single scope — holds data (tags, extras, breadcrumbs, attributes, user, contexts, etc.) |
| `IScopes` | Multi-scope container — manages global, isolation, and current scope; delegates capture calls to `SentryClient` |
| `ISpan` | Performance span — timing, tags, data, measurements |
| `ITransaction` | Top-level transaction — extends `ISpan` |

### Configuration

`SentryOptions` is the base configuration class. Platform-specific subclasses:
- `SentryAndroidOptions` — Android-specific options
- Integration modules may add their own (e.g. `SentrySpringProperties`)

See the `options` rule for how to add and wire up a new option.

### Internal Classes (Not Public API)

| Class | Description |
|-------|-------------|
| `SentryClient` | Sends events/envelopes to Sentry — receives captured data from `Scopes` |
| `SentryEnvelope` / `SentryEnvelopeItem` | Low-level envelope serialization |
| `Scope` | Concrete implementation of `IScope` |
| `Scopes` | Concrete implementation of `IScopes` |

## Adding New Public API

When adding a new method that users can call (e.g. a new scope operation), these classes typically need changes:

### Interfaces and Static API
1. `IScope` — add the method signature
2. `IScopes` — add the method signature (usually delegates to a scope)
3. `Sentry` — add static method that calls `getCurrentScopes()`

### Implementations
4. `Scope` — actual implementation with data storage
5. `Scopes` — delegates to the appropriate scope (global, isolation, or current based on `defaultScopeType`)
6. `CombinedScopeView` — defines how the three scope types combine for reads (merge, first-wins, or specific scope)

### No-Op and Adapter Classes
7. `NoOpScope` — no-op stub for `IScope`
8. `NoOpScopes` — no-op stub for `IScopes`
9. `ScopesAdapter` — delegates to `Sentry` static API
10. `HubAdapter` — deprecated bridge from old `IHub` API
11. `HubScopesWrapper` — wraps `IScopes` as `IHub`

### Serialization (if the data is sent to Sentry)
12. Add serialization/deserialization in the relevant data class or create a new one implementing `JsonSerializable` and `JsonDeserializer`

### Tests
13. Write tests for all implementations, especially `Scope`, `Scopes`, `SentryTest`, and any new data classes
14. No-op classes typically don't need separate tests unless they have non-trivial logic

## Protocol / Data Model Classes

Classes in the `io.sentry.protocol` package represent the Sentry event protocol. They implement `JsonSerializable` for serialization and have a companion `Deserializer` class implementing `JsonDeserializer`. When adding new fields to protocol classes, update both serialization and deserialization.

## Namespaced APIs

Newer features are namespaced under `Sentry.<feature>()` rather than added directly to `Sentry`. Each namespaced API has an interface, implementation, and no-op. Examples:

- `Sentry.logger()` → `ILoggerApi` / `LoggerApi` / `NoOpLoggerApi` (structured logging, `io.sentry.logger` package)
- `Sentry.metrics()` → `IMetricsApi` / `MetricsApi` / `NoOpMetricsApi` (metrics)

Options for namespaced features are similarly nested under `SentryOptions`, e.g. `SentryOptions.getMetrics()`, `SentryOptions.getLogs()`.

These APIs may share infrastructure like the type system (`SentryAttributeType.inferFrom()`) — changes to shared components (e.g. attribute types) may require updates across multiple namespaced APIs.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.