Check code hygiene

From brianwestphal/apple-fm · View interactive version

Check code hygiene is an AI agent skill from the GitHub repository brianwestphal/apple-fm. Check code for standardization, readability, maintenance complexity, and defensive coding practices

How to use this skill

Skill file

Analyze the apple-fm codebase for code hygiene issues. Generate a report on

standardization, readability, maintenance complexity, and defensive coding.

Scope: src/, apple-fm-helper/main.swift, and (where relevant) tests/.

Analysis Areas

1. Standardization

(cliArgs.ts, protocol.ts, session.ts). Flag a name that matches neither.

constants. Flag inconsistencies.

imports (eslint enforces order — if lint passes, order is fine). The .js

check is your responsibility.

--temp expects a number, got "abc"). Flag terse throw new Error('failed').

apple-fm-helper/main.swift, tests/fixtures/stub-helper.js, and

docs/4-protocol.md must all agree. Flag any divergence.

2. Readability

than 3.

timeout, and chars-per-token live as named constants — flag any new inline

literal that should be one.

missing rationale on non-obvious code (e.g. the cumulative-partial diffing in

the Swift streaming path).

3. Maintenance Complexity

only helper.ts spawns the process; pure logic stays in protocol.ts /

session.ts / cliArgs.ts. Flag any layer violation (e.g. session.ts

spawning directly instead of going through an injected GenerateFn).

4. Defensive Coding

numbers; parseEvent throws on malformed lines; helper.ts bounds the

subprocess with a timeout and captures stderr. Verify these still hold.

non-null assertions (tests get a pass). House style is unknown + narrowing.

exit surfaces stderr. Flag any regression.

and exits nonzero; availability is checked before generation.

Report Format

For each finding: File (path + lines), Category

(standardization | readability | maintenance | defensive), Severity

(high | medium | low), Description, Suggestion.

End with a prioritized top-N (apple-fm is small — expect 0–5 in a healthy state).

Suggest Hot Sheet tickets (hs-task for cleanups, hs-bug for defects) for

non-trivial findings.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.