Law Of Demeter Swift
Enforces Law of Demeter principles in Swift frontend code, reducing dependencies & improving modularity for cleaner architecture.
Install on your platform
We auto-selected Claude Code based on this skill’s supported platforms.
Run in terminal (recommended)
claude mcp add law-of-demeter-swift npx -- -y @trustedskills/law-of-demeter-swift
Or manually add to ~/.claude/settings.json
{
"mcpServers": {
"law-of-demeter-swift": {
"command": "npx",
"args": [
"-y",
"@trustedskills/law-of-demeter-swift"
]
}
}
}Requires Claude Code (claude CLI). Run claude --version to verify your install.
About This Skill
What it does
This skill, law-of-demeter-swift, helps developers adhere to the Law of Demeter when writing Swift code. It provides guidance on reducing direct dependencies between objects and promoting looser coupling through method calls. The skill encourages using only methods of an object or its parameters/arguments, preventing unnecessary access to internal data structures. This leads to more maintainable and testable codebases.
When to use it
- Refactoring existing Swift code to improve modularity and reduce dependencies.
- Designing new Swift classes and objects with a focus on adhering to the Law of Demeter principles.
- Reviewing Swift code for potential violations of the Law of Demeter, identifying areas for improvement.
- When needing to simplify complex object interactions and minimize side effects.
Key capabilities
- Provides guidance on applying the Law of Demeter in Swift.
- Identifies potential violations of the principle within existing code.
- Suggests refactoring strategies to improve code structure.
- Promotes looser coupling between objects.
Example prompts
- "Analyze this Swift code snippet and identify any violations of the Law of Demeter."
- "How can I refactor this class to better adhere to the Law of Demeter?"
- "Explain the benefits of applying the Law of Demeter in a Swift project."
Tips & gotchas
The skill assumes basic familiarity with object-oriented programming concepts and the principles of software design. It's most effective when used proactively during development rather than as a reactive debugging tool.
Tags
TrustedSkills Verification
Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.
Security Audits
| Gen Agent Trust Hub | Pass |
| Socket | Pass |
| Snyk | Pass |
🌐 Community
Passed automated security scans.