code-size
Skill915 starsChanged 22 days agoMITView on GitHub
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.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- hathach/agentrctheir own version, first seen Nov 22, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- hathach/agentrc★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository184 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- app-intentsSkill
- foundation-modelsSkill
- apple-intelligenceSkill
- visual-intelligenceSkill
- ad-attributionSkill
- app-description-writerSkill
- apple-search-adsSkill
- iap-finalizerSkill
- keyword-optimizerSkill
- marketing-strategySkill
- originality-checkSkill
- ratings-mechanicsSkill
- rejection-handlerSkill
- review-response-writerSkill
- screenshot-plannerSkill
- app-storeSkill
- web-presenceSkill
- core-mlSkill
- animation-patternsSkill
- design-systemSkill
- game-feelSkill
- liquid-glassSkill
- sf-symbolsSkill
- designSkill
- typographySkill
- ui-prototypingSkill
- ux-writingSkill
- attributed-stringSkill
- foundationSkill
- accessibility-generatorSkill
- account-deletionSkill
- analytics-setupSkill
- announcement-bannerSkill
- app-clipSkill
- app-extensionsSkill
- app-icon-generatorSkill
- app-store-assetsSkill
- auth-flowSkill
- background-processingSkill
- ci-cd-setupSkill
- cloudkit-syncSkill
- consent-flowSkill
- custom-product-pagesSkill
- data-exportSkill
- debug-menuSkill
- deep-linkingSkill
- error-monitoringSkill
- feature-flagsSkill
- featuring-nominationSkill
- feedback-formSkill
- force-updateSkill
- http-cacheSkill
- image-loadingSkill
- in-app-eventsSkill
- lapsed-userSkill
- live-activity-generatorSkill
- localization-setupSkill
- logging-setupSkill
- milestone-celebrationSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Use this skill when:
- Very specific: line 47
Commit .swiftlint-baseline.json.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.jsonCommit .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 —
swiftlint lint --quiet | wc -l > .swiftlint-count
# Gate: current count must not exceed the committed countWhen 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 dispatchtype_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
| Pitfall | Problem | Solution |
| Enabling without a baseline | Day-one wall of violations, gate ignored | --write-baseline first, gate on new only |
| Mass-refactoring to satisfy thresholds | Working code broken for a number | Freeze old violations; fix opportunistically |
Inline swiftlint:disable comments | Exemptions scattered and invisible | excluded: list in config, with reasons |
| Thresholds loosened per-project | Cap quietly stops capping | Change thresholds only with a written reason |
References
testing/fitness-functions/— set/count invariants a per-line rule can't expresstesting/coverage-ratchet/— the coverage half of the metrics gauntletios/coding-best-practices/— iOS-specific lint fragment (style/API rules)generators/ci-cd-setup/— base.swiftlint.ymltemplate these fragments merge into
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

