Swift
A collection of skills for AI coding agents. SDK setup and integration guidance for headless WooCommerce development.
npx -y skills add cocart-headless/cocart-skills --skill swiftAssembled 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
- Not using
try await— All SDK methods are async throwing. Forgettingtryorawaitwill cause compile errors. Usedo { try await ... } catch { ... }blocks. - Hardcoding credentials — Use
Bundle.main.infoDictionaryfor config values and Keychain for secrets. Never commit API keys to source control. - Recreating the client in every view — Create the client once (e.g. as an
@StateObjector in a singleton) and pass it down. Recreating it loses the in-memory cart key. - Ignoring Sendable requirements — In Swift 6 strict concurrency, ensure CoCart responses are handled on the correct actor. Use
@MainActorfor UI updates.
When to Load References
- Configuring authentication (guest, Basic Auth, consumer keys, JWT) → references/authentication.md
- Working with cart operations (add, update, remove, coupons, currency) → references/cart.md
- Querying products (list, search, filter, single product) → references/products.md
WordPress / WooCommerce Requirements
- WooCommerce installed and active
- CoCart plugin installed (free tier available)
- CoCart Plus for advanced features
- Optional: CoCart JWT Authentication for JWT auth
What ships with it: 3 files
5.4 KB alongside SKILL.md
references/
- authentication.md952 B
- cart.md3.9 KB
- products.md586 B