Creating New Files with Codex

In this final unit, you’ll explore how Codex can help you create entirely new files and populate them with useful content — just by describing what you want. This includes writing new Python files, generating code from scratch, and setting up files like unit tests.

This hands-on unit focuses on expanding your workflow to include file generation and scaffolding, making Codex a powerful tool not just for editing — but also for building.

Generating New Files with a Prompt

Once you’ve launched Codex inside your project directory, try a natural prompt like:

Codex will:

  • Create the new file
  • Read the functions from math_utils.py
  • Generate appropriate test cases using a testing framework like unittest or pytest
  • Show you a preview before applying the change

You’ll have the chance to review the proposed content and approve it — or edit the suggestion before it’s applied.

Example Prompt

Imagine your file math_utils.py contains this function:

Now you run Codex and type:

Codex might suggest creating a new file with this content:

You can then review and approve the file creation and content.

Use Cases

This technique is useful for:

  • Generating boilerplate code
  • Writing tests or config files
  • Creating documentation stubs
  • Starting new scripts or tools

You’ll save time by letting Codex scaffold the structure, while you focus on the logic.

Summary

In this unit, you learned how to use Codex to create new files and populate them with relevant code using natural language. This helps automate setup tasks and streamline the start of new files or components in your projects.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal