Spark component migrate token

From leboncoin/spark-ios · View interactive version

Spark component migrate token is an AI agent skill from the GitHub repository leboncoin/spark-ios. Migrate a spark-ios-component-XXX from use cases / models / view models to component tokens (XXXToken exposed through theme.component.xxx) consumed by the SwiftUI views through private view modifiers. Keeps the ViewModel and use cases still used by the UIKit component.

How to use this skill

Skill file

Spark Component Migrate Token Skill

Overview

This skill migrates the SwiftUI part of a component to the component token architecture introduced by refactor/inputotp

(see Modules/Components/InputOTP for the full real-world example, commit refactor(inputotp): replace use cases and view models with tokens and view modifiers).

Target architecture:

Theme
 └─ theme.component.xxx            -> ComponentToken+XXX.swift          (public)
     └─ XXXToken (+ categories)    -> Token/XXXToken(+Category).swift   (public, skill spark-component-token)
         └─ EnvironmentTheme.xxx   -> EnvironmentTheme+XXXToken.swift   (internal shortcuts)
             └─ ViewModifiers      -> ViewModifier/XXXYyyViewModifier.swift (private struct + internal View extension)
                 └─ SparkXXX (SwiftUI view, no ViewModel)

Component Selection

All operations are performed in Modules/Components/{component-name}/.

Step 0 — Analysis (mandatory, before any change)

  1. List every UseCase, Model and ViewModel of the component.
  2. Check if the component has a UIKit view (SparkUIXXX, View/UIKit, ...).
  3. For each UseCase / Model / ViewModel, determine who uses it:
  1. Present the plan to the user (what is created, what is removed, what is kept for UIKit) and wait for confirmation if anything is ambiguous.

⚠️ Components not fully migrated still have a UIKit component relying on the ViewModel. Never delete a ViewModel, UseCase or Model still referenced by UIKit code. Delete only once there is no remaining reference (check with grep in Sources).

Step 1 — Tokens

Use the skill spark-component-token to create Sources/Core/Token/XXXToken.swift and its categories

(XXXToken+Colors.swift, +Border, +Layout, +Opacity, +Typography, +Size, ...).

Step 2 — ComponentToken extension

Sources/Core/Extension/Token/ComponentToken+XXX.swift — see template/ComponentToken+XXX.swift.

Exposes the token publicly through theme.component.xxx (ComponentToken is defined in Modules/Theming/Sources/Core/Component/ComponentToken.swift).

Step 3 — EnvironmentTheme extension

Sources/Core/Extension/Token/EnvironmentTheme+XXXToken.swift — see template/EnvironmentTheme+XXXToken.swift.

Step 4 — View modifiers

Sources/Core/ViewModifier/XXXYyyViewModifier.swift — see template/XXXOpacityViewModifier.swift (example with opacity).

Step 5 — SwiftUI views

Step 6 — Clean up

Only for what was flagged SwiftUI only in Step 0:

Step 7 — Tests

Step 8 — Documentation

Workflow

Code Conventions

When to Ask for Help

Use AskUserQuestion if:

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.