Home › MonoGame › MonoGame AGENTS.md

MonoGame AGENTS.md

AGENTS.md for 2D/3D games in C# with MonoGame 3.8: game loop, content pipeline, scenes, and allocation-free updates.

AGENTS.mdMonoGame

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

AGENTS.mdDownload  
# AGENTS.md: MonoGame (C#)

## Commands
`dotnet build` · `dotnet run --project src/Game` · `dotnet test` · content: `dotnet mgcb-editor` (GUI) or build via the `Content.mgcb` file

## Structure
- `Game1` (rename to the game's name) only wires services and the scene manager. Each scene/screen is a class with `Load`, `Update(GameTime)`, `Draw(SpriteBatch)`, `Unload`.
- Game logic (rules, AI, physics math) in plain C# classes without MonoGame dependencies where possible, so they're unit-testable.
- Assets go through the content pipeline (`Content.mgcb`); load with `Content.Load<Texture2D>("sprites/player")` once in `LoadContent`/scene load, never in `Update` or `Draw`.

## Loop rules
- Use `(float)gameTime.ElapsedGameTime.TotalSeconds` for movement; consider a fixed timestep (`IsFixedTimeStep = true`) for physics.
- Input through a small input service that tracks previous and current `KeyboardState`/`GamePadState` for "pressed this frame" checks.
- One `SpriteBatch.Begin/End` per layer; sort and batch by texture (use texture atlases). Use `SamplerState.PointClamp` for pixel art.
- Avoid allocations in `Update`/`Draw`: no LINQ, no `new` per frame, reuse lists, pool bullets/particles, cache strings for HUD text.
- Resolution independence via a render target at the virtual resolution, scaled to the window.
- Dispose `RenderTarget2D` and other GPU resources you create.

## Done
Build has no warnings, tests pass, and the game runs and plays the changed feature.

Related rules

REST API design AGENTS.md

AGENTS.md for designing consistent HTTP/JSON APIs: resource naming, status codes, errors, pagination, and versioning.

AGENTS.mdAPI design

Bevy game engine AGENTS.md

AGENTS.md for Bevy (0.16+) games in Rust: ECS systems, plugins, required components, and fast dev builds.

AGENTS.mdBevy (Rust)

Git commits & PRs AGENTS.md

AGENTS.md rules for how agents commit: Conventional Commits, atomic changes, safe git commands, and PR descriptions.

AGENTS.mdAgent workflows

CrewAI multi-agent AGENTS.md

AGENTS.md for CrewAI 1.x projects: YAML agents and tasks, crews and flows, tools, and cost-aware runs.

AGENTS.mdLLM apps & agents

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.