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…

MITAuto-check: notesMobile

Install Code Size

skills CLI
$ npx skills add rshankras/claude-code-apple-skills --skill code-size -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install rshankras/claude-code-apple-skills code-size --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/swift/code-size .claude/skills/code-size && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
code-size
GitHub stars
783
Token cost
~1.1k tokens
SKILL.md length
441 words
Files
2
Skills in repo
41
Repo updated
First seen
Licence
MIT

At a glance

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…

  • Agent-written code needs deterministic size constraints
  • SKILL.md covers When This Skill Activates, The Rules, Brownfield Adoption: Baseline,… and When a Rule Fires, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Tasks that involve iOS development

What it does

Code Size is an agent skill from rshankras/claude-code-apple-skills. 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.

Its SKILL.md is about 1.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `rules/swiftlint.yml`).

It sits in Mobile, covering iOS development. The repository describes itself as: Claude Code skills for Apple platform development (iOS, macOS, iPadOS) — product validation, code generation, App Store optimization, and more. The licence is MIT.

When your agent uses it

  • Agent-written code needs deterministic size constraints
  • Tasks that involve iOS development

Example prompts

  • “/code-size”

Requirements

  • Pre-approved tools (allowed-tools): Read, Write, Edit, Glob, Grep, Bash

What it can do on your machine

Read from SKILL.md and the folder at commit 9ffb831. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Glob
    • Grep
    • Bash

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Code Size loads about 1.1k tokens when it runs. Until then it costs about 73 tokens; SKILL.md has 441 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~73
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Write, Edit, Glob, Grep, Bash

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from rshankras/claude-code-apple-skills at commit 9ffb831, republished under its MIT licence (© rshankras). 441 words, ~1,082 tokens.

Download SKILL.mdSave it as .claude/skills/code-size/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
code-size
description
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.
allowed-tools
Read, Write, Edit, Glob, Grep, Bash
last_verified
2026-07-24
review_by
2027-07-01

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):

RuleWarningErrorWhat it caps
cyclomatic_complexity1020Independent paths through one function
function_body_length50100Lines per function body
type_body_length300500Lines per type body
file_length5001000Lines per file
function_parameter_count58Parameters per function

Merge the fragment into the project's .swiftlint.yml (alongside any opt_in_rules/custom_rules fragments already adopted).

Brownfield Adoption: Baseline, Never Mass-Refactor

Turning these rules on in an existing codebase must not trigger a refactoring spree — bulk rewrites to satisfy a linter are how working code gets broken. Freeze today's violations and gate only new ones:

bash
# One-time: record existing violations (SwiftLint 0.55+)
swiftlint lint --write-baseline .swiftlint-baseline.json

# The gate from then on — fails only on NEW violations
swiftlint lint --strict --baseline .swiftlint-baseline.json

Commit .swiftlint-baseline.json. Shrink it opportunistically: when touching a baselined function for other reasons, fix its violation and regenerate the baseline in the same commit.

Fallback for older SwiftLint (before 0.55, no baseline support): record the violation count instead —

bash
swiftlint lint --quiet | wc -l > .swiftlint-count
# Gate: current count must not exceed the committed count
Show full SKILL.md (169 more words)Show less

When a Rule Fires

The fix is structural, not suppressive:

  • cyclomatic_complexity / function_body_length → extract the branches into named functions, or replace the branch ladder with a table/enum dispatch
  • type_body_length / file_length → split by responsibility (extensions in separate files count separately)
  • function_parameter_count → introduce a parameter struct

// swiftlint:disable is not a fix. The rare legitimate exemption (a generated file, a big-but-flat data table) belongs in .swiftlint.yml's excluded: list with a comment — visible in one place, not scattered through source.

Common Pitfalls

PitfallProblemSolution
Enabling without a baselineDay-one wall of violations, gate ignored--write-baseline first, gate on new only
Mass-refactoring to satisfy thresholdsWorking code broken for a numberFreeze old violations; fix opportunistically
Inline swiftlint:disable commentsExemptions scattered and invisibleexcluded: list in config, with reasons
Thresholds loosened per-projectCap quietly stops cappingChange thresholds only with a written reason

References

  • testing/fitness-functions/ — set/count invariants a per-line rule can't express
  • testing/coverage-ratchet/ — the coverage half of the metrics gauntlet
  • ios/coding-best-practices/ — iOS-specific lint fragment (style/API rules)
  • generators/ci-cd-setup/ — base .swiftlint.yml template these fragments merge into

© rshankras, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/swift/code-size of rshankras/claude-code-apple-skills.

  • SKILL.md
  • rules/swiftlint.yml

Open the folder on GitHubat commit 9ffb831

Compare with similar skills

Code Size next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Code Size compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Code Size this skillrshankras/claude-code-apple-skills783—~1.1kAutomated safety check: NotesMIT
Swiftui Protwostraws/SwiftUI-Agent-Skill5.1k2 repos~1.5kAutomated safety check: PassMIT
Swiftui UI PatternsAFK-surf/OpenBridge4304 repos~887Automated safety check: PassMIT
Swiftui Performance Auditharperreed/dotfiles3348 repos~1.4kAutomated safety check: PassNone
Swift Testing ExpertAvdLee/Swift-Testing-Agent-Skill4691 repos~1.2kAutomated safety check: PassMIT
Hig Project Contextraintree-technology/hig-doctor1435 repos~1.2kAutomated safety check: PassMIT

Similar skills

  • Swiftui Pro

    twostraws/SwiftUI-Agent-Skill

    Comprehensively reviews SwiftUI code for best practices on modern APIs, maintainability, and performance.

    5.1k GitHub starsUsed in 2 repos~1.5k tokens
    MobileAuto-check passed
  • Swiftui UI Patterns

    AFK-surf/OpenBridge

    Best practices and example-driven guidance for building SwiftUI views and components.

    430 GitHub starsUsed in 4 repos~887 tokens
    MobileAuto-check passed
  • Swiftui Performance Audit

    harperreed/dotfiles

    Audit and improve SwiftUI runtime performance from code review and architecture.

    334 GitHub starsUsed in 8 repos~1.4k tokens
    MobileAuto-check passed
  • Swift Testing Expert

    AvdLee/Swift-Testing-Agent-Skill

    Expert guidance for Swift Testing: test structure, expect/require macros, traits and tags, parameterized tests, test plans, parallel execution, async waiting patterns, and XCTest migration.

    469 GitHub starsUsed in 1 repo~1.2k tokens
    MobileAuto-check passed
  • Hig Project Context

    raintree-technology/hig-doctor

    Create or update a shared Apple design context document that other HIG skills use to tailor guidance.

    143 GitHub starsUsed in 5 repos~1.2k tokens
    MobileAuto-check passed
  • Swift Testing Pro

    twostraws/Swift-Testing-Agent-Skill

    Writes, reviews, and improves Swift Testing code using modern APIs and best practices.

    448 GitHub stars~1.1k tokensUpdated 4 mo ago
    MobileAuto-check passed

More from rshankras/claude-code-apple-skills

All 41 skills in this repo
  • Accessibility Generator

    rshankras/claude-code-apple-skills

    Generate accessibility infrastructure for VoiceOver, Dynamic Type, and accessibility features.

    783 GitHub stars~1.4k tokensUpdated 2 mo ago
    Auto-check: notes
  • Animation Patterns

    rshankras/claude-code-apple-skills

    SwiftUI animation patterns including springs, transitions, PhaseAnimator, KeyframeAnimator, SF Symbol effects, scroll-driven effects, mesh gradients, text renderers, and shader effects.

    783 GitHub stars~2.1k tokensUpdated 2 mo ago
    Auto-check passed
  • App Description Writer

    rshankras/claude-code-apple-skills

    Generate compelling App Store descriptions that convert browsers into users.

    783 GitHub stars~1.3k tokensUpdated 2 mo ago
    Auto-check passed
  • App Icon Generator

    rshankras/claude-code-apple-skills

    Generates an app icon for macOS or iOS — a fast CoreGraphics placeholder and/or flat layered source art to finish in Icon Composer (the Liquid Glass / iOS 26+ standard).

    783 GitHub stars~5.1k tokensUpdated 2 mo ago
    Auto-check: notes
  • App Namer

    rshankras/claude-code-apple-skills

    Turn an app idea into validated, App-Store-ready name candidates.

    783 GitHub stars~3.4k tokensUpdated 2 mo ago
    Auto-check passed
  • Bundles And Licensing

    rshankras/claude-code-apple-skills

    Revenue beyond the single-app price tag — own-app bundles, Family Sharing as a conversion lever, cross-developer bundles & suites, and institutional licensing via Group Purchases / Apple School &…

    783 GitHub stars~1.8k tokensUpdated 2 mo ago
    Auto-check passed

Categories

Questions about Code Size

What does Code Size 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 Size is an agent skill from rshankras/claude-code-apple-skills. 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.

When should I use Code Size?

Code Size fits situations like: agent-written code needs deterministic size constraints; tasks that involve iOS development.

How do I install Code Size in Claude Code?

Run `npx skills add rshankras/claude-code-apple-skills --skill code-size -a claude-code`. Or copy the skill folder (skills/swift/code-size in rshankras/claude-code-apple-skills) into .claude/skills/code-size in your project. Claude Code loads it when a task matches its description.

How do I install Code Size in Codex?

Run `npx skills add rshankras/claude-code-apple-skills --skill code-size -a codex`. Or copy the skill folder (skills/swift/code-size in rshankras/claude-code-apple-skills) into .agents/skills/code-size in your project. Codex loads it when a task matches its description.

Can I use Code Size in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rshankras/claude-code-apple-skills --skill code-size -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/code-size, .gemini/skills/code-size, .github/skills/code-size and .opencode/skills/code-size in your project.

What does Code Size need to run?

SKILL.md names no scripts, command-line tools or credentials: Code Size is instructions for the agent only. Its frontmatter pre-approves these tools: Read, Write, Edit, Glob, Grep, Bash.

Does Code Size access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Code Size safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Code Size use?

Code Size is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Code Size use?

About 1.1k tokens (SKILL.md is roughly 4.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Code Size?

Skills that share tags, products or a category with Code Size: Swiftui Pro (twostraws/SwiftUI-Agent-Skill, 5.1k stars), Swiftui UI Patterns (AFK-surf/OpenBridge, 430 stars), Swiftui Performance Audit (harperreed/dotfiles, 334 stars) and Swift Testing Expert (AvdLee/Swift-Testing-Agent-Skill, 469 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Code Size?

rshankras (a GitHub user) maintains it in rshankras/claude-code-apple-skills, which has 783 GitHub stars. The repository holds 41 skills in this directory. The repository was last updated on July 24, 2026.

Source: rshankras/claude-code-apple-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.