From swiftasb-skills
Build or refactor a SwiftUI app feature on top of SwiftASB using framework-owned SwiftUI state, SwiftASB thread and turn handles, observable companions, clear runtime diagnostics, and safe validation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/swiftasb-skills:build-swiftui-appThis 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 SwiftUI app use SwiftASB to start Codex work, show live progress, expose plan and goal state, handle approvals or user input, list stored threads, archive or unarchive stored threads, inspect app-server-owned worktree, selected Git status, project identity, thread source, filesystem/config/extension/MCP/workspace facts, observe SwiftASB-owned feature operations, expose app-wide inventory, and expose recent thread history without replaying raw app-server protocol payloads into app state.
The real job is to connect SwiftUI views to SwiftASB's Swift-native handles and observable companions. SwiftUI owns view lifetime and rendering. SwiftASB owns the local Codex app-server process, app-wide library and inventory companions, thread agenda companions, 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, review and shell-command entry points, thread, agenda, and turn handles, typed events, request responses, diagnostics, and recent-history companions.
Keep the shown workspace model at the app or scene ownership boundary; it is not a reusable-view dependency. Reusable SwiftUI panels receive the specific values, bindings, and action closures they need. Prefer existing or deliberately custom environment values/actions for genuine hierarchy-wide capabilities, and do not reintroduce a ViewModel, store, coordinator, or service injection layer below that boundary.
Before implementing or proposing SwiftUI structure, read the relevant Apple documentation through Apple Dev Skills or official Apple docs.
Minimum rules to rely on:
@State is view-managed storage, and SwiftUI updates dependent views when the value changes.@Observable objects in @State; subviews update when they read changed observable properties.App whose body provides one or more Scene values.@Observable macro rather than bare Observable protocol conformance.Authoritative docs:
swiftasb:choose-integration-shape selects a SwiftUI app shape.Verify current SwiftASB docs and public API before editing:
Sources/SwiftASB/SwiftASB.docc/GettingStartedWithSwiftASB.mdSources/SwiftASB/SwiftASB.docc/SwiftUIObservableCompanions.mdSources/SwiftASB/SwiftASB.docc/ThreadHistoryAndObservables.mdSources/SwiftASB/SwiftASB.docc/HandlingTurnProgressAndApprovals.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+Dashboard.swiftSources/SwiftASB/Public/CodexThread+Agenda.swiftSources/SwiftASB/Public/CodexTurnHandle.swiftAs of SwiftASB v1.8.0, SwiftUI-facing integrations should prefer:
CodexAppServer.start(_:) with CodexAppServer.StartupRequest for normal one-call startup, compatibility validation, initialization, and typed CodexAppServerStartupError failuresCodexAppServer.start(), cliExecutableDiagnostics(), and initialize(_:) only when the app intentionally owns custom diagnostics, compatibility policy, or test setup before initializationCodexAppServer for process ownership, diagnostics, thread creation, stored-thread operations, feature-operation-event streams, and app-wide capability readsCodexAppServer.makeLibrary(configuration:) for 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 badges, and model/MCP/hook snapshots that refresh when app-server app/skill/MCP state changesCodexAppServer.makeInventory(configuration:) for routine app-wide model capabilities, global MCP summaries, hook diagnostics, apps, skills, plugins, and collaboration modesCodexAppServer.fs, CodexAppServer.config, and CodexAppServer.extensions for app-server-owned file metadata, directory/file reads, file discovery with match metadata, effective config, advanced extension pagination, plugin detail reads, and already-configured marketplace upgradesCodexAppServer.mcp for MCP server installs, full status snapshots, and app-wide or thread-scoped MCP resource contentsSwiftASBFeaturePolicy for feature-category defaults and host app authority, with gitObservability, extensionInventory, and extensionMaintenance enabled by default and mutation-oriented categories disabled until the app opts inCodexAppServer.featureOperationEvents() for human-readable SwiftASB-owned mutation records, such as marketplace maintenance attemptsCodexWorkspace for session cwd, app-server-owned worktree snapshots, project identity, Git repository facts, selected Git status snapshots, active permission profile, and runtime filesystem/network permission factsCodexThread for conversation-scoped text turns, plan-mode turns, request routing, archive/unarchive, thread actions, thread goals, and local historyCodexThread.startReview(against:placement:) for code-review UI, and CodexThread.sendShellCommand(_:) only for explicit user-level shell actions when shellCommandExecution is enabledCodexTurnHandle for one active turn, including events, steering, interruption, request responses, and completion handoffCodexThread.makeDashboard() for thread-level current stateCodexThread.makeAgenda() for current goal state, accepted plan snapshots, proposed plan text, and summary titlesCodexThread.startPlanningTurn(...) and CodexAppServer.TurnCollaborationMode.plan(...) for explicit plan-mode UI controlsCodexTurnHandle.minimap for active-turn current stateCodexTurnItem.Kind.sleep when custom turn-history or minimap-adjacent UI switches over public turn item kindsCodexThread.makeRecentTurns(...), makeRecentFiles(...), and makeRecentCommands(...) for local history viewsCodexAppServer.ThreadListQD, CodexFS.FileDiscoveryQD, CodexThread.HistoryWindowQD, CodexThread.RecentFilesQD, and CodexThread.RecentCommandsQD when SwiftUI state needs repeatable query intentASBPresentation, ASBAppKit, and ASBSwiftUI products when the app wants ready-made sidebar, agenda, or dashboard panels over SwiftASB presentation snapshotshttps://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 READMESwiftASBASBPresentation, ASBAppKit, and ASBSwiftUI when the app uses SwiftASB's reusable presentation snapshots or native UI panelsCodexAppServerCodexAppServer.Library when the UI needs stored-thread lists before a thread is selectedCodexThreadCodexTurnHandleappServer.start(_:) for normal clients and the lower-level start() plus initialize(_:) sequence only for custom diagnostics or tests.CodexAppServer.CodexAppServer.Library from the app server when the UI has a launcher, sidebar, project browser, or app-wide diagnostics surface.appServer.fs, appServer.config, appServer.makeInventory(configuration:), appServer.extensions, appServer.mcp, CodexWorkspace, and SwiftASBFeaturePolicy when SwiftUI needs filesystem, config, plugin/skill/app, collaboration-mode, marketplace-maintenance, MCP resource or install state, worktree, selected Git status, project identity, thread source, permission facts, or feature-category choices from Codex.makeAgenda() when the UI shows goals or plans.CodexTurnHandle or CodexThread.Prefer one app-facing model that makes ownership visible:
import Observation
import SwiftASB
@MainActor
@Observable
final class CodexWorkspaceModel {
private let appServer = CodexAppServer()
var inventory: CodexAppServer.Inventory?
var library: CodexAppServer.Library?
var thread: CodexThread?
var dashboard: CodexThread.Dashboard?
var agenda: CodexThread.Agenda?
var currentMinimap: CodexTurnHandle.Minimap?
var errorMessage: String?
func start(workspacePath: String) async {
do {
let session = try await appServer.start(
.init(
clientInfo: .init(
name: "ExampleApp",
title: "Example App",
version: "1.0.0"
)
)
)
_ = session.cliExecutableDiagnostics
inventory = try await appServer.makeInventory(
configuration: .init(
hookListCurrentDirectoryPaths: [workspacePath],
extensionCurrentDirectoryPaths: [workspacePath]
)
)
let thread = try await appServer.startThread(
.init(currentDirectoryPath: workspacePath)
)
self.thread = thread
library = try await appServer.makeLibrary(
configuration: .init(
sortedBy: .turnFinishedNewestFirst,
groupedBy: .repository,
query: .unarchived(limit: 30),
mcpServerStatusRequest: .init(detail: .toolsAndAuthOnly)
)
)
dashboard = await thread.makeDashboard()
agenda = try await thread.makeAgenda()
} catch {
errorMessage = "SwiftASB could not start the local Codex runtime: \(error)"
}
}
func refreshAppSnapshots() async {
await inventory?.refresh()
await library?.refreshAppSnapshots()
}
func selectThread(_ threadID: String?) {
library?.selectThread(threadID)
}
func plan(_ prompt: String) async {
guard let thread else {
errorMessage = "SwiftASB cannot start a planning turn before a thread exists."
return
}
do {
let turn = try await thread.startPlanningTurn(prompt)
currentMinimap = turn.minimap
for try await event in turn.events {
if case .completed = event {
_ = try await turn.complete()
currentMinimap = nil
return
}
}
} catch {
errorMessage = "SwiftASB planning turn failed before completion: \(error)"
}
}
func run(_ prompt: String) async {
guard let thread else {
errorMessage = "SwiftASB cannot start a turn before a thread exists."
return
}
do {
let turn = try await thread.startTextTurn(prompt)
currentMinimap = turn.minimap
for try await event in turn.events {
if case .completed = event {
_ = try await turn.complete()
currentMinimap = nil
return
}
}
} catch {
errorMessage = "SwiftASB turn failed before completion: \(error)"
}
}
func stop() async {
await appServer.stop()
}
}
Use this as a shape, not as a file to paste blindly. Match the app's real lifetime, error model, and UI needs.
CodexAppServerStartupError startup and compatibility failures before offering turn controls.inventory for routine app-wide model capabilities, global MCP summaries, hook diagnostics, apps, skills, plugins, and collaboration modes.library for stored-thread sidebars, cwd or repository grouping, stable worktree groups, repository/worktree filters, selected worktree or repository context, selected Git status, project identity display, thread-source badges, library-local selection, app-wide model capabilities, MCP server status, and hook diagnostics.library.selectedGitStatus, lastGitStatusReadAt, and latestGitStatusErrorDescription when a selected-worktree status panel needs branch, SHA, remotes, dirty/untracked counts, or refresh failures.CodexAppServer.ThreadListQD when the same sidebar query should drive both direct listThreads reads and library loading.CodexAppServer.fs and CodexFS.FileDiscoveryQD for sandbox-safe file pickers, metadata panes, directory browsers, file-byte previews, watches, highlighted matches, and ranking explanations.CodexAppServer.mcp when the UI needs to install MCP servers, show full MCP details, or show text/blob resource contents advertised by a configured MCP server.CodexAppServer.config, CodexAppServer.extensions, and CodexWorkspace for diagnostics views that show effective config, requirements, advanced extension detail, marketplace maintenance, worktree snapshots, selected Git status, project identity, active profile, and filesystem/network permissions.SwiftASBFeaturePolicy to present feature-category toggles only when the app actually lets users change SwiftASB-owned authority. Read-only Git observability and extension inventory are enabled by default; stronger mutation categories should stay deliberate app choices.CodexAppServer.featureOperationEvents() when SwiftUI needs to show marketplace-upgrade results or future SwiftASB-owned mutation records. Do not emit parallel UI events for routine read-only refreshes.agenda for plan and goal UI when the view needs current goal state, accepted plan steps, proposed plan text, or goal mutations. Use CodexThread.readGoal(), setGoal(_:), clearGoal(), setName(_:), archive(), unarchive(), updateMetadata(gitInfo:), compactContext(), and rollbackLastTurns(_:) from app-facing actions that already own the selected thread.CodexThread.startReview(against:placement:) only from review controls that clearly say what will be reviewed and where the result appears.CodexThread.sendShellCommand(_:) only behind explicit user opt-in for high-impact shell execution; preserve shell syntax and explain that it does not inherit the thread sandbox policy.dashboard for thread-wide current activity. Use thread.startPlanningTurn(...) for Plan buttons instead of sending slash commands through a text prompt.currentMinimap for the active turn's command, file-edit, dynamic-tool, collab-tool, MCP, and compaction activity.CodexTurnItem.Kind.sleep explicitly in custom turn item switches so UI remains forward-safe for Codex CLI 0.142.x history and live events.ASBThreadSidebar, ASBAgendaPanel, and ASBDashboardPanel from ASBSwiftUI when the app wants SwiftASB-owned presentation snapshots rendered with packaged UI instead of custom panels.Run the repository's documented validation path.
For SwiftPM packages:
swift build
swift test
For Xcode apps, use the repository's documented xcodebuild or Xcode MCP workflow. Do not assume SwiftPM validation is enough for an app project with Xcode-owned project settings.
Live Codex integration tests should be opt-in, isolated in temporary workspaces, and bounded by hard timeouts.
swiftasb:explain-swiftasb when the user needs adoption tradeoffs before implementation.swiftasb:choose-integration-shape when ownership or app shape is unclear.apple-dev-skills:explore-apple-swift-docs for SwiftUI, Observation, SwiftPM, or AppKit documentation.CodexWire... models into SwiftUI view state.CodexAppServerStartupError cases when mapping errors into UI text.npx claudepluginhub gaelic-ghost/socket --plugin swiftasb-skillsCreates, edits, and verifies skills using a test-driven development approach with pressure scenarios and subagents.