Skip to content

Commit 1fb0e34

Browse files
committed
chore(claude): add sorting + open-PR rules to CLAUDE.md
Fleet-wide propagation from meander (b0f0cb2 + db95184). Adds: - "Sorting" subsection under Code Style: codifies the rule that config lists, object keys, import specifiers, top-level function placement, and set-like array literals all sort alphanumerically (literal byte order). Position-bearing arrays opt out. - "Open PRs" bullet under SHARED STANDARDS: when commits are added to an open PR, the title + description must be rewritten to match. Patch C (sort .claude/settings.json deny/allow) is N/A here — this repo's settings.json has no permissions block.
1 parent 49ccd70 commit 1fb0e34

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ See `docs/references/error-messages.md` for worked examples and anti-patterns.
153153
## 📚 SHARED STANDARDS
154154

155155
- Commits: [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) `<type>(<scope>): <description>` — NO AI attribution
156+
- **Open PRs:** when adding commits to an OPEN PR, ALWAYS update the PR title and description to match the new scope. A title like `chore: foo` after you've added security-fix and docs commits to it is now a lie. Use `gh pr edit <num> --title "..." --body "..."` (or `--body-file`) and rewrite the body so it reflects every commit on the branch, grouped by theme. The reviewer should be able to read the PR description and know what's in it without scrolling commits.
156157
- Scripts: Prefer `pnpm run foo --flag` over `foo:bar` scripts
157158
- Dependencies: After `package.json` edits, run `pnpm install`
158159
- Backward Compatibility: 🚨 FORBIDDEN to maintain — actively remove when encountered
@@ -218,6 +219,18 @@ Core infrastructure library for Socket.dev security tools.
218219
- **Exports**: Named only. `export default` FORBIDDEN (breaks dual CJS/ESM). Enforced by oxlint `no-default-export` + build + CI validation.
219220
- **Function order**: Files with 3+ exports require alphabetical ordering — private first (alphabetical), then exported (alphabetical). Constants/types before functions.
220221

222+
### Sorting
223+
224+
Sort lists alphanumerically (literal byte order, ASCII before letters). Apply this to:
225+
226+
- **Config lists**`permissions.allow` / `permissions.deny` in `.claude/settings.json`, `external-tools.json` checksum keys, allowlists in workflow YAML.
227+
- **Object key entries** — sort keys in plain JSON config + return-shape literals + internal-state objects. (Exception: `__proto__: null` always comes first, ahead of any data keys.)
228+
- **Import specifiers** — sort named imports inside a single statement: `import { encrypt, randomDataKey, wrapKey } from './crypto.mts'`. Imports that say `import type` follow the same rule. Statement *order* is the project's existing convention (`node:` → external → local → types) — that's separate from specifier order *within* a statement.
229+
- **Method / function source placement** — within a module, sort top-level functions alphabetically. Convention: private functions (lowercase / un-exported) sort first, exported functions second. The first-line `export` keyword is the divider.
230+
- **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.
231+
232+
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.
233+
221234
### Package Exports
222235

223236
All modules exported via `package.json` exports field. When adding modules, update exports or run `scripts/generate-package-exports.mjs`.

0 commit comments

Comments
 (0)