Introduction: Moving Beyond Local Changes

In the previous lessons, you learned how to use Codex to make local code changes in a Django project. You practiced writing clear prompts to update code in a single file or make small adjustments. Now, let’s take the next step and look at how to handle more complex updates — those that require changes across multiple files and settings.

These types of changes are called structural changes. For example, moving all your CSS from an HTML template into a static file is not just a single edit. It involves updating your Django settings, creating new files, and making sure everything is connected properly. In this lesson, we will explore a reliable approach to handle such tasks with Codex.

The Generation Knowledge Approach

When you need LLM to perform a complex task, it’s easy to miss a step if you try to do everything at once. This is where the generation knowledge approach comes in. The idea is simple:

  1. First, ask LLM to generate some information that is related to the task. It will help LLM to get more context.
  2. Then, send the actual request to LLM.

This two-step method improves the model's performance and adds one extra validation step, where you can make adjustments or request clarifications.

Let’s see how this works in practice.

Example: Enabling Static CSS Files in Django

Suppose you want to move your CSS from an HTML template to a static file in your Django project. Before you ask Codex to make any changes, you should first find out what steps are needed.

You can start by asking Codex a question like this:

Codex will usually respond with a list of steps, such as:

  • Creating a static directory in your Django app.
  • Placing your CSS file in the static directory.
  • Updating your Django settings to include static files configuration.
  • Loading static files in your HTML templates using {% load static %}.
  • Linking the CSS file in your HTML template with the correct path.

By asking for this information first, you make sure you understand the full scope of the task. Also this helps Codex avoid missing any important steps.

Example: Moving Inline CSS to a Static File

Now that you know what needs to be done, you can ask Codex to perform the actual changes. Here’s how you might phrase your prompt:

Let’s break down what happens here:

  • You are telling Codex exactly what you want: move the CSS out of the HTML and into a static file.
  • You are also asking Codex to handle all the related updates, such as creating the static file, updating the template to load the CSS, and making sure the settings are correct.

By following this two-step approach, you make sure that all necessary changes are made and nothing is left out.

Making it Faster

The biggest bottleneck problem of Codex is exploring the entire project structure. It can "think" up to 10 minutes, trying to figure out all the details. When making local changes, we guided it with the exact location of the change. It is much more complicated with structural changes. However, we can utilize the generated knowledge approach here as well. Here is an example of how you can make the Codex work faster:

Step 1: Ask Codex to generate general knowledge about the topic

Step 2: Ask Codex to prepare an action plan. Provide it with context. For example:

Step 3: Send an actual request to Codex. Be specific. For instance:

Such specific requests will make Codex work way faster. However, this approach requires a good understanding of the project's structure and the framework. If you are not sure which details to specify, you can always go with a slower method, letting Codex explore the files and making decisions. Don't forget to read it's explanations to obtain a clear context!

Summary And What’s Next

In this lesson, you learned how to use the generation knowledge approach to handle structural changes in your Django project with Codex. First, you ask Codex to list all the steps required for your task. Then, you use that information to guide your prompt for making the actual changes. This method helps you manage complex updates with confidence and accuracy.

You are now ready to practice this approach in the exercises that follow. Try using generation knowledge for different types of structural changes and see how it helps you work more effectively with Codex.

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