Open the broken studio booking page, select 2 guests, and click Confirm booking. The box under the button still says “No booking yet.” In this Mac walkthrough you’ll give OpenAI Codex a copy of that page, ask it to fix the button, and repeat the click to see whether the confirmation actually works.

You’ll need an internet connection, a ChatGPT account with Codex access, and the Terminal and Safari apps that come with your Mac. We use the command-line version of Codex. The practice folder contains two small files. The reservation is fictional and the button only updates the text on your screen.

1. Open Terminal and check your sign-in

Press Command–Space, type Terminal, and press Return. For each command box in this guide, click its copy button, click the Terminal window, press Command–V, then press Return. Start with this one.

codex --version

If you see codex-cli followed by a version number, skip the installer below. If you see command not found: codex, run this Mac installation command from OpenAI’s CLI guide. When the installer finishes, press Command–N in Terminal to open a new window and repeat the version check.

curl -fsSL https://chatgpt.com/codex/install.sh | sh

Now check whether Codex recognizes your account.

codex login status

Our Mac printed Logged in using ChatGPT. If yours says you’re signed out, type codex login in Terminal, press Return, and complete sign-in in the browser that opens. Return to Terminal and run the status check again. If you’ve reached your account’s usage limit, keep the practice folder and resume the repair when you have access again.

Terminal shows the CLI version and a successful ChatGPT sign-in.
Terminal shows the CLI version and a successful ChatGPT sign-in.

2. Get the starter files into a fresh folder

Paste the entire next box into Terminal once. It creates a fresh folder inside Documents, downloads the English starter ZIP, unpacks it, and moves you into codex-booking-en. Keep using this Terminal window for the rest of the lesson.

cd "$(mktemp -d "$HOME/Documents/codex-lesson.XXXXXX")" &&
  curl -fL https://phuketaipro.com/wp-content/uploads/pap-examples/codex-booking/codex-booking-en-63f0b596acc4.zip -o starter.zip &&
  unzip -q starter.zip && cd codex-booking-en

Check the folder and its contents.

basename "$PWD"; ls

The first line should be codex-booking-en. The next line should list booking.js and index.html. HTML defines the page you see. The JavaScript file controls what happens when you click. If these names don’t match, repeat the download command to start in a fresh folder.

Our practice folder contains booking.js and index.html. Your CLI version may differ.
Our practice folder contains booking.js and index.html. Your CLI version may differ.

3. Reproduce the broken click

From Terminal, open the copy you just downloaded in Safari.

open -a Safari index.html

Under Number of guests, choose 2 guests and click Confirm booking once. Look at the cream box directly below the button. If it still says No booking yet., you’ve reproduced the bug. Leave this tab open so you can test the same page after the repair.

After clicking with 2 guests selected, the status still reads “No booking yet.”
After clicking with 2 guests selected, the status still reads “No booking yet.”

4. Give Codex the click and the expected result

Press Command–Tab to return to the same Terminal window. Make a copy of the broken script so you can compare the two versions. Run this command once, before the repair.

cp booking.js booking-before.txt

Copy the whole command below, including the quotation marks, and press Return. codex exec gives Codex one task in the current folder. The request names the file it can change, the button the visitor clicks, and the result the visitor should see.

codex exec --ignore-user-config --skip-git-repo-check --sandbox workspace-write "Fix only booking.js. In index.html, clicking Confirm booking should update the status using the selected guest count. Keep the page design and wording. Explain the cause and the edit in two sentences."
The request received by Codex, under the user label in the terminal output.
The request received by Codex, under the user label in the terminal output.

You’ll see output as Codex reads and edits the files. Wait for its summary and for Terminal to accept another command. workspace-write allows edits in the workspace. --skip-git-repo-check allows this ordinary practice folder to work without a Git repository. We included --ignore-user-config to keep personal settings out of the exercise. If your CLI flags that option as unknown, update using the official guide or remove just that option and retry.

5. Check the line Codex changed

Compare the backup with the working file in the same Terminal window.

diff -u booking-before.txt booking.js
The minus line looks for #reserve. The plus line looks for #confirm, the actual button ID.
The minus line looks for #reserve. The plus line looks for #confirm, the actual button ID.

In our run, the line beginning with a minus sign looked for #reserve. The button in the page is named confirm, so the script couldn’t find it to attach the click action. The plus line replaces the lookup with #confirm. Your edit may differ. The browser test in the next step will tell you whether it works. If the comparison prints nothing, the two files match. Read the end of the Codex output to see whether the run finished or reported an error.

6. Refresh the same page and try two more guest counts

Return to the local Safari tab you opened in step 3. Press Command–R, select 2 guests again, and click Confirm booking. The box should now say Booking confirmed for 2 guests. Change to 3 guests and click again. The confirmation should change to 3. Try 1 guest too. That last check catches a fix that always prints the same number.

After reloading and clicking again, the same page confirms the booking for 2 guests.
After reloading and clicking again, the same page confirms the booking for 2 guests.

Try the repaired page from our run. If that example works but your local page still looks broken, check that Safari opened index.html in the same folder where Codex ran. The quickest way to get back to that exact file is to repeat the Safari command in step 3.

Try the same approach on your own site. Before opening Codex, write down what you clicked, what appeared, and what should have appeared. After the edit, test with two different inputs, as you did with the guest counts here.

Official OpenAI documentation

Install and start Codex CLI · Run one task with codex exec · CLI command and flag reference. The screenshots in this edition come from our English repair run and its working booking page.

Explore Phuket AI Pro’s hands-on AI courses