agentleFS
molayabmolayab/swift-ai-provider-kit/.claude/skills/add-provider/SKILL.md

add-provider

Skill1 starsChanged 8 months agoMITView on GitHub

Scaffolds a complete new AI provider for AIProviderKit. Use when asked to 'add a provider', 'integrate OpenAI', 'add Gemini support', 'implement a new model provider', or 'add support for [any AI API]'. Follows the mapper pattern — no changes to AIClient needed.

We split this skill into the rules it gives an agent

5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before writing a single line, read these files:

    line 20
  2. Distinctive:

    Add in this order — products array, then targets array, then test targets array:

    line 36
  3. Very specific:

    Write each file using the templates in references/templates.md as a starting point.

    line 100
  4. Very specific:

    Every test: given / when / then comments.

    line 110
  5. Distinctive:

    All three must exit clean.

    line 138

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

You are a Swift 6 package architect implementing a new AI provider for AIProviderKit. Apply the Open/Closed Principle: no changes to AIClient or any existing provider are required.

Constraints

✅ Always: mirror ClaudeProvider's folder structure exactly, keep all mapping logic in mapper types, use ContentBlock as the only cross-boundary content type, use JSONValue for all tool I/O, inject auth via AuthorizationProvider

⚠️ Ask first: if the provider's API uses a non-standard auth scheme, pagination model, or lacks SSE streaming

🚫 Never: hardcode API keys, call URLSession directly in provider or mapper code, put mapping logic inside the provider class, use Any or [String: Any]

Step 1 — Read first

Before writing a single line, read these files:

Sources/ClaudeProvider/ClaudeProvider.swift
Sources/ClaudeProvider/Authorization/APIKeyAuthorization.swift
Sources/ClaudeProvider/Mapping/ClaudeRequestMapper.swift
Sources/ClaudeProvider/Mapping/ClaudeResponseMapper.swift
Sources/ClaudeProvider/Models/ClaudeModels.swift
Sources/ClaudeProvider/Networking/HTTPClient.swift
Tests/ClaudeProviderTests/Mocks/MockHTTPClient.swift
Documentation/AddingAProvider.md
Package.swift

Step 2 — Register in Package.swift

Add in this order — products array, then targets array, then test targets array:

// products:
.library(name: "$ARGUMENTSProvider", targets: ["$ARGUMENTSProvider"]),

// targets (after existing providers):
.target(
    name: "$ARGUMENTSProvider",
    dependencies: ["AIProviderKit"],
    path: "Sources/$ARGUMENTSProvider",
    swiftSettings: [
        .enableUpcomingFeature("ExistentialAny"),
        .enableUpcomingFeature("StrictConcurrency")
    ],
    plugins: [.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLintPlugins")]
),

// test targets:
.testTarget(
    name: "$ARGUMENTSProviderTests",
    dependencies: ["$ARGUMENTSProvider", "AIProviderKit"],
    path: "Tests/$ARGUMENTSProviderTests",
    swiftSettings: [
        .enableUpcomingFeature("ExistentialAny"),
        .enableUpcomingFeature("StrictConcurrency")
    ],
    plugins: [.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLintPlugins")]
),

Step 3 — Create files

Mirror ClaudeProvider's layout exactly:

Sources/$ARGUMENTSProvider/
├── $ARGUMENTSProvider.swift           ← StreamableProvider conformance
├── Authorization/
│   └── $ARGUMENTSAuthorization.swift  ← AuthorizationProvider
├── Mapping/
│   ├── $ARGUMENTSRequestMapper.swift  ← AIRequest → provider body
│   └── $ARGUMENTSResponseMapper.swift ← provider response/SSE → AIResponse
├── Models/
│   └── $ARGUMENTSModels.swift         ← AIModel constants + internal Codable types
└── Networking/
    ├── HTTPClient.swift               ← copy from ClaudeProvider verbatim
    └── URLSession$ARGUMENTSClient.swift

Tests/$ARGUMENTSProviderTests/
├── $ARGUMENTSProviderTests.swift
├── Authorization/
│   └── $ARGUMENTSAuthorizationTests.swift
├── Mapping/
│   ├── $ARGUMENTSRequestMapperTests.swift
│   └── $ARGUMENTSResponseMapperTests.swift
└── Mocks/
    └── MockHTTPClient.swift           ← copy from ClaudeProviderTests verbatim

For Swift code templates for each file, see references/templates.md.

Step 4 — Implement

Write each file using the templates in references/templates.md as a starting point. Key mapping responsibilities:

MapperMust handle
RequestMappermessages → provider format, system prompt, tools schema, sampling params
ResponseMappercontent → [ContentBlock], stop reason → StopReason, tokens → TokenUsage
ResponseMapper.mapStreamEventSSE data line → AIStreamEvent

Step 5 — Write tests

Every test: given / when / then comments. Always inject MockHTTPClient — never call the real API.

// Example: mapper test
@Suite("$ARGUMENTSRequestMapper")
struct $ARGUMENTSRequestMapperTests {
    private let sut = $ARGUMENTSRequestMapper()

    @Test("maps model identifier")
    func map_setsModelIdentifier() {
        // Given
        let request = AIRequest(model: .$ARGUMENTS_MODEL_CONSTANT, messages: [])
        // When
        let mapped = sut.map(request)
        // Then
        #expect(mapped.model == "provider-model-id")
    }
}

Step 6 — Verify (in order, fix before proceeding)

swift build
swift test --filter $ARGUMENTSProviderTests
swift package plugin --allow-writing-to-package-directory swiftlint lint --strict

All three must exit clean. Report the result of each command.

Download now (ZIP)

  • Other versions15 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 15

    1. ThinkInAIXYZ/deepchat★ 6.4ksame name
    2. tddworks/ClaudeBar★ 1.6ksame name
    3. pydantic/genai-prices★ 407same name
    4. agent-cli-framework/aclif★ 20same name
    5. hyhmrright/StockAI★ 13same name
    6. VincentShipsIt/meterbar.dev★ 10same name
    7. yerdaulet-damir/vibe-coding-rules★ 10same name
    8. kiminmonaco/ClaudeBar★ 8same name
    9. RonenMars/threadbase-mobile★ 4same name
    10. qiaojinxia/okapi★ 2same name

    5 more not listed

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Used alongsideProjects with it also use release.

    Other files people use alongside this one.

    Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
    • MicrosoftSkill

      release

      Use ONLY when the user explicitly asks to cut/publish a Huabu desktop release or tag a version. Performs an outward action — bumps the version in apps/desktop/package.json, commits + annotated-tags vX.Y.Z, and pushes the branch + tag. That tag push auto-builds the macOS/Windows installers and publishes a GitHub Release. Provides `status`, `bump`, `tag-push`, and a one-command `run` (bump → tag-push).

      Also in 3 projects that use this

  • In this repository12 other files it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.