Building a Roguelike from Your Codebase with GitHub Copilot CLI

A developer turned his codebase into a terminal roguelike using GitHub Copilot CLI's /delegate command and Binary Space Partitioning. Same commit, same dungeon. New commit, new layout. Here's how procedural generation and async AI coding actually work in practice.

Building a Roguelike from Your Codebase with GitHub Copilot CLI

TL;DR

  • GitHub Dungeons turns any repository into a playable terminal roguelike using Binary Space Partitioning
  • Copilot CLI's /delegate command handles async code generation while you work on game design
  • Each commit SHA seeds a unique dungeon layout — same code, same map; new commit, new dungeon
  • Developers who want to experiment with procedural generation or learn Go through a practical project

The Big Picture

Most developers treat their codebase as a static artifact. Lee Reilly turned his into a dungeon crawler. GitHub Dungeons is a terminal roguelike that generates playable levels from your repository structure, complete with procedurally generated rooms, corridors, and enemies. Navigate with arrow keys, fight bugs, hunt for the exit. Every repo produces a different map. Every commit reshapes the layout.

This isn't just a novelty project. It demonstrates how GitHub Copilot CLI's /delegate command changes the development workflow. Instead of writing boilerplate and fighting syntax, you describe behavior in plain English and let Copilot generate working code asynchronously. The result: more time designing mechanics, less time debugging edge cases.

The project also showcases Binary Space Partitioning (BSP), a procedural generation technique that creates structured-but-random dungeon layouts. BSP is the secret behind roguelikes that feel intentional rather than chaotic. Understanding it means understanding how to build replayable systems that don't feel repetitive.

How It Works

GitHub Dungeons uses your repository's latest commit SHA as a seed for dungeon generation. Same commit, same layout. New commit, new dungeon. This ties the game directly to your codebase evolution — as your code changes, so does the map.

The core generation algorithm is Binary Space Partitioning. Start with one large rectangle representing the entire dungeon. Split it recursively into smaller regions — horizontal or vertical cuts, chosen randomly. Keep splitting until regions are too small to fit a room. Each final "leaf" region becomes a room, with slight randomization in size and position to avoid grid-like uniformity.

Rooms connect via L-shaped corridors. The algorithm walks back up the BSP tree and links sibling regions. This guarantees every room is reachable while maintaining the structured chaos that makes roguelikes navigable. No dead ends. No impossible layouts. Just enough randomness to feel organic.

The game itself is written in Go, a language Reilly doesn't normally use. Working with Copilot CLI meant focusing on game mechanics instead of Go syntax. Commands like /delegate offload implementation to GitHub's cloud-based coding agent, which generates code asynchronously and opens pull requests with the results.

For example, the command "/delegate Make each level progressively harder e.g. on level 2 there are extra baddies, but more health potions" produced a working difficulty curve. Reilly reviewed the PR, tweaked the balance, and merged. Same approach for cheat codes, fog of war, and auto-attack mechanics. The /yolo command (an alias for /allow-all) became thematically appropriate — roguelikes are built around permadeath, and you really do only get one life.

Reilly even had Copilot generate a "dungeon scribe" agent that created documentation and ASCII art diagrams explaining the BSP algorithm. The agent lives in the repo as a markdown file, ready to generate technical docs on demand. This kind of meta-tooling — using AI to document AI-assisted development — is where Copilot CLI starts to feel less like autocomplete and more like a development team.

What This Changes For Developers

The workflow shift is subtle but significant. Traditional development: write code, test, debug, repeat. With /delegate: describe behavior, review generated code, iterate on design. You stay in a higher-level mindset. Less context-switching between "what should this do" and "how do I make Go do this."

This matters most when working outside your primary language. Reilly built a Go project without being a Go expert. Copilot handled idioms, error handling, and package structure. He focused on game balance, player experience, and easter eggs. The result shipped faster and felt more polished because he spent time on what makes the game fun, not what makes the compiler happy.

The async nature of /delegate is underrated. Kick off a feature request, switch to another task, come back to a PR. It's like having a junior dev who works while you sleep, except the junior dev doesn't need code review training and never gets tired. The tradeoff: you still need to review carefully. Generated code isn't always optimal. But it's usually correct enough to iterate from.

For procedural generation specifically, this approach unlocks experimentation. Want to try a different room connection algorithm? Describe it, delegate it, test it. The feedback loop compresses from hours to minutes. You can explore design space faster because implementation friction drops to near-zero.

Try It Yourself

Install the extension if you have GitHub Copilot CLI:

gh extension install leereilly/gh-dungeons

Then run it in any repository:

gh dungeons

Control your character with WASD, arrow keys, or Vim keys. Find the hidden door. Escape five levels. The game tracks kills, conquered levels, and other stats. Fog of war limits visibility. Auto-attack triggers when you move into enemies.

For the truly reckless, there's a pre-commit hook mode that deletes uncommitted changes unless you beat the entire game. Do not enable this unless you understand exactly what it does and enjoy pain.

The Bottom Line

Use GitHub Copilot CLI if you want to prototype faster, work outside your primary language, or experiment with complex algorithms without getting bogged down in implementation details. Skip it if you're working on performance-critical code where you need full control over every line, or if your workflow already optimizes for deep focus on implementation.

The real opportunity here isn't just faster coding. It's the ability to stay in design mode longer. When Copilot handles scaffolding and boilerplate, you spend more time thinking about what the software should do and less time fighting syntax. That shift — from "how do I code this" to "what should this be" — is where creative development work happens. GitHub Dungeons proves you can build something genuinely fun while barely touching the language you're writing in. That's the unlock.

Source: GitHub Blog