Skip to content

Commit f5d7c6e

Browse files
committed
docs(standards): add process.chdir() prohibition to code style
Added working directory rule to CLAUDE.md: - Never use process.chdir() as it breaks tests, worker threads, and causes race conditions - Always use { cwd } options and absolute paths instead - Pass { cwd: absolutePath } to spawn/exec/fs operations This rule prevents global state mutation anti-pattern that causes test failures in worker threads.
1 parent 25021aa commit f5d7c6e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

CLAUDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ TypeScript implementation of [Package URL specification](https://github.com/pack
146146
`import type { ArgParserConfig } from './argv.mjs'`
147147
-`import { parseScriptArgs, isQuiet, type ArgParserConfig } from './argv.mjs'`
148148

149+
#### Working Directory
150+
- **🚨 NEVER use `process.chdir()`** - use `{ cwd }` options and absolute paths instead
151+
- Breaks tests, worker threads, and causes race conditions
152+
- Always pass `{ cwd: absolutePath }` to spawn/exec/fs operations
153+
149154
#### Optional Properties
150155
With `exactOptionalPropertyTypes`, assign conditionally:
151156
-`if (value !== undefined) { this.prop = value }`

0 commit comments

Comments
 (0)