This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Build:
swift buildRun tests:
swift testRun specific test:
swift test --filter "testName"Run tests with code coverage:
swift test --enable-code-coverageBuild in verbose mode:
swift build -vMattermostKit is a Swift 6 package for sending messages to Mattermost via Incoming Webhooks. The architecture follows a protocol-based design for testability and uses Swift 6 strict concurrency throughout.
- Actor-based client:
MattermostWebhookClientis anactorfor thread-safe async operations - Protocol abstraction:
NetworkClientprotocol enables dependency injection for testing - Slack-compatible: Uses the same attachment schema as Slack for compatibility
- Mattermost-specific: Supports
Props.card(sidebar content) andPriority(urgent/important)
Mattermost webhooks do not support Slack's Block Kit. Only use:
- Markdown text in the
textfield - Slack-compatible
attachmentsarray - Mattermost-specific
props.cardandpriority
Client Layer (Sources/MattermostKit/Client/):
MattermostWebhookClient- Main actor that encodes and sends messagesNetworkClientprotocol - Abstraction for HTTP POST operationsURLSessionNetworkClient- Default URLSession-based implementation
Models (Sources/MattermostKit/Models/):
Message- Core message withtext,username,iconEmoji,attachments,props,priorityAttachment- Slack-compatible attachments with fields, colors, actionsProps- Mattermost metadata (primarilycardfor RHS sidebar)Priority- Message priority levels (.urgent,.important)
Error Handling (Sources/MattermostKit/Errors/):
MattermostErrorenum covers:invalidURL,networkError,invalidResponse,encodingError,invalidMessage- Note: No
rateLimitExceeded(not applicable to Mattermost webhooks)
Tests use MockNetworkClient actor (Tests/MattermostKitTests/MockNetworkClient.swift) which:
- Captures all requests for verification
- Queues predefined responses or errors
- Implements
NetworkClientprotocol
All models use CodingKeys to convert camelCase Swift properties to snake_case API fields (e.g., iconEmoji → icon_emoji).
- macOS 12.0+, iOS 15.0+, tvOS 15.0+, watchOS 8.0+
- Swift 6.2+
- Zero external dependencies