A Reusable Context Block for Every Codex Project

At work, we have many microservices. Each service has its own Git repository. This is good for keeping services separate, but it creates another problem: no single repository explains the full system.

Repository A may contain the orders service. Repository B may contain the payments service. But a task in orders may still depend on a payment rule, a shared database field, or an event used by another team.

Codex needs this wider context to make the right change. But I also do not want to add every code repository to every Codex project. A project should contain only the code needed for that task.

My solution is to keep the shared information in a separate context repository and attach it wherever it is needed.

The context repository works like a reusable Tetris block. It fits into Project A with Repository A, Project B with Repository B, or Project C with both repositories.

Think of context as a Tetris block

The picture above shows the main idea.

The context repository is like a reusable Tetris block. I can fit the same block into different Codex projects. The code beside it changes based on the task, but the shared context block stays available.

This keeps each project focused:

The third setup is useful when one task needs simultaneous changes across two services. Codex can see both codebases and the shared rules that connect them.

What is the context repository?

The context repository is a normal Git repository. It mainly contains Markdown files that explain the system.

It can include:

The repository does not run in production. Its purpose is to give developers and Codex a clear map of the system.

Why keep it in Git?

We can store this information in Lucidchart, Confluence, or another documentation tool. Those tools are useful for people, especially when we want to explain something visually.

But Git gives us a few extra benefits:

This makes the context part of our engineering work instead of a document that slowly becomes outdated.

How I use it with Codex

I attach the context repository to every Codex project that needs system-level information, just like adding the same Tetris block to a new layout.

The code repositories depend on the task. I add only the codebase—or part of the architecture—that I am working on.

Project A

If I am changing Repository A, I create a focused Codex project with:

Codex reads the shared rules and schemas, then makes the change in Repository A.

Project B

If the task belongs to Repository B, I create another focused project with:

The code repository changes, but the source of shared context stays the same.

Project C

Some tasks need simultaneous changes in more than one service. For example, a schema change in Repository A may also require an update in Repository B.

For that task, the Codex project can include:

Codex can now understand the shared rule and work across both repositories at the same time. The context block helps it see how the two codebases fit together.

A simple example

Suppose I want to add partial order cancellation.

The orders repository contains the order code. The payments repository contains refund code. The context repository explains the cancellation rules, the order schema, and the events shared by both services.

My prompt can be simple:

Add support for partial order cancellation. Read the cancellation rules, order schema, and event details from the context repository first. Update the orders and payments repositories where needed. Tell me if the code and the documents do not match.

Codex now has three things:

Keeping the context useful

This approach works only if the context repository stays up to date.

When we change a schema, business rule, API, or event, we also update the related document. The update should be reviewed just like a code change.

A few simple rules help:

If the document and the code do not match, Codex should point out the difference. It should not silently guess which one is correct.

The main benefit

Without shared context, every task starts with searching across repositories and asking people how the system works. Codex faces the same problem.

With a context repository, the important knowledge is in one tracked place. I can attach that reusable block to a project with one code repository or to a project with several repositories for a simultaneous change.

The idea is simple: keep each Codex project focused on the code it needs, then attach the shared context block for better results.