codex icon indicating copy to clipboard operation
codex copied to clipboard

handle node_modules dir correctly

Open danielj86 opened this issue 1 year ago • 7 comments

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.

danielj86 avatar Apr 16 '25 20:04 danielj86

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 😅

adamkdean avatar Apr 16 '25 20:04 adamkdean

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.

DawnKosmos avatar Apr 18 '25 12:04 DawnKosmos

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.

idiomic avatar Apr 18 '25 16:04 idiomic

Yes, .codexignore is a must have.

behrangsa avatar Apr 18 '25 16:04 behrangsa

Addressed by #206

idiomic avatar Apr 18 '25 16:04 idiomic

Some paths are hatdcoded to be ignored:

https://github.com/openai/codex/blob/82f5abbeea54b172fab29eb87bc9d15dab36c2a9/codex-cli/src/utils/singlepass/context_files.ts#L95

behrangsa avatar Apr 18 '25 16:04 behrangsa

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

codex-maintainers avatar Aug 07 '25 18:08 codex-maintainers