|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +Single source of truth for agents working in this repo. `CLAUDE.md` imports this file via |
| 4 | +`@AGENTS.md`, so Claude Code, Codex, and any other agent that reads `AGENTS.md` share the same |
| 5 | +instructions. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Behavioral Guidelines |
| 10 | + |
| 11 | +Behavioral guidelines to reduce common LLM coding mistakes. (Adapted from Andrej Karpathy's |
| 12 | +[CLAUDE.md](https://github.com/multica-ai/andrej-karpathy-skills/blob/main/CLAUDE.md).) |
| 13 | + |
| 14 | +**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment. |
| 15 | + |
| 16 | +### 1. Think Before Coding |
| 17 | +**Don't assume. Don't hide confusion. Surface tradeoffs.** |
| 18 | +- State your assumptions explicitly. If uncertain, ask. |
| 19 | +- If multiple interpretations exist, present them — don't pick silently. |
| 20 | +- If a simpler approach exists, say so. Push back when warranted. |
| 21 | +- If something is unclear, stop. Name what's confusing. Ask. |
| 22 | + |
| 23 | +### 2. Simplicity First |
| 24 | +**Minimum code that solves the problem. Nothing speculative.** |
| 25 | +- No features beyond what was asked. |
| 26 | +- No abstractions for single-use code. |
| 27 | +- No "flexibility" or "configurability" that wasn't requested. |
| 28 | +- If you write 200 lines and it could be 50, rewrite it. |
| 29 | + |
| 30 | +Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify. |
| 31 | + |
| 32 | +### 3. Surgical Changes |
| 33 | +**Touch only what you must. Clean up only your own mess.** |
| 34 | +- Don't "improve" adjacent code, comments, or formatting. |
| 35 | +- Don't refactor things that aren't broken. |
| 36 | +- Match existing style, even if you'd do it differently. |
| 37 | +- Remove imports/variables YOUR changes made unused; leave pre-existing dead code unless asked. |
| 38 | + |
| 39 | +The test: every changed line should trace directly to the request. |
| 40 | + |
| 41 | +### 4. Goal-Driven Execution |
| 42 | +**Define success criteria. Loop until verified.** |
| 43 | +- "Add validation" → "Write tests for invalid inputs, then make them pass." |
| 44 | +- "Fix the bug" → "Write a test that reproduces it, then make it pass." |
| 45 | + |
| 46 | +For multi-step tasks, state a brief plan with a verify step for each item. |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## Third-Party Library Docs |
| 51 | + |
| 52 | +For **any third-party library**, use the **context7** MCP to fetch up-to-date documentation rather |
| 53 | +than relying on training data, which lags real library APIs. If the context7 MCP server is not |
| 54 | +available, set it up: https://context7.com/install |
| 55 | + |
| 56 | +Key libraries in this repo to pull docs for: `react-native`, `react-native-builder-bob`, `turbo`, |
| 57 | +`@0xtrails/api`, `@0xtrails/wallet`, `0xtrails`. |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## Project Overview |
| 62 | + |
| 63 | +`@0xsequence/oms-react-native-sdk` is a React Native SDK (Turbo Module) for the OMS platform, |
| 64 | +bridging native iOS (Swift) and Android (Kotlin) SDKs to TypeScript. It exposes wallet auth (email |
| 65 | +OTP, OIDC redirect), transaction signing, balance queries, and session management to React Native |
| 66 | +and Expo apps. |
| 67 | + |
| 68 | +## Repository Structure |
| 69 | + |
| 70 | +- `src/` — TypeScript public API and native module bindings |
| 71 | +- `lib/` — built output (CommonJS, ESM, TypeScript declarations); generated by `yarn prepare` |
| 72 | +- `android/` — Kotlin native module |
| 73 | +- `ios/` — ObjC/Swift native module |
| 74 | +- `examples/sdk-example/` — React Native CLI example app |
| 75 | +- `examples/trails-actions-example/` — Trails demo with redirect auth |
| 76 | +- `examples/expo-example/` — standalone Expo example (not in Yarn workspace; uses `npm`) |
| 77 | +- `.github/workflows/` — CI (lint, typecheck, Android + iOS builds) |
| 78 | + |
| 79 | +## Tech Stack |
| 80 | + |
| 81 | +- **Language:** TypeScript (React Native Turbo Module; native layers in Kotlin + Objective-C/Swift) |
| 82 | +- **Package manager:** Yarn 4 (Berry) with workspaces; `examples/expo-example` uses `npm` standalone |
| 83 | +- **Build tool:** `react-native-builder-bob` + Turbo |
| 84 | +- **Linting:** ESLint 9 flat config + Prettier |
| 85 | +- **Node version:** v24.13.0 (see `.nvmrc`) |
| 86 | + |
| 87 | +## Build & Run |
| 88 | + |
| 89 | +```bash |
| 90 | +# Install dependencies |
| 91 | +yarn install |
| 92 | + |
| 93 | +# Build the library |
| 94 | +yarn prepare |
| 95 | + |
| 96 | +# Typecheck |
| 97 | +yarn typecheck |
| 98 | + |
| 99 | +# Lint |
| 100 | +yarn lint |
| 101 | + |
| 102 | +# Run SDK example (React Native CLI) |
| 103 | +yarn sdk-example start |
| 104 | + |
| 105 | +# Run Expo example (standalone — uses npm, not yarn workspace) |
| 106 | +cd examples/expo-example && npm install && npm start |
| 107 | +``` |
| 108 | + |
| 109 | +## Testing |
| 110 | + |
| 111 | +See **[TESTING.md](./TESTING.md)** for testing conventions, manual verification checklist, and the |
| 112 | +plan for when automated tests are added. |
| 113 | + |
| 114 | +## Documentation |
| 115 | + |
| 116 | +`API.md` at the repo root documents the full public TypeScript API for consumers. |
| 117 | + |
| 118 | +## Conventions |
| 119 | + |
| 120 | +- Commit messages and PR titles follow [Conventional Commits](https://www.conventionalcommits.org), |
| 121 | + e.g. `feat(auth): add OIDC refresh token support`. |
| 122 | +- The public API surface is documented in `API.md` — update it whenever `src/index.tsx` exports |
| 123 | + change. |
| 124 | +- The `lib/` directory is generated; never edit it by hand. |
| 125 | +- `examples/expo-example` is intentionally outside the Yarn workspace (`!examples/expo-example` in |
| 126 | + `package.json#workspaces`) — install its deps with `npm`, not `yarn`. |
| 127 | +- Native builds (Android/iOS) are slow; validate JS-layer changes with `yarn lint && yarn typecheck` |
| 128 | + first; leave full native builds to CI. |
| 129 | +- The `resolutions` block in `package.json` pins `0xtrails` / `@0xtrails/*` — update all three |
| 130 | + entries together when bumping the trails version. |
| 131 | +- Pre-release versions use the `0.x.y-alpha.N` scheme. Publishing steps are in `README.md`. |
| 132 | + |
| 133 | +## CI/CD |
| 134 | + |
| 135 | +Two workflows in `.github/workflows/`: |
| 136 | +- **`ci.yml`** — runs on pull requests, workflow dispatch, and pushes to `master`: lint, typecheck, |
| 137 | + library build, Android build, iOS build. |
| 138 | +- **`quick-checks.yml`** — runs on push to non-master branches: lint + typecheck only. |
| 139 | + |
| 140 | +Pull requests run full CI, including native builds. If the native layer changed, make sure the |
| 141 | +Android and iOS PR checks pass before merging; validate locally when you need faster feedback. |
| 142 | + |
| 143 | +## Common Pitfalls |
| 144 | + |
| 145 | +- Running `yarn` inside `examples/expo-example` will fail — it's not a Yarn workspace member. Use |
| 146 | + `npm` there, or `yarn expo-example <script>` from the root. |
| 147 | +- `yarn prepare` regenerates `lib/` — if builds look stale, run `yarn clean && yarn prepare`. |
| 148 | +- The podspec resolves `oms-client-swift-sdk` and the Android module resolves |
| 149 | + `io.github.0xsequence:oms-client-kotlin-sdk` — bump native SDK versions in the podspec and |
| 150 | + `android/build.gradle` together. |
| 151 | +- Turbo cache can mask failures: if something seems wrong, run with `--force` to skip the cache. |
| 152 | +- Signed commits are required (enforced by branch protection) — configure `git commit -S` locally. |
| 153 | + |
| 154 | +## Maintenance Matrix |
| 155 | + |
| 156 | +| When this changes… | Also update… | |
| 157 | +|-------------------------------------------|-----------------------------------------------------------| |
| 158 | +| `src/index.tsx` exports | `API.md`, `lib/` (run `yarn prepare`) | |
| 159 | +| Native SDK version (Swift / Kotlin) | `OmsClientReactNativeSdk.podspec`, `android/build.gradle` | |
| 160 | +| `package.json` scripts or test commands | `TESTING.md`, `.github/workflows/ci.yml` | |
| 161 | +| Node version (`.nvmrc`) | `turbo.json#globalDependencies`, CI setup action | |
| 162 | +| `resolutions` (`0xtrails` / `@0xtrails/*`)| All three resolution entries together | |
| 163 | +| Repo structure (new top-level dirs) | `AGENTS.md` structure section | |
| 164 | +| Contributing workflow | `CONTRIBUTING.md`, `README.md` | |
0 commit comments