Contents

The Foundation: Preparing Your Game Project for AI Collaboration

This article explains why providing high-quality context to an AI assistant is the most critical step for success in game development, and how to create a project “bible” to get the best results.


Have you ever asked an AI coding assistant for help, only to get a generic answer that doesn’t fit your project? It’s a common frustration. You ask for a function to handle player inventory, and it gives you a solution that completely ignores your game’s Entity-Component-System (ECS) architecture.

The problem isn’t the AI; it’s the context.

AI assistants are powerful, but they aren’t mind readers. The quality of their output is directly proportional to the quality of the context you provide. This article, the first in my series on AI-assisted game development, will teach you the single most important step for success: creating a project “bible” that gives the AI the context it needs to become a true collaborator.

Why Context is King: Garbage In, Garbage Out

Think of an AI assistant like a brilliant new developer on their first day. They might know how to code, but they don’t know your project’s history, its architectural patterns, or its goals. If you ask them to “add a feature” without any context, they’ll make assumptions based on their general knowledge, which will likely be wrong for your specific codebase.

This is the “Garbage In, Garbage Out” principle. A vague prompt with no context will almost always yield a generic, unhelpful result.

In my MonoRpg case study, a 2D RPG framework built with MonoGame, asking the AI to “write a function to load a map” without context would be a waste of time. The AI doesn’t know I’m using the LDtk map editor, or that my architecture is built around an ECS pattern. However, by providing that context upfront, I can get a response that is not only correct but also perfectly tailored to my existing code.

Creating Your Project Bible: The CONTEXT.md File

The solution is to create a central document that serves as a “project bible” for the AI. This file, which I’ll call CONTEXT.md, should live at the root of your project. Its purpose is to give the AI a high-level overview of everything it needs to know to be effective.

Here are the essential sections to include for a typical game development project, using my MonoRpg as an example.

1. Project Overview

Start with a brief, high-level summary of the project.

# CONTEXT.md - MonoRpg Project Bible

## Project Overview

MonoRpg is a 2D RPG framework built with MonoGame and .NET. It serves as the foundation for games that feature elements like a top-down perspective, a quest system, and turn-based card combat.

2. Core Architecture

This is the most critical section. Describe the fundamental patterns your project uses.

## Core Architecture

-   **Entity-Component-System (ECS):** The game is built using an ECS pattern. Entities are simple IDs, Components are pure data, and Systems contain all logic. Do not suggest solutions that involve creating large, stateful classes for game objects.
-   **Dependency Injection (DI):** Services are managed by a DI container (Microsoft.Extensions.DependencyInjection). Services should be stateless and registered at startup.
-   **Rendering Pipeline:** The game uses a custom rendering pipeline with distinct layers for the world, entities, and UI. Depth sorting is handled by the Y-position of entities.

3. Build & Run Commands

Tell the AI how to compile and run your project. This allows it to verify that its code suggestions are valid.

## Build & Run Commands

-   **Build Project:** `dotnet build`
-   **Run Project:** `dotnet run --project src/MonoRpg.Desktop`

4. Directory Structure

Provide a simplified map of your codebase so the AI knows where to find things and where to put new files.

## Directory Structure

-   `src/MonoRpg.Core/`: Core game logic, independent of platform.
-   `src/MonoRpg.Desktop/`: The desktop (MonoGame) client.
-   `src/MonoRpg.Domain/`: ECS definitions (Entities, Components).
-   `src/MonoRpg.Systems/`: All game systems.
-   `content/`: Game assets, including maps and sprites.

5. Coding Conventions

Briefly mention any important coding styles or patterns.

## Coding Conventions

-   All code follows standard C#/.NET conventions.
-   Service interfaces are prefixed with `I` (e.g., `IMapManager`).
-   Private fields are prefixed with `_`.

Structuring for Success

How you write your CONTEXT.md matters. Use clear, simple language and structure the document for easy parsing.

  • Use Markdown: It’s universally understood by AI.
  • Use Headings: ## and ### help the AI quickly navigate to relevant sections.
  • Use Fenced Code Blocks: ```csharp makes code unambiguous.
  • Be Explicit: Don’t be afraid to state rules directly, like “Do not suggest solutions that involve creating large, stateful classes.”

Conclusion: A Foundation for Collaboration

Investing an hour to create a CONTEXT.md file is the highest-leverage activity you can do to improve your experience with AI coding assistants. It transforms the AI from a generic chatbot into a specialized, context-aware pair programmer.

By providing this foundation, you reduce frustrating back-and-forth, get more accurate and relevant code, and unlock the true potential of AI-assisted development.

In the next article in this series, I’ll show you how to use this CONTEXT.md file to have the AI act as an architect, helping you plan out complex new features for your game.