code-size
Enforce complexity and size limits on Swift code with SwiftLint threshold rules — cyclomatic complexity, function/type/file length, parameter count — adopted via a violations baseline so existing code never blocks. Use when agent-written code needs deterministic size constraints.
npx skills add rshankras/claude-code-apple-skills --skill code-size --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Code Size & Complexity Limits Complexity is the strongest single predictor of defect density, and code written *by agents* balloons fastest — an agent under pressure adds one more branch to an existing function far more readily than it extracts a new one. These five SwiftLint threshold rules are the deterministic cap: they keep functions small enough that tests can actually cover their branches, and they keep agents from wrangling with their own tangles. ## When This Skill Activates Use this skill when: - Setting up quality gates for a project where agents write most of the code - A review keeps flagging "this function is too long/branchy" by hand - Functions have grown past what their tests plausibly cover - Adopting the deterministic gauntlet (see `testing/fitness-functions/`) ## The Rules The fragment at `rules/swiftlint.yml` configures five built-in SwiftLint rules (all enabled by default in SwiftLint — this fragment sets the thresholds): | Rule | Warning | Error | What it caps | |---|---|---|---| | `cyclomatic_complexity` | 10 | 20 | Independent paths through one function | | `function_body_length` | 50 | 100 | Lines per function body | | `type_body_length` | 300 | 500 | Lin
- When This Skill Activates
- The Rules
- Brownfield Adoption: Baseline, Never Mass-Refactor
- When a Rule Fires
- Common Pitfalls
- References
swiftlint lint --write-baseline .swiftlint-baseline.json The gate from then on — fails only on NEW violations swiftlint lint --strict --baseline .swiftlint-baseline.json swiftlint lint --quiet | wc -l > .swiftlint-count
What does the code-size skill do?
Enforce complexity and size limits on Swift code with SwiftLint threshold rules — cyclomatic complexity, function/type/file length, parameter count — adopted via a violations baseline so existing code never blocks. Use when agent-written code needs deterministic size constraints.
How do I install it?
Run `npx skills add rshankras/claude-code-apple-skills --skill code-size --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From rshankras/claude-code-apple-skills, a repository with 589 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
