Logo Swift Code Reviewer

Swift Code Reviewer

Cộng đồng
Viniciuscarvalho
swift-code-reviewer

Perform thorough code reviews for Swift/SwiftUI code, including spec adherence (PR description + linked issues), code quality, architecture, performance, security, Swift 6+ best practices, project standards from .claude/CLAUDE.md, and meta-feedback on recurring patterns that suggest gaps in the agent's instructions. Use when reviewing PRs/MRs (especially AI-generated ones), performing quality audits, validating against original spec, or providing structured feedback with severity levels and improvement suggestions for both the code and the agent loop that produced it.

Tổng quan

Nhà phát hànhViniciuscarvalho
Kho mãswift-code-reviewer-skill
Tên kỹ năngswift-code-reviewer
Sao
39
Bản fork
6
Tệp đi kèm
115
Giấy phépMIT
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ộ.

  • 115 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 Viniciuscarvalho 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 Swift Code Reviewer 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/Viniciuscarvalho/swift-code-reviewer-skill/tree/main
  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/Viniciuscarvalho/swift-code-reviewer-skill.git \
  .claude/skills/swift-code-reviewer
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 Swift Code Reviewer 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 Swift Code Reviewer 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 Swift Code Reviewer 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.

Swift/SwiftUI Code Review Skill

Multi-layer review covering Swift 6+ concurrency, SwiftUI patterns, performance, security, architecture, and project-specific standards. Reads .claude/CLAUDE.md and outputs Critical/High/Medium/Low severity findings with file:line references and before/after code examples.

When to Use This Skill

  • "Review this PR"
  • "Review my code" / "Review my changes" / "Review uncommitted changes"
  • "Code review for [component]"
  • "Audit this codebase" / "Check code quality"
  • "Review against .claude/CLAUDE.md" / "Check if this follows our coding standards"
  • "Architecture review" / "Performance audit" / "Security review"
  • "Review this PR against the spec"
  • "Did the agent miss anything from issue #123?"
  • "What rules am I missing in CLAUDE.md based on this PR?"
  • "Review this AI-generated PR"

Workflow

Phase 0 — Resolve Scope

Objective: Produce a canonical scope object before any analysis begins. Every later phase reads from this object — no phase fetches the changeset independently.

Mode Detection

Run these checks in order; stop at the first match:

PriorityConditionMode
1PR number or URL supplied by userPR — gh pr view <n> --json files,baseRefName
2Explicit file paths supplied by userFile — supplied paths → scope.modified, skip detection
3gh pr view --json number returns a result for current branchPR (auto-detected)
4"staged" or "cached" in user's invocationStaged — git diff --cached --name-status
5DefaultLocal — git diff --name-status <base>...HEAD + git diff --name-status (union)

Base branch resolution (for PR auto-detect and Local mode):

bash
# 1. PR metadata (authoritative when a PR exists)
gh pr view --json baseRefName --jq '.baseRefName'
# 2. Remote default branch
git rev-parse --abbrev-ref origin/HEAD
# 3. Last resort
git branch -r | grep -E 'origin/(main|master)$' | head -1

If gh is unavailable or unauthenticated, announce loudly and fall back to Local:

"gh unavailable — falling back to local mode against origin/main. Run gh auth login for full PR scope detection."

Scope Object
scope = {
  modified:         Set<Path>   // first-class findings — full file, all severity levels
  deleted:          Set<Path>   // spec-adherence reasoning only — skip per-file analysis loop
  testsForModified: Set<Path>   // coverage findings → main report; other findings → Adjacent Observations
  related:          Set<Path>   // read for context only — all findings → Adjacent Observations
}

Populate modified and deleted:

bash
# PR mode
gh pr view <n> --json files --jq '.files[] | [.path, .status] | @tsv'
# Local / Staged
git diff --name-status <base>...HEAD
  • Status M, A, C → scope.modified
  • Status D → scope.deleted
  • Status R (rename) → new path → scope.modified; record old path so the agent avoids critiquing unchanged content as new code

Populate testsForModified: For each path in scope.modified:

  1. Mirror into test tree: Features/Login/LoginViewModel.swift → Tests/Features/Login/LoginViewModelTests.swift
  2. Fall back: search for *Tests.swift in the same directory
  3. Add found paths (that exist on disk) to scope.testsForModified

Populate related: Added during Phase 1 as the agent reads imported files, protocol declarations, and parent views for context.

Excluded paths — filter from all sets before finalising:

  • Pods/**, Carthage/**, .build/**, DerivedData/**, .swiftpm/**
  • *.generated.swift, *.pb.swift, R.generated.swift
  • Any patterns in a review-excluded-paths block in .claude/CLAUDE.md
Scope Banner (mandatory — first output before any findings)
Scope: PR #123 · base: main · modified: 7 · tests-for-modified: 3 · deleted: 1 · related: 12

For auto-detected PR, prepend a detection notice:

Detected open PR #123 (base: main). Run with --local to review uncommitted work instead.
Scope: PR #123 · base: main · modified: 7 · tests-for-modified: 3 · deleted: 1 · related: 12

For local mode:

Scope: local (base: main) · modified: 4 (3 pushed, 1 uncommitted) · related: 8
Scope Enforcement

These rules apply throughout Phases 1–3:

  • L1 — file-level: Any file in scope.modified is reviewed in full — every line is in scope, not just changed lines.
  • O1 — quarantine: Findings against files outside scope.modified (and outside coverage checks in scope.testsForModified) go into Adjacent Observations — a dedicated section at the end of the report labelled "out of scope for this PR — file separately."
  • Severity rollup (Critical: N | High: N | …) counts only in-scope findings. Adjacent Observations are excluded.

Phase 1 — Context Gathering

  1. Read the Spec
    • For PRs: gh pr view <num> --json title,body,closingIssuesReferences,labels
    • For linked issues: gh issue view <num> --json title,body,labels
    • For MRs: glab mr view <num> and glab issue view <num>
    • Extract:
      • Stated goal / problem being solved
      • Explicit acceptance criteria (look for checkboxes, "should", "must", "Given/When/Then")
      • Edge cases or non-goals mentioned
      • Out-of-scope items
    • If no PR/issue context is available, note this and fall back to inferring intent from the diff.
  2. Try to load .claude/CLAUDE.md.
    • If missing: add a note to the report — "No project standards file found — review uses default Apple guidelines" — then continue.
  3. Use scope.modified from Phase 0 as the authoritative file list. To understand what changed in each file:
    • PR mode: gh pr diff <n> -- <file>
    • Local mode: git diff <base>...HEAD -- <file>
    • If scope.modified is empty after Phase 0, stop and report the scope banner with no findings.
  4. Read each file in scope.modified in full. As you encounter imported files, protocol declarations, parent views, and other dependencies, add them to scope.related — they can be read freely, but findings against them go to Adjacent Observations. Test files in scope.testsForModified are read here for coverage analysis.

Phase 2 — Analysis

For each category, load the reference file before writing findings:

0. Spec Adherence

Reference: references/spec-adherence.md

  • Requirement Coverage
    • Does each acceptance criterion map to a concrete code change?
    • Are edge cases mentioned in the spec handled?
    • For files in scope.testsForModified: are tests covering the scenarios described in the spec? Coverage gaps → main report. Other issues found in those test files → Adjacent Observations.
  • Scope Discipline
    • Flag changes outside the stated scope (scope creep)
    • Flag unrelated refactors bundled into the PR
  • Deleted Files: For each path in scope.deleted, reason about whether its removal satisfies or violates a spec requirement. Include in the Requirement Coverage table; skip the per-file analysis loop.
  • Missing Work
    • TODOs, fatalError("not implemented"), empty function bodies
    • Stubbed mocks that should be real implementations
    • Acceptance criteria with no corresponding diff
  • Intent Drift
    • Code solves a similar but different problem than stated
    • Naming/structure suggests a different mental model than the spec
  1. Swift Quality — concurrency, error handling, optionals, naming → references/swift-quality-checklist.md; for concurrency findings also read skills/swift-concurrency/references/sendable.md and actors.md
  2. SwiftUI Patterns — property wrappers, state management, deprecated APIs → references/swiftui-review-checklist.md; for wrapper selection read skills/swiftui-expert-skill/references/state-management.md
  3. Performance — view body cost, ForEach identity, lazy loading, retain cycles → references/performance-review.md
  4. Security — force unwraps, Keychain vs UserDefaults, input validation, no secrets in logs → references/security-checklist.md
  5. Architecture — MVVM/MVI/TCA compliance, DI, testability → references/architecture-patterns.md
  6. Project Standards — validate against .claude/CLAUDE.md rules → references/custom-guidelines.md

For test file findings, consult skills/swift-testing/references/test-organization.md. For navigation/routing findings, consult skills/swiftui-ui-patterns/references/navigationstack.md.

Phase 2.5 — Pattern Detection (for Agent Loop Feedback)

Objective: Identify recurring issues that point to gaps in the agent's instructions, not just the code.

After collecting per-file findings, aggregate them:

  1. Group findings by rule (e.g., "force-unwrap", "deprecated NavigationView", "missing @MainActor on UI mutation").
  2. Mark any rule that fires ≥2 times across the diff as a recurring pattern.
  3. For each recurring pattern, draft a one-line rule suitable for .claude/CLAUDE.md or an agent system prompt — written as a directive, not a description.
  4. If the same recurring pattern appeared in past reviews (check git log of .claude/CLAUDE.md), escalate priority — the existing rule isn't strong enough or isn't being read.

Threshold rationale: one occurrence is a slip; two is a pattern; three+ means the agent's instructions are silent on this and need an explicit rule.

Reference: references/agent-loop-feedback.md.

Phase 3 — Report

Group findings by file → sort by severity within each file → write prioritized action items.

Severity: Critical (crash/data race/security hole) · High (anti-pattern/major arch violation) · Medium (quality/maintainability) · Low (style/suggestion).

Include one-sentence positive feedback where code is notably well-written. Never pad with generic praise.

Concrete Finding Examples

Force Unwrap → guard let (Critical)

LoginViewModel.swift:89 — Current:

swift
let user = repository.currentUser!

Finding: crashes if currentUser is nil (e.g., after sign-out race condition).

Fix:

swift
guard let user = repository.currentUser else {
    logger.error("currentUser nil — aborting login flow")
    return
}

Missing @MainActor on UI-bound ViewModel (High)

FeedViewModel.swift:12 — Current:

swift
class FeedViewModel: ObservableObject {
    @Published var posts: [Post] = []

    func load() async {
        posts = try? await api.fetchPosts()  // ⚠️ mutates @Published off main thread
    }
}

Finding: @Published mutations must happen on the main actor in Swift 6 strict concurrency; this is a data race.

Fix:

swift
@MainActor
@Observable
final class FeedViewModel {
    var posts: [Post] = []

    func load() async throws {
        posts = try await api.fetchPosts()  // safe: whole class is @MainActor-isolated
    }
}

Also migrate from ObservableObject/@Published to @Observable (iOS 17+) — see skills/swiftui-expert-skill/references/state-management.md.

Output Format

Scope: PR #123 · base: main · modified: 7 · tests-for-modified: 3 · deleted: 1 · related: 12

# Code Review — <scope>

## Summary
Files: N | Critical: N | High: N | Medium: N | Low: N

## Spec Adherence

**Source**: PR #123 / Issue #456

| Requirement | Status | Location |
|-------------|--------|----------|
| User can log in with email | ✅ Implemented | LoginView.swift:23 |
| Show error on invalid credentials | ⚠️ Partial — missing 401 case | LoginViewModel.swift:67 |
| Persist session in Keychain | ❌ Not implemented | — |
| Rate limit retries | ❌ Not implemented | — |

**Scope creep**: 1 unrelated change (UserSettings.swift refactor) — recommend
splitting into a separate PR.

---

## <Filename.swift>

[Severity] **<Category>** (line N)
Current: `<problematic snippet>`
Fix: <explanation + corrected snippet>

## Positive Observations
...

## Prioritized Action Items
- [Must fix] ...
- [Should fix] ...
- [Consider] ...

---

## Agent Loop Feedback

Recurring patterns suggest the following rules are missing or under-emphasized
in `.claude/CLAUDE.md`:

### Pattern: Force-unwraps (4 occurrences)
**Files**: LoginView.swift:89, NetworkService.swift:34, UserRepo.swift:12,78

**Suggested rule**:
> Never use `!`, `try!`, or `as!`. Use `guard let` with explicit early return,
> typed throws, or `as?` with handling. Force-unwraps are crashes waiting to happen.

### Pattern: Deprecated NavigationView (2 occurrences)
**Files**: ProfileView.swift:15, SettingsView.swift:22

**Suggested rule**:
> Use `NavigationStack` exclusively. `NavigationView` is deprecated as of iOS 16.

### Pattern: Business logic in View body (3 occurrences)
**Files**: LoginView.swift:45, ProfileView.swift:78, FeedView.swift:34

**Suggested rule**:
> Views must not contain business logic, network calls, or data transformations.
> Move all such work into the @Observable view model.

---

## Adjacent Observations
*Out of scope for this PR. Findings in files read for context that were not modified in this PR.
Not counted in the summary above. File separately or address in a follow-up PR.*

### <RelatedFile.swift> (unmodified)

[Severity] **<Category>** (line N)
Current: `<snippet>`
Note: <what the issue is — no action required for this PR>

Full templates and severity classification: references/feedback-templates.md.

Companion Skills

Full reference tables (all files, when to consult each): references/companion-skills.md.

SkillUse for
skills/swiftui-expert-skill/SwiftUI state, Liquid Glass, macOS patterns, accessibility
skills/swift-concurrency/Actors, Sendable, Swift 6 migration, async/await
skills/swift-testing/Swift Testing framework, test doubles, snapshots
skills/swift-expert/Swift 6+ patterns, protocols, memory, SPM
skills/swiftui-ui-patterns/Navigation, sheets, theming, async state, grids

Platform Commands

bash
# GitHub PR
gh pr diff <n>
gh pr view <n> --json files,comments

# GitLab MR
glab mr diff <n>
glab mr view <n> --json

# Local changes
git diff             # unstaged
git diff --cached    # staged
git diff HEAD~1      # last commit
git diff -- path/to/file.swift

Limitations

  • Spec adherence checks require an accessible PR description or linked issue. When reviewing local changes with no PR context, mark spec adherence as "not assessed" rather than guessing intent.
  • Agent loop feedback assumes the code was AI-generated or AI-assisted. For fully human-written code, recurring patterns are still useful but should be framed as team coding standards rather than agent instructions.

Reference Files

  • references/review-workflow.md — detailed process, diff parsing, git commands
  • references/feedback-templates.md — output templates, severity classification
  • references/spec-adherence.md — parsing PR/issue specs, requirement coverage tables, scope creep classification
  • references/agent-loop-feedback.md — recurring-pattern threshold, directive phrasing, suggested-rule template
  • references/swift-quality-checklist.md — Swift 6+, concurrency, optionals, naming
  • references/swiftui-review-checklist.md — property wrappers, state, modern APIs
  • references/performance-review.md — view optimization, ForEach, resource management
  • references/security-checklist.md — input validation, Keychain, network security
  • references/architecture-patterns.md — MVVM/MVI/TCA, DI, testability
  • references/custom-guidelines.md — parsing .claude/CLAUDE.md
  • references/companion-skills.md — full companion skill tables

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.

và 55 tệp khác.

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

Kỹ năng AI Swift Code Reviewer làm được gì?

Perform thorough code reviews for Swift/SwiftUI code, including spec adherence (PR description + linked issues), code quality, architecture, performance, security, Swift 6+ best practices, project standards from .claude/CLAUDE.md, and meta-feedback on recurring patterns that suggest gaps in the agent's instructions. Use when reviewing PRs/MRs (especially AI-generated ones), performing quality audits, validating against original spec, or providing structured feedback with severity levels and improvement suggestions for both the code and the agent loop that produced it.

Vì sao nên dùng Swift Code Reviewer 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. Swift Code Reviewer 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 Swift Code Reviewer trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/Viniciuscarvalho/swift-code-reviewer-skill/tree/main. 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 Swift Code Reviewer?

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 Swift Code Reviewer 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 Swift Code Reviewer 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 Swift Code Reviewer có miễn phí không?

Có. Kỹ năng này được Viniciuscarvalho phát hành trên GitHub theo giấy phép MIT. 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 👇