The first session in a real repository must prove one thing: Codex sees the right project and acts inside the expected boundary. The temptation to install dependencies at once or run a mass refactor is strong but harmful - it mixes verifying the environment with the work and deprives you of a clean starting point. The right start is not a task but an inventory: first you look at the state yourself, then you give the agent a narrow exploration with no right to change.
Before launching it helps to look at git yourself and sign in in a predictable mode. git status --short --branch shows the starting point, and running codex with explicit flags --sandbox read-only and --ask-for-approval on-request sets a strict boundary for the first acquaintance. Read-only at the start is cheap insurance: the agent reads and proposes but touches nothing until you have raised the mode consciously. A clean start turns any subsequent diff into a meaningful picture rather than a riddle.
Right after signing in you check what actually loaded with the /status command. It shows the project root and current directory, the model, the active permission profile or sandbox mode, the approval policy, the writable roots and the context. This is a snapshot of the environment: until you have seen it, you do not know under what conditions the agent works. The project root especially matters - it is what confirms that Codex took the expected repository, not a neighboring directory that happened to be current.
The first request is worth making an exploration without changes rather than a broad task. It is sensible to ask to show the entry points, the install, lint, typecheck and test commands from the project files, the active AGENTS.md instructions and three risks before the first edit - with an explicit ban on installing dependencies and running network commands. Such a request gives a map of the project and a list of what cannot be reliably inferred from the code, without letting the agent prematurely edit a poorly understood repository.
Trust in the working directory here is a conscious decision, not a button on the way to work. Project-local configuration from .codex/ loads only after you have trusted the workspace, because it may contain executable settings written by someone else. In a version-controlled directory Codex usually proposes the Auto baseline: workspace-write and on-request. For an unknown or non-version-controlled folder it is safer to start with read-only and raise trust later.
It helps to see this start in full once: the git check, signing in read-only and the request to explore without edits. Below are these commands and the wording. You return to them when setting up work in a new repository: the sequence "state first, then narrow exploration, and only then changes" keeps the first session controllable. It is the order, not the set of flags by itself, that separates a controlled start from a jump into blind edits.
Raising the mode is a separate conscious step after the check. When the map of the project is obtained and the risks are named, the mode is raised with the /permissions command or an explicit restart with --sandbox workspace-write and --ask-for-approval on-request. The point is that writable access is granted not by default but for an already understood task. This is exactly the same logic as throughout the book: authority is widened for a proven need, not in advance "so it does not get in the way".
Explore the repository without changes. Show:
1. the entry points;
2. the install, lint, typecheck and test commands from the project files;
3. the active AGENTS.md instructions;
4. three risks before the first edit.
Do not install dependencies or run network commands.The typical first-run failure is predictable: a broad task with no boundaries on a repository not yet trusted or studied. An agent allowed to change and install dependencies at once quickly creates a lot of changes and a false confidence that it "got it all". The right start is a clean git, signing in read-only, a read /status and a request with a goal, boundaries and a ban on edits. Having mastered this order once, you will begin any new work predictably rather than at random.
cd /path/to/repository
git status --short --branch
# a strict boundary for the first acquaintance
codex --sandbox read-only --ask-for-approval on-request
# after the check - raise the mode consciously
codex --sandbox workspace-write --ask-for-approval on-request