agentleFS
SentryKnown publishergetsentry/sentry-cocoa/Sources/AGENTS.md

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

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-cocoa repository that our weekly crawl found: only 13 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about getsentry/sentry-cocoa

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

8 more on GitHub
  • 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.

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
  1. Distinctive:

    Prefer Swift for new code when target boundaries allow it

    line 7
  2. Very specific:

    Use [[Class alloc] init], not [Class new]

    line 8
  3. Distinctive:

    Prefer protocol-oriented design when it improves testability or composition

    line 14
  4. Distinctive:

    Follow the Swift API Design Guidelines

    line 15
  5. Very specific:

    Default to internal and expose only intentional SDK API as public

    line 16
  6. Very specific:

    Prefer private over fileprivate

    line 17
  7. Very specific:

    Do not put an @objc extension in a file by itself.

    line 19
  8. Distinctive:

    Never let the SDK crash the host app

    line 23
  9. Very specific:

    Prefer Result<T, Error> or optional returns over throwing for internal APIs

    line 25
  10. Very specific:

    Always use explicit capture lists when capturing self

    line 27
  11. Very specific:

    Prefer [weak self] with guard let self for closures stored by the SDK

    line 28
  12. Very specific:

    Prefer SentryDependencyContainer providers for SDK-owned dependencies

    line 32
  13. Very specific:

    Use getLazyVar or getOptionalLazyVar for lazily-created defaults

    line 33
  14. Distinctive:

    Do not add static shared service singletons

    line 35
  15. Very specific:

    Put lifecycle-owned shared services in SentryDependencyContainer

    line 36
  16. Very specific:

    When process-lifetime hooks require global access, use a narrow proxy with synchronized weak lifecycle targets, following …

    line 37
  17. Distinctive:

    Add headerdocs for public API

    line 42
  18. Distinctive:

    Do not remove or rename public symbols without deprecating them with migration guidance

    line 46
  19. Very specific:

    Do not add @objc, NSObject inheritance, NS_SWIFT_NAME, or Objective-C wrappers unless an existing contract or identified consumer requires …

    line 48
  20. Very specific:

    Use @_spi(Private) for unstable API consumed by hybrid SDKs

    line 49
  21. Very specific:

    Keep @_spi(Private) out of public headers

    line 50
  22. Very specific:

    Use SENTRY_NO_INIT for types that must not be publicly instantiated

    line 51
  23. Very specific:

    Follow develop-docs/SENTRY-OBJC.md for wrappers and API placement

    line 52
  24. Distinctive:

    Use compile-time gates for code that cannot compile or link on a target, not for ordinary runtime behavior

    line 56
  25. Very specific:

    Keep Swift, Objective-C, and SentryObjC declaration and implementation gates aligned

    line 60
  26. Very specific:

    Use #available or @available for runtime OS availability only after the code can compile with the oldest supported Xcode

    line 62
  27. Distinctive:

    When newer SDK symbols are absent from older Xcode headers, combine runtime availability with a compile-time gate or dynamic lookup instead …

    line 63
  28. Very specific:

    Follow SentryNetworkTracker.swift when a service needs protocol-based mocking without retaining the abstraction in release builds

    line 67
  29. Distinctive:

    Keep consumers typed against those shared names so test, debug, and release builds use the same call sites

    line 71
  30. Very specific:

    Use SentryMutex<T> for new Swift mutable state

    line 76
  31. Very specific:

    Do not use NSLock, NSRecursiveLock, or legacy synchronized helpers for new Swift code

    line 78
  32. Very specific:

    Use @synchronized(self) for Objective-C mutable state in scope, hub, and client code

    line 80
  33. Very specific:

    Prefer SentryDispatchQueueWrapper over raw queues for testability

    line 81
  34. Distinctive:

    Never do synchronous work on the main thread in production paths

    line 82
  35. Distinctive:

    Check upstream KSCrash when investigating relevant bugs

    line 86
  36. Distinctive:

    Do not allocate heap memory, acquire locks, or send Objective-C messages in signal handlers

    line 88
  37. Very specific:

    Treat pthread_self() as an explicit accepted exception to strict signal safety

    line 91

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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_BEGIN and NS_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 internal and expose only intentional SDK API as public
  • Prefer private over fileprivate
  • Mark classes final unless designed for subclassing
  • Do not put an @objc extension in a file by itself; static linkers strip those object files. Add a dummy @objc NSObject subclass in the same file and reference it from SentrySDKInternal (see PlaceholderProcessInfoClass). Enforced by standalone_objc_extension in linters/SwiftLintCustomRules

Error Handling and Closures

  • Never let the SDK crash the host app
  • Wrap public entry points in do/catch or equivalent
  • Prefer Result<T, Error> or optional returns over throwing for internal APIs
  • Log production errors through SentryLog instead of assertions
  • Always use explicit capture lists when capturing self
  • Prefer [weak self] with guard let self for closures stored by the SDK

Dependencies and Shared Access

  • Prefer SentryDependencyContainer providers for SDK-owned dependencies
  • Use getLazyVar or getOptionalLazyVar for 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, NSObject inheritance, 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_INIT for types that must not be publicly instantiated
  • Follow develop-docs/SENTRY-OBJC.md for 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(...), and canImport(...) 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.h and SentryProfilingConditionals.h, including SENTRY_HAS_UIKIT, SENTRY_TARGET_REPLAY_SUPPORTED, and SENTRY_TARGET_PROFILING_SUPPORTED
  • Keep Swift, Objective-C, and SentryObjC declaration and implementation gates aligned
  • Preserve older Xcode compatibility with #if swift(>=...), compiler feature probes from SentryCompiler.h, and canImport or __has_include checks
  • Use #available or @available for 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.swift when 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 to SentryDependencyContainer
  • 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 State struct
  • Do not use NSLock, NSRecursiveLock, or legacy synchronized helpers 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 SentryDispatchQueueWrapper over 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, and SENTRY_ASYNC_SAFE_LOG_* macros
  • Bounds-check fixed buffers, validate indices, and use snprintf instead of sprintf
  • Treat pthread_self() as an explicit accepted exception to strict signal safety

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.