Sort lists alphanumerically (literal byte order, ASCII before letters).
- Config lists —
permissions.allow/permissions.denyin.claude/settings.json,external-tools.jsonchecksum keys, allowlists in workflow YAML. - Object key entries — keys in plain JSON config + return-shape literals + internal-state objects. (Exception:
__proto__: nullalways comes first, ahead of any data keys.) - Import specifiers — sort named imports inside a single statement:
import { encrypt, randomDataKey, wrapKey } from './crypto.mts'.import typefollows the same rule. Statement order (node:→ external → local → types) is separate from specifier order within a statement. - Method / function placement — within a module, sort top-level functions alphabetically. Convention: private functions (lowercase / un-exported) sort first, exported functions second. The
exportkeyword is the divider. - Array literals — when the array is a config list, allowlist, or set-like collection. Position-bearing arrays (e.g.
argv, anything where index matters semantically) keep their meaningful order. Setconstructor arguments —new Set([...])andnew SafeSet([...])literals. The runtime is order-insensitive, so source order is alphanumeric. Same rationale as Array literals: predictable diffs, no merge conflicts on insertions.
When in doubt, sort. The cost of a sorted list that didn't need to be is approximately zero; the cost of an unsorted list that did need to be is a merge conflict.