swift-logging-pro
Skill5 starsChanged 11 days agoMITView on GitHub
Reviews Swift logging code using os.Logger for correct privacy markers, subsystem/category conventions, and appropriate log levels. Use when writing or reviewing logging code.
In this repository19 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- app-intents-proSkill
- coredata-swift6-proSkill
- instruments-profiling-proSkill
- motion-design-proSkill
- store-compliance-proSkill
- swift-accessibility-proSkill
- swift-adaptive-layout-proSkill
- swift-concurrency-proSkill
- swiftdata-proSkill
- swift-design-system-proSkill
- swift-docc-proSkill
- swift-error-handling-proSkill
- swift-memory-storage-proSkill
- swift-modularization-proSkill
- swift-package-proSkill
- swift-testing-proSkill
- swiftui-proSkill
- xcode-security-proSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 1 is distinctive, and 7 are 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.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Check os.Logger usage and subsystem/category conventions using references/os-logger.md.
- Very specific: line 16
Verify log level choice matches the message severity using references/log-levels.md.
- Distinctive: line 19
If doing a partial review, load only the relevant reference files.
- Very specific: line 24
Use os.Logger (modern API), not OSLog (legacy) or print() (no privacy, no levels, no subsystem filtering).
- Very specific: line 25
Always specify subsystem (typically reverse-DNS bundle ID) and category (component name) when creating a Logger.
- Very specific: line 26
All interpolated values default to private — explicitly mark with .public only when safe (e.g., status enums, fixed strings).
- Very specific: line 27
Never log usernames, passwords, tokens, email addresses, or PII — even with .public.
- Very specific: line 28
Use the appropriate level: .debug for development noise, .info for normal events, .notice for important events, .error for recoverable …
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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
Review Swift logging code for correctness, privacy compliance, and consistent subsystem conventions. Report only genuine problems - do not nitpick or invent issues.
Review process:
- Check
os.Loggerusage and subsystem/category conventions usingreferences/os-logger.md. - Validate privacy markers on logged values using
references/privacy.md. - Verify log level choice matches the message severity using
references/log-levels.md. - Flag
print()statements in production code (acceptable in tests, scripts).
If doing a partial review, load only the relevant reference files.
Core Instructions
- Use
os.Logger(modern API), notOSLog(legacy) orprint()(no privacy, no levels, no subsystem filtering). - Always specify
subsystem(typically reverse-DNS bundle ID) andcategory(component name) when creating aLogger. - All interpolated values default to
private— explicitly mark with.publiconly when safe (e.g., status enums, fixed strings). - Never log usernames, passwords, tokens, email addresses, or PII — even with
.public. - Use the appropriate level:
.debugfor development noise,.infofor normal events,.noticefor important events,.errorfor recoverable failures,.faultfor programmer errors. - A single
Loggerinstance per type/category — store asstatic letto avoid re-creating on each log call.
Output Format
Organize findings by file. For each issue:
- State the file and relevant line(s).
- Name the rule being violated.
- Show a brief before/after code fix.
Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.
Example output:
MyService.swift
Line 18: Privacy violation — user identifier logged as .public.
// Before
logger.info("Loaded user \(userId, privacy: .public)")
// After
logger.info("Loaded user \(userId, privacy: .private)")Line 34: Use .error level for recoverable failures, not .info.
// Before
logger.info("Network request failed: \(error.localizedDescription)")
// After
logger.error("Network request failed: \(error.localizedDescription)")Line 45: print() statement in production code — replace with Logger.
// Before
print("Cache miss for key \(key)")
// After
logger.debug("Cache miss for key \(key, privacy: .public)")Summary
- Privacy (high): User-identifying data logged as
.publicon line 18 — change to.private. - Severity (medium): Recoverable failure logged at
.info— should be.error. - Modernization (low):
print()statement should useLogger.
End of example.
References
references/os-logger.md—os.Loggerbasics, subsystem/category conventions, instance creation patterns.references/privacy.md—.public,.private,.sensitivemarkers, redaction, what never to log.references/log-levels.md—.debug,.info,.notice,.error,.faultsemantics, performance impact.
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.

