Logo: Swift Code Reviewer

Swift Code Reviewer

Communautéit
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.

Iwwersiicht

EditeurViniciuscarvalho
Repositoryswift-code-reviewer-skill
Skill-Nummswift-code-reviewer
Stären
39
Forks
6
Matgeliwwert Dateien
115
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 115 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Viniciuscarvalho huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Swift Code Reviewer an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/Viniciuscarvalho/swift-code-reviewer-skill/tree/main
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Viniciuscarvalho/swift-code-reviewer-skill.git \
  .claude/skills/swift-code-reviewer
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Swift Code Reviewer an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Swift Code Reviewer automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Swift Code Reviewer net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

An nach 55 weider Dateien.

Heefeg gestallte Froen

Wat mécht de KI-Skill 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.

Firwat Swift Code Reviewer op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Swift Code Reviewer besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Swift Code Reviewer an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/Viniciuscarvalho/swift-code-reviewer-skill/tree/main an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Swift Code Reviewer benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Swift Code Reviewer benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Swift Code Reviewer domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Swift Code Reviewer gratis?

Jo. Viniciuscarvalho huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇