Agent skill · AI & Agents

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.

rshankrasgithub.com/rshankrasGitHub ↗
claude-codecan modify filesMIT
Install
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.

Facts
Files in the skill folder: 2
SKILL.md size: 4 KB
Bundled scripts: none
Allowed tools: ReadWriteEditGlobGrepBash
Path: skills/swift/code-size/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 589
Language: Swift

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 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

What's inside
Steps it walks through
  1. When This Skill Activates
  2. The Rules
  3. Brownfield Adoption: Baseline, Never Mass-Refactor
  4. When a Rule Fires
  5. Common Pitfalls
  6. References
Ships with 1 file
  • rules/swiftlint.yml
Commands it runs
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
More from claude-code-apple-skills
All skills →
About this skill
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.

Keep going