Builder tools

Codex Opened the Wrong Folder? Check the Repository Before You Ask for Changes

Cihan's view: Start Codex from the intended project, ask it to report the directory and status without editing, then compare the result with a fictional file checklist before approving any change.

Choose another work task →

Codex can inspect files, edit a project, and run local commands from your terminal. That is useful until you start it one folder too high and ask for a change. The first fix is not a better prompt. It is a read-only check of the working directory.

This documentation-based guide uses a fictional project and an illustrative result. No Codex session or code change is claimed.

What you need

  • Codex CLI installed and signed in.
  • A disposable copy of a small project.
  • A terminal opened in the folder you intend to inspect.
  • A short file checklist that says what the task may touch.

OpenAI’s Codex CLI documentation describes starting Codex from a project directory, inspecting files, making changes, and running local tools. It also shows /status and /permissions as session controls. Use those controls to confirm the boundary before approving an edit.

The fictional project

Use this folder for practice:

weekly-report/
  AGENTS.md
  README.md
  data/
    week-40.csv
  reports/
    week-39.md
  scripts/
    totals.py

The task is narrow: inspect data/week-40.csv and prepare a report in reports/week-40.md. Do not edit AGENTS.md, README.md, scripts/totals.py, or anything outside weekly-report/.

1. Make the boundary visible

Write this task note before you start Codex:

Project root: weekly-report/
Read: data/week-40.csv
Write: reports/week-40.md only
Do not edit: AGENTS.md, README.md, scripts/totals.py
Do not inspect: parent folders or other projects
First action: read-only location and file check
Approval stop: wait before writing the report
Acceptance check: the input CSV is unchanged and only the named report is new or changed

The note gives you something to compare with the session. It is not a permission rule by itself.

2. Ask for a read-only check

Start Codex from the intended project directory. Then use a request like this:

Before doing any work, perform a read-only boundary check.

1. Report the current working directory.
2. Report the repository status without changing files.
3. List only the files needed for this task: data/week-40.csv,
   reports/week-39.md, and the project instruction file.
4. Confirm that the proposed output is reports/week-40.md.
5. Do not edit, create, delete, install, or run network commands.
6. Stop and wait for approval after the check.

Compare your report with this task boundary:
- Project root: weekly-report/
- Input: data/week-40.csv
- Output: reports/week-40.md only
- Excluded: parent folders, other projects, README.md, scripts/totals.py

If the response names a different folder or discovers a different project, stop. Do not correct it by approving a write and hoping the path sorts itself out.

3. Review the illustrative check

A suitable result could look like this:

Working directory: /home/example/weekly-report
Repository status: clean
Requested input found: data/week-40.csv
Existing reference found: reports/week-39.md
Instruction file found: AGENTS.md
Proposed output: reports/week-40.md
Write action: not performed
Network or install action: not performed
Boundary note: all requested paths are inside weekly-report/

This is an editor-written example, not captured Codex output. The important part is the relationship between the folder, the input, the proposed output, and the actions that did not happen.

Acceptance checks

The boundary check passes when:

  1. The working directory is the intended project root.
  2. The input and reference files exist at the expected paths.
  3. The proposed output is inside the project and matches the task note.
  4. No write, install, network, or unrelated inspection occurred.
  5. The repository status is unchanged after the check.
  6. A person approves the next action before Codex writes the report.

After the report is created, review the diff and confirm that data/week-40.csv is unchanged. A correct folder check does not prove that the report itself is accurate.

Troubleshooting

  • Codex reports the parent folder: exit the session, change into weekly-report/, and repeat the read-only check. Do not rely on a relative path that has not been confirmed.
  • The input file is missing: stop and verify the filename and project copy. Do not ask Codex to create replacement data.
  • Codex proposes edits during the check: decline the action and restate that the first step is read-only. Use /permissions to inspect the active approval mode before continuing.
  • The repository is already dirty: record the existing status and review the diff before asking Codex to do anything. A later diff may include changes you did not make.
  • The output path is outside the project: rewrite the task boundary or choose the correct project. Do not approve the write as a shortcut.

Limits and safe use

Use fictional or approved data while learning. Keep credentials and production directories out of the exercise. Codex’s permission controls help manage actions, but they do not validate the business logic or the resulting report. Review the diff and the source data before sharing the output.

TRY this read-only check before a small Codex task. SKIP approving edits when the working directory or proposed paths are unclear. USE the report only after a person checks the diff and the source.

Sources and next step

The useful habit is simple: confirm the folder first, then decide whether the edit belongs there.

About Cihan

Creator and operator focused on practical AI for business professionals. Background and editorial approach →