How to create a new Python project with Codex
Codex produces consistent project scaffolding when you explicitly point it at the Modern Python Project Setup Guide for AI Assistants. Use the canonical Markdown URL (https://pydevtools.com/handbook/explanation/modern-python-project-setup-guide-for-ai-assistants/index.md) inside your first prompt so Codex follows the uv-based workflow on macOS, Linux, and Windows.
Launch Codex with the guide loaded
1. Open a terminal in your repository root
Codex works best when it starts in the directory that already contains your project files (or the Git repo where the project will live). On macOS/Linux you can cd /path/to/repo; on Windows use PowerShell’s Set-Location.
2. Prime Codex on macOS or Linux
Use a here-document to feed the setup instructions and your project request through stdin:
cat <<'EOF' | codex exec -
You are helping me create a modern Python project.
Use https://pydevtools.com/handbook/explanation/modern-python-project-setup-guide-for-ai-assistants/index.md as the authoritative playbook.
Project path: $(pwd)
Project goal:
- Create a uv-based FastAPI service named payments
- Configure Ruff (lint+format), pytest with coverage, and pre-commit hooks
- Document the workflow in README.md
Confirm the plan, then run each command from the project root.
EOFCodex reads the URL directly and keeps the entire guide in its working memory for that session.
3. Prime Codex on Windows (PowerShell)
Run the equivalent prompt with PowerShell’s here-string syntax:
@'
You are helping me create a modern Python project.
Use https://pydevtools.com/handbook/explanation/modern-python-project-setup-guide-for-ai-assistants/index.md as the authoritative playbook.
Project path: $(Get-Location)
Project goal:
- Create a uv-based FastAPI service named payments
- Configure Ruff (lint+format), pytest with coverage, and pre-commit hooks
- Document the workflow in README.md
Confirm the plan, then run each command from the project root.
'@ | codex exec -4. Iterate without leaving the repo root
Keep the same terminal session open so Codex continues to run commands relative to your repository. When you need a new project variant, rerun the prompt with updated “Project goal” bullets.
Prompt template
Copy/paste this template and adjust the goal section for each project:
You are helping me create a modern Python project.
Use https://pydevtools.com/handbook/explanation/modern-python-project-setup-guide-for-ai-assistants/index.md as the authoritative playbook.
Project path: <absolute path or $(pwd)>
Project goal:
- <describe the app or library you need>
- <list required tools or dependencies>
Confirm the plan, then run each command from the project root.Verify Codex is following the guide
Ask Codex to explain how it will add dependencies or tests. It should reference uv add, uv run pytest, ruff check, and pre-commit, all pulled from the linked guide. If it falls back to pip install or omits tooling, restart the session and resend the prompt with the URL.