sentry-cocoa / Sources
AGENTS.md1.1k starsChanged 3 months agoMITView on GitHub
Scope: Sources/**. Also follow root instructions.
Trending
Quiet this year.thin dataabout the whole repository
Who's talking about getsentry/sentry-cocoa
- getsentry/sentry-react-native“(ios only) codepush.restartApp triggers invalid OutOfMemory errors”GitHub · Oct 13, 2021 · 15 reactions
- expo/expo“[SDK 51] Xcode 16 compilation fails on pegged Sentry version”GitHub · Jul 2, 2024 · 14 reactions
- getsentry/sentry-java“JVM Profiling”GitHub · Apr 1, 2023 · 14 reactions
- getsentry/sentry-react-native“missing ucontext64_t type Xcode Version 16.0 (16A242d)”GitHub · Sep 18, 2024 · 8 reactions
- getsentry/sentry-dotnet“Feature: Session Replay support for .NET MAUI”GitHub · Jan 30, 2023 · 8 reactions
The biggest 5 of 13 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 13
Talked about on GitHub (13 times).
On GitHub · 13
- Oct 13, 2021(ios only) codepush.restartApp triggers invalid OutOfMemory errors — getsentry/sentry-react-native15 reactions · 77 comments
- Jul 2, 2024[SDK 51] Xcode 16 compilation fails on pegged Sentry version — expo/expo14 reactions · 12 comments
- Apr 1, 2023JVM Profiling — getsentry/sentry-java14 reactions · 18 comments
- Sep 18, 2024missing ucontext64_t type Xcode Version 16.0 (16A242d) — getsentry/sentry-react-native8 reactions · 2 comments
- Jan 30, 2023Feature: Session Replay support for .NET MAUI — getsentry/sentry-dotnet8 reactions · 9 comments
8 more on GitHub
- Apr 16, 2025RCN Fetch failure: cannot parse response — firebase/firebase-ios-sdk6 reactions · 22 comments
- Nov 4, 2020Version 2.0.0 not building with use_frameworks — getsentry/sentry-react-native6 reactions · 4 comments
- Mar 25, 2024Apple privacy manifest requirements (File timestamp, System boot time & Disk space) — getsentry/sentry-react-native5 reactions · 8 comments
- Mar 25, 2024feat(replay): Add Mobile Replay Alpha — getsentry/sentry-react-native4 reactions · 8 comments
- Oct 22, 2025Session Replay for iOS — getsentry/sentry-dotnet3 reactions · 2 comments
- Sep 24, 2024Public API for manual replay control — getsentry/sentry3 reactions · 10 comments
- Feb 1, 2024[Epic] Mobile Session Replay — getsentry/sentry3 reactions · 2 comments
- Nov 20, 2023Tracing: W3C Trace Context Support — getsentry/team-sdks3 reactions · 9 comments
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- develop-docs/AGENTS.mdAGENTS.md
- .github/AGENTS.mdAGENTS.md
- scripts/AGENTS.mdAGENTS.md
- TestApps/AGENTS.mdAGENTS.md
- Tests/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- relay-conformance-auditSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
37 rules. About 0 are common, 13 are distinctive, and 24 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
24
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
Prefer Swift for new code when target boundaries allow it
- Very specific: line 8
Use [[Class alloc] init], not [Class new]
- Distinctive: line 14
Prefer protocol-oriented design when it improves testability or composition
- Distinctive: line 15
Follow the Swift API Design Guidelines
- Very specific: line 16
Default to internal and expose only intentional SDK API as public
- Very specific: line 17
Prefer private over fileprivate
- Very specific: line 19
Do not put an @objc extension in a file by itself.
- Distinctive: line 23
Never let the SDK crash the host app
- Very specific: line 25
Prefer Result<T, Error> or optional returns over throwing for internal APIs
- Very specific: line 27
Always use explicit capture lists when capturing self
- Very specific: line 28
Prefer [weak self] with guard let self for closures stored by the SDK
- Very specific: line 32
Prefer SentryDependencyContainer providers for SDK-owned dependencies
- Very specific: line 33
Use getLazyVar or getOptionalLazyVar for lazily-created defaults
- Distinctive: line 35
Do not add static shared service singletons
- Very specific: line 36
Put lifecycle-owned shared services in SentryDependencyContainer
- Very specific: line 37
When process-lifetime hooks require global access, use a narrow proxy with synchronized weak lifecycle targets, following …
- Distinctive: line 42
Add headerdocs for public API
- Distinctive: line 46
Do not remove or rename public symbols without deprecating them with migration guidance
- Very specific: line 48
Do not add @objc, NSObject inheritance, NS_SWIFT_NAME, or Objective-C wrappers unless an existing contract or identified consumer requires …
- Very specific: line 49
Use @_spi(Private) for unstable API consumed by hybrid SDKs
- Very specific: line 50
Keep @_spi(Private) out of public headers
- Very specific: line 51
Use SENTRY_NO_INIT for types that must not be publicly instantiated
- Very specific: line 52
Follow develop-docs/SENTRY-OBJC.md for wrappers and API placement
- Distinctive: line 56
Use compile-time gates for code that cannot compile or link on a target, not for ordinary runtime behavior
- Very specific: line 60
Keep Swift, Objective-C, and SentryObjC declaration and implementation gates aligned
- Very specific: line 62
Use #available or @available for runtime OS availability only after the code can compile with the oldest supported Xcode
- Distinctive: line 63
When newer SDK symbols are absent from older Xcode headers, combine runtime availability with a compile-time gate or dynamic lookup instead …
- Very specific: line 67
Follow SentryNetworkTracker.swift when a service needs protocol-based mocking without retaining the abstraction in release builds
- Distinctive: line 71
Keep consumers typed against those shared names so test, debug, and release builds use the same call sites
- Very specific: line 76
Use SentryMutex<T> for new Swift mutable state
- Very specific: line 78
Do not use NSLock, NSRecursiveLock, or legacy synchronized helpers for new Swift code
- Very specific: line 80
Use @synchronized(self) for Objective-C mutable state in scope, hub, and client code
- Very specific: line 81
Prefer SentryDispatchQueueWrapper over raw queues for testability
- Distinctive: line 82
Never do synchronous work on the main thread in production paths
- Distinctive: line 86
Check upstream KSCrash when investigating relevant bugs
- Distinctive: line 88
Do not allocate heap memory, acquire locks, or send Objective-C messages in signal handlers
- Very specific: line 91
Treat pthread_self() as an explicit accepted exception to strict signal safety
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md 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.
Files
Sources
Scope:
Sources/**. Also follow root instructions.
Objective-C
- Prefer Swift for new code when target boundaries allow it
- Use
[[Class alloc] init], not[Class new] - Wrap headers with
NS_ASSUME_NONNULL_BEGINandNS_ASSUME_NONNULL_END - Mark nullable parameters and properties explicitly
Swift
- Prefer protocol-oriented design when it improves testability or composition
- Follow the Swift API Design Guidelines
- Default to
internaland expose only intentional SDK API aspublic - Prefer
privateoverfileprivate - Mark classes
finalunless designed for subclassing - Do not put an
@objcextension in a file by itself; static linkers strip those object files. Add a dummy@objcNSObjectsubclass in the same file and reference it fromSentrySDKInternal(seePlaceholderProcessInfoClass). Enforced bystandalone_objc_extensioninlinters/SwiftLintCustomRules
Error Handling and Closures
- Never let the SDK crash the host app
- Wrap public entry points in
do/catchor equivalent - Prefer
Result<T, Error>or optional returns over throwing for internal APIs - Log production errors through
SentryLoginstead of assertions - Always use explicit capture lists when capturing
self - Prefer
[weak self]withguard let selffor closures stored by the SDK
Dependencies and Shared Access
- Prefer
SentryDependencyContainerproviders for SDK-owned dependencies - Use
getLazyVarorgetOptionalLazyVarfor lazily-created defaults - Override dependencies through
SentryDependencyContainer.sharedInstance()in tests - Do not add static shared service singletons
- Put lifecycle-owned shared services in
SentryDependencyContainer - When process-lifetime hooks require global access, use a narrow proxy with synchronized weak lifecycle targets, following
SentryNetworkTrackerProxy
Comments
- Comment non-obvious rationale, workarounds, and gotchas, not visible behavior
- Add headerdocs for public API
Public API
- Do not remove or rename public symbols without deprecating them with migration guidance
- Design new public API Swift-first
- Do not add
@objc,NSObjectinheritance,NS_SWIFT_NAME, or Objective-C wrappers unless an existing contract or identified consumer requires Objective-C support - Use
@_spi(Private)for unstable API consumed by hybrid SDKs - Keep
@_spi(Private)out of public headers - Use
SENTRY_NO_INITfor types that must not be publicly instantiated - Follow
develop-docs/SENTRY-OBJC.mdfor wrappers and API placement
Conditional Compilation
- Use compile-time gates for code that cannot compile or link on a target, not for ordinary runtime behavior
- In Swift, use
os(...),targetEnvironment(...), andcanImport(...)for platform and module capabilities - Gate UI code by both supported platforms and
!SENTRY_NO_UI_FRAMEWORK - In Objective-C and C/C++, prefer capability macros from
SentryDefines.handSentryProfilingConditionals.h, includingSENTRY_HAS_UIKIT,SENTRY_TARGET_REPLAY_SUPPORTED, andSENTRY_TARGET_PROFILING_SUPPORTED - Keep Swift, Objective-C, and
SentryObjCdeclaration and implementation gates aligned - Preserve older Xcode compatibility with
#if swift(>=...), compiler feature probes fromSentryCompiler.h, andcanImportor__has_includechecks - Use
#availableor@availablefor runtime OS availability only after the code can compile with the oldest supported Xcode - When newer SDK symbols are absent from older Xcode headers, combine runtime availability with a compile-time gate or dynamic lookup instead of referencing the symbol directly
Conditional Service Protocol Stripping
- Follow
SentryNetworkTracker.swiftwhen a service needs protocol-based mocking without retaining the abstraction in release builds - Under
#if SENTRY_TEST || SENTRY_TEST_CI || DEBUG, define the service protocol, conform the concrete service, and narrow its dependency protocols for mock injection - Under
#else, typealias the service protocol name to the concrete generic implementation and its dependency protocol name toSentryDependencyContainer - This strips the protocol abstraction from release builds while preserving the same dependency-facing names in every configuration
- Keep consumers typed against those shared names so test, debug, and release builds use the same call sites
Thread Safety
- Assume public methods can be called from arbitrary queues
- Use
SentryMutex<T>for new Swift mutable state - Group related protected values in a private
Statestruct - Do not use
NSLock,NSRecursiveLock, or legacysynchronizedhelpers for new Swift code - Refactor reentrant locking before adopting non-recursive
SentryMutex - Use
@synchronized(self)for Objective-C mutable state in scope, hub, and client code - Prefer
SentryDispatchQueueWrapperover raw queues for testability - Never do synchronous work on the main thread in production paths
SentryCrash
- Check upstream KSCrash when investigating relevant bugs
- Signal handlers must remain async-signal-safe
- Do not allocate heap memory, acquire locks, or send Objective-C messages in signal handlers
- Accepted signal-handler operations include
write(),vsnprintf,strerror_r, C11 atomics, andSENTRY_ASYNC_SAFE_LOG_*macros - Bounds-check fixed buffers, validate indices, and use
snprintfinstead ofsprintf - Treat
pthread_self()as an explicit accepted exception to strict signal safety
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
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.

