handle node_modules dir correctly

Resolved 💬 7 comments Opened Apr 16, 2025 by danielj86 Closed Aug 7, 2025

By default, Codex should ignore the node_modules directory when indexing code or listing files. It should only access node_modules when explicitly requested by the user.

View original on GitHub ↗

7 Comments

adamkdean · 1 year ago
Codex continues to list all files including node_modules, in a variety of ways, despite being told in CODEX.md not to. The only way I have stopped it from doing this so far is to tell it at the very beginning to always use tree --gitignore for file listings. If Codex could respect .gitignore that'd save many tokens!

Closing #102 as we seemed to create these at the same time @danielj86 😅

DawnKosmos · 1 year ago

I think a generall feature, like a .codexignore file that list all folders, files, the ai should not use would be helpful and save tons of tokens.

idiomic · 1 year ago

Agreed, this is also an issue in Rust crates with the "targets" build directory. I would also expect the .git directory to be ignored by default.

behrangsa · 1 year ago

Yes, .codexignore is a must have.

idiomic · 1 year ago

Addressed by #206

codex-maintainers · 11 months ago

Thanks for the feedback! Please try the latest version of Codex CLI to see if this issue persists. If it does, feel free to open a PR or report it in the codex-rs/ implementation. We're primarily focused on the native/Rust implementation now. More details here: https://github.com/openai/codex/discussions/1174