-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add /skills #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kieran-osgood-shopify
wants to merge
1
commit into
main
Choose a base branch
from
kieran-osgood/05-08-featadd/skills
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Checkout Kit Lifecycle Events | ||
|
|
||
| Use `SKILL.md` as the entrypoint for this skill. Read `references/guide.md` for shared lifecycle event guidance, then read the target platform file: `references/swift.md`, `references/android.md`, or `references/react-native.md`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| --- | ||
| name: checkout-kit-lifecycle-events | ||
| description: Use when implementing, migrating, or reviewing Checkout Kit lifecycle event handling, including completion, cancellation, failure, external links, and UCP-backed Checkout Protocol notifications. | ||
| --- | ||
|
|
||
| # Checkout Kit Lifecycle Events | ||
|
|
||
| Use this skill when the user needs to handle checkout lifecycle events, migrate callback/event-processor code, or wire protocol notifications into app state. | ||
|
|
||
| ## Start with local truth | ||
|
|
||
| Read these local files before suggesting code: | ||
|
|
||
| - `README.md` for current package and docs links. | ||
| - The target platform README: `swift/README.md`, `android/README.md`, or `react-native/README.md`. | ||
| - `protocol/services/shopping/embedded.openrpc.json` for protocol notifications and request methods. | ||
| - `protocol/schemas/` for UCP payload shape. | ||
| - `references/guide.md` for shared lifecycle event guidance. | ||
| - The platform sample for the target app: `references/swift.md`, `references/android.md`, or `references/react-native.md`. | ||
|
|
||
| Prefer local source over memory. Use Shopify docs only to confirm current public guidance: https://shopify.dev/docs/storefronts/mobile |
48 changes: 48 additions & 0 deletions
48
skills/checkout-kit-lifecycle-events/references/android.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Android | ||
|
|
||
| ```kotlin | ||
| import com.shopify.checkoutkit.CheckoutProtocol | ||
| import com.shopify.checkoutkit.DefaultCheckoutEventProcessor | ||
| import com.shopify.checkoutkit.ShopifyCheckoutKit | ||
| import com.shopify.checkoutkit.lifecycleevents.CheckoutCompletedEvent | ||
|
|
||
| val protocolClient = CheckoutProtocol.Client() | ||
| .on(CheckoutProtocol.ready) { payload -> | ||
| recordDelegations(payload.delegations) | ||
| } | ||
| .on(CheckoutProtocol.start) { checkout -> | ||
| hideLoadingShell(checkout) | ||
| } | ||
| .on(CheckoutProtocol.complete) { checkout -> | ||
| navigateToConfirmation(checkout) | ||
| } | ||
| .on(CheckoutProtocol.messagesChange) { checkout -> | ||
| renderCheckoutMessages(checkout.messages) | ||
| } | ||
| .on(CheckoutProtocol.lineItemsChange) { checkout -> | ||
| syncCartSummary(checkout.lineItems) | ||
| } | ||
| .on(CheckoutProtocol.buyerChange) { checkout -> | ||
| syncBuyerState(checkout.buyer) | ||
| } | ||
| .on(CheckoutProtocol.paymentChange) { checkout -> | ||
| syncPaymentState(checkout.payment) | ||
| } | ||
| .onOpenExternalUrl { uri -> | ||
| openExternalUrl(uri) | ||
| true | ||
| } | ||
|
|
||
| val processor = object : DefaultCheckoutEventProcessor(activity) { | ||
| override fun onCheckoutCompleted(event: CheckoutCompletedEvent) { | ||
| // Keep only if the app still needs legacy completion handling. | ||
| } | ||
| } | ||
|
|
||
| ShopifyCheckoutKit.present( | ||
| checkoutUrl = checkoutUrl, | ||
| context = activity, | ||
| checkoutEventProcessor = processor, | ||
| communicationClient = protocolClient, | ||
| ) | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Lifecycle Events Guide | ||
|
|
||
| ## Core Model | ||
|
|
||
| Lifecycle handling should connect checkout state changes to app-owned side effects: navigation, confirmation screens, loading UI, cart refreshes, external URL handling, and error UI. | ||
|
|
||
| Prefer protocol notifications where the platform exposes them. Keep legacy callbacks only when the platform still requires them or when the protocol does not expose the event needed by the app. | ||
|
|
||
| ## Protocol Events | ||
|
|
||
| Use protocol events as the source of truth when available: | ||
|
|
||
| - `ec.ready`: handshake and delegated capability discovery. | ||
| - `ec.start`: checkout is visible and interactive enough for host UI transitions. | ||
| - `ec.complete`: checkout completed; navigate or refresh order state. | ||
| - `ec.messages.change`: checkout warnings, errors, and informational messages changed. | ||
| - `ec.line_items.change`: line items changed. | ||
| - `ec.buyer.change`: buyer details changed. | ||
| - `ec.payment.change`: payment state changed. | ||
| - `ec.window.open_request`: checkout requests that the host open an external URL. | ||
|
|
||
| Do not assume every legacy callback has a one-to-one replacement. If a callback mixed several concerns, split it into protocol handlers and app-owned state transitions. | ||
|
|
||
| ## Platform Samples | ||
|
|
||
| Read the platform file for the target app: | ||
|
|
||
| - `references/swift.md` | ||
| - `references/android.md` | ||
| - `references/react-native.md` | ||
|
|
||
| ## Review Checklist | ||
|
|
||
| - Completion handling navigates or refreshes state exactly once. | ||
| - Cancellation and failure paths restore the host UI and preserve cart state. | ||
| - External links are handled intentionally. | ||
| - Protocol handlers update app state without duplicating legacy callback side effects. | ||
| - Web pixel events are not relayed to the native layer. | ||
| - Event payload handling does not assume personally identifiable information is present. |
44 changes: 44 additions & 0 deletions
44
skills/checkout-kit-lifecycle-events/references/react-native.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # React Native | ||
|
|
||
| Use this as the intended wrapper shape. Check the installed React Native package before copying names directly. | ||
|
|
||
| ```tsx | ||
| import {Linking} from 'react-native'; | ||
| import { | ||
| createCheckoutProtocolClient, | ||
| useShopifyCheckoutSheet, | ||
| } from '@shopify/checkout-kit'; | ||
|
|
||
| const shopifyCheckout = useShopifyCheckoutSheet(); | ||
|
|
||
| const checkoutClient = createCheckoutProtocolClient() | ||
| .on('ec.ready', ({delegate}) => { | ||
| recordDelegations(delegate); | ||
| }) | ||
| .on('ec.start', ({checkout}) => { | ||
| hideLoadingShell(checkout); | ||
| }) | ||
| .on('ec.complete', ({checkout}) => { | ||
| navigateToConfirmation(checkout); | ||
| }) | ||
| .on('ec.messages.change', ({checkout}) => { | ||
| renderCheckoutMessages(checkout.messages); | ||
| }) | ||
| .on('ec.line_items.change', ({checkout}) => { | ||
| syncCartSummary(checkout.line_items); | ||
| }) | ||
| .on('ec.buyer.change', ({checkout}) => { | ||
| syncBuyerState(checkout.buyer); | ||
| }) | ||
| .on('ec.payment.change', ({checkout}) => { | ||
| syncPaymentState(checkout.payment); | ||
| }) | ||
| .onOpenExternalUrl((url) => { | ||
| Linking.openURL(url); | ||
| return true; | ||
| }); | ||
|
|
||
| shopifyCheckout.present(checkoutUrl, { | ||
| protocolClient: checkoutClient, | ||
| }); | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Swift | ||
|
|
||
| ```swift | ||
| import ShopifyCheckoutKit | ||
| import UIKit | ||
|
|
||
| let checkout = ShopifyCheckoutKit.present(checkout: checkoutURL, from: viewController) | ||
| .onComplete { event in | ||
| navigateToConfirmation(event) | ||
| } | ||
| .onCancel { | ||
| handleCheckoutCancel() | ||
| } | ||
| .onFail { error in | ||
| renderCheckoutError(error) | ||
| } | ||
| .onLinkClick { url in | ||
| openExternalURL(url) | ||
| } | ||
| ``` | ||
|
|
||
| ```swift | ||
| final class AppCheckoutDelegate: CheckoutDelegate { | ||
| func checkoutDidComplete(event: CheckoutCompletedEvent) { | ||
| navigateToConfirmation(event) | ||
| } | ||
|
|
||
| func checkoutDidCancel() { | ||
| handleCheckoutCancel() | ||
| } | ||
|
|
||
| func checkoutDidFail(error: CheckoutError) { | ||
| renderCheckoutError(error) | ||
| } | ||
|
|
||
| func checkoutDidClickLink(url: URL) { | ||
| openExternalURL(url) | ||
| } | ||
| } | ||
|
|
||
| ShopifyCheckoutKit.present( | ||
| checkout: checkoutURL, | ||
| from: viewController, | ||
| delegate: AppCheckoutDelegate() | ||
| ) | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Present, Preload, and Invalidate Checkout | ||
|
|
||
| Use `SKILL.md` as the entrypoint for this skill. Read `references/guide.md` for shared lifecycle rules, then read the target platform file: `references/swift.md`, `references/android.md`, or `references/react-native.md`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| --- | ||
| name: checkout-kit-present-preload-invalidate | ||
| description: Use when implementing or reviewing Checkout Kit present, preload, and invalidate behavior across platforms, especially when deciding when to preload after cart changes and when to clear cached checkout state. | ||
| --- | ||
|
|
||
| # Present, Preload, and Invalidate Checkout | ||
|
|
||
| Use this skill when the user is wiring Checkout Kit into a cart or checkout flow, improving checkout performance, or debugging stale checkout state. | ||
|
|
||
| ## Start with local truth | ||
|
|
||
| Read these local files before suggesting code: | ||
|
|
||
| - `README.md` for current package and docs links. | ||
| - The target platform README: `swift/README.md`, `android/README.md`, or `react-native/README.md`. | ||
| - Sample apps for realistic cart and checkout wiring. | ||
| - The platform source for exact function names and configuration shape. | ||
| - `references/guide.md` for lifecycle rules, platform-neutral flow, and review checklist. | ||
| - The platform sample for the target app: `references/swift.md`, `references/android.md`, or `references/react-native.md`. | ||
|
|
||
| Prefer local source over memory. Use Shopify docs only to confirm current public guidance: https://shopify.dev/docs/storefronts/mobile |
45 changes: 45 additions & 0 deletions
45
skills/checkout-kit-present-preload-invalidate/references/android.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # Android | ||
|
|
||
| ```kotlin | ||
| import androidx.lifecycle.lifecycleScope | ||
| import com.shopify.checkoutkit.ShopifyCheckoutKit | ||
| import kotlinx.coroutines.Job | ||
| import kotlinx.coroutines.delay | ||
| import kotlinx.coroutines.launch | ||
|
|
||
| private var preloadJob: Job? = null | ||
| private var preloadedCheckoutUrl: String? = null | ||
|
|
||
| fun onCartStateSettled(checkoutUrl: String) { | ||
| preloadJob?.cancel() | ||
| preloadJob = lifecycleScope.launch { | ||
| delay(300) | ||
| ShopifyCheckoutKit.preload(checkoutUrl, activity) | ||
| preloadedCheckoutUrl = checkoutUrl | ||
| } | ||
| } | ||
|
|
||
| fun onCheckoutTapped(checkoutUrl: String) { | ||
| ShopifyCheckoutKit.present( | ||
| checkoutUrl = checkoutUrl, | ||
| context = activity, | ||
| checkoutEventProcessor = checkoutEventProcessor, | ||
| ) | ||
| } | ||
|
|
||
| fun onCheckoutAffectingStateChanged(freshCheckoutUrl: String, cartOrBuyerChanged: Boolean) { | ||
| val preloadedCheckoutIsStale = preloadedCheckoutUrl != null && preloadedCheckoutUrl != freshCheckoutUrl | ||
|
|
||
| if (cartOrBuyerChanged && preloadedCheckoutIsStale) { | ||
| ShopifyCheckoutKit.invalidate() | ||
| preloadedCheckoutUrl = null | ||
| } | ||
|
|
||
| onCartStateSettled(freshCheckoutUrl) | ||
| } | ||
|
|
||
| fun onSessionBoundaryChanged() { | ||
| ShopifyCheckoutKit.invalidate() | ||
| preloadedCheckoutUrl = null | ||
| } | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is currently pseudocode filler - we havent written out the design for the react-native but i expect it to be mroe like
new CheckoutProtocol.Client().on