Skip to content

Commit ff7a26a

Browse files
antonisclaude
andcommitted
docs: Revamp AGENTS.md with boundaries, skills index, and stack framing
Address #6638. Add the three high-value sections the "great AGENTS.md" checklist calls for and that were missing: a three-tier ✅/⚠️/🚫 Boundaries section, a Skills-load-on-demand index, and a hybrid-SDK Stack framing that points at live version sources rather than copying rot-prone version strings. Fix a drifted diagnostics example (logger -> debug) and add a skill-precedence pointer in packages/core. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent fcb71ca commit ff7a26a

2 files changed

Lines changed: 57 additions & 6 deletions

File tree

AGENTS.md

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
# AGENTS.md
22

3-
Sentry React Native SDK — monorepo using yarn workspaces with a single package at `packages/core`.
3+
Sentry React Native SDK — a **hybrid SDK**: a TypeScript/JS layer on top that wraps the native **sentry-cocoa** (iOS) and **sentry-android/java** SDKs through a JS↔native bridge. Monorepo using yarn workspaces; the SDK itself is the `packages/core` package.
4+
5+
## Stack
6+
7+
- **Published packages:** `@sentry/react-native` (`packages/core`, the SDK) + companion `@sentry/expo-upload-sourcemaps`; yarn 4 workspaces.
8+
- **Wraps native SDKs:** sentry-cocoa (iOS) + sentry-android/java (Android) through the JS↔native bridge.
9+
- **Hosts:** React Native on **both** the New (TurboModule/Fabric) and Old (bridge) Architecture, plus Expo and React.
10+
- **Exact versions** (don't copy them here — they rot): JS deps and host peer ranges in [`packages/core/package.json`](packages/core/package.json); the bundled native SDK versions per release in [`SDK-VERSIONS.md`](SDK-VERSIONS.md) (regenerated each release by `craft-pre-release.sh`).
11+
12+
Changes to the wrapped native SDKs can ripple to them and to downstream hybrid SDKs (Flutter, .NET/MAUI, Unity) — see *Cross-Platform Dependencies*.
413

514
## Agent Responsibilities
615

7-
- **Continuous Learning**: Document new patterns in the appropriate nested `AGENTS.md` file.
8-
- **Context Management**: After compaction, re-read `AGENTS.md` files relevant to your current task.
16+
- **Reach for a skill first.** For anything beyond a trivial edit, load the matching skill (see *Skills*) — it carries the deep, current guidance this file only indexes.
17+
- **Continuous Learning:** when you discover a durable pattern, record it in the nearest nested `AGENTS.md` (or the relevant skill), not inline in a PR.
18+
- **Context Management:** after compaction, re-read the `AGENTS.md` for the surface you're touching before continuing.
919

1020
## Setup
1121

@@ -32,6 +42,26 @@ yarn build
3242
| ObjC/C++ lint | `yarn lint:clang` |
3343
| Swift lint | `yarn lint:swift` |
3444

45+
## Boundaries
46+
47+
**✅ Always**
48+
- Run `yarn lint`, `yarn test`, and `yarn circularDepCheck` before calling a change done; regenerate the API report (`yarn api-report`) when the public surface moved.
49+
- Make a change work on **both** architectures (New + Old) and **both** platforms (iOS + Android) — a fix that only covers one is not done.
50+
- Gate any user data placed in events/breadcrumbs/spans/logs on `options.sendDefaultPii`.
51+
- Catch native errors at the bridge boundary and degrade — reject/log, never let them propagate.
52+
53+
**⚠️ Ask first**
54+
- Adding or changing any dependency, `.vscode` extension, GitHub Action, or native dependency — verify provenance first (load `code-guidelines`*Adding dependencies*).
55+
- Changing the public API (`packages/core/src/js/index.ts` barrel, exported options) or a codegen/bridge spec (`NativeRNSentry.ts`, `*NativeComponent.ts`) — these are breaking and need a deprecation path.
56+
- Changing CI workflows, release config, or anything under `scripts/`.
57+
58+
**🚫 Never**
59+
- Crash the host app — a native exception that reaches the app is the highest-severity failure this SDK can cause.
60+
- Break the public API or bridge ABI without a `@deprecated` migration path (an app can ship new JS against an older cached native binary).
61+
- Hand-edit generated files: `packages/core/etc/sentry-react-native.api.md` (regenerate it) or New-Architecture codegen output — regenerate, never edit by hand.
62+
- Add `CHANGELOG.md` noise for routine internal/CI/test/chore changes — the user-facing sections (`### Features`, `### Fixes`) are for user-visible changes. A genuinely notable internal change goes under the `### Internal` section instead, not among the user-facing entries.
63+
- Commit secrets, tokens, or DSNs.
64+
3565
## Commit Conventions
3666

3767
Follow conventional commit format: `<type>(<scope>): <subject>`
@@ -99,6 +129,21 @@ Changes may impact downstream SDKs. Coordinate with other teams when modifying n
99129
- **Inline comments** for complex logic only
100130
- Update `CHANGELOG.md` for user-visible changes
101131

132+
## Skills — load on demand
133+
134+
The deep, task-specific guidance lives in `.agents/skills/` (registered in `agents.toml`) and is loaded when you need it — this file is the always-on operating manual, the skills are the specialists. Reach for one **before** doing the matching work:
135+
136+
| Skill | Load it when |
137+
|-------|--------------|
138+
| `spec` | The *what* isn't pinned down yet — a fuzzy issue or idea to scope into acceptance criteria. Hands off to `design-first`. |
139+
| `design-first` | Starting a feature/integration, changing the public barrel, crossing the bridge, or changing a codegen spec — shape modules and seams before coding. |
140+
| `code-guidelines` | Implementing, refactoring, designing APIs, writing integrations, handling breaking changes, or adding dependencies. |
141+
| `test-guidelines` | Writing, modifying, or reviewing Jest tests, fixtures, and mocks. |
142+
| `review` | A three-axis (Standards / Spec / Correctness) pass on a branch or PR before opening or merging. |
143+
| `diagnosing-bugs` | A hard bug, flaky test, CI hang, native crash, or perf regression — builds a red-capable loop before hypothesizing. |
144+
145+
Warden's automated PR review and `agents.toml` also pull **remote** specialists (`security-review`, `gha-security-review`, `span-convention-review`, and more) — invoke those for depth beyond the local pass.
146+
102147
## Nested AGENTS.md Files
103148

104149
- [`packages/core/AGENTS.md`](packages/core/AGENTS.md) — TypeScript/JavaScript code style, testing, patterns

packages/core/AGENTS.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# packages/core — TypeScript/JavaScript SDK
22

3+
> **Depth lives in the skills.** The `code-guidelines` and `test-guidelines` skills (`.agents/skills/`) hold the authoritative, current guidance on code style, API/integration design, the bridge, and tests — load them before non-trivial work. This file covers the package's build/test commands, quick-reference conventions, and the **TurboModule subsystem**, which is documented nowhere else. Where a convention here overlaps a skill, the skill wins.
4+
35
## Build & Test
46

57
```bash
@@ -95,14 +97,18 @@ describe('MyComponent', () => {
9597

9698
## Common Patterns
9799

100+
> Diagnostics use **`debug`** from `@sentry/core`, not `logger``logger` is the Logs API and emits log *events* (and recurses in the bridge hot path). See *TurboModule Instrumentation* below.
101+
98102
### Error Handling
99103

100104
```typescript
105+
import { debug } from '@sentry/core';
106+
101107
try {
102108
const result = await riskyOperation();
103109
return result;
104110
} catch (error) {
105-
logger.error('Operation failed', error);
111+
debug.error('Operation failed', error);
106112
// Don't throw - log and return fallback
107113
return fallbackValue;
108114
}
@@ -117,14 +123,14 @@ const { RNSentry } = NativeModules;
117123

118124
export async function nativeOperation(param: string): Promise<boolean> {
119125
if (!RNSentry) {
120-
logger.warn('Native module not available');
126+
debug.warn('Native module not available');
121127
return false;
122128
}
123129

124130
try {
125131
return await RNSentry.nativeOperation(param);
126132
} catch (error) {
127-
logger.error('Native operation failed', error);
133+
debug.error('Native operation failed', error);
128134
return false;
129135
}
130136
}

0 commit comments

Comments
 (0)