Access granted · practical field guide

    OpenAI Codex tutorial for reliable repository work

    Use Codex for a bounded repository task when the finished work needs a visible diff and review evidence. Start with durable guidance in AGENTS.md, add the context needed for this task, and verify what changed before you accept it.

    You will finish with

    • one outcome contract
    • one repository or workspace context file
    • one reusable skill
    • one verified change
    • one handoff note another person can continue

    Question, brainstorm or quick draft

    Chat

    An answer or first draft

    Connected business knowledge and files

    ChatGPT Work

    A reviewed artifact

    Code, tests and repository files

    Codex

    A diff with evidence

    0/14 complete

    Step 01

    How to use OpenAI Codex for the right task

    Chat, Work and Codex are not interchangeable. Begin with the place where the source of truth lives and the evidence the finished task must produce.

    If the source of truth is…Start with…Finish with…
    code, tests and repository filesCodexa diff, tests and review evidence
    connected business knowledge and filesChatGPT Worka document, spreadsheet, presentation or report
    a question, brainstorm or quick draftChatan answer or first draft

    Do this now

    1. 1.Name the source of truth for one live task.
    2. 2.Name the final artifact and the permission boundary.
    3. 3.Pick the smallest surface that can finish it.

    Realistic example

    The broken resource renderer

    The source of truth is this React/TypeScript repository; success requires a rendered access page, a diff and build evidence. That makes it a Codex task, not a Work task.

    Expected output: A read-only inspection plan before edits.

    Copyable prompt

    Act as a work-surface selector. Do not change anything.
    
    Task: [one real task]
    Source of truth: [repo / files / connected knowledge / web]
    Finished artifact: [diff / report / decision / other]
    Permission boundary: [read-only / draft only / approved write]
    
    Return exactly:
    1. Recommended surface: Chat, ChatGPT Work or Codex
    2. Why this source and artifact require it
    3. First safe action
    4. Files, tools or sources to inspect
    5. Proof that would let a reviewer accept the result
    6. One assumption that could change the recommendation

    Verification or handoff

    Write down why this surface is correct. If the next step needs a git diff, shell command, test run or repository edit, move it to Codex.

    Step 02

    Write the outcome contract

    Do not start with “make it better.” Give Codex the messy version of your intent, then ask it to turn that into a finish line, non-goals and proof.

    Operating-loop card

    FieldFor this access-page refresh
    TriggerA high-impression tutorial page has weak organic click-through.
    Approved sourcesThe existing page, direct GSC evidence, official Codex documentation and repository instructions.
    Codex may doInspect the source, propose and prepare a scoped content change in an isolated worktree.
    OutputA reviewable diff, rendered pages and type, test and build evidence.
    VerifierA human reviews the exact copy and the change evidence.
    Correction routeRejected copy returns to the brief with the reason, then receives a new review snapshot.
    Owner and next triggerThe issue owner accepts or rejects the snapshot. The next trigger is the 28-day GSC review.

    Do this now

    1. 1.Capture the raw request in your own words before polishing it.
    2. 2.Fill outcome, scope, non-goals and source of truth.
    3. 3.Name constraints, verification commands and human approval points.

    Realistic example

    This access-page rebuild

    Raw brief: the tutorial needs the advanced workflow guidance from a transcript, without publishing unverified product claims. The contract turns that into scoped content files, reviewable copy and type/test/build checks.

    Expected output: No escaped newline markers, copyable prompts, current links and all checks pass.

    Copyable prompt

    Turn this messy request into a task contract. Do not edit files.
    
    Raw request: [paste notes]
    Source of truth: [files, issue, docs or URL]
    What must not change: [non-goals]
    Human who accepts the result: [name or role]
    
    Return a one-screen contract with:
    - outcome and user-facing effect
    - in-scope and out-of-scope files or systems
    - required evidence
    - approval points
    - smallest reversible first move
    - assumptions that need confirmation
    - a stop condition

    Verification or handoff

    A reviewer should be able to reject an edit that is outside the written scope without debating taste.

    Step 03

    Start your first Codex task safely

    Let Codex inspect before it edits. Start with the smallest permission boundary that can answer the question, especially in an unfamiliar repository.

    pwd
    git status
    find . -name AGENTS.md -o -name AGENTS.override.md
    git log -5

    Do this now

    1. 1.Read repository instructions and current git status.
    2. 2.Map the relevant files and available checks.
    3. 3.Request a plan, then explicitly approve the first edit.

    Realistic example

    Preserve unrelated work

    A dirty checkout is not a reason to overwrite it. Create an isolated worktree from current main and keep the original work untouched.

    Expected output: A clean branch with a narrow file list.

    Copyable prompt

    Run a read-only repository reconnaissance for [task]. Do not edit, install, send, deploy or use an alternate tool to bypass a missing permission.
    
    Inspect: repository instructions, git status, relevant route or module, existing tests and the nearest source of truth.
    
    Return:
    - current behavior, with file paths
    - the narrowest safe change
    - exact files that would change
    - checks that prove behavior, not just compilation
    - risks, missing evidence and explicit approval points
    - one recommended next command
    Stop after the plan.

    Verification or handoff

    Confirm the proposed files do not overlap unrelated user changes, that all planned writes are reversible or reviewable, and that no alternate tool path bypasses an approval boundary.

    Step 04

    How to use AGENTS.md and Codex memory

    Put required rules in checked-in guidance, shared state in reviewed records, and optional recall in local memories. Do not make a generated memory file the only place a rule must apply.

    LayerPut this hereWhy
    checked-in AGENTS.md and docscommands, safety boundaries, ownership and durable repository rulesCodex can apply relevant project guidance and the team can review it
    reviewed project and decision recordsactive decisions, handoffs, source links and current project factsthe shared state has an owner and a review path
    local Codex memorieshelpful recall from eligible prior chatsgenerated local state can help, but it is not a mandatory rule source

    Source authority card

    Fact or ruleAuthoritative sourceOwnerFreshness or review trigger
    release statusGitHub issue, CI result and live runtime evidencerelease ownerrecheck at the exact commit SHA before deployment
    repository rulesapplicable AGENTS.md and checked-in documentationrepository ownerwhen the rule, directory or tool boundary changes
    active decisionreviewed decision recordnamed decision ownerat its stated review date or when new evidence conflicts

    Failure and first remedy

    FailureWhat goes wrongFirst remedy
    stale guidanceCodex follows a rule that no longer matches the repositoryname an owner and review date; remove or update the checked-in rule
    oversized instructionsimportant guidance gets buried or the instruction chain reaches its budgetkeep root guidance navigational and move specialized rules near the work
    uncontrolled tool outputlogs or generated output crowd out the task contextinspect unknown output first; cap, filter or summarize it before continuing
    generated-memory conflictoptional recall disagrees with the repository or decision recordtreat checked-in guidance and reviewed records as the authority; correct the durable source
    missing decision recordthe next session repeats a settled choice or guessesrecord the decision, source, owner and next review in the shared system
    checked-in rules → reviewed decisions and project state → optional local recall → task plan → source files and tests

    Do this now

    1. 1.Find the highest applicable AGENTS.md and name one rule that must apply every time.
    2. 2.Name the reviewed system that holds active decisions and handoffs for this project.
    3. 3.Before a large command or tool call, inspect the expected output and choose a cap, filter or summary.
    4. 4.Keep root guidance navigational; place rare, specialized rules in the directory where they apply.

    Realistic example

    This repository

    Its AGENTS.md requires an isolated session, architecture reading, preservation of unrelated work and type/unit/build verification. The issue and reviewed decision record hold the current scope and approval. Local recall can help find prior context, but it does not replace either source.

    Expected output: A short instruction chain, a reviewable decision record and task context that stays focused.

    Copyable prompt

    Build a context map for [task]. Do not edit files.
    
    Return a four-row authority table:
    1. required rule or fact
    2. authoritative source and exact location
    3. owner
    4. freshness trigger or conflict-resolution rule
    
    Then identify:
    - one rule that must be checked in
    - one decision that needs a reviewed record
    - one optional memory that must not become authority
    - one large-output risk and how to bound it
    
    Optional local memories: recall only; compare them with the checked-in rule and reviewed decision record before relying on them.
    
    Finish with the smallest repair, if any.

    Verification or handoff

    A required rule must be findable in checked-in guidance or another reviewed source of truth. Before accepting a memory-based suggestion, compare it with the current repository instructions and decision record.

    Step 05

    Plan and isolate the work

    A plan turns a vague request into a reviewable change. Isolation protects unrelated work and makes the final diff coherent.

    request → inspection → plan → isolated change → checks → diff review → handoff

    Do this now

    1. 1.Identify the issue and current baseline.
    2. 2.Start a session branch or worktree.
    3. 3.Record in-scope files and stop if scope expands materially.

    Realistic example

    The resource-page contract

    A page is not complete when only its React component exists. The landing, access route, capture config, manifest, sitemap, OG surface, IndexNow and tests have to move together.

    Expected output: A dependency-aware implementation checklist.

    Copyable prompt

    Plan issue [number] without editing files.
    
    Outcome: [one sentence]
    Baseline: [current behavior or URL]
    Non-goals: [what must remain untouched]
    
    Create a dependency-ordered plan. For each step give:
    - exact files
    - observable behavior change
    - deterministic or browser proof
    - rollback path
    - approval needed before the step
    
    End with a one-line diff budget and the first step that is safe to execute.

    Verification or handoff

    Compare the finished diff with the file list. Explain every intentional omission before handoff.

    Step 06

    Turn repeated behavior into a skill

    If you explain the same workflow twice, turn it into a reusable instruction. Grow it deliberately: one successful manual run, a small personal skill, repeat validation, then a team-owned workflow with review.

    Starter skillUse it afterInput → output
    change-plantwo similar repository tasksissue + source files → scoped plan, file list and proof
    release-prooftwo releases need the same checkscandidate URL + expected markers → production evidence receipt
    source-authority-mapa decision depends on several systemsfact + sources → authority, owner and freshness table
    content-refresha page repeats a measurable SEO problemURL + GSC window → evidence-led revision proposal and review date

    Do this now

    1. 1.Find the existing workflow owner.
    2. 2.Read its required files and verification gates.
    3. 3.Propose a small addition only after the manual run works.

    Realistic example

    One-off to system

    Instead of “create another resource page,” use the resource-page skill to clone the reference, update every required surface and report the evidence. It becomes a team workflow only after examples, an owner and review gates exist.

    Expected output: A repeatable workflow with one source of truth.

    Copyable prompt

    Design a reusable skill only if this workflow has succeeded manually at least once.
    
    Workflow: [repeated job]
    Trigger phrases: [what users actually ask]
    Inputs: [sources and constraints]
    Output: [observable artifact]
    Authority boundary: [what it may prepare versus what needs approval]
    
    First find an existing owner. If none fits, draft a compact SKILL.md with: purpose, trigger, inputs, ordered steps, verification, failure behavior and stop condition. Include one realistic regression case. Do not create a duplicate or a skill for generic advice.

    Verification or handoff

    Blind-test the instruction on a related task. Before sharing it with a team, name the owner, permissions, example task and change-review rule.

    Step 07

    Connect MCP deliberately

    Every integration increases capability and the permission surface. Start read-only, allowlist the tools needed, and name failure behavior before use.

    ConnectionUseful forDefault posture
    Supabaseinspect approved application dataread-only first
    GitHubissues, PRs and sourcescoped repository access
    SEO toolsresearch evidenceresearch only until verified
    custom MCPdomain actionsallowlist tools and approvals

    Do this now

    1. 1.List the exact tools needed.
    2. 2.Identify data access and side effects.
    3. 3.Define approval and revocation points.

    Realistic example

    Wrong database, wrong answer

    This repository explicitly requires the Supabase connector for application data and warns against using an unrelated database connector.

    Expected output: A scoped read-only query or a clear stop.

    Copyable prompt

    Create an MCP preflight for [goal]. Do not call tools yet.
    
    For every proposed tool, return a row with:
    - data it can read
    - state it can change
    - minimum permission needed
    - evidence it returns
    - failure behavior
    - whether a human must approve immediately before use
    
    Choose the smallest read-only tool set first. Name the exact action that must remain blocked.

    Verification or handoff

    Record the tool used and source returned. Treat a tool error as a blocker, never as permission to guess.

    Step 08

    Use subagents with control

    Parallel work helps only when the slices are independent and the evidence can be reviewed by the lead agent.

    lead agent → researcher / implementer / verifier → lead synthesis

    Do this now

    1. 1.Split only independent work.
    2. 2.Give each role a narrow output and no-overlap boundary.
    3. 3.Combine findings before changing shared files.

    Realistic example

    A useful verifier brief

    Ask a read-only verifier to find duplication, escaped newlines and the browser checks that would prove a resource-page fix.

    Expected output: Findings with file paths and evidence, not edits.

    Copyable prompt

    Delegate a read-only verification slice.
    
    Role: [researcher / verifier]
    Question: [one answerable question]
    Scope: [exact files, URLs or sources]
    Must not do: [edits, sends, deployments, external writes]
    Return format: finding, evidence, exact location, confidence and unresolved gap.
    
    Stop when evidence is incomplete. Do not make product decisions or inspect outside the stated scope.

    Verification or handoff

    Do not delegate ambiguous product decisions, destructive work or overlapping file ownership.

    Step 09

    Run durable work with goals and monitors

    Long-running work needs a named goal, a verifier and a stop condition, not an agent running forever. Keep the project thread current, report only material changes and escalate when a human decision is needed.

    goal → plan → smallest safe action → verifier → material update or stop → handoff

    Do this now

    1. 1.Write one measurable goal and the command, test or review that verifies it.
    2. 2.Choose a cadence and define what counts as a material update.
    3. 3.Set an owner, stop condition and approval point before any monitoring starts.

    Realistic example

    A safe pull-request monitor

    Check the PR twice daily for review feedback and failed checks. Summarize only changed status, draft fixes with evidence, and stop at merge, a blocker or a request for approval.

    Expected output: A concise status update, not silent, open-ended autonomy.

    Copyable prompt

    Design a durable monitor for [goal]. Default to read-only monitoring. Do not send messages, merge, publish or change external state unless the exact approval is present.
    
    Source of truth: [issue, PR, dashboard or URL]
    Verifier: [test, status field or human review]
    Cadence: [frequency]
    Material change: [specific condition]
    
    Return a monitor contract with: what to check, current baseline, proof of progress, update rule, stop condition, owner, escalation path and the exact approval needed for a proposed fix.

    Verification or handoff

    A monitor is safe only if another person can answer: what it checks, how it proves progress, when it stays quiet, when it stops and who can authorize the next action.

    Step 10

    Ship evidence, not confidence

    “It looks right” is not a release check. Use a verification ladder that covers code, rendered behavior and asset substance.

    npm run check:types
    npm run test:unit
    npm run build

    Do this now

    1. 1.Inspect the source and diff.
    2. 2.Run type, unit and production-build checks.
    3. 3.Open the rendered page and verify links and assets substantively.

    Realistic example

    The SPA fallback trap

    A missing image can return HTTP 200 because the SPA catch-all serves HTML. Check content type for image assets, not status alone.

    Expected output: A browser-verified page and content-type evidence.

    Copyable prompt

    Act as a release verifier for [change]. Do not modify files.
    
    Acceptance criteria: [paste]
    Expected rendered marker: [heading, control or metadata]
    Relevant checks: [commands]
    
    Return a release receipt:
    - source diff reviewed
    - each command and result
    - rendered behavior evidence
    - asset or API substance checks where relevant
    - failed or unavailable proof
    - release recommendation: accept, revise or hold
    Never treat HTTP 200 alone as proof.

    Verification or handoff

    Check that no escaped newline marker appears, no prompt body is duplicated, copy buttons work, mobile is readable and every jump link resolves.

    Step 11

    Teams and enterprise governance

    Enterprise Codex is a capability-and-authorization problem. A rollout is ready only when access, change authority and review accountability are explicit.

    RoleResponsibility
    memberworks inside the approved boundary
    technical ownermaintains repository and workflow context
    security reviewerapproves data and tool exposure
    workspace admincontrols groups, seats and settings

    Do this now

    1. 1.Choose an approved repository and limited pilot group.
    2. 2.Set read-only first, then controlled write.
    3. 3.Define audit evidence, rollback and an owner.

    Realistic example

    Pilot worksheet

    Capture approved users, repositories, apps/MCP tools, read-write boundary, approval points, prohibited actions, expiry, fallback and rollback criteria before enabling a workflow.

    Expected output: A pilot another admin can audit.

    Copyable prompt

    Pilot goal: [goal]
    Approved users/groups: [groups]
    Approved repositories: [repos]
    Allowed apps and MCP tools: [tools]
    Read/write boundary: [boundary]
    The agent must never: [prohibited actions]
    Human approval points: [points]
    Who accepts a source-of-record, production or external state change: [role]
    Exception and fallback: [route]
    Access expiry or revocation: [rule]
    Audit evidence: [evidence]
    Data and secret handling: [policy]
    Rollback/exit criteria: [criteria]
    Owner: [owner]

    Verification or handoff

    The organization must answer what Codex may access, what it may change, what it must never do, who accepts a real state change and how access ends or falls back safely.

    Step 12

    The non-developer route

    You do not need to be a full-time developer to use Codex safely. You do need plain-language explanations, approval points and proof of what changed.

    Do this now

    1. 1.Start with one bounded task.
    2. 2.Ask for a plain-language plan before edits.
    3. 3.Review changed files and remaining risks at the end.

    Realistic example

    Content-page update

    A non-developer can own an issue-driven update to a resource page: inspect, approve the plan, review the preview and confirm the checks.

    Expected output: A reviewed change, not a mystery automation.

    Copyable prompt

    I am the accountable non-developer for [outcome]. Start with a plain-language plan and do not edit until I approve.
    
    Explain:
    1. what changes for the user
    2. the smallest files or systems involved
    3. what could go wrong
    4. the evidence I will see before accepting it
    5. the one decision only I need to make now
    
    After implementation, return a before-and-after summary, changed files, proof, remaining uncertainty and the safe rollback.

    Verification or handoff

    Hand off to ChatGPT Work when the next output is a business artifact and no repository, shell or test evidence is required.

    Step 13

    Start with a role-specific context pack

    These are examples, not universal defaults. Start with one recurring job, then give Codex a narrow context pack, a clear approval boundary and evidence that lets another person review the result.

    RoleFirst workflowContext packHuman proof
    FounderWeekly decision briefgoals, decisions, active initiatives, ownerssources, owner, next decision
    ConsultantClient briefscope, notes, approved examples, source filessources, assumptions, review checklist
    Chief of staffMeeting briefcalendar, priorities, metrics, follow-up systemowner, due date, source, escalation path

    Do this now

    1. 1.Choose one role and one recurring workflow.
    2. 2.Write down the minimum source material and what is explicitly out of scope.
    3. 3.State the human who accepts the result and the proof they need.

    Realistic example

    Meeting preparation

    A chief of staff gives Codex the calendar, last meeting notes, the priority list and the owner for each open decision. Codex drafts a brief. The chief of staff confirms what becomes an assignment or escalation.

    Expected output: A reviewable brief, not an unsupervised set of commitments.

    Copyable prompt

    Build a first-run context pack. Do not take action yet.
    
    Role: [founder / consultant / chief of staff]
    Recurring workflow: [one repeated job]
    Approved sources: [specific systems and files]
    Agent may do: [read, organize, draft]
    Human must approve: [commitments, external messages, assignments]
    
    Return:
    - a one-page context pack
    - source authority and owner for each field
    - an explicit non-goal
    - the first safe run
    - the proof required before the human accepts the result
    - a review date for stale context

    Verification or handoff

    Reject any output that lacks its source, owner, approval boundary or review evidence.

    Step 14

    Handoff and maintenance

    Finish by improving the system that will handle the next task. A completed change should be legible to a teammate who did not see the conversation.

    Do this now

    1. 1.Record what changed or was confirmed, not only the files touched.
    2. 2.Attach the sources and validation that support that state.
    3. 3.Name unresolved questions, the owner, next action and review date.

    Realistic example

    A useful closeout

    The handoff says the generic text renderer was replaced, names the two access pages, links the source model, lists checks run and records the remaining release approval.

    Expected output: A durable state record with a clear owner and next review date.

    Copyable prompt

    Prepare a handoff that a new operator can continue without this chat.
    
    Use this exact structure:
    - state changed or confirmed
    - source-of-record links
    - validation performed and result
    - unresolved question or constraint
    - owner and next action
    - review date or trigger
    - changed files and visible behavior
    - rollback or correction route
    - durable instruction to update, if the same failure could recur
    
    If any field is unknown, write UNKNOWN and name the evidence needed.

    Verification or handoff

    If you cannot name the state, source, validation, next owner or remaining risk, the handoff is not done.

    Finish with a handoff

    Make the next run easier.

    Record what changed, why it changed, the checks or sources used, remaining limits, the next owner and the next review date. A useful workflow is one another person can continue without redoing the discovery.