# Introduction to the IAP AI skill

> Understand what the In-App Purchasing AI skill does, which AI assistants support it, and how to prompt it safely.

Starting in IAP version 5.3.0, the In-App Purchasing (IAP) package includes an AI skill that helps you migrate to and integrate Unity IAP v5. A skill is a set of instructions that a compatible AI assistant loads when your request matches the task the skill describes. As a result, a general-purpose assistant follows Unity's current v5 procedures instead of writing code from memory.

You install the skill into a compatible AI assistant, then prompt it in plain language to perform a migration or integration. The skill inspects your project to identify the billing system already present and selects one task path. For the full list of tasks the skill supports, refer to [IAP AI skill capabilities reference](./ai-skill-features.md).

To install the skill and run it, refer to [Install and use the IAP AI skill](./use-ai-skills.md).

## How the skill works

Every task follows the same principles.

* Scan first: Before the skill writes anything, it inspects files such as `manifest.json`, C# scripts, and Gradle templates to identify the billing system already present, then selects one task path.
* Report before changes: For migrations and conversions, the skill produces a report that describes what it found, what it changes, any blockers, and the manual steps you must complete. It doesn't edit code until you approve the report.
* Guard and verify: The skill places risky changes behind `#if` compiler flags so you can roll them back, and it rechecks the generated code against the v5 API.

> **Note:**
>
> The skill generates code and reasons about your project, but it can't perform actions in the Unity Editor or the stores for you. Steps such as creating products in App Store Connect or Google Play Console, running the Receipt Validation Obfuscator, or resolving Android dependencies remain manual. The report lists these steps.

## Compatible AI assistants

You can use the skill with any AI assistant that supports the `SKILL.md` skill format. How you make the assistant aware of the skill depends on the assistant:

* Unity AI Assistant and Unity AI Desktop: If you subscribe to either product, the skill is built in and you don't need to install it. Prompt the assistant with a keyword such as `in-app purchase` or `migrate native billing`, and the assistant activates the skill automatically. Use Agent mode when you want the assistant to create or modify scripts and scenes.
* Claude Code: Install the skill directly from the Unity Editor. Claude Code activates the skill automatically when your request matches its description, so you don't need to name any file.
* Other AI assistants: For assistants such as OpenAI Codex, copy the skill into your project from the skill folder, then either reference the `SKILL.md` file at the start of each prompt or register it in the assistant's configuration file so that it loads for every session.

For the install steps for each option, refer to [Install and use the IAP AI skill](./use-ai-skills.md).

## Best practices for safe use

Purchase code handles real transactions, so review the skill's output before you release your game. Follow these practices for every task:

* Work on a branch: Keep a clean rollback so you can revert the skill's changes with Git.
* Read the report before you approve it: Every migration and conversion produces a report of changes, blockers, and manual steps. Review it rather than approving it unread.
* Grant and save before you confirm: Unity IAP v5 delivers each purchase as a pending order that you fulfill and then confirm, so grant and persist the reward before you call `ConfirmPurchase`. An unconfirmed purchase re-delivers safely, but a confirmed purchase that you didn't save is lost. For more information, refer to [Purchases](./purchases.md).
* Handle success and failure events: Subscribe to both the success and failure events for every purchase, and to `OnPurchaseDeferred` for Ask to Buy.
* Confirm that the code targets v5: The v4 types `IStoreListener`, `UnityPurchasing.Initialize`, and `ConfigurationBuilder` don't exist in v5, so reject any output that uses them and confirm that the assistant loaded the skill. To check the rest of the output, compare it against the API mapping tables in [Upgrade from IAP v4 to v5](./upgrade-to-iap-v5.md).
* Test on a real device: Compile, then test purchases on a device with a sandbox or test account. The Editor doesn't reproduce pending, deferred, or restore purchase behavior.

## Example prompts

Prompt the assistant in plain language. The following table shows a starting prompt for each common goal. For the details that every prompt needs to produce accurate results, refer to [Write an effective prompt](./use-ai-skills.md#write-an-effective-prompt).

| Goal                                      | Example prompt                                                                                                                                               |
| :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Add IAP to a project                      | `Add Unity IAP 5. Products: coins100 (Consumable) grants 100 coins; removeads (NonConsumable) removes ads. Use my SaveManager. Show a plan first.`           |
| Migrate v4 to v5                          | `Migrate my IAP from Unity IAP v4 to v5 on a branch. Show the v4-to-v5 mapping before you edit anything.`                                                    |
| Convert a Google Play billing integration | `Convert my custom BillingClient integration to Unity IAP 5. Provide a migration report and detect any blockers first. Keep the old code behind #if guards.` |
| Integrate D2C payment providers           | `Add Unity IAP D2C payments with Stripe for my consumables. List the routing-rule and redirect steps.`                                                       |
| Edit the Codeless catalog                 | `Add a $1.99 consumable 'gems_50' to my IAP product catalog.`                                                                                                |

> **Tip:**
>
> If the output uses v4 API such as `IStoreListener` or `UnityPurchasing.Initialize`, the assistant didn't load the skill. Start again and reference the `SKILL.md` file explicitly, for example: `Read the in-app-purchases SKILL.md and follow it.`
