lockdown renders .claude/settings.json without trailing newline #32

Closed
opened 2026-05-28 07:06:04 +00:00 by coilysiren · 0 comments
Owner

Problem lockdown.BuildPlan / writeSettingsJSON render .claude/settings.json with no trailing newline.

json.MarshalIndent output was written verbatim, so generated settings.json ended without a final newline. In any repo where the end-of-file-fixer pre-commit hook runs, the committed copy gains a trailing newline, but coily regenerates without one. Every coily lockdown --apply --replace / coily setup re-baseline re-dirties the file; the next commit re-adds the newline; the two tools fight forever.

lockdown/user_hook.go already appended '\n' to the user-settings render, so this was an inconsistency between the three marshal sites, not a deliberate choice.

Fix Append '\n' after json.MarshalIndent in both claudeCodeBuildSettings (per-repo render) and writeSettingsJSON (recursion-root merge), matching user_hook.go. Added TestBuildPlan_AfterEndsWithNewline to lock it.

User-facing symptom tracked at coilysiren/coily#135.

**Problem** `lockdown.BuildPlan` / `writeSettingsJSON` render `.claude/settings.json` with no trailing newline. `json.MarshalIndent` output was written verbatim, so generated `settings.json` ended without a final newline. In any repo where the `end-of-file-fixer` pre-commit hook runs, the committed copy gains a trailing newline, but coily regenerates without one. Every `coily lockdown --apply --replace` / `coily setup` re-baseline re-dirties the file; the next commit re-adds the newline; the two tools fight forever. `lockdown/user_hook.go` already appended `'\n'` to the user-settings render, so this was an inconsistency between the three marshal sites, not a deliberate choice. **Fix** Append `'\n'` after `json.MarshalIndent` in both `claudeCodeBuildSettings` (per-repo render) and `writeSettingsJSON` (recursion-root merge), matching `user_hook.go`. Added `TestBuildPlan_AfterEndsWithNewline` to lock it. User-facing symptom tracked at coilysiren/coily#135.
Sign in to join this conversation.
No labels
P0
P1
P2
P3
P4
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
coilyco-flight-deck/cli-guard#32
No description provided.