From swiftasb-skills
Build or refactor a Swift package API on top of SwiftASB without leaking raw app-server wire models, while keeping live Codex probes opt-in, isolated, timeout-bounded, and documented.
How this skill is triggered — by the user, by Claude, or both
Slash command
/swiftasb-skills:build-swift-packageThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
When a task combines SwiftData with SwiftUI, keep SwiftData directly coupled to SwiftUI through Apple's data-driven path: `modelContainer`, environment `modelContext`, `@Query`, SwiftData model objects, and bindings. Do not add repositories, stores, service layers, DTO mirrors, view-model caches, wrapper objects, or other abstraction layers between SwiftData and SwiftUI. If this skill is not th...
When a task combines SwiftData with SwiftUI, keep SwiftData directly coupled to SwiftUI through Apple's data-driven path: modelContainer, environment modelContext, @Query, SwiftData model objects, and bindings. Do not add repositories, stores, service layers, DTO mirrors, view-model caches, wrapper objects, or other abstraction layers between SwiftData and SwiftUI. If this skill is not the right owner for SwiftData-backed SwiftUI work, hand off to apple-dev-skills:swiftui-app-architecture-workflow instead of inventing an intermediate data layer.
Help a Swift package use SwiftASB internally while exposing the package's own small, Swift-native API to its callers.
The real job is to keep the package's public surface understandable. SwiftASB can own Codex runtime startup, app-wide library and inventory state, thread agenda state, stable worktree groups, repository/worktree filters, selected-worktree Git status, project identity and thread-source facts, app-server-owned worktree snapshots, app-server-routed filesystem/config/extension/MCP reads, workspace permission facts, feature policy, feature-operation events, plan-mode turn starts, goal helpers, code-review and shell-command entry points, typed threads, turns, events, diagnostics, query descriptors, and local history inside the implementation, but the package author should decide deliberately whether consumers see SwiftASB handles directly or a narrower domain-specific API.
Before implementing or proposing package structure, read the relevant SwiftPM and Swift documentation through Apple Dev Skills, Swift.org, or official Apple docs.
Minimum rules to rely on:
Package.swift manifest at the package root.Package defines package name, products, targets, dependencies, platforms, resources, and Swift language mode.Authoritative docs:
swiftasb:choose-integration-shape selects a package library, command-line package, helper package, or test harness shape.Verify current SwiftASB docs and public API before editing:
README.mdSources/SwiftASB/SwiftASB.docc/GettingStartedWithSwiftASB.mdSources/SwiftASB/SwiftASB.docc/HandlingTurnProgressAndApprovals.mdSources/SwiftASB/SwiftASB.docc/ReadingDiagnosticsAndHistory.mdSources/SwiftASB/SwiftASB.docc/ThreadHistoryAndObservables.mdSources/SwiftASB/SwiftASB.docc/AppWideCapabilities.mdSources/SwiftASB/SwiftASB.docc/CodexInventory.mdSources/SwiftASB/SwiftASB.docc/CodexMCP.mdSources/SwiftASB/SwiftASB.docc/CodexFS.mdSources/SwiftASB/SwiftASB.docc/CodexConfig.mdSources/SwiftASB/SwiftASB.docc/CodexExtensions.mdSources/SwiftASB/SwiftASB.docc/CodexWorkspace.mdSources/SwiftASB/SwiftASB.docc/FeaturePermissionPolicy.mdSources/SwiftASB/SwiftASB.docc/ThreadManagement.mdSources/SwiftASB/Public/CodexAppServer+Library.swiftSources/SwiftASB/Public/CodexAppServer+Inventory.swiftSources/SwiftASB/Public/CodexAppServer+LoadedThreads.swiftSources/SwiftASB/Public/CodexAppServer+CodexExtensions.swiftSources/SwiftASB/Public/CodexAppServer+MCP.swiftSources/SwiftASB/Public/CodexMCP.swiftSources/SwiftASB/Public/CodexFS.swiftSources/SwiftASB/Public/CodexConfig.swiftSources/SwiftASB/Public/CodexWorkspace.swiftSources/SwiftASB/Public/CodexAppServer+Bootstrap.swiftSources/SwiftASB/Public/CodexAppServer.swiftSources/SwiftASB/Public/CodexDiagnostics.swiftSources/SwiftASB/Public/CodexErrors.swiftSources/SwiftASB/Public/CodexReviewHandle.swiftSources/SwiftASB/Public/CodexThread.swiftSources/SwiftASB/Public/CodexThread+Agenda.swiftSources/SwiftASB/Public/CodexTurnHandle.swiftAs of SwiftASB v1.8.0, package integrations should prefer:
CodexAppServer.start(_:) with CodexAppServer.StartupRequest for normal one-call subprocess startup, compatibility validation, initialization, and typed CodexAppServerStartupError failuresCodexAppServer.start(), cliExecutableDiagnostics(), and initialize(_:) only when the package intentionally owns custom diagnostics, compatibility policy, or test setup before initializationCodexAppServer for subprocess ownership, diagnostics, stored-thread operations, model capability reads, feature-operation-event streams, and hook diagnosticsCodexAppServer.makeLibrary(configuration:) when the package intentionally exposes app-wide stored-thread lists, cwd or repository grouping, stable worktree groups, repository/worktree filters, selected worktree or repository context, selected-worktree Git status, library-local selection, CodexWorkspace.ProjectInfo project identity, CodexAppServer.ThreadSource source facts, or app-wide model/MCP/hook snapshots that refresh when app-server app/skill/MCP state changesCodexAppServer.makeInventory(configuration:) when the package intentionally exposes routine app-wide model capabilities, global MCP summaries, hook diagnostics, apps, skills, plugins, or collaboration modesCodexAppServer.fs, CodexAppServer.config, and CodexAppServer.extensions when the package intentionally exposes app-server-owned filesystem, config, advanced extension pagination, plugin detail reads, or already-configured marketplace upgradesCodexAppServer.mcp when the package intentionally exposes MCP installs, full status snapshots, or app-wide or thread-scoped MCP resource contentsSwiftASBFeaturePolicy and CodexAppServer.featureOperationEvents() when the package intentionally exposes SwiftASB-owned authority choices or mutation-operation recordsCodexWorkspace when consumers need session cwd, app-server-owned worktree snapshots, project identity, Git repository facts, selected Git status snapshots, active permission profile, or runtime filesystem/network permission factsCodexThread for conversation-scoped text turns, plan-mode turns, archive/unarchive, thread actions, thread goals, request responses, and local historyCodexThread.startReview(against:placement:) and CodexReviewHandle when the package intentionally exposes app-server review startsCodexThread.sendShellCommand(_:) only when the package intentionally exposes high-impact user-level shell execution and requires the host to enable shellCommandExecutionCodexThread.makeAgenda() and goal helpers when the package intentionally exposes plan and goal stateCodexTurnHandle for one active turn, including events, steering, interruption, request responses, and completion handoffCodexTurnItem.Kind.sleep when the package switches over public turn item kinds or exposes turn-history classificationsASBPresentation, ASBAppKit, and ASBSwiftUI products only when the package intentionally exposes reusable presentation or UI componentshttps://github.com/gaelic-ghost/SwiftASB1.8.0 when using current one-call startup, Codex CLI 0.142.x compatibility, app-wide library or inventory, stable worktree groups, repository/worktree filters, selected-worktree Git status, feature policy, feature-operation events, extension marketplace maintenance, project identity, thread source, filesystem match metadata, MCP installs/status/resource reads, config warnings, extension inventory, workspace, query-descriptor, thread archive/unarchive, code-review starts, shell-command execution, plan/goal UI, sleep turn-item classification, presentation products, or recent-activity guidance; otherwise verify the support window in SwiftASB's READMESwiftASBswift build and swift test, plus any repo-documented checks.Prefer a narrow package-owned facade when the package is not primarily a SwiftASB wrapper:
import SwiftASB
public struct WorkspaceSummaryRequest: Sendable {
public var workspacePath: String
public var prompt: String
public init(workspacePath: String, prompt: String) {
self.workspacePath = workspacePath
self.prompt = prompt
}
}
public struct WorkspaceSummary: Sendable {
public var text: String
}
public actor WorkspaceSummarizer {
private let appServer: CodexAppServer
public init() {
self.appServer = CodexAppServer()
}
public func shutdown() async {
await appServer.stop()
}
public func summarize(_ request: WorkspaceSummaryRequest) async throws -> WorkspaceSummary {
_ = try await appServer.start(
.init(
clientInfo: .init(
name: "WorkspaceSummarizer",
title: "Workspace Summarizer",
version: "1.0.0"
)
)
)
let thread = try await appServer.startThread(
.init(currentDirectoryPath: request.workspacePath)
)
let turn = try await thread.startTextTurn(request.prompt)
for try await event in turn.events {
if case .completed = event {
_ = try await turn.complete()
return WorkspaceSummary(text: "Summary completed.")
}
}
throw WorkspaceSummaryError.turnEndedWithoutCompletion
}
}
public enum WorkspaceSummaryError: Error, Sendable {
case turnEndedWithoutCompletion
}
Use this as a shape, not as a file to paste blindly. Most packages should return their own real result data, stream their own progress values, and map SwiftASB failures into errors their consumers can understand.
CodexAppServer, CodexThread, or CodexTurnHandle only when the package is intentionally a thin SwiftASB extension surface.CodexWire... models out of public API unless the user explicitly asks for protocol-level work.CodexAppServer.fs, CodexAppServer.config, CodexAppServer.makeInventory(configuration:), CodexAppServer.extensions, CodexAppServer.mcp, CodexWorkspace, and SwiftASBFeaturePolicy over direct local reads when the package needs facts owned by the Codex app-server, including worktree snapshots, selected Git status, project identity, repository facts, inventory, extension detail, MCP status/resources, marketplace maintenance, and feature-category choices.CodexTurnItem.Kind.sleep explicitly when switching over CodexTurnItem.Kind; do not collapse it into an unknown or failure state.CodexThread.CodexTurnHandle silently when the package promises cancellation behavior.swift test deterministic and free of live Codex subprocess requirements.SWIFTASB_LIVE_TESTS=1.Run the repository's documented validation path. For plain Swift packages, the baseline is:
swift build
swift test
If the package is also an Xcode app workspace, use the repository's documented Xcode workflow instead of assuming SwiftPM is sufficient.
swiftasb:explain-swiftasb when the user needs adoption tradeoffs before implementation.swiftasb:choose-integration-shape when ownership or public API shape is unclear.swiftasb:diagnose-integration when startup, turn, approval, MCP, diagnostics, or history behavior fails.apple-dev-skills:sync-swift-package-guidance when the package repo's AGENTS.md or maintainer workflow needs alignment./Users/..., ~/..., or ../SwiftASB into public package manifests.CodexAppServerStartupError cases when mapping errors into package-owned error types.npx claudepluginhub gaelic-ghost/socket --plugin swiftasb-skillsCreates, edits, and verifies skills using a test-driven development approach with pressure scenarios and subagents.