code-size

code-size is a skill for Claude Code from rshankras/claude-code-apple-skills. It costs 51 tokens per session (998 once invoked), scanned A, original, MIT.

Swift code-size rules set limits for complexity, function length, type length, file length, and parameter count using SwiftLint, a tool that checks Swift source code for style and quality problems.

In plain words
What is it for?
Use it to add repeatable quality checks to agent-written Swift code and flag functions or types that have grown too large or complicated.
Why use it?
It makes oversized or hard-to-test code visible automatically while allowing existing violations through a recorded baseline.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the apple-skills plugin — 182 skills shipped together , and of apple-skills

Good fit Use it to add repeatable quality checks to agent-written Swift code and flag functions or types that have grown too large or complicated.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/rshankras/claude-code-apple-skills/code-size
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add rshankras/claude-code-apple-skills --skill code-size
Clone the repo
git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills

Made for: Claude Code.

Or install apple-skills, the plugin that ships this one along with the rest of its 182 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for code-size

README.md
[![agentmods](https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/code-size/github.svg)](https://agentmods.dev/skills/rshankras/claude-code-apple-skills/code-size)
Your own site
<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/code-size"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/code-size/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for code-size

Your own site · 80×15
<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/code-size"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/code-size.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 51 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 998 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00051 $0.00998
Opus 5.5 $0.00020 $0.00399
Sonnet 5.5 $0.00010 $0.00200
Haiku 4.5 $0.00005 $0.00100

Measured yesterday against content hash 9d1cf30e0f6f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

code-size scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/swift/code-size/SKILL.md · 81 lines

How it starts

The opening of the file, as written. The whole thing — 81 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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 Lines per type body
file_length 500 1000 Lines per file
function_parameter_count 5 8 Parameters 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:

# 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.

Read the full file on GitHub · 81 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 81 lines · 51 tokens per session scan A 9d1cf30e0f6f

Subscribe to this mod's changes

code-size is a skill published in the GitHub repository rshankras/claude-code-apple-skills (864 stars, last pushed 2d ago), licensed MIT. It adds 51 tokens to every session and 998 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-05.

Related

code-size compared with skills from other repositories

code-size next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
code-sizershankras/claude-code-apple-skillsSkill8642d agoMITA51Claude Code
make-pr-easy-to-reviewmichael-denyer/pstack-claudeSkill4.1kyesterdayMITA57Claude Code
review-workcode-yeongyu/oh-my-openagentSkill71kyesterdaynoneA63Claude Code, Codex
security-reviewwaybarrios/opencode-power-packSkill5514d agoMITA64Claude Code
review-checklistwesammustafa/Claude-Code-Everything-You-Need-to-KnowSkill3.5k3d agononeA25Claude Code, Codex
reviewdevoxx/DevoxxGenieIDEAPluginSkill687yesterdayMITA90Claude Code
apex-reviewtonone-ai/tononeSkill7723d agoMITA46Claude Code