Back to AI Q&A
Codex doesn't look at the project before writing code? Let it search for existing implementations first

Codex doesn't look at the project before writing code? Let it search for existing implementations first

AI Q&A Admin 75 views

Codex rewrites a set of code as soon as it comes up, usually not because the model can't write it, but because the task description doesn't require it to understand the project first. The correct approach is to let Codex search for existing implementations, confirm conventions, and call chains, and then let it change to the minimum scope.

Don't just say "help me make it happen"

If you just say "make a login feature" or "fix a payment problem", Codex may create new files, rewrite components, and add a structure it thinks makes sense based on common experience. For older projects, this is easy to fight with the existing architecture.

A better first sentence is: "Don't change the file yet, search for logins, permissions, interface requests, and error handling methods that are already in the project, and list the files you want to reuse." This step can pull it back from "creation mode" to "maintenance mode".

Let it be planned before the change

Let Codex output three things: related files, points that need to be modified, and boundaries that need not to be modified. For example, "only change 'src/auth', do not move the routing system; Existing toast and form checksum are used; Test only supplement login failure scenarios".

If it has a large number of new files in its plans, pause it and let it explain why it can't reuse existing modules. Many times, after this step it shrinks the scheme.

The prompt can be written like this

"Read and reuse existing implementations first, don't create new parallel architectures. Please search for relevant documents first, explain how to deal with similar logic in the current project, and then give a minimum change plan. Do not edit files without confirmation. ”

This prompt is equally useful for Cursor, Claude Code, and Copilot Chat. AI programming tools are most afraid of too broad goals, and they will understand "completing requirements" as "rebuilding a set".

Judge whether it really looks at the project

See if it references the real file name, function name, route name, and test entrance. If the answer only says "Normally" and "Suggested to create" without any in-project evidence, don't let it code.

High-reading AI programming Q&A often points to one core: let the tool work for your project, not let the project accommodate the tool. The same goes for Codex, searching first and then modifying, which is much more stable than changing and then fixing.

Recommended Tools

More