You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Generating examples apps using Cursor](#generating-example-apps-using-cursor)
24
25
-[Using code examples in the docs site](#using-code-examples-in-the-docs-site)
25
-
-[Generating Tutorials and Metadata](#generating-tutorials-and-metadata)
26
+
-[Generating Tutorials and Metadata with cursor](#generating-tutorials-and-metadata-with-cursor)
26
27
27
28
<hr />
28
29
29
30
# Introduction
30
31
31
32
The example apps in this examples directory are compiled and tested as part of our CI CD pipeline. The goal of this is to ensure the examples found here are always able to run against the latest version of the Immutable Typescript SDK.
32
33
33
-
Selected portions of code from these example apps are then displayed as code snippets in our docs site, which means our code snippets in the docs are inherently always accurate as well. How to include the code from here in the docs site is explained below.
34
+
Selected portions of code from these example apps are then displayed as code snippets in our docs site, which means our code snippets in the docs are inherently always accurate as well. How to include the code from here in the docs site is explained below.
34
35
35
36
These example apps can also be used directly as a reference and run locally to test and develop with.
36
37
@@ -325,6 +326,95 @@ Run your tests
325
326
```bash
326
327
pnpm test
327
328
```
329
+
330
+
# Generating example apps using cursor
331
+
332
+
1) Open the product folder under /examples/{product}/_prompts
333
+
334
+
2) Under the {product}/_prompts directory, open the example-app-2-add-feature.txt file.
335
+
336
+
3) Copy all of the content in the example-app-2-add-feature.txt file.
337
+
338
+
4) Paste it on to Cursor. Make sure that you're using Agent mode and the model to be used is Claude 3.7 (Thinking)
339
+
340
+
5) After pasting the prompt, in the chat window you can type:
341
+
app name: <app name(if exists)>
342
+
feature name: <nameofthefeature>
343
+
and cursor will generate the feature page in the given app.
344
+
345
+
6) To update an existing feature, the prompt will identify if the given <featurename> exists in the <appname> directory. If it does, it will check if
346
+
the <featurename> has the manually-edited field value as true in the feature.json file.
347
+
348
+
7) If the flag above exists, it will ask for a confirmation, otherwise, it will use best practices to update the existing feature page.
349
+
350
+
8) Once the feature page is completed, under the same directory as example-app-2-add-feature.txt, open example-app-3-fix-ui.txt and copy all of its contents.
351
+
352
+
9) Paste it on to a new Cursor window and in the chat window you can type:
353
+
354
+
feature name: <nameofthefeature>
355
+
356
+
Here, cursor will check and fix pages with styling issues to ensure that it looks consistent with other example apps.
357
+
358
+
10) Once the styling changes have been made, under the same directory as example-app-2-add-feature.txt, open example-app-4-testing.txt and copy all of its contents.
359
+
360
+
11) Paste it on to a new Cursor window and in the chat window you can type:
361
+
app name: <app name(if exists)>
362
+
feature name: <nameofthefeature>
363
+
364
+
12) Cursor will then run tests and build until everything passes and renders properly.
365
+
366
+
13) When the prompt is done running, make sure to double check if the tests are comprehensive enough and also check if the feature page was built properly using best practices.
367
+
368
+
14) Run `pnpm dev` and check every page's styling. If something looks off, you can manually fix it.
369
+
370
+
## If an App Doesn't Exist Yet
371
+
372
+
You must create the app first by going to the example-app-1-create-app-template.txt file and paste it on to Cursor's chat window and use Agent Mode + Claude 3.7 Sonnet Thinking.
373
+
374
+
In the chat window, type in:
375
+
feature name: <name>
376
+
377
+
Then Cursor will build out the example app's setup, etc.
378
+
IF Cursor doesn't run build at the end, manually type on the chat window 'run build'.
379
+
380
+
IMPORTANT: For any prompts, if cursor is not done with its operations but it has reached 25 tool calls, you will need to manually type "continue" on the chat window for cursor to continue building.
381
+
382
+
## Understanding the Prompt Files
383
+
384
+
The example generation process uses three different prompt files, each with a specific purpose:
385
+
386
+
### example-app-1-create-app-template.txt
387
+
-**Purpose**: Creates the initial app structure and boilerplate
388
+
-**When to use**: Only when you need to create a completely new example app
389
+
-**What it does**: Sets up the project structure, configuration files, basic components, and placeholder pages
390
+
-**Output**: A functioning but minimal app with no implemented features
391
+
392
+
### example-app-2-add-feature.txt
393
+
-**Purpose**: Implements or updates a specific feature within an existing app
394
+
-**When to use**: After creating an app with example-app-1-create-app-template.txt, or when adding/updating features
395
+
-**What it does**: Creates or modifies the feature implementation with proper error handling, UI states, and best practices
396
+
-**Output**: A fully implemented feature page within the app structure
397
+
398
+
### example-app-3-fix-ui.txt
399
+
-**Purpose**: Apply styling changes to the given example app if possible to ensure styling consistency with other example apps
400
+
-**When to use**: After running example-app-2-add-feature.txt to implement a feature
401
+
-**What it does**: Modifies the example app's UI/UX to ensure that the app looks consistent with other example apps
402
+
-**Output**: A fully implemented feature page within the app structure with consistent UI/UX looks.
403
+
404
+
### example-app-4-testing.txt
405
+
-**Purpose**: Tests, validates, and fixes issues in the implementation
406
+
-**When to use**: After running example-app-2-add-feature.txt to implement a feature
407
+
-**What it does**: Runs tests, checks coverage, builds the app, and fixes any detected issues
408
+
-**Output**: A tested, validated feature ready for use
409
+
410
+
**Typical Workflow:**
411
+
1. Use example-app-1-create-app-template.txt to create a new app (only once per app)
412
+
2. Use example-app-2-add-feature.txt to implement each feature in the app
413
+
3. Use example-app-3-fix-ui.txt to fix the app's UI/UX styling and make it look consistent to other example apps.
414
+
4. Use example-app-4-testing.txt after each feature implementation to test and validate
415
+
5. Once you've generated the example app or feature, you should manually review the implementation and the UI. It's likely you will need to make some manual adjustments to get the app to function and look like our other example apps because the cursor can not reliably get it 100% correct.
416
+
6. Once you're happy with your example app or feature, you need to [re-run the tutorial generation prompt](#generating-tutorials-and-metadata-with-cursor) for your example app before creating your PR so the new example app or feature is piped into the docs site with it's corresponding tutorial.
417
+
328
418
# Using code examples in the docs site
329
419
330
420
Creating and using code snippets is relatively straight forward. You can pull in a whole file or by adding some comments you can pull in just a particular few lines of a file as necessary.
@@ -369,7 +459,6 @@ It's very simple to use the code snippet in the docs site, you just add a code b
369
459
````md
370
460
```tsx reference=examples/checkout/sdk-connect-with-nextjs/src/app/connect-with-metamask/page.tsx#get-wallet-allow-list title="Get the wallet allow list"
371
461
```
372
-
```
373
462
````
374
463
Or if you want to display the whole file just don't include a `#` label at the end of the file reference e.g.
375
464
@@ -416,9 +505,9 @@ Once your `docs` PR is merged, Netlify should automatically build and deploy the
416
505
417
506
If this happens you will need to log into the Netlify site, check the error and retry the build. Usually this will fix the deployment issue, otherwise follow up on the error message shown by Netlify.
418
507
419
-
# Generating Tutorials and Metadata
508
+
# Generating tutorials and metadata with cursor
420
509
421
-
Whenever you add a new example app, or update an existing example app, you can use the prompts in the `prompt.txt` files in each `examples/product` folder to generate the tutorials and metadata for the example apps using Cursor AI.
510
+
Whenever you add a new example app, or update an existing example app, you can use the prompts in the `tutorial-generation-generic.txt`OR `tutorial-generation-{product}.txt`files in each `examples/product/_prompts` folder to generate the tutorials and metadata for the example apps using Cursor AI.
422
511
423
512
These AI generated tutorials and metadata files are then piped through to the docs site in the CI/CD pipeline, where they are used to display the example apps and their code walkthroughs. If you don't follow these steps, your example app will not be displayed on the docs site.
424
513
@@ -431,7 +520,7 @@ Follow these steps to generate the tutorials and metadata for the example apps:
431
520
1. Delete the existing tutorial.md and metadata.json files in the example app you are wanting to generate the tutorials and metadata for.
432
521
2. Open the Composer window in Cursor IDE (Claude 3.7-sonnet-thinking).
433
522
3. Press the `+` button clear the context of the composer window.
434
-
4. Open the `prompt.txt` file in the examples/product folder you are wanting to generate the tutorials and metadata for e.g. `examples/passport/prompt.txt`.
523
+
4. Open the `tutorial-generation-generic.txt`OR `tutorial-generation-{product}.txt`file in the examples/product/_prompts folder you are wanting to generate the tutorials and metadata for e.g. `examples/passport/_prompts/tutorial-generation-generic.txt`.
435
524
5. Copy and pate the prompt into the composer window, or attach it as a file.
436
525
6. After adding the prompt, in the composer window, type `app name: <name of the example app>` e.g. `app name: login-with-nextjs` where the app name is the folder name of the example app in the examples/product folder you are wanting to generate the tutorials and metadata for.
437
526
7. Press enter and let the AI generate the tutorials and metadata.
0 commit comments