agentsclimarketplace

Swift

Skill cocart-headless/cocart-skills/skills/swift

A collection of skills for AI coding agents. SDK setup and integration guidance for headless WooCommerce development.

Install
npx -y skills add cocart-headless/cocart-skills --skill swift

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

CoCart Swift SDK patterns for headless WooCommerce. Use when setting up CoCart in Swift projects for iOS, macOS, watchOS, tvOS, or visionOS apps.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

3.8 KB, 777 tokens by cl100k_base, as published. Nobody here has run it

CoCart Swift SDK Skill

You are an expert in the CoCart Swift SDK (cocart-headless/cocart-swift-sdk). When a user adds "use CoCart" to a prompt and their project is Swift-based (iOS, macOS, watchOS, tvOS, visionOS), apply this skill.

Note: The Swift SDK is still in development and not yet production-ready. Mention this when relevant and encourage users to report bugs.

Installation

Swift Package Manager

// Package.swift
dependencies: [
    .package(url: "https://github.com/cocart-headless/cocart-swift-sdk.git", from: "1.0.0")
]

Or in Xcode: File > Add Package Dependencies > paste the repository URL.

Requirements: Swift 5.9+ / Xcode 15+. iOS 16+, macOS 13+, watchOS 9+, tvOS 16+, visionOS 1+.

Quick Start

import CoCart

let client = CoCart(url: "https://your-store.com")

// Browse products (no auth required)
let products = try await client.products().all()

// Add item to cart (guest session created automatically)
try await client.cart().addItem(productId: 123, quantity: 2)

// Get cart
let cart = try await client.cart().get()
print("Items: \(cart.getItems().count)")
print("Total: \(cart.get("totals.total") ?? "")")

Configuration

let client = CoCart(
    url: "https://your-store.com",
    config: CoCartConfig(
        cartKey: "existing_cart_key",
        username: "[email protected]",
        password: "password",
        jwtToken: "your-jwt-token",
        consumerKey: "ck_xxxxx",
        consumerSecret: "cs_xxxxx",
        timeout: 30,
        maxRetries: 2,
        restPrefix: "wp-json",
        namespace: "cocart",
        mainPlugin: .basic,
        etag: true
    )
)

Common Mistakes

  1. Not using try await — All SDK methods are async throwing. Forgetting try or await will cause compile errors. Use do { try await ... } catch { ... } blocks.
  2. Hardcoding credentials — Use Bundle.main.infoDictionary for config values and Keychain for secrets. Never commit API keys to source control.
  3. Recreating the client in every view — Create the client once (e.g. as an @StateObject or in a singleton) and pass it down. Recreating it loses the in-memory cart key.
  4. Ignoring Sendable requirements — In Swift 6 strict concurrency, ensure CoCart responses are handled on the correct actor. Use @MainActor for UI updates.

When to Load References

WordPress / WooCommerce Requirements

What ships with it: 3 files

5.4 KB alongside SKILL.md

references/

Keep looking

Skills are one crate of 326,984. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.