mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-06 02:47:56 +00:00
docs: add rules for using safeWriteJson
Add concise rules for using safeWriteJson instead of JSON.stringify with file operations to ensure atomic writes and prevent data corruption. Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
This commit is contained in:
parent
dd5410803a
commit
4d5668962b
1 changed files with 6 additions and 0 deletions
6
.roo/rules-code/use-safeWriteJson.md
Normal file
6
.roo/rules-code/use-safeWriteJson.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# JSON File Writing Must Be Atomic
|
||||
|
||||
- You MUST use `safeWriteJson(filePath: string, data: any): Promise<void>` from `src/utils/safeWriteJson.ts` instead of `JSON.stringify` with file-write operations
|
||||
- `safeWriteJson` will create parent directories if necessary, so do not call `mkdir` prior to `safeWriteJson`
|
||||
- `safeWriteJson` prevents data corruption via atomic writes with locking and streams the write to minimize memory footprint
|
||||
- Test files are exempt from this rule
|
||||
Loading…
Add table
Reference in a new issue