Skip to content

Commit 1abddb8

Browse files
authored
Committing AI guidelines and gitignore for local config stuff. (#280)
* Committing AI guidelines and gitignore for local config stuff. * Update uses of example setup * Committing AI guidelines and gitignore for local config stuff. * PR guidance * Additional tweaks to commands and AGENTS file --------- Co-authored-by: Evan Masseau <>
1 parent cf33b02 commit 1abddb8

File tree

11 files changed

+113
-18
lines changed

11 files changed

+113
-18
lines changed

.cursor/BUGBOT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
For context on this project, review `/AGENTS.md`.

.github/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/f
4242
To get started with the project, run the following in the root directory to install the required dependencies for each package:
4343

4444
```sh
45-
yarn example-setup
45+
yarn example setup
4646
```
4747

4848
And configure the pre-commit hooks with:
@@ -138,7 +138,7 @@ Our pre-commit hooks verify that the linter and tests pass when committing.
138138
The `package.json` file contains various scripts for common tasks:
139139

140140
- `yarn`: setup project by installing dependencies.
141-
- `yarn example-setup`: install dependencies for the example app
141+
- `yarn example setup`: install dependencies for the example app
142142
- `yarn typecheck`: type-check files with TypeScript.
143143
- `yarn lint`: lint files with ESLint.
144144
- `yarn test`: run unit tests with Jest.

.github/pull_request_template.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# Description
2-
<!-- Briefly describe the feature or bug that your pull request addresses, 1-2 sentences. -->
32

3+
<!-- Briefly describe the feature or bug that your pull request addresses, 1-2 sentences. -->
44

55
## Due Diligence
6+
67
<!-- Best practices before submitting, add additional notes below -->
8+
79
- [ ] I have tested this on a simulator/emulator or a physical device, on iOS and Android (if applicable).
810
- [ ] I have added sufficient unit/integration tests of my changes.
911
- [ ] I have adjusted or added new test cases to team test docs, if applicable.
1012
- [ ] I am confident these changes are implemented with feature parity across iOS and Android (if applicable).
1113

1214
## Release/Versioning Considerations
15+
1316
<!-- Help determine how this should be categorized for release, add additional notes below. -->
1417
<!-- Please add the planned version as a `milestone` label on this PR -->
18+
1519
- [ ] `Patch` Contains internal changes or backwards-compatible bug fixes.
1620
- [ ] `Minor` Contains changes to the public API.
1721
- [ ] `Major` Contains **breaking** changes.
@@ -20,15 +24,14 @@
2024
- [ ] This is planned work for an upcoming release.
2125
- If no, author or reviewer should account for this in a release plan, or describe why not below.
2226

23-
2427
## Changelog / Code Overview
25-
<!-- What was changed / added / removed and why. Attach screenshots or other supporting materials -->
2628

29+
<!-- What was changed / added / removed and why. Attach screenshots or other supporting materials -->
2730

2831
## Test Plan
29-
<!-- Provide reproducible testing steps. Link any artifacts, recordings, spreadsheets, etc. -->
3032

33+
<!-- Provide reproducible testing steps. Link any artifacts, recordings, spreadsheets, etc. -->
3134

3235
## Related Issues/Tickets
33-
<!-- Link to relevant Jira issues, Slack discussions, Google Docs -->
3436

37+
<!-- Link to relevant Jira issues, Slack discussions, Google Docs -->

.github/workflows/ios-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
6060
run: |
6161
export RCT_NEW_ARCH_ENABLED=${{ inputs.new-architecture }}
62-
yarn example-setup
62+
yarn example setup
6363
rm -f example/ios/.xcode.env.local
6464
6565
- name: Build example for iOS

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ android/keystores/debug.keystore
7878

7979
# generated by bob
8080
lib/
81+
82+
# Local AI settings files
83+
.claude

AGENTS.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# AI Agent Guidelines
2+
3+
This file provides guidance to AI coding agents (Claude Code, Cursor, GitHub Copilot, etc.) when
4+
working with code in this repository.
5+
6+
You should assume the role of a senior React Native developer with substantial hybrid app development experience
7+
in addition to a deep background in native development on Android and iOS.
8+
9+
You will be asked to help with code reviews, feature implementations, and debugging issues in this SDK.
10+
You prioritize code quality, maintainability, and adherence to the project's architecture and coding styles and standards.
11+
You create reusable code, searching for existing implementations first, and if you see conflicting
12+
or duplicative methods of doing the similar tasks, refactor common functionality into shared helpers/utilities.
13+
The experience of 3rd party developers integrating the SDK should be smooth, intuitive and as simple as possible.
14+
You prefer solutions using the most modern, practical and efficient approaches available in the React Native ecosystem.
15+
Always use up-to-date resources considering that React Native is an ever-changing landscape, old answers are often
16+
out of date or misleading. You avoid mistakes, and would rather answer that you don't know, or take more time
17+
researching than make something up. Cite your sources especially for anything with a modicum of uncertainty.
18+
19+
## Project Overview
20+
21+
This repository contains the Klaviyo React Native SDK, which provides a bridge between React Native applications
22+
and the native Klaviyo SDKs for iOS (Swift) and Android (Kotlin). The SDK enables key Klaviyo functionality including
23+
analytics tracking, push notifications, and in-app forms in React Native applications.
24+
25+
## Repository Structure
26+
27+
- `/src/`: TypeScript implementation of the React Native SDK
28+
- `index.tsx`: Main entry point exporting the Klaviyo interface
29+
- `*.ts`: API-specific implementations (Profile, Event, Push, Forms)
30+
- `/ios/`: Native iOS/Swift bridge implementation
31+
- `/android/`: Native Android/Kotlin bridge implementation
32+
- `/example/`: Example React Native app demonstrating SDK usage
33+
34+
## Development Guidelines
35+
36+
### Core Principles
37+
38+
1. **Type Safety**: All code should be fully typed with TypeScript. Any bridged data should be thoroughly validated.
39+
2. **Platform Consistency**: Keep API surface consistent across platforms
40+
3. **Error Handling**: Ensure proper error handling and propagation
41+
4. **Documentation**: Keep inline documentation current
42+
5. **Testing**: Update tests when changing functionality
43+
44+
### Native Bridge Development
45+
46+
- **iOS**: Objective-C and Swift bridge layer communicating to Swift SDK
47+
- **Android**: Kotlin module bridge communicating to Kotlin SDK
48+
49+
### Common Development Tasks
50+
51+
#### Building and Testing
52+
53+
```bash
54+
# Install dependencies
55+
yarn install
56+
57+
# Build TypeScript code
58+
yarn build
59+
60+
# Run TypeScript type-checking
61+
yarn typecheck
62+
63+
# Run linter
64+
yarn lint
65+
66+
# Run tests
67+
yarn test
68+
69+
# Install dependencies for running the example app
70+
yarn example setup
71+
```
72+
73+
#### Running Example App
74+
75+
```bash
76+
# Start Metro bundler
77+
yarn example start
78+
79+
# Run iOS example
80+
yarn example ios
81+
82+
# Run Android example
83+
yarn example android
84+
```
85+
86+
## Pull Requests
87+
88+
If prompted to create a pull request, favor starting it in draft unless asked otherwise.
89+
You **MUST** follow the pull request template used by this repository, including important details
90+
in the relevant subsections of the template.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ code to call out key setup steps, search for `iOS Installation Step` and `Androi
106106
To run the example app:
107107

108108
- Clone this repository
109-
- From the root directory, run `yarn example-setup`. This is an alias that will do the following:
109+
- From the root directory, run `yarn example setup`. This is an alias that will do the following:
110110
- Run `yarn install --immutable` from the root directory
111111
- Navigate to the `example` directory and run `bundle install`
112112
- Navigate to the `example/ios` directory and run `bundle exec pod install`
@@ -407,7 +407,6 @@ native code. Note that either of these approaches is sufficient to inform the Kl
407407

408408
2. **Native Notification Permission**:
409409
Follow instructions from our native SDK documentation to request permission from native code:
410-
411410
- [Android](https://github.com/klaviyo/klaviyo-android-sdk#collecting-push-tokens)
412411
- [iOS](https://github.com/klaviyo/klaviyo-swift-sdk?tab=readme-ov-file#request-push-notification-permission)
413412

Troubleshooting.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Android Troubleshooting
44

55
### `minSdkVersion` Issues
6+
67
We have seen projects, particularly on react-native versions `0.72.x` and `0.71.x`, that required a `minSdkVersion`
78
of `24`, despite the Klaviyo Android SDK supporting API 23+. If you encounter this, please file an issue in our
89
repository and provide version numbers of your react-native dependencies.
@@ -13,7 +14,6 @@ repository and provide version numbers of your react-native dependencies.
1314

1415
1. If you are seeing issues related to `minimum deployment target` when installing pods, you may need to update your
1516
minimum iOS version to 13.0 in your Podfile with one of the following strategies:
16-
1717
- Specify iOS version directly in the `Podfile`:
1818
```ruby
1919
MIN_IOS_OVERRIDE = '13.0'
@@ -24,6 +24,7 @@ repository and provide version numbers of your react-native dependencies.
2424
platform :ios, min_ios_version_supported
2525
```
2626
- Set the deployment target to 13.0 in XCode, and then pull `IPHONEOS_DEPLOYMENT_TARGET` from the XCode project:
27+
2728
```ruby
2829
#######
2930
# Read min iOS version from Xcode project and set as min iOS version for Podfile
@@ -64,10 +65,8 @@ There are many workarounds suggested in this issue's thread and a few other simi
6465
However, the workaround that worked for us involves intercepting the launch arguments in the app delegate and adding
6566
a key `UIApplicationLaunchOptionsURLKey`, which React Native expects to be present when calling the `Linking.getInitialURL()` listener.
6667
67-
6868
Here's a method to implement this workaround:
6969

70-
7170
```swift
7271
- (NSMutableDictionary *)getLaunchOptionsWithURL:(NSDictionary * _Nullable)launchOptions {
7372
NSMutableDictionary *launchOptionsWithURL = [NSMutableDictionary dictionaryWithDictionary:launchOptions];
@@ -88,7 +87,6 @@ Here's a method to implement this workaround:
8887
Ensure that this method is called from `application:didFinishLaunchingWithOptions:` before calling the superclass method with the
8988
modified launch arguments, like so:
9089

91-
9290
```swift
9391
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
9492
{
@@ -108,7 +106,7 @@ This implementation is included in the example app in this repo and can be used
108106
Make sure to use the URL scheme (rntest://) of the example app when testing.
109107

110108
### iOS APNS Token Troubleshooting
109+
111110
There is an open issue with [`@react-native-firebase/messaging`](https://github.com/invertase/react-native-firebase/issues/8022) where the SDK will uppercase any APNS token returned using `messaging().getAPNSToken()`.
112111
You can verify this by adding a log the `AppDelegate.m` file that prints the deviceToken (you will need to convert to a hex string).
113112
This might have no impact on your use case, but is something to consider when designing.
114-

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.3.1",
44
"private": true,
55
"scripts": {
6+
"setup": "(yarn install --immutable && bundle install && cd ios && bundle exec pod install)",
67
"android": "react-native run-android",
78
"ios": "react-native run-ios",
89
"start": "react-native start",

0 commit comments

Comments
 (0)