All Prompts

Gate my app behind a Yard license key

by Yard

Add a license screen that validates keys and activates devices against Yard.

First, confirm Yard is set up on this machine. Run `yard version`, and check that the Yard skill exists at ~/.agents/skills/yard/SKILL.md (%USERPROFILE%\.agents\skills\yard\SKILL.md on Windows). If either the CLI or the skill is missing, fetch https://yard.sh/setup.txt and follow it through to the end before you do anything else. If both are already in place, go straight to the task below.

---

Make my app ask for a Yard license key and only unlock once Yard says the key is valid for this device.

1. Check yard me --json for .team_permissions.license_keys, device_activations and api_keys. If any are missing, stop and give me https://yard.sh/pricing. Turn keys on for the project in this directory with yard projects edit <slug> --spec - --json, using {"license_key_enabled": true, "activations_enabled": true, "max_activations": 3} (ask me if I want a different device limit).
2. Create an API key with yard keys create --spec - --json using {"name": "app-license-check", "scopes": ["licenses:validate", "licenses:activate"]}. Both scopes are needed, because sending a device_id activates the device. These integration scopes are safe to ship inside the app. Inject the key at build time from an environment variable rather than committing it, and tell me where to store it.
3. Add a license screen: the user pastes a key, the app sends POST https://api.yard.sh/v1/licenses/validate with Authorization: Bearer <api key> and a JSON body of license_key, device_id and device_name. Generate device_id once with a random UUID and store it in the app's config directory. Save the key only when the response says valid, and show the response's error text when it doesn't.
4. In release builds, reject any response whose sandbox field is set, because those keys come from simulated test purchases. Re-check the stored key on launch without blocking startup.

Ask me where the license screen should live in the UI before you build it. When you're done, tell me how to test it: create a sandbox, buy the project inside it (simulated, no card), and paste that key into a development build.