Tipkit generator

From gustavscirulis/snapgrid · View interactive version

Tipkit generator is an AI agent skill from the GitHub repository gustavscirulis/snapgrid. Generate TipKit infrastructure with inline/popover tips, rules, display frequency, and testing utilities. Use when adding contextual tips or feature discovery to an iOS/macOS app.

How to use this skill

Skill file

TipKit Generator

Generate a complete TipKit setup for contextual tips and feature discovery, including tip definitions, rules, display frequency, inline and popover presentation, and testing utilities.

When This Skill Activates

Use this skill when the user:

Pre-Generation Checks

1. Project Context Detection

2. Conflict Detection

Search for existing TipKit usage:

Glob: **/*Tip*.swift
Grep: "import TipKit" or "Tips.configure"

If found, ask user:

Configuration Questions

Ask user via AskUserQuestion:

  1. What features need tips?
  1. Tip presentation style? (per tip or general preference)
  1. Rule types needed?
  1. Display frequency?
  1. Tip ordering?

Generation Process

Step 1: Read Templates

Read the templates file for code patterns:

Read("skills/generators/tipkit-generator/templates.md")

Step 2: Create Core Files

Generate these files based on configuration:

  1. Tips/ directory with one file per tip (e.g., SearchTip.swift, FilterTip.swift)
  2. Tips/TipEvents.swift - Centralized event definitions
  3. Tips/TipsConfiguration.swift - Tips.configure() setup and testing utilities

Step 3: Determine File Location

Check project structure:

Step 4: Integrate Tips

Output Format

After generation, provide:

Files Created

Sources/Tips/
├── SearchTip.swift            # Tip with rules and options
├── FilterTip.swift            # Another tip definition
├── TipEvents.swift            # Centralized event definitions
└── TipsConfiguration.swift    # Tips.configure() + testing helpers

Integration Steps

App Entry Point (Required):

import TipKit

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .task {
                    try? Tips.configure([
                        .displayFrequency(.daily),
                        .datastoreLocation(.applicationDefault)
                    ])
                }
        }
    }
}

Inline Tip:

import TipKit

struct SearchView: View {
    let searchTip = SearchTip()

    var body: some View {
        VStack {
            TipView(searchTip)
            SearchBar()
        }
    }
}

Popover Tip:

import TipKit

struct ToolbarView: View {
    let filterTip = FilterTip()

    var body: some View {
        Button("Filter", systemImage: "line.3.horizontal.decrease.circle") {
            // action
        }
        .popoverTip(filterTip)
    }
}

Event Donation (at action site):

Button("Search") {
    performSearch()
    SearchTip.searchPerformed.donate()
}

Tip Invalidation (when tip is no longer relevant):

func onFeatureUsed() {
    // User discovered the feature, invalidate the tip
    searchTip.invalidate(reason: .actionPerformed)
}

Testing Instructions

  1. Reset DataStore between runs:

```swift

// Add to a debug menu or call in preview

try? Tips.resetDatastore()

```

  1. Show all tips for testing:

```swift

// Ignores rules and frequency -- shows everything

Tips.showAllTipsForTesting()

```

  1. Show specific tips for testing:

```swift

Tips.showTipsForTesting([SearchTip.self])

```

  1. Test scenarios:

Common Gotchas

  1. Forgetting Tips.configure() -- Tips will never appear if you do not call Tips.configure() before any tip is displayed. This must happen early, typically in the App body or .task.
  1. Rules not evaluating -- Parameter-based rules require you to set the parameter value explicitly. If you define @Parameter static var hasSeenFeature = false but never set it to true, the rule never passes.
  1. DataStore conflicts in tests -- If you run unit tests and the app simultaneously, they may share the same DataStore. Use .datastoreLocation(.url(...)) to isolate them.
  1. Display frequency blocking tips -- If you set .displayFrequency(.daily) and a tip was already shown today, no new tips will appear until tomorrow. Use .immediate during development.
  1. Tips not dismissing after invalidation -- You must hold a reference to the tip instance and call .invalidate(reason:) on that instance. Creating a new instance and invalidating it does nothing to the displayed tip.
  1. TipGroup ordering ignored -- Tips in a TipGroup only show in order if their rules are all satisfied. If Tip B's rules pass but Tip A's do not, neither will show (Tip A blocks Tip B).

Patterns

Good Patterns

Bad Patterns

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.