Tame Your File Chaos with Codex CLI

Use Codex CLI to organize a messy folder with natural language prompts.

Introduction

30 Second Summary

Everyone has that one folder. It is full of files named things like report_FINAL_final (2).txt and IMG_4521.jpg, all mixed together with no rhyme or reason.

In this project, you will use Codex CLI, an AI coding agent that runs in your terminal, to scan a folder of 20+ chaotically named files and reorganize them into clean subfolders. You will type what you want in plain English and watch Codex physically move every file into the right place.

What You'll Build

Picture typing a single sentence into your terminal and watching 20 scattered files sort themselves into labeled folders, organized by your personal rules.

By the end of this project, you'll have:

  • An AI-powered analysis that scans a cluttered folder and maps every file into a proposed organization plan before anything moves.
  • A fully reorganized directory where every file has been sorted into the right subfolder by Codex from a single English prompt.
  • A personal AGENTS.md configuration file that teaches Codex your preferred naming conventions and sorting rules for any future cleanup.
  • Secret Mission: Build a reusable Codex skill that packages your file organization workflow so you can run it on any folder with a single prompt.

Are there any prerequisites?

You need a Mac and a ChatGPT Go account. Codex CLI is included free with your Go plan, and this project walks you through the full installation.

Before We Start

Before we dive in, let's get clear on what you're about to build and why it matters to you.

Install and Sign In to Codex CLI

Codex CLI is an AI coding agent from OpenAI that runs right in your terminal. It can read files, run shell commands, and restructure entire folders based on plain English prompts.

Before Codex can organize anything, you need the tool installed on your Mac and connected to your ChatGPT Go account. In this step, you will install Codex CLI, sign in, and confirm it launches successfully.

In this step, get ready to:
  • Install Codex CLI on your Mac.
  • Sign in to Codex with your ChatGPT Go account.
  • Confirm the interactive terminal UI launches and responds to commands.
Install Codex CLI on your Mac

Codex CLI has a one-line installer for macOS. It downloads and sets up the binary so you can run codex from any terminal window.

  • Press Cmd+Space (macOS) to open your search bar.
  • Type Terminal and press Enter to open it.
  • Install Codex CLI by running this command:
curl -fsSL https://chatgpt.com/codex/install.sh | sh

What does this command do?

This command downloads the official Codex CLI installer script from OpenAI and runs it. The -fsSL flags tell curl to follow redirects, fail silently on errors, and show progress.

The installer places the codex binary on your system so it is available from any terminal session.

The installer may print instructions about adding Codex to your shell path. Follow any instructions it displays before continuing.

  • Verify the installation succeeded by running:
codex --version

✔️ I see a version number

Codex CLI is installed and ready to go. Move on to the next substep.

ⓧ Command not found

Your terminal cannot find the codex binary yet. This usually means your shell has not picked up the new path.

  • Close your terminal completely and reopen it.
  • Run codex --version again.
  • If it still fails, check whether the installer printed a line asking you to add something to your shell profile. Copy and run that line, then restart your terminal.
Sign in to Codex with your ChatGPT account

Codex CLI needs to connect to your ChatGPT Go account to access AI models. The sign-in flow opens a browser window where you log in with your existing ChatGPT credentials.

  • Launch Codex by running:
codex

What happens when you run this?

Since this is your first time running Codex, it detects that you are not signed in. You will see a screen asking how you want to authenticate.

A browser window will open after you choose to sign in. Complete the login in your browser and Codex will receive your credentials automatically.

  • Select Continue to sign in with ChatGPT.
  • Your browser opens to the ChatGPT login page. Sign in with the same account you use for ChatGPT Go.
  • After you sign in successfully, your browser confirms the login. Switch back to your terminal.

Browser did not open?

If your browser does not open automatically, check your terminal output for a URL. Copy that URL and paste it into your browser manually to complete the sign-in flow.

help me sign in to Codex CLI with my ChatGPT account

Once signed in, Codex caches your login so you will not need to sign in again next time.

Confirm the interactive TUI launches successfully

Codex CLI has a built-in interactive terminal UI (TUI) where you type prompts and watch Codex work. Before moving on, you need to confirm it is fully operational.

  • If Codex is not already running, launch it by running:
codex

You should see the interactive TUI load, showing the model name, your current directory, and a prompt where you can type.

  • Type the following command inside the Codex TUI and press Enter:
/status

Before you look at the output, what do you think the /status command will show you about your current session?

What does /status show?

The /status command displays your current session configuration. You should see the active model name, your current working directory, and your permission level.

This confirms Codex is connected to OpenAI's servers through your ChatGPT Go account and ready to accept prompts.

You can also try other slash commands like /permissions and /model to explore what is available. Type /init to see a list of all commands.

Codex TUI not loading?

Make sure you completed the sign-in step. If the TUI shows a login screen instead of the prompt, select Continue and complete the browser authentication flow again.

If the TUI crashes or displays an error, close the terminal, reopen it, and run codex again.

help me get the Codex CLI interactive TUI working

Your Codex CLI is installed, signed in, and responding to commands. Next up, you will create a folder full of messy files for Codex to organize.

Create a Realistic File Mess

Codex CLI is installed and ready to go. You have a powerful AI agent at your fingertips, waiting for a task.

Before pointing Codex at anything important, you need a safe practice folder with realistic clutter. In this step, you will generate 20 chaotically named files spanning five different types so Codex has a real mess to work with.

In this step, get ready to:
  • Run a shell script that generates 20 test files of different types in a messy-folder directory.
  • Explore the file mess to see why manual sorting is painful.
Create the test files with a shell script

You need 20 files that look like real-world clutter: documents with messy names like Q2 revenue FINAL (2).txt, random photos like IMG_4521.jpg, data files, code snippets, and downloads all tossed together. A shell script creates all of them in one shot.

  • Create the first half of the script by pasting this command into your terminal:
cat > ~/create_mess.sh << 'EOF'
#!/bin/bash
# Creates a messy folder with realistic test files for Codex to organize

mkdir -p ~/messy-folder
cd ~/messy-folder

# Documents
echo "Q2 2026 Revenue Report - Draft version" > "Q2 revenue FINAL (2).txt"
echo "Meeting notes from Monday standup" > "notes monday.txt"
echo "Project proposal for client ABC" > "proposal_v3_FINAL_final.txt"
echo "Shopping list for BBQ this weekend" > "shopping list.txt"
echo "Resume - updated August 2026" > "resume_aug2026.txt"

# Image placeholders
echo "[image data]" > "IMG_4521.jpg"
echo "[image data]" > "IMG_4522.jpg"
echo "[image data]" > "screenshot 2026-08-01.png"
echo "[image data]" > "Photo Mar 15.png"
echo "[image data]" > "profile_pic_NEW.jpg"
EOF

What does this command do?

The cat > ~/create_mess.sh << 'EOF' pattern is called a heredoc. It writes everything between the two EOF markers into a new file called create_mess.sh in your home directory.

  • mkdir -p ~/messy-folder creates the target folder. The -p flag means it won't error if the folder already exists.
  • Each echo ... > "filename" line creates a file with dummy content. The file names are intentionally messy to mimic real-world clutter.
  • Add the remaining file types to the script by pasting this command:
cat >> ~/create_mess.sh << 'EOF'

# Data files
echo "Name,Email,Phone" > "contacts backup.csv"
echo "Item,Amount" > "expenses_july.csv"
echo "Task,Status" > "project_tracker.csv"

# Code files
echo "print('hello world')" > "test.py"
echo "console.log('test')" > "script.js"
echo '{"name": "test"}' > "config.json"

# Downloads
echo "[PDF content]" > "invoice_00382.pdf"
echo "[PDF content]" > "flight_confirmation.pdf"
echo "[PDF content]" > "ebook_chapter1.pdf"
echo "[archive data]" > "backup_old.zip"

echo "Created $(ls | wc -l | tr -d ' ') messy files in ~/messy-folder"
EOF

What does this command do?

Notice the double arrow >> instead of a single >. This appends to the existing file instead of overwriting it.

  • This second block adds CSV data files, code snippets, PDFs, and a zip archive.
  • The last line prints a count of how many files were created so you get instant confirmation.
  • Run the script to generate all 20 files by entering:
bash ~/create_mess.sh
  • You should see the output: Created 20 messy files in ~/messy-folder.

Seeing "No such file or directory"?

  • Make sure both paste commands finished without errors. If you see a trailing > prompt in your terminal, the heredoc did not close properly. Type EOF on its own line and press Enter to close it.
  • Confirm the script file exists by running cat ~/create_mess.sh. You should see the full script contents. If the file is empty or missing, re-paste both commands from above.

Still stuck? Ask for help.

✔️ Awesome, I've got everything!

Great. Make sure both paste commands completed without errors before moving on.

ⓧ I'd like to double check the full code

The full create_mess.sh script is built from two paste commands. To verify your file is correct:

  • Run cat ~/create_mess.sh to print the file contents.
  • Confirm the script starts with #!/bin/bash and ends with the echo "Created..." line.
  • Check that you see five sections of files: Documents (5 files), Image placeholders (5 files), Data files (3 files), Code files (3 files), and Downloads (4 files).

If anything is missing, delete the file and re-paste both commands from above.

Explore the mess

Your messy-folder now has 20 files dumped into one flat directory. Imagine opening this folder after a month of downloads, screenshots, and half-finished documents. Try to mentally sort them into categories.

  • List all the files in your messy folder by running:
ls ~/messy-folder

You should see a wall of filenames with no rhyme or reason. Text documents sit next to image files. CSVs are mixed in with Python scripts. Some names have spaces, some use underscores, and some have absurd suffixes like FINAL_final.

Before you run the next command, how many files do you think the script created?

  • Count the files by running:
ls ~/messy-folder | wc -l

You should see 20. That is 20 files with no subfolders, no naming consistency, and five different file types jumbled together. Sorting this by hand means reading every single filename, guessing its purpose, and dragging it somewhere. This is exactly the kind of tedious work an AI agent can handle for you.

Seeing a different number?

  • If you see fewer than 20, the script may not have completed. Re-run bash ~/create_mess.sh and check the count again.
  • If you see more than 20, the folder may contain extra files from a previous run or other source. Delete the folder with rm -rf ~/messy-folder and re-run the script for a clean start.

Need help figuring out what went wrong?

Your messy folder is ready. Next up, you will point Codex at this chaos and watch it analyze every file in seconds.

Ask Codex to Analyze the Mess

Your messy folder is sitting on your Mac with 20 chaotically named files crammed together. Now imagine trying to sort them by hand. You would need to read every filename, guess what type each file is, and mentally group them into categories.

That is exactly the kind of tedious work an AI coding agent excels at. In this step, you will point Codex CLI at the mess and ask it to analyze everything in plain English. You will also discover an important safety feature that keeps Codex from changing your files without permission.

In this step, get ready to:
  • Launch Codex inside your messy folder and observe its read-only default.
  • Get a structured file-by-type analysis with a proposed organization plan.
  • Discover how Codex's sandbox prevents unintended changes to your files.
Navigate to your messy folder and launch Codex

Your ~/messy-folder is not a Git repository. That matters because Codex defaults to read-only sandbox mode for non-version-controlled folders. It can look at your files but cannot create, move, or delete anything.

  • Switch back to your terminal.
  • Navigate to your messy folder by running this command:
cd ~/messy-folder
  • Launch Codex by running:
codex

The Codex interactive TUI opens, showing the model name, your current directory, and available commands.

What is read-only sandbox mode?

Non-version-controlled folders default to read-only. Codex can read file names and contents, but cannot run commands that modify the filesystem.

This is a safety feature. It prevents Codex from accidentally moving or deleting files in folders you have not explicitly trusted.

Codex didn't launch?

Make sure you are inside ~/messy-folder before running codex. You can confirm your location by running pwd and checking that the output ends with messy-folder.

If you see a sign-in prompt instead of the TUI, your session may have expired. Follow the sign-in flow again with your ChatGPT account.

Help me troubleshoot Codex not launching.

Ask Codex to break down your files

Now you will put Codex to work. You type natural language prompts directly into the Codex TUI, just like sending a message in a chat.

  • Type the following prompt into the Codex TUI and press Enter:
What's in this folder? Give me a breakdown by file type and suggest how to organize everything into subfolders.

Codex reads every file in the directory and produces a structured analysis. You will see your files grouped into categories like documents, images, data files, code, and downloads, along with a proposed subfolder structure.

What just happened?

Codex scanned the filename and contents of every file in ~/messy-folder. It grouped the 20 files by type and proposed a clean folder structure.

All of that came from a single natural language prompt. No scripting, no manual sorting, no regex.

Ask Codex to organize the files

Codex's analysis looks great. The natural next step is to ask it to execute the plan and actually move the files.

Before you send this next prompt, what do you think will happen? Will Codex be able to create folders and move your files?

  • Type this prompt into Codex and press Enter:
Go ahead and organize these files into those folders.

Codex attempts to create directories and move files, but it either asks for approval it cannot grant or reports that writing is blocked by the read-only sandbox. It can read and analyze, but it cannot make changes.

Why can't Codex make changes?

Your ~/messy-folder is not a Git repository. Non-version-controlled folders default to read-only sandbox mode.

Read-only mode is a safety net. Codex proved it can analyze your files correctly. Now you need to explicitly grant it permission before it can touch anything. That is exactly what you will do in the next step.

  • Exit Codex by typing the following slash command and pressing Enter:
/exit
  • Confirm that no files moved by running:
ls ~/messy-folder

All 20 files are still sitting flat in ~/messy-folder with no subfolders. Codex analyzed everything but changed nothing.

Files already moved into subfolders?

If you see subfolders like documents/ or images/, Codex may have had write access. This can happen if you launched Codex with the --sandbox workspace-write flag by accident.

Delete the folder and recreate it by running the create_mess.sh script again. Then relaunch Codex with just codex (no flags) so it defaults to read-only.

Help me reset my messy folder and try again.

Codex has proven it understands your files. In the next step, you will grant it write permissions and watch it reorganize the entire folder in seconds.

Grant Permissions and Let Codex Organize

Codex has already done the hard part. It scanned every file in your messy folder and mapped out exactly where each one belongs.

There is just one problem. Codex is still locked in read-only mode, so it can read your files but cannot move them. In this step, you will unlock write permissions and watch Codex reorganize all 20 files into clean subfolders.

In this step, get ready to:
  • Grant Codex write permissions to your folder.
  • Have Codex organize all 20 files into categorized subfolders.
  • Verify each file landed in the correct folder.
Grant Codex write permissions

Right now Codex is running inside ~/messy-folder in read-only mode. The /permissions command lets you change what Codex can do without leaving the session.

  • In the Codex TUI, type the following command and press Enter:
/permissions
  • Codex displays a list of approval presets. Select Default (option 1). This grants workspace-write permissions, meaning Codex can read and edit files in the current folder and run commands.

Codex confirms the updated policy. You should see a message indicating that Codex can now edit files and run commands in this workspace.

What does /permissions do?

The /permissions command controls what Codex can do without asking you first. The Default preset gives Codex workspace-write access. It can read files, create folders, move files, and run commands inside the current directory. It still asks for approval before accessing the internet or editing files outside the workspace.

Already exited Codex?

If you already closed the Codex session, you can relaunch with write permissions directly. Run this from your terminal while in ~/messy-folder:

codex --sandbox workspace-write
Tell Codex to organize your files

With write permissions unlocked, Codex can now execute the plan it proposed in the previous step. Time to let it do the heavy lifting.

  • Type the following prompt into Codex and press Enter:
Organize all the files in this folder into subfolders by category. Create folders for documents, images, data, code, and downloads. Move each file to the right folder.

Watch Codex work. It creates each subdirectory, then moves every file into the matching folder. Codex may ask for your approval before running certain commands. If prompted, approve the actions to let it continue.

What is Codex doing?

Codex is running shell commands like mkdir and mv behind the scenes. It reads each filename, determines the file type from its extension and name, then moves it into the appropriate subfolder. All of this happens from a single natural language prompt.

Codex says it cannot write or move files?

This means the permissions did not update correctly. Type /permissions again and confirm you selected the Default preset. If the issue persists, type /exit to close Codex, then relaunch with explicit permissions:

codex --sandbox workspace-write

help me debug Codex permissions

Verify the organized structure

Codex should be done moving files. Before you check the results, think about what you expect to see.

  • What do you think ls ~/messy-folder will show now? Instead of 20 loose files, you should see just the subfolder names.
  • Exit Codex by typing /exit and pressing Enter.
  • Check the top level of your folder by running:
ls ~/messy-folder

You should see organized subfolders like documents/, images/, data/, code/, and downloads/ instead of a wall of 20 filenames.

  • Confirm files landed in the right places by checking at least two subfolders:
ls ~/messy-folder/documents
ls ~/messy-folder/images

What should I see?

The documents/ folder should contain your text files like Q2 revenue FINAL (2).txt, notes monday.txt, and proposal_v3_FINAL_final.txt.

The images/ folder should contain IMG_4521.jpg, IMG_4522.jpg, and your other image files. Feel free to check data/, code/, and downloads/ too.

Still seeing loose files at the root?

If some files remain at the top level, Codex may not have finished moving everything. Relaunch Codex with write permissions and prompt it again to move the remaining files.

If no subfolders were created at all, the permissions were likely still read-only when Codex tried to execute. Relaunch with explicit permissions using codex --sandbox workspace-write and try the organize prompt again.

help me fix my Codex file organization

Your messy folder is now clean and organized. Every file found its home in a category subfolder, all from a single English prompt. Next up, you will teach Codex your personal organization preferences so it follows your rules automatically.

Teach Codex Your Organization Preferences

Codex CLI just proved it can analyze and reorganize an entire folder of chaotic files. Your 20 test files are now sitting neatly in categorized subfolders.

But Codex used its own judgment to pick category names and decide where files belong. What if you prefer different naming conventions or sorting rules? In this step, you will create an AGENTS.md file that teaches Codex your personal preferences so it follows them automatically in every future session.

In this step, get ready to:
  • Create an AGENTS.md file with your folder structure, naming conventions, and organization rules.
  • Add new messy test files to simulate fresh clutter arriving in your folder.
  • Have Codex organize the new files following your AGENTS.md rules.
Create your AGENTS.md file

AGENTS.md is a special configuration file that Codex reads automatically when it starts a session. Think of it as a set of standing instructions. Instead of explaining your preferences every time you prompt, you write them once and Codex follows them going forward.

How does Codex find AGENTS.md?

In a Git repository, Codex walks up the directory tree to find AGENTS.md files. Since ~/messy-folder is not a Git repository, Codex only checks the current directory.

That means placing AGENTS.md right inside ~/messy-folder is exactly where it needs to be.

  • Create your AGENTS.md file by running this command in your terminal:
cat > ~/messy-folder/AGENTS.md << 'EOF'
# File Organization Rules

## Folder Structure
Organize files into these categories:
- documents/ - text files, notes, proposals, resumes
- images/ - photos, screenshots, profile pictures
- data/ - CSV files, spreadsheets, data exports
- code/ - scripts, config files, source code
- downloads/ - PDFs, installers, archives, ebooks

## Naming Conventions
- Use lowercase with hyphens for folder names
- Remove duplicate suffixes like "FINAL_final" or "(2)"
- Add dates in YYYY-MM-DD format when a date is present in the filename
- Keep file extensions unchanged

## Rules
- Never delete files, only move them
- If unsure about a file's category, put it in a misc/ folder
- Group related files together when possible
- Skip hidden files (starting with .)
- Do not move AGENTS.md itself
EOF

What do these rules do?

  • Folder Structure defines the five categories Codex should sort files into, matching the folders it already created.
  • Naming Conventions tells Codex to clean up messy filenames. It should strip duplicate suffixes like FINAL_final and reformat dates to YYYY-MM-DD.
  • Rules sets safety constraints. Codex must never delete files, should put anything unknown into a misc/ folder, and must leave AGENTS.md itself untouched.
  • Confirm the file was created by running:
ls ~/messy-folder

You should see AGENTS.md listed alongside your five organized subfolders.

Don't see AGENTS.md?

  • Make sure you pressed Enter after pasting the entire command, including the final EOF line. If your terminal is still waiting for input, type EOF on its own line and press Enter.
  • Check that the file has content by running cat ~/messy-folder/AGENTS.md. If it is empty, delete it and re-run the heredoc command.
  • Still stuck? Help me create an AGENTS.md file in ~/messy-folder using a heredoc command.

Why not use the /init command?

Codex has a built-in /init command that generates a scaffold AGENTS.md for you. Writing it by hand teaches you the format and lets you encode your own preferences from the start.

✔️ Awesome, I've got everything!

Great. Make sure you have saved the file before moving on.

ⓧ I'd like to double check the full code

Here is the full AGENTS.md file. Run cat ~/messy-folder/AGENTS.md and compare your output to this:

# File Organization Rules

## Folder Structure
Organize files into these categories:
- documents/ - text files, notes, proposals, resumes
- images/ - photos, screenshots, profile pictures
- data/ - CSV files, spreadsheets, data exports
- code/ - scripts, config files, source code
- downloads/ - PDFs, installers, archives, ebooks

## Naming Conventions
- Use lowercase with hyphens for folder names
- Remove duplicate suffixes like "FINAL_final" or "(2)"
- Add dates in YYYY-MM-DD format when a date is present in the filename
- Keep file extensions unchanged

## Rules
- Never delete files, only move them
- If unsure about a file's category, put it in a misc/ folder
- Group related files together when possible
- Skip hidden files (starting with .)
- Do not move AGENTS.md itself
Add new messy test files

To test that AGENTS.md actually changes how Codex behaves, you need fresh files that have not been organized yet. These files have intentionally messy names designed to trigger your naming convention rules.

  • Create four new test files in ~/messy-folder by running these commands:
# New messy files to test AGENTS.md rules
echo "Budget forecast Q3 2026" > ~/messy-folder/"Budget FINAL_FINAL.txt"
echo "[image data]" > ~/messy-folder/"IMG_8834.png"
echo "Team sync notes from August 20" > ~/messy-folder/"notes Aug 20.txt"
echo "[binary data]" > ~/messy-folder/"random_stuff.dat"

Why these specific filenames?

  • Budget FINAL_FINAL.txt has a duplicate suffix that your naming rules say to remove.
  • notes Aug 20.txt has a date your rules say to reformat to YYYY-MM-DD.
  • random_stuff.dat has an extension that does not match any category, so it should land in misc/.
  • Confirm the new files are sitting loose in the root by running:
ls ~/messy-folder

You should see your five organized subfolders, AGENTS.md, and four new loose files mixed together. That clutter is exactly what Codex will clean up next.

Don't see the new files?

  • Make sure each echo command ran without errors. Filenames with spaces need the surrounding quotes to work correctly.
  • Check you used ~/messy-folder/ as the path prefix for each file. Without it, the files end up in whatever directory your terminal is currently in.
  • Still stuck? Help me create test files with spaces in the filenames using echo in my Mac terminal.
Let Codex organize the new files with your rules

Now for the real test. You will launch Codex inside ~/messy-folder again and ask it to organize the new files. This time, Codex will read your AGENTS.md before it does anything.

  • Navigate to ~/messy-folder and launch Codex with write permissions by running these commands:
cd ~/messy-folder
codex --sandbox workspace-write

Codex opens its interactive TUI. It automatically detects and loads the AGENTS.md file in the current directory.

  • Type this prompt into Codex:
Organize the new files in this folder following the rules in AGENTS.md.
  • Watch Codex work. It reads your AGENTS.md, identifies the four loose files, and begins creating directories and moving files. If Codex asks for approval before running commands, approve each action.

What is Codex doing differently this time?

In Step 4, Codex used its own judgment to sort files. This time, it reads your naming conventions first. It should strip the FINAL_FINAL suffix, reformat the date in notes Aug 20.txt to YYYY-MM-DD format, and route the unknown .dat file to misc/.

Once Codex finishes, exit the TUI to return to your regular terminal.

Before you check the results, think about what you expect to see. Which subfolder did the .dat file land in? Did Codex rename any files to match your naming conventions?

  • Check the root of ~/messy-folder by running:
ls ~/messy-folder

The four loose files should be gone. You should see only your subfolders (including a new misc/ folder if Codex created one for the .dat file) and AGENTS.md.

  • Check that naming conventions were applied by running:
ls ~/messy-folder/documents

Look for the files that were renamed. The FINAL_FINAL suffix should be gone, and the date from notes Aug 20.txt should now be in YYYY-MM-DD format.

Codex is an AI, not a script

The exact renamed filenames may vary slightly from run to run. As long as Codex removed the duplicate suffix, reformatted the date, and sorted the unknown file into misc/, your AGENTS.md rules are working.

Files not renamed or sorted incorrectly?

  • Run cat ~/messy-folder/AGENTS.md to confirm your rules file has the correct content. An empty or malformed file means Codex had nothing to follow.
  • Make sure you launched Codex from inside ~/messy-folder. Codex only checks the current directory for AGENTS.md when the folder is not a Git repository.
  • Try being more explicit in your prompt. Include the specific rule you want applied, like "rename files to remove duplicate suffixes like FINAL_FINAL."
  • Need more help? Codex isn't following my AGENTS.md naming rules when organizing files.

Secret mission

Build a Reusable File Organizer Skill

Right now your file organization workflow only works in ~/messy-folder because that is where your AGENTS.md lives. What if you could package it into a portable skill that works in any folder with a single prompt? In this secret mission, you will create a Codex skill that makes your file organizer reusable anywhere.

Clean Up Your Resources

Clean Up Your Resources

This project runs entirely locally on your Mac, so there are no ongoing costs or cloud resources to worry about.

Decide whether to keep your test folders for future practice, or delete them to free up space.

Resources you used:

  • ~/messy-folder - organized test folder with AGENTS.md, subfolders, and the .agents/skills/ directory (local only, no cost).
  • ~/messy-folder-2 - second test folder from the Secret Mission (local only, no cost).

Keep everything running

No action needed. Choose this if you want to keep practising with Codex or try organizing your real files.

  • Your test folders stay on your Mac ready for experimentation.
  • Codex CLI remains installed and ready to use. Try pointing it at your real ~/Downloads folder when you are ready to organize real files.
  • Your AGENTS.md and SKILL.md files are reusable. Copy the .agents/ directory into any folder where you want Codex to apply your file organization skill.

Pause - I'll come back to this later

Since everything runs locally, there are no processes to shut down or costs accumulating. Your files and folders will be right where you left them.

  • If you have the Codex TUI open, press Ctrl+C to exit.
  • Your test folders, AGENTS.md, and SKILL.md all stay on disk. You can relaunch codex from either folder anytime to pick up where you left off.

Delete - I don't want to use this again

Remove both test folders and start fresh.

  • Delete both test folders by running this command in your terminal:
rm -rf ~/messy-folder ~/messy-folder-2
  • Confirm the folders are gone by running:
ls ~/messy-folder ~/messy-folder-2

You should see a "No such file or directory" message for both paths.

What about Codex CLI?

Codex CLI stays installed on your Mac. It is free with your ChatGPT Go plan and takes up minimal space, so there is no cost or performance reason to remove it.

If you do want to remove it, check the Codex CLI GitHub page for uninstall instructions matching your original install method.

Nice Work!

Nice Work!

You just turned a chaotic pile of 20+ files into a neatly organized folder structure, and you did it all by talking to an AI agent in plain English. You now have a working Codex CLI setup that can tame file chaos on command.

You've learned how to:

  • Prompt Codex CLI to scan, analyze, and physically reorganize files into categorized subfolders using natural language prompts.
  • Control Codex's sandbox permissions to keep files safe in read-only mode by default and grant write access only when you trust the plan.
  • Create an AGENTS.md file that encodes your personal organization rules so Codex follows them automatically in every future session.
  • Secret Mission: Built a reusable Codex skill that packages your file organization workflow into a portable module you can drop into any directory.

Ready to quiz yourself?