Token导航 LogoToken导航

Agent Skill · 前端设计

law-of-demeter-swift(LAW OF demeter Swift 命令行)

law-of-demeter-swift 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

law-of-demeter-swift 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 4,816。

总安装 799周安装 32GitHub Stars 公开资料未说明下载 259核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:law-of-demeter-swift(LAW OF demeter Swift 命令行)
来源仓库:https://github.com/antgly/law-of-demeter-swift-skill
仓库路径:skills/law-of-demeter-swift
安装命令:
npx skills add https://github.com/antgly/law-of-demeter-swift-skill --skill law-of-demeter-swift
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/antgly/law-of-demeter-swift-skill --skill law-of-demeter-swift

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

law-of-demeter-swift 用于处理 GitHub 仓库、Issue 和 Pull Request 信息。适合在 Codex、Claude、Cursor、Gemini CLI 中整理代码协作事项。通过 npx 安装后,结合原始 README 核验具体用法。

安装前需确认权限和维护状态,避免触发不必要的网络或命令操作。建议根据项目实际需求验证其适用性。

来源仓库内路径:skills/law-of-demeter-swift

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/antgly/law-of-demeter-swift-skill --skill law-…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

law-of-demeter-swift 怎么安装?

在终端执行 npx skills add https://github.com/antgly/law-of-demeter-swift-skill --skill law-of-demeter…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

law-of-demeter-swift 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

law-of-demeter-swift 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

law-of-demeter-swift 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

law-of-demeter-swift 用的人多吗?

公开数据是累计安装 799 次,近一周安装 32 次,下载 259 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

law-of-demeter-swift 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
law-of-demeter-swift

LAW OF demeter Swift 命令行 · 本页

799—需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Law of Demeter for Swift (Strict Review Mode)

Purpose

Enforce Law of Demeter (LoD) in Swift code with a strict-by-default review posture:

  • Flag deep structural access (a.b.c, a?.b?.c)
  • Flag chained domain lookups across model/service boundaries
  • Flag async/actor traversal chains after await
  • Prefer owner-level, intent-focused APIs
  • Preserve Swift API naming style (no Java-style getX() suggestions)
Core rule: Ask for what you need. Do not traverse internal structure to reach strangers.

Strict Review Mode (Default Behavior)

In this strict version, assume a likely LoD violation when all of the following are true:

  1. The code is in domain/app/business logic (not a boundary adapter or fluent DSL)
  2. A caller traverses 2+ domain hops to obtain a value or trigger behavior
  3. The traversal exposes another type’s internal structure or storage shape
  4. The caller could reasonably ask an owning type/service for the same result

Examples that should be flagged in strict mode

  • company.employee(for: id)?.address.city
  • order.customer.paymentMethod.last4
  • session.user.profile.preferences.theme
  • try await accountService.currentAccount().owner.notificationSettings.marketingEmailsEnabled

What Counts as a “Stranger” (Swift Edition)

Inside a method or computed property body, safe collaborators are generally:

  • self
  • parameters
  • locals created in the method
  • direct stored properties / direct collaborators

A likely LoD violation occurs when code reaches through one of those collaborators to a nested collaborator that the caller does not own.

Ask yourself

  • Am I using a direct collaborator?
  • Or am I using a collaborator only as a path to reach a stranger?

Swift-Specific Requirements (Naming + Design)

1) Preserve Swift API style at the call site

When proposing a refactor:

  • cheap read-only data → property

- employee.city - order.paymentLast4

  • action / async / throws / work → method

- company.city(for:) - accountService.marketingEmailsEnabled()

Do not suggest Java-style names like:

  • getCity()
  • getPostalCode()
  • getMarketingEmailsEnabled()

2) Dot count is a trigger, not proof

A long chain is a signal. In strict mode, review it, then classify it:

  • Structural reach-through → flag
  • Intentional fluent API / stdlib pipeline → usually allow

3) Concurrency does not exempt LoD

Swift async/await and actor code is still subject to LoD. If await is followed by traversal through returned internals, treat it as a likely design smell.


Aggressive Detection Heuristics (Use in Reviews)

Flag or strongly scrutinize code matching these patterns:

Pattern A: Deep property traversal

  • a.b.c
  • a.b.c.d
  • a?.b?.c
  • a?.b?.c?.d

Pattern B: Domain call + traversal

  • service.fetchX().y.z
  • repo.load().nested.value
  • store.state.user.profile

Pattern C: Async call + traversal (high-priority smell)

  • try await service.currentSession().user.profile.preferences
  • await actor.snapshot().nested.value

Pattern D: Temporary drilling variables

let profile = user.profile
let address = profile.address
return address.postalCode

Pattern E: Repeated chain access across files

If the same chain or a similar chain appears in multiple locations, escalate severity and suggest centralizing the API.


Review Severity Levels (Strict)

Use these levels when reporting:

Domain hop definition: Count domain hops as the number of transitions (dots) between domain segments. For example, order.customer.address.city has 3 domain hops (order → customer → address → city). Treat 2+ domain hops as a likely LoD violation; the severity depends on context as described below.

High severity

  • Async/actor traversal chain after await
  • 2+ domain hops in app/business logic
  • Public API exposing nested structure
  • Repeated chain smell in multiple call sites

Medium severity

  • 2-hop domain traversal in internal code
  • UI/view model reaches into nested domain types
  • Tests needing deep stubs because of traversal

Low severity / review note

  • Borderline chain in boundary mapping code
  • One-off read in local adapter code (still worth watching)

What Not to Flag (False-Positive Guardrails)

Even in strict mode, do not auto-flag these unless they also expose domain internals improperly:

1) Standard library pipelines

let ids = orders
    .filter(\.isOpen)
    .map(\.id)
    .sorted()

2) Common string/value transformations

let normalized = input
    .trimmingCharacters(in: .whitespacesAndNewlines)
    .lowercased()

3) Intentional fluent APIs / builders / DSLs

If chaining is the designed public abstraction, it may be fine.

4) DTO/adapter mapping code at boundaries

Some structural traversal is expected when decoding / mapping external data. Keep it localized and do not leak it throughout the app.

In strict mode, boundary code is reviewed, not automatically exempted.

Refactoring Strategy (Strict, Minimal, Swift-Idiomatic)

When you flag a violation, propose the smallest safe refactor that improves design.

Preferred order of fixes

  1. Add forwarding property (cheap, stable data)
  2. Add owner-level method (query/action/async/throws)
  3. Move behavior to owner
  4. Add façade/protocol (especially across module boundaries)
  5. Collapse async traversal behind actor/service API

Do this first (minimal change path)

  • Add a property or method on the most appropriate owner
  • Replace the call site chain
  • Keep behavior unchanged
  • Keep names Swift-idiomatic

Canonical Examples (Strict Mode)

❌ Flag: caller traverses nested structure

import Foundation

struct Address {
    let city: String
    let postalCode: String
}

struct Employee {
    let id: UUID
    let address: Address
}

final class Company {
    private let employeesByID: [UUID: Employee]

    init(employeesByID: [UUID: Employee]) {
        self.employeesByID = employeesByID
    }

    func employee(for employeeID: UUID) -> Employee? {
        employeesByID[employeeID]
    }
}

let postalCode = company.employee(for: employeeID)?.address.postalCode

✅ Prefer: owner-level query

import Foundation

struct Address {
    let city: String
    let postalCode: String
}

struct Employee {
    let id: UUID
    private let address: Address

    var city: String { address.city }
    var postalCode: String { address.postalCode }
}

final class Company {
    private let employeesByID: [UUID: Employee]

    init(employeesByID: [UUID: Employee]) {
        self.employeesByID = employeesByID
    }

    func postalCode(for employeeID: UUID) -> String? {
        employeesByID[employeeID]?.postalCode
    }

    func city(for employeeID: UUID) -> String? {
        employeesByID[employeeID]?.city
    }
}

let postalCode = company.postalCode(for: employeeID)

Swift Concurrency Example (Strict)

❌ High severity: async traversal chain

let marketingEmailsEnabled = try await accountService
    .currentAccount()
    .owner
    .notificationSettings
    .marketingEmailsEnabled

Why this is high severity:

  • await boundary + structural traversal
  • Caller learns internal account/owner/settings layout
  • Refactors spread across many call sites

✅ Prefer: intent-focused actor/service API

let marketingEmailsEnabled = try await accountService.marketingEmailsEnabled()

✅ Possible implementation

actor AccountService {
    private var account: Account?

    func marketingEmailsEnabled() throws -> Bool {
        guard let account else { throw AccountError.notLoaded }
        return account.marketingEmailsEnabled
    }
}

enum AccountError: Error {
    case notLoaded
}

struct Account {
    private let owner: User

    var marketingEmailsEnabled: Bool {
        owner.marketingEmailsEnabled
    }
}

struct User {
    private let notificationSettings: NotificationSettings

    var marketingEmailsEnabled: Bool {
        notificationSettings.marketingEmailsEnabled
    }
}

struct NotificationSettings {
    let marketingEmailsEnabled: Bool
}

Copilot/Codex Review Instructions (Strict Output Format)

When reviewing code, use this response pattern for each likely violation:

1) Identify the chain

  • Quote the exact chain
  • Name the owner and the stranger(s)

2) Explain the coupling

  • What internal structure is leaked?
  • Why will refactors be harder?
  • Why is this especially risky if async/actor-based?

3) Propose a Swift-idiomatic replacement

  • Prefer property for cheap data
  • Prefer method for async/throws/work
  • Avoid getX() naming

4) Show a minimal patch direction

  • Add owner-level property/method
  • Replace call site
  • Preserve behavior

5) Classify severity

  • High / Medium / Low (with a one-line reason)

Review Comment Templates (Strict)

Template: medium severity (sync chain)

  • LoD concern (medium): company.employee(for: id)?.address.city reaches through Employee into Address, which leaks internal structure to the caller. Consider adding company.city(for:) (or Employee.city if that’s the right ownership boundary) and calling that instead.

Template: high severity (async/actor chain)

  • LoD concern (high): try await accountService.currentAccount().owner.notificationSettings.marketingEmailsEnabled crosses an async boundary and then traverses nested internals. This tightly couples callers to Account/User/NotificationSettings layout. Prefer an intent-level API such as try await accountService.marketingEmailsEnabled().

Template: naming reminder

  • Swift API naming: If you add a replacement API, prefer Swift-style names (city, city(for:), marketingEmailsEnabled()) rather than Java-style getCity() / getMarketingEmailsEnabled().

Quick Decision Rules (Strict)

Flag immediately if

  • 2+ domain hops (a.b.c in business logic)
  • async/await + traversal (await x().y.z)
  • public API returns structure only to force traversal by callers
  • repeated chain smells in multiple files

Usually allow if

  • stdlib pipeline chain
  • string/value fluent transformations
  • builder/DSL chain
  • localized DTO mapping code at a boundary

If unsure

Treat as review note and ask:

  • “Can this caller ask an owner for intent-level data instead?”

Anti-Regression Guidance

After refactoring one LoD violation, look for siblings:

  • Same chain in other files
  • Similar chains on the same type
  • Tests that still mock deep internals
  • Public APIs that encourage traversal

If found, propose a small follow-up refactor to centralize the new owner-level API.


Bottom Line

Strict mode favors maintainability over convenience.

In Swift code, especially with actors and async services, prefer APIs that:

  • express intent
  • hide structure
  • preserve Swift naming conventions
  • reduce refactor blast radius
  • keep call sites simple and resilient

平台分布

Codex

36.71%
按下载量换算95

Claude

28.48%
按下载量换算74

Cursor

17.26%
按下载量换算45

Gemini CLI

10%
按下载量换算26

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills