Logo Implement Feature

Implement Feature

Tổ chứcPhổ biến
tddworks
implement-feature

Hướng dẫn triển khai tính năng trong ClaudeBar theo phương pháp ưu tiên kiến trúc, TDD, mô hình miền phong phú và các mẫu Swift 6.2. Dùng kỹ năng này khi: (1) Thêm chức năng mới vào ứng dụng (2) Tạo mô hình miền phù hợp với cách người dùng hình dung về hệ thống (3) Xây dựng giao diện SwiftUI sử dụng trực tiếp mô hình miền (4) Người dùng hỏi “triển khai X thế nào” hoặc “thêm tính năng Y” (5) Triển khai tính năng trải rộng trên nhiều mô-đun (DataSources, Providers, Quotas) và App

Tổng quan

Nhà phát hànhtddworks
Kho mãClaudeBar
Tên kỹ năngimplement-feature
Sao
1.5K
Bản fork
153
Tệp đi kèm
5
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 5 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được tddworks công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Implement Feature trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/tddworks/ClaudeBar/tree/main/.claude/skills/implement-feature
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/tddworks/ClaudeBar.git /tmp/ClaudeBar
mkdir -p .claude/skills
cp -r /tmp/ClaudeBar/.claude/skills/implement-feature .claude/skills/implement-feature
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Implement Feature trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Implement Feature ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Implement Feature với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Implement Feature in ClaudeBar

Implement features using architecture-first design, TDD, rich domain models, and Swift 6.2 patterns.

Workflow Overview

┌─────────────────────────────────────────────────────────────┐
│  1. ARCHITECTURE DESIGN (Required - User Approval Needed)  │
├─────────────────────────────────────────────────────────────┤
│  • Read the design docs — they are the source of truth     │
│  • Place the feature: owner, capability, extension point    │
│  • Write the design change into the docs first              │
│  • Analyze requirements                                     │
│  • Create component diagram                                 │
│  • Show data flow and interactions                          │
│  • Present to user for review                               │
│  • Wait for approval before proceeding                      │
└─────────────────────────────────────────────────────────────┘
                            │
                            ▼ (User Approves)
┌─────────────────────────────────────────────────────────────┐
│  2. TDD IMPLEMENTATION                                      │
├─────────────────────────────────────────────────────────────┤
│  • Model tests → models (Quotas / Providers / Domain)       │
│  • Module tests → generic rules and workers (DataSources)   │
│  • Views, reading the domain directly                       │
└─────────────────────────────────────────────────────────────┘

Phase 0: Architecture Design (MANDATORY)

Before writing any code, design it in the docs and get user approval. The design docs are the source of truth (AGENTS.md → Design docs are the source of truth).

Step 0: Read the design docs, and place the feature in them

Read the design in order (ARCHITECTURE.md maps it): USER_JOURNEYS.md (the person and the moment), CANONICAL_MODEL.md (the tree, the words, each law and its owner, owned vs offered), TARGET_ARCHITECTURE.md (the pieces and their one job, the flows), then any docs/features/<x>/design.md it touches. Then answer:

QuestionIf yes
Does it answer another question than the product's lifecycle?it is a capability (CANONICAL §2.1): declared in the definition, its own types, reached through a handle that is nil when not declared — never a flag on Provider, never chosen by a provider's name. A runner outside the modules is supplied by the Engine (TARGET_ARCHITECTURE §10)
Does a provider need something the definition can't say?a generic rule or worker in DataSources (ENGINE_DESIGN), then a line of JSON — never a Swift line that names the provider
Does it react to a refresh, a selection, a setting?it observes an extension point (e.g. QuotaMonitor.onRefreshed) — the Monitor is not edited for it
Does it notify?its own port in Alerting — not a new method on an existing alerter
Is a law missing, or owned twice?add it to CANONICAL §5 with one owner

When the docs don't cover it, write the change into them first (tree lines, laws with owners, a pieces table, a TARGET section) — that doc change is the architecture you present in Step 4. Code that disagrees with the docs is behind; don't bend the design to it.

Step 0b: Think the domain first

Before components, ask how the domain should be: from the root problem (the issue, the journey) to the facts it must respect, to the concepts those force, then compare with the code. Ask the five questions of every type the feature touches, and draw now beside proposed → domain-shape.md. A new aggregate, a moved law or a changed owner goes into the docs in Step 0's change.

Step 1: Analyze Requirements

Identify:

  • What new models/types are needed
  • Which existing components will be modified
  • Data flow between components
  • External dependencies (CLI, API, etc.)

Step 2: Create Architecture Diagram

Use ASCII diagram showing all components and their interactions:

Example: Codex accounts (#326) — a definition change plus generic pieces

┌──────────────────────────────────────────────────────────────────────┐
│                            ARCHITECTURE                               │
├──────────────────────────────────────────────────────────────────────┤
│  Resources (data)        Modules (Swift, no vendor names)    App     │
│                                                                      │
│  ┌──────────────┐   ┌─────────────────────────────┐   ┌───────────┐  │
│  │ codex.json   │──▶│ Providers                   │──▶│ Accounts  │  │
│  │  accounts:   │   │  ProviderCatalog.detect()   │   │ card      │  │
│  │  folder, ids │   │  ProviderDefinition.Accounts│   └───────────┘  │
│  │  dataSources │   │  Provider owns its Accounts │                  │
│  └──────────────┘   └──────────────┬──────────────┘                  │
│                                    │                                 │
│                     ┌──────────────▼──────────────┐                  │
│                     │ DataSources                 │                  │
│                     │  identity, requiresFiles,   │                  │
│                     │  JSON-RPC `then`, env       │                  │
│                     └──────────────┬──────────────┘                  │
│                                    ▼                                 │
│                     ┌─────────────────────────────┐                  │
│                     │ Quotas  (UsageSnapshot …)   │                  │
│                     └─────────────────────────────┘                  │
└──────────────────────────────────────────────────────────────────────┘

Step 3: Document Component Interactions

List each component with:

  • Purpose: What it does
  • Inputs: What it receives
  • Outputs: What it produces
  • Dependencies: What it needs
Example:

| Component      | Purpose                | Inputs          | Outputs        | Dependencies    |
|----------------|------------------------|-----------------|----------------|-----------------|
| AddedAccounts  | Validate a login folder| folder path     | account config | DataSources     |
| identity rule  | Fail closed on swaps   | credential      | UsageError     | —               |

Step 4: Present for User Approval

IMPORTANT: Always ask user to confirm the design is correct before implementing — the doc change (tree, laws and owners, pieces), the diagram, and for UI a mockup in design-concept/<feature>/ on mock data.

Use AskUserQuestion tool with options:

  • "Approve - proceed with implementation"
  • "Modify - I have feedback on the design"

Do NOT proceed to Phase 1 until user explicitly approves.


Core Principles

1. Rich Domain Models (User's Mental Model)

Domain models encapsulate behavior, not just data:

swift
// Rich domain model with behavior
public struct UsageQuota: Sendable, Equatable {
    public let percentRemaining: Double

    // Domain behavior - computed from state
    public var status: QuotaStatus {
        QuotaStatus.from(percentRemaining: percentRemaining)
    }

    public var isDepleted: Bool { percentRemaining <= 0 }
    public var needsAttention: Bool { status.needsAttention }
}

2. Swift 6.2 Patterns (No ViewModel/AppState Layer)

Views consume domain models directly from QuotaMonitor:

swift
// QuotaMonitor is the single source of truth
@MainActor @Observable
public final class QuotaMonitor {
    // The providers you keep: add, delete, order, the derived lineup
    public let providers: Providers

    public var logins: [Account]   // every login
    public var lineup: [Account]   // the lineup
    public func login(id: String) -> Account?

    // Selection state
    public var selectedProviderId: String
    public var selectedLogin: Account?
    public var selectedProviderStatus: QuotaStatus
}

// Views consume domain directly - NO AppState layer
struct MenuContentView: View {
    let monitor: QuotaMonitor  // Injected from app

    var body: some View {
        // Use delegation methods, not monitor.providers.enabled
        ForEach(monitor.lineup, id: \.id) { login in
            ProviderPill(provider: login)
        }
    }
}

3. Protocol-Based DI with @Mockable

Ports for what lies outside the app live at a module's root and are @Mockable; their implementations are internal in Internal/:

swift
@Mockable
public protocol NetworkClient: Sendable {
    func request(_ request: URLRequest) async throws -> (Data, URLResponse)
}

Architecture

Reference: MODULAR_DESIGN.md (modules) · TARGET_ARCHITECTURE.md (how a provider runs) · ARCHITECTURE.md (the app layers)

The code is mid-migration from three layers to modules. Find which side the behaviour lives on before you change it:

WhereHoldsTests
Modules/Providers/Resources/Providers/<id>.json (+ .js)every built-in provider: where the key is, how to fetch, how to readModules/Providers/Tests/ (golden tests over StubbedProvider / ClaudeHarness)
Modules/Providers/SourcesProviderCatalog (finds every definition), Engine (the shared ports), Provider (the one lifecycle: refresh, fallback chain, accounts), ProviderDefinition, settings and account contracts, the capabilities (UsageHistory, GuestPasses, InUse)Modules/Providers/Tests/
Modules/DataSources/SourcesDataSource and its workers: credential lookups (environment, login shell, files, Keychain, browser cookies and storage, SQLite) and refreshes; HTTP, steps, JSON-RPC, terminal, command, file, directory, SQLite, local-server and CloudWatch fetches; JSON / text / script mapping; UsageLog and its log readers; the process runnersModules/DataSources/Tests/
Modules/Quotas/Sourcesthe usage model: UsageSnapshot, UsageQuota, UsageError, plans, costs, DailyUsageStat / DailyUsageReport (interim shapes, see each type's - Note:)Tests/DomainTests/ and the tests of the module that uses it
Modules/AWSClientsthe AWS SDK behind DataSources' CloudWatchClient and PriceCatalog portsModules/AWSClients/Tests/
Sources/DomainQuotaMonitor, Notify!, sessions, In use's NewSessionsTests/DomainTests/
Sources/Infrastructurestorage, notifications, hooks, the shell environment, Claude's guest-pass runnerTests/InfrastructureTests/
Sources/AppSwiftUI views reading the domain directly; ClaudeBarApp.init, the composition root, which builds the Engine and names no providerTests/AppTests/, Tests/AcceptanceTests/

A bug in a migrated provider is fixed in its JSON, or generically in DataSources, never with vendor-named Swift. Modules never import Domain.

Key patterns:

  • Modules by context — the domain at a module's root, its implementation in Internal/, one factory enum per module (DataSources.make, ProviderFactory.make)
  • Providers are data — a feature a provider needs becomes a generic rule or worker, then a line of JSON
  • Protocol-based DI — @Mockable ports; Chicago-school tests assert on state
  • No ViewModel layer — views read QuotaMonitor and Provider directly
  • Settings — generic per-provider values (dataSourceKind, isOn) before a new sub-protocol

TDD Workflow (Chicago School)

Name each test should <outcome> [when <situation>], in the person's words, never a method, type or mechanism verb → Naming tests.

We follow Chicago school TDD (state-based testing):

  • Test state changes and return values, not interactions
  • Focus on the "what" (observable outcomes), not the "how" (method calls)
  • Mocks stub dependencies to return data, not to verify calls
  • Design emerges from tests (emergent design)

Phase 1: Domain Model Tests

Test state and computed properties:

swift
@Suite
struct FeatureModelTests {
    @Test func `should be normal when half is left`() {
        // Given - set up initial state
        let model = FeatureModel(value: 50)

        // When/Then - verify state/return value
        #expect(model.status == .normal)
    }

    @Test func `should have 70 left and stay healthy after using 30 of 100`() {
        // Given
        var model = FeatureModel(value: 100)

        // When - perform action
        model.consume(30)

        // Then - verify new state
        #expect(model.value == 70)
        #expect(model.status == .healthy)
    }
}

Phase 2: Module Tests (DataSources / Providers)

Stub dependencies to return data, assert on resulting state:

swift
@Suite
struct FeatureServiceTests {
    @Test func `should load three items when the service answers`() async throws {
        // Given - stub dependency to return data (not verify calls)
        let mockClient = MockNetworkClient()
        given(mockClient).fetch(any()).willReturn(validResponseData)

        let service = FeatureService(client: mockClient)

        // When
        let result = try await service.fetch()

        // Then - verify returned state, not interactions
        #expect(result.items.count == 3)
        #expect(result.status == .loaded)
    }
}

Phase 3: Integration

Create the views. ClaudeBarApp.init is the composition root: it builds the Engine (the ports every provider shares) and calls ProviderCatalog().detect(). A provider is never wired there; a new port is a new Engine field, built once in init (keep startup work there, never in ClaudeBarMain). Acceptance specs in Tests/AcceptanceTests/ compose real modules with stubbed ports.

bash
tuist test Providers         # one module's tests while working (schemes: Providers, DataSources, Domain, Infrastructure, AppTests, AcceptanceTests)
# tuist caches results; the final check, and a forced re-run of one suite, use xcodebuild:
xcodebuild test -workspace ClaudeBar.xcworkspace -scheme ClaudeBar-Workspace -destination 'platform=macOS,arch=arm64'
xcodebuild test -workspace ClaudeBar.xcworkspace -scheme ClaudeBar-Workspace \
  -destination 'platform=macOS,arch=arm64' -only-testing:ProvidersTests/ClaudeAPITests

References

Checklist

Architecture Design (Phase 0)

  • Read CANONICAL_MODEL, TARGET_ARCHITECTURE and the feature's design.md
  • Place it: owner, capability (handle nil when not declared), extension point
  • Thought the domain first: root problem → concepts, the five questions asked of touched types, now/proposed drawn (domain-shape.md)
  • Write the design change into the docs first
  • Analyze requirements and identify components
  • Create ASCII architecture diagram with component interactions
  • Document component table (purpose, inputs, outputs, dependencies)
  • Get user approval before proceeding

Implementation (Phases 1-3) - Chicago School TDD

  • Write failing test asserting expected STATE (Red)
  • Write minimal code to pass the test (Green)
  • Refactor while keeping tests green
  • Put each type in the module MODULAR_DESIGN.md names (never a vendor-named type in a module)
  • Test state changes and return values (not interactions)
  • Define protocols with @Mockable for external dependencies
  • Stub mocks to return data, assert on resulting state
  • Implement ports in the module's Internal/
  • Create views consuming domain models directly
  • Views render and tell only — no comparing, counting or reading quotas to decide
  • Public surface is tells and answers; rules internal; no Bool flag the caller decides; each aggregate changes only its own state
  • Docs updated in the same change (status, build truth, laws)
  • Real UI screenshots on mock data (scripts/demo-screenshots.sh) for UI changes
  • Full xcodebuild test green (tuist test skips cached targets)

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Implement Feature làm được gì?

Hướng dẫn triển khai tính năng trong ClaudeBar theo phương pháp ưu tiên kiến trúc, TDD, mô hình miền phong phú và các mẫu Swift 6.2. Dùng kỹ năng này khi: (1) Thêm chức năng mới vào ứng dụng (2) Tạo mô hình miền phù hợp với cách người dùng hình dung về hệ thống (3) Xây dựng giao diện SwiftUI sử dụng trực tiếp mô hình miền (4) Người dùng hỏi “triển khai X thế nào” hoặc “thêm tính năng Y” (5) Triển khai tính năng trải rộng trên nhiều mô-đun (DataSources, Providers, Quotas) và App

Vì sao nên dùng Implement Feature trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Implement Feature là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Implement Feature trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/tddworks/ClaudeBar/tree/main/.claude/skills/implement-feature. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Implement Feature?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Implement Feature với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Implement Feature với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Implement Feature có miễn phí không?

Có. Kỹ năng này được tddworks phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇