/referral-system
Generates referral/invite infrastructure with unique codes, deep link sharing, reward tracking, and fraud prevention. Use when user wants referral codes, invite friends flow, or viral growth mechanics.
$ npx -y skills add rshankras/claude-code-apple-skills --skill referral-system --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/referral-system
Context preview
The summary Claude sees to decide when to auto-load this skill.
Generates referral/invite infrastructure with unique codes, deep link sharing, reward tracking, and fraud prevention. Use when user wants referral codes, invite friends flow, or viral growth mechanics.
SKILL.md
referral-system.SKILL.mdname: referral-system
description: Generates referral/invite infrastructure with unique codes, deep link sharing, reward tracking, and fraud prevention. Use when user wants referral codes, invite friends flow, or viral growth mechanics.
allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion]
last_verified: 2026-07-16
review_by: 2027-06-22
os_version: iOS 27 / macOS 27
Referral System Generator
Generate a production referral/invite system with unique code generation, deep link sharing, reward tracking, fraud prevention, and SwiftUI views for inviting friends and monitoring referral performance.
When This Skill Activates
Use this skill when the user:
- Asks to "add a referral system" or "referral codes"
- Wants to "invite friends" or "refer a friend" flow
- Mentions "viral growth" or "invitation system"
- Asks about "referral rewards" or "referral tracking"
- Wants "invite codes" or "shareable invite links"
Pre-Generation Checks
1. Project Context Detection
- [ ] Check Swift version (requires Swift 5.9+)
- [ ] Check deployment target (iOS 17+ / macOS 14+ for @Observable and SwiftData)
- [ ] Identify source file locations
- [ ] Check for existing entitlements (Associated Domains for deep links)
2. Conflict Detection
Search for existing referral/invite code:
Glob: **/*Referral*.swift, **/*Invite*.swift, **/*InviteCode*.swift
Grep: "referralCode" or "inviteCode" or "ReferralManager"
If existing referral system found:
- Ask if user wants to replace or extend it
- If extending, identify integration points
3. Deep Link Setup Detection
Search for existing deep link handling:
Glob: **/*DeepLink*.swift, **/*UniversalLink*.swift
Grep: "onOpenURL" or "userActivity" or "NSUserActivity"
If deep link handling exists, integrate with it rather than generating a standalone handler.
Configuration Questions
Ask user via AskUserQuestion:
1. **Reward type?**
- Both-get (referrer and invitee both earn a reward) -- recommended
- Referrer-only (only the person who shares gets rewarded)
- Points-based (both parties earn points toward rewards)
2. **Code format?**
- Short alphanumeric (e.g., `A7K2M9`) -- recommended
- Custom prefix (e.g., `MYAPP-A7K2M9`)
- Username-based (e.g., `john-A7K2`)
3. **Sharing method?**
- Deep link (universal link with embedded code) -- recommended
- Clipboard copy (copy code to pasteboard)
- Share sheet (system share with link and message)
- All of the above
4. **Storage?**
- SwiftData (local persistence, recommended for most apps)
- UserDefaults (lightweight, for simple single-code scenarios)
- CloudKit (sync across devices)
Generation Process
Step 1: Read Templates
Read `templates.md` for production Swift code.
Step 2: Create Core Files
Generate these files: 1. `ReferralCode.swift` -- Model with unique code generation, expiration, usage tracking 2. `ReferralManager.swift` -- @Observable manager for code lifecycle and redemption 3. `ReferralReward.swift` -- Reward configuration, conditions, and fulfillment tracking
Step 3: Create UI Files
4. `InviteView.swift` -- SwiftUI invite screen with code display and sharing 5. `ReferralDashboardView.swift` -- Stats view for referral performance
Step 4: Create Integration Files
6. `ReferralDeepLinkHandler.swift` -- Deep link parsing and redemption triggering
Step 5: Determine File Location
Check project structure:
- If `Sources/` exists -> `Sources/Referral/`
- If `App/` exists -> `App/Referral/`
- Otherwise -> `Referral/`
Output Format
After generation, provide:
Files Created
Referral/
├── ReferralCode.swift # Code model with generation and validation
├── ReferralManager.swift # @Observable manager for code lifecycle
├── ReferralReward.swift # Reward config and fulfillment tracking
├── InviteView.swift # Invite screen with share actions
├── ReferralDashboardView.swift # Referral stats dashboard
└── ReferralDeepLinkHandler.swift # Deep link parsing and redemption
Integration Steps
**Add deep link handling in your App struct:**
@main
struct MyApp: App {
@State private var referralManager = ReferralManager()
private let deepLinkHandler = ReferralDeepLinkHandler()
var body: some Scene {
WindowGroup {
ContentView()
.environment(referralManager)
.onOpenURL { url in
if let code = deepLinkHandler.extractCode(from: url) {
Task {
await referralManager.redeemCode(code)
}
}
}
}
}
}**Present the invite screen:**
struct ProfileView: View {
@State private var showInvite = false
var body: some View {
Button("Invite Friends") { showInvite = true }
.sheet(isPresented: $showInvite) {
InviteView()
}
}
}**Show referral dashboard:**
NavigationLink("My Referrals") {
ReferralDashboardView()
}Testing
@Test
func generatedCodeIsUnique() async throws {
let manager = ReferralManager(store: InMemoryReferralStore())
let code1 = await manager.generateCode(for: "user-1")
let code2 = await manager.generateCode(for: "user-2")
#expect(code1.value != code2.value)
}
@Test
func redemptionGrantsReward() async throws {
let manager = ReferralManager(store: InMemoryReferralStore())
let code = await manager.generateCode(for: "referrer-1")
let result = await manager.redeemCode(code.value, redeemedBy: "invitee-1")
#expect(result == .success)
#expect(manager.rewards(for: "referrer-1").count == 1)
#expect(manager.rewards(for: "invitee-1").count == 1)
}
@Test
func selfReferralIsRejected() async throws {
let manager = ReferralManager(store: InMemoryReferralStore())
let code = await manager.generateCode(for: "Read more
name: referral-system description: Generates referral/invite infrastructure with unique codes, deep link sharing, reward tracking, and fraud prevention. Use when user wants referral codes, invite friends flow, or viral growth mechanics. allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion] last_verified: 2026-07-16 review_by: 2027-06-22 os_version: iOS 27 / macOS 27
Referral System Generator
Generate a production referral/invite system with unique code generation, deep link sharing, reward tracking, fraud prevention, and SwiftUI views for inviting friends and monitoring referral performance.
When This Skill Activates
Use this skill when the user:
- Asks to "add a referral system" or "referral codes"
- Wants to "invite friends" or "refer a friend" flow
- Mentions "viral growth" or "invitation system"
- Asks about "referral rewards" or "referral tracking"
- Wants "invite codes" or "shareable invite links"
Pre-Generation Checks
1. Project Context Detection
- [ ] Check Swift version (requires Swift 5.9+)
- [ ] Check deployment target (iOS 17+ / macOS 14+ for @Observable and SwiftData)
- [ ] Identify source file locations
- [ ] Check for existing entitlements (Associated Domains for deep links)
2. Conflict Detection
Search for existing referral/invite code:
Glob: **/*Referral*.swift, **/*Invite*.swift, **/*InviteCode*.swift Grep: "referralCode" or "inviteCode" or "ReferralManager"
If existing referral system found:
- Ask if user wants to replace or extend it
- If extending, identify integration points
3. Deep Link Setup Detection
Search for existing deep link handling:
Glob: **/*DeepLink*.swift, **/*UniversalLink*.swift Grep: "onOpenURL" or "userActivity" or "NSUserActivity"
If deep link handling exists, integrate with it rather than generating a standalone handler.
Configuration Questions
Ask user via AskUserQuestion:
1. **Reward type?**
- Both-get (referrer and invitee both earn a reward) -- recommended
- Referrer-only (only the person who shares gets rewarded)
- Points-based (both parties earn points toward rewards)
2. **Code format?**
- Short alphanumeric (e.g., `A7K2M9`) -- recommended
- Custom prefix (e.g., `MYAPP-A7K2M9`)
- Username-based (e.g., `john-A7K2`)
3. **Sharing method?**
- Deep link (universal link with embedded code) -- recommended
- Clipboard copy (copy code to pasteboard)
- Share sheet (system share with link and message)
- All of the above
4. **Storage?**
- SwiftData (local persistence, recommended for most apps)
- UserDefaults (lightweight, for simple single-code scenarios)
- CloudKit (sync across devices)
Generation Process
Step 1: Read Templates
Read `templates.md` for production Swift code.
Step 2: Create Core Files
Generate these files: 1. `ReferralCode.swift` -- Model with unique code generation, expiration, usage tracking 2. `ReferralManager.swift` -- @Observable manager for code lifecycle and redemption 3. `ReferralReward.swift` -- Reward configuration, conditions, and fulfillment tracking
Step 3: Create UI Files
4. `InviteView.swift` -- SwiftUI invite screen with code display and sharing 5. `ReferralDashboardView.swift` -- Stats view for referral performance
Step 4: Create Integration Files
6. `ReferralDeepLinkHandler.swift` -- Deep link parsing and redemption triggering
Step 5: Determine File Location
Check project structure:
- If `Sources/` exists -> `Sources/Referral/`
- If `App/` exists -> `App/Referral/`
- Otherwise -> `Referral/`
Output Format
After generation, provide:
Files Created
Referral/ ├── ReferralCode.swift # Code model with generation and validation ├── ReferralManager.swift # @Observable manager for code lifecycle ├── ReferralReward.swift # Reward config and fulfillment tracking ├── InviteView.swift # Invite screen with share actions ├── ReferralDashboardView.swift # Referral stats dashboard └── ReferralDeepLinkHandler.swift # Deep link parsing and redemption
Integration Steps
**Add deep link handling in your App struct:**
@main
struct MyApp: App {
@State private var referralManager = ReferralManager()
private let deepLinkHandler = ReferralDeepLinkHandler()
var body: some Scene {
WindowGroup {
ContentView()
.environment(referralManager)
.onOpenURL { url in
if let code = deepLinkHandler.extractCode(from: url) {
Task {
await referralManager.redeemCode(code)
}
}
}
}
}
}**Present the invite screen:**
struct ProfileView: View {
@State private var showInvite = false
var body: some View {
Button("Invite Friends") { showInvite = true }
.sheet(isPresented: $showInvite) {
InviteView()
}
}
}**Show referral dashboard:**
NavigationLink("My Referrals") {
ReferralDashboardView()
}Testing
@Test
func generatedCodeIsUnique() async throws {
let manager = ReferralManager(store: InMemoryReferralStore())
let code1 = await manager.generateCode(for: "user-1")
let code2 = await manager.generateCode(for: "user-2")
#expect(code1.value != code2.value)
}
@Test
func redemptionGrantsReward() async throws {
let manager = ReferralManager(store: InMemoryReferralStore())
let code = await manager.generateCode(for: "referrer-1")
let result = await manager.redeemCode(code.value, redeemedBy: "invitee-1")
#expect(result == .success)
#expect(manager.rewards(for: "referrer-1").count == 1)
#expect(manager.rewards(for: "invitee-1").count == 1)
}
@Test
func selfReferralIsRejected() async throws {
let manager = ReferralManager(store: InMemoryReferralStore())
let code = await manager.generateCode(for: "A collection of Claude Code skills for iOS, macOS, watchOS, visionOS, and Apple platform development. These skills help you plan and build apps, maintain code quality, ensure HIG compliance, and guide you from idea to App Store.
Repo: rshankras/claude-code-apple-skills
Other skills on rshankras-apple-skills.
- /app-store
App Store optimization and marketing skills for descriptions, screenshots, keywords, review responses, and comprehensive promotional strategy. Use when user needs help with App Store presence, ASO, marketing, or customer communication.
Open skill - /ad-attribution
Privacy-preserving ad measurement with AdAttributionKit (SKAdNetwork's successor) — install and re-engagement attribution, conversion-value strategy under crowd anonymity, and end-to-end postback testing. Use when running paid acquisition beyond Apple Ads, measuring
Open skill - /app-description-writer
Generate compelling App Store descriptions that convert browsers into users. Use when writing initial descriptions, improving existing copy, or drafting promotional text and What's New for a major update.
Open skill - /apple-search-ads
Apple Search Ads campaign strategy for indie developers — paid acquisition, keyword bidding, budget planning, and ROAS optimization. Use when user asks about running ads, paid user acquisition, or Apple Search Ads campaigns.
Open skill - /iap-finalizer
Take a one-time in-app purchase from MISSING_METADATA to READY_TO_SUBMIT in App Store Connect — set its price schedule and localized display name/description (and optional review screenshot) via the ASC REST API. Use at Phase 6 (Pre-Release), after the IAP is built in-app (Phase
Open skill - /keyword-optimizer
Optimize app title, subtitle, and keywords for maximum App Store discoverability. Use when launching a new app, improving search rankings, entering new markets/languages, or safely optimizing ASO for an app with existing traffic.
Open skill

