Spark create component

From leboncoin/spark-ios · View interactive version

Spark create component is an AI agent skill from the GitHub repository leboncoin/spark-ios. Create a new SwiftUI-only component in the Modules/Components folder (core code + tests + documentation) from the Figma and Zeroheight specifications, with the Token + ViewModifier architecture.

How to use this skill

Skill file

Create a New Component

Overview & Prerequisites

This skill creates a complete new component: the core code, the tests and the documentation.

❗️ This skill should be used from the root of the repository ❗️

All new components are created for SwiftUI only. There is no UIKit view (SparkUIXXX), and no UseCase, Model or ViewModel: the styling rules live in the Token (exposed through theme.component.xxx) and are applied by the views through private ViewModifiers.

Reference implementation: Modules/Components/InputOTP. Read it before writing any code.

The skill will:

  1. Get the component specification from Figma and Zeroheight (through their MCPs)
  2. Create the component structure from the template and register it (Package.swift, Import.swift, Demo)
  3. Implement the core code with the dedicated skills (Enum, Token, Environment, ViewModifier, View, ...)
  4. Add the unit tests and the snapshot tests
  5. Write the DocC documentation

Input Parameters

Gather the required parameters one by one. Check if the user has already provided each piece of information. If not, ask for each parameter individually in a conversational message.

Required Parameters (ask one at a time):

  1. Component Name (PascalCase format)
  1. Description (Brief description for the documentation)
  1. Figma Link (URL to the Figma design)
  1. Zeroheight Link (URL to the Zeroheight specifications)
  1. Anatomy Image Path (Local path to the anatomy image file)

Important:

Workflow

Step 1: Validate Parameters

Step 2: Prepare Component Names

From the component name, generate:

Step 3: Get the Specification (Figma + Zeroheight MCPs)

Use the links with the related MCPs to get the full specification before writing any code:

Then write a short specification summary for the user and wait for their validation:

Step 4: Copy the Template

cp -r .template/component/ "Modules/Components/${COMPONENT_NAME_PASCAL}/"

Step 5: Anatomy Image

Step 6: Replace All Placeholders

Replace these exact placeholders in the file contents, then rename the files with mv:

| Placeholder | Underscores | Replace With | Example |

|------------|-------------|--------------|---------|

| __COMPONENT_NAME___ | 2 prefix, 3 suffix | PascalCase | SegmentedControl |

| ___COMPONENT_NAME___ | 3 each side | PascalCase | SegmentedControl |

| ___component_name___ | 3 each side | lowercase | segmentedcontrol |

| ___component-name___ | 3 each side | kebab-case | segmented-control |

Step 7: Update documentation.json

Modules/Components/{ComponentName}/documentation.json:

Update the Zeroheight link (TODO) in README.md.

Step 8: Register the Component

Package.swift (single package, keep the alphabetical order, 4 spaces indentation):

```swift

// {ComponentName}

.target(

name: "SparkComponent{ComponentName}",

dependencies: [

"SparkCommon",

"SparkTheming"

// + "SparkResources" or other components if needed

],

path: "Modules/Components/{ComponentName}/Sources/Core"

),

.target(

name: "SparkComponent{ComponentName}Testing",

dependencies: [

"SparkComponent{ComponentName}",

"SparkCommon",

"SparkCommonTesting",

"SparkThemingTesting",

"SparkTheme"

],

path: "Modules/Components/{ComponentName}/Sources/Testing"

),

```

```swift

.testTarget(

name: "SparkComponent{ComponentName}UnitTests",

dependencies: [

"SparkComponent{ComponentName}",

"SparkComponent{ComponentName}Testing",

"SparkCommonTesting",

"SparkThemingTesting"

],

path: "Modules/Components/{ComponentName}/Tests/UnitTests"

),

.testTarget(

name: "SparkComponent{ComponentName}SnapshotTests",

dependencies: [

"SparkComponent{ComponentName}",

"SparkComponent{ComponentName}Testing",

"SparkCommonSnapshotTesting",

],

path: "Modules/Components/{ComponentName}/Tests/SnapshotTests"

),

```

Spark/Sources/Core/Import.swift:

Step 9: Implement the Core Code

Follow the creation order of a new component (see CLAUDE.md), using the matching skill for each type:

  1. [ ] Enum (spark-component-enum): the configuration enums (intent, size, variant, ...)
  2. [ ] Token (spark-component-token): XXXToken + categories (+Colors, +Spacing, +Animation, ...), ComponentToken+XXX (theme.component.xxx) and EnvironmentTheme+XXXToken
  3. [ ] Environment (spark-component-environment): the EnvironmentValues and the public view modifiers configuring the component
  4. [ ] ViewModifier: private view modifiers reading the tokens from @Environment(\.theme), with an internal View extension
  5. [ ] AccessibilityIdentifier (spark-component-accessibility-identifier)
  6. [ ] View (spark-component-view): SparkXXX in View/Public (replace the template file), sub-views in View/Internal

❗️ Do not create a UIKit view, a UseCase, a Model or a ViewModel.

Step 10: Tests

Step 11: Documentation

Step 12: Verify

Error Handling

If any step fails:

  1. Stop the process immediately
  2. Report the specific error and the failing step to the user
  3. Suggest a corrective action if applicable

Final Output

When complete, give the user:

  1. 📁 The path of the new component: Modules/Components/{ComponentName}/
  2. 📝 A summary of the created and modified files (component, Package.swift, Import.swift, Demo, assets)
  3. ✅ The test results (unit and snapshot)
  4. ⚠️ The parts of the specification not implemented or to confirm with the designers
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.