Dungeons & Desktops: Building a procedurally generated roguelike with GitHub Copilot CLI

TL;DR · AI Summary
Using GitHub Copilot CLI to build a procedurally generated roguelike game, showcasing practical applications of AI-assisted development.
Key Takeaways
- GitHub Copilot CLI can significantly enhance development efficiency, especially
- Procedural generation techniques allow for the creation of infinitely varied gam
- The article provides detailed code examples and development processes to help de
Outline
Jump quickly between sections.
Introduces the background and purpose of using GitHub Copilot CLI to build a roguelike game.
Describes the overall structure and goals of the project.
Details how to set up the development environment.
Explains how to use GitHub Copilot CLI to implement procedurally generated levels.
Provides specific code snippets and explanations.
Summarizes the project outcomes and looks ahead to future improvements.
Mindmap
See how the topics connect at a glance.
查看大纲文本(无障碍 / 无 JS 友好)
- 构建 Roguelike 游戏
- 引言
- 项目概述
- 环境搭建
- 核心功能实现
- 代码示例
- 总结与展望
Highlights
Key sentences worth saving and sharing.
GitHub Copilot CLI can significantly enhance development efficiency, especially when dealing with complex logic.
Procedural generation techniques allow for the creation of infinitely varied game levels.
The article provides detailed code examples and development processes to help developers get started quickly.
Dungeons & Desktops: Building a procedurally generated roguelike with GitHub Copilot CLI - The GitHub Blog
Skip to contentSkip to sidebar
[](https://github.com/)/Blog
Try GitHub Copilot CLISee what's new
Learn about artificial intelligence and machine learning across the GitHub ecosystem and the wider industry.
Learn how to build with generative AI.
Change how you work with GitHub Copilot.
Everything developers need to know about LLMs.
Machine learning tips, tricks, and best practices.
Explore the capabilities and benefits of AI code generation and how it can improve your developer experience.
Learn more
Resources for developers to grow in their skills and careers.
Insights and best practices for building apps.
Tips & tricks to grow as a professional developer.
Improve how you use GitHub at work.
Learn how to move into your first professional role.
Stay current on what’s new (or new again).
Learn how to start building, shipping, and maintaining software with GitHub.
Learn more
Get an inside look at how we’re building the home for all developers.
Discover how we deliver a performant and highly available experience across the GitHub platform.
Explore best practices for building software at scale with a majority remote team.
Get a glimpse at the technology underlying the world’s leading AI-powered developer platform.
Learn how we build security into everything we do across the developer lifecycle.
Find out what goes into making GitHub the home for all developers.
Our engineering and security teams do some incredible work. Let’s take a look at how we use GitHub to be more productive, build collaboratively, and shift security left.
Learn more
Explore how to write, build, and deploy enterprise software at scale.
Automating your way to faster and more secure ships.
Guides on continuous integration and delivery.
Tips, tools, and tricks to improve developer collaboration.
DevOps resources for enterprise engineering teams.
How to integrate security into the SDLC.
Ensuring your builds stay clean.
Learn why Gartner positioned GitHub as a Leader for the second year in a row.
Learn more
Keep up with what’s new and notable from inside GitHub.
An inside look at news and product updates from GitHub.
The latest on GitHub’s platform, products, and tools.
Insights into the state of open source on GitHub.
The latest policy and regulatory changes in software.
Data-driven insights around the developer ecosystem.
Older news and updates from GitHub.
Learn how to use retrieval-augmented generation (RAG) to capture more insights.
Learn more
Everything open source on GitHub.
The latest Git updates.
Spotlighting open source maintainers.
How open source is driving positive change.
Explore open source games on GitHub.
Organizations worldwide are incorporating open source methodologies into the way they build and ship their own software.
Learn more
Stay up to date on everything security.
Application security, explained.
Demystifying supply chain security.
Updates from the GitHub Security Lab.
Helpful tips on securing web applications.
Learn about core challenges in DevSecOps, and how you can start addressing them with AI and automation.
Learn more
Search
Categories
Learn about artificial intelligence and machine learning across the GitHub ecosystem and the wider industry.
Learn how to build with generative AI.
Change how you work with GitHub Copilot.
Everything developers need to know about LLMs.
Machine learning tips, tricks, and best practices.
Explore the capabilities and benefits of AI code generation and how it can improve your developer experience.
Resources for developers to grow in their skills and careers.
Insights and best practices for building apps.
Tips & tricks to grow as a professional developer.
Improve how you use GitHub at work.
Learn how to move into your first professional role.
Stay current on what’s new (or new again).
Learn how to start building, shipping, and maintaining software with GitHub.
Get an inside look at how we’re building the home for all developers.
Discover how we deliver a performant and highly available experience across the GitHub platform.
Explore best practices for building software at scale with a majority remote team.
Get a glimpse at the technology underlying the world’s leading AI-powered developer platform.
Learn how we build security into everything we do across the developer lifecycle.
Find out what goes into making GitHub the home for all developers.
Our engineering and security teams do some incredible work. Let’s take a look at how we use GitHub to be more productive, build collaboratively, and shift security left.
Explore how to write, build, and deploy enterprise software at scale.
Automating your way to faster and more secure ships.
Guides on continuous integration and delivery.
Tips, tools, and tricks to improve developer collaboration.
DevOps resources for enterprise engineering teams.
How to integrate security into the SDLC.
Ensuring your builds stay clean.
Learn why Gartner positioned GitHub as a Leader for the second year in a row.
Keep up with what’s new and notable from inside GitHub.
An inside look at news and product updates from GitHub.
The latest on GitHub’s platform, products, and tools.
Insights into the state of open source on GitHub.
The latest policy and regulatory changes in software.
Data-driven insights around the developer ecosystem.
Older news and updates from GitHub.
Learn how to use retrieval-augmented generation (RAG) to capture more insights.
Everything open source on GitHub.
The latest Git updates.
Spotlighting open source maintainers.
How open source is driving positive change.
Explore open source games on GitHub.
Organizations worldwide are incorporating open source methodologies into the way they build and ship their own software.
Stay up to date on everything security.
Application security, explained.
Demystifying supply chain security.
Updates from the GitHub Security Lab.
Helpful tips on securing web applications.
Learn about core challenges in DevSecOps, and how you can start addressing them with AI and automation.
See what's newTry GitHub Copilot CLI
Dungeons & Desktops: Building a procedurally generated roguelike with GitHub Copilot CLI
Learn how one Hubber used GitHub Copilot CLI to build an extension that turns any codebase into a unique, roguelike dungeon.

[Lee Reilly](https://github.blog/author/leereilly/ "Posts by Lee Reilly")·@leereilly
May 12, 2026
| 8 minutes
- Share:
- [](https://x.com/share?text=Dungeons%20%26amp%3B%20Desktops%3A%20Building%20a%20procedurally%20generated%20roguelike%20with%20GitHub%20Copilot%20CLI&url=https%3A%2F%2Fgithub.blog%2Fai-and-ml%2Fgithub-copilot%2Fdungeons-desktops-building-a-procedurally-generated-roguelike-with-github-copilot-cli%2F)
- [](https://www.facebook.com/sharer/sharer.php?t=Dungeons%20%26amp%3B%20Desktops%3A%20Building%20a%20procedurally%20generated%20roguelike%20with%20GitHub%20Copilot%20CLI&u=https%3A%2F%2Fgithub.blog%2Fai-and-ml%2Fgithub-copilot%2Fdungeons-desktops-building-a-procedurally-generated-roguelike-with-github-copilot-cli%2F)
- [](https://www.linkedin.com/shareArticle?title=Dungeons%20%26amp%3B%20Desktops%3A%20Building%20a%20procedurally%20generated%20roguelike%20with%20GitHub%20Copilot%20CLI&url=https%3A%2F%2Fgithub.blog%2Fai-and-ml%2Fgithub-copilot%2Fdungeons-desktops-building-a-procedurally-generated-roguelike-with-github-copilot-cli%2F)
I got nerd-sniped into the GitHub Copilot CLI Challenge and made a questionable decision: I turned my codebase into a roguelike dungeon.
It started with a simple prompt: Build a GitHub CLI extension in Go that takes the current repository and turns it into a playable roguelike dungeon, with dungeons generated with BSP [snip]. And then /yolo .
The result is GitHub Dungeons, a terminal game that generates a dungeon from your codebase. Rooms, corridors, and enemies, all built from your repo and rendered right in your terminal. You navigate with arrow keys, fight bugs, and hunt for the exit. Every repository produces a different map. Every commit reshapes the layout. And if your HP hits zero, you start over.

💡 Fun fact:/yolo (“you only live once”) is a Copilot CLI command (an alias for /allow-all). Fitting, since roguelikes are built around permadeath. You really do only get one life.
Roguelikes trace back to games like _Rogue_ in the 1980s – terminal-based adventures where each run generated a new dungeon, and death meant starting over.
That combination of procedural generation, permadeath, and text-based interfaces (later formalized in things like the “Berlin Interpretation”) makes the genre feel surprisingly modern, and a perfect fit for the command line.
GitHub Dungeons leans into that tradition. It’s written in Go, which I don’t normally use, but working with Copilot meant I could focus on behavior instead of syntax.
What is procedural generation?
Procedural generation (or “procgen” as the cool kids call it) is a way of creating content algorithmically instead of designing it by hand. In games, that usually means levels, maps, enemies, or items are generated at runtime using a set of rules plus a bit of randomness.
So instead of designing _one_ dungeon, you design a system that generates _many_.
That’s what gives roguelikes their replayability:
- Every run is different
- Layouts change every time
- Something
- Something
In GitHub Dungeons, that system is tied to your repo. The layout is seeded by your latest commit, so the same code produces the same dungeon, and every change reshapes it.
So how does a repository actually become a dungeon?
At a high level, GitHub Dungeon layouts are generated using Binary Space Partitioning (BSP), seeded by your repository’s latest commit SHA (more on BSP in a bit). That means the same codebase produces a consistent layout, while still evolving as the code changes.
In practice:
- The same commit always generates the same map
- Different repositories produce layouts that feel structurally distinct
- As the code changes, the dungeon evolves with it
It’s procedural generation—but tied directly to your codebase. That’s the idea.
The interesting part was actually building it.
Building it with Copilot CLI
Working with GitHub Copilot CLI meant describing behavior instead of writing everything from scratch. One command that made a big difference was /delegate. Instead of just generating code inline, /delegate hands the task off to GitHub’s Copilot coding agent running in the cloud.
I could describe what I wanted in plain English, kick it off, and then go do something else while it worked independently. When it finished, it opened a pull request with the results.
For example,/delegate Make each level progressively harder e.g. on level 2 there are extra baddies, but more health potions
Copilot generated a solid first pass asynchronously, and I reviewed and tweaked the PR from there until the balance felt right. I took the same approach to other features like adding cheat codes that make the player invincible (because why not).
I even had Copilot generate a “dungeon scribe” agent, a small helper that added documentation and ASCII art diagrams to explain how dungeons were generated, which felt very on-brand for a terminal roguelike.
I even had Copilot generate a dungeon scribe agent to create documentation and explain how dungeons were generated with ASCII art diagrams, which felt very on-brand for a terminal roguelike.
Using Copilot (especially with
/delegate) is like having an army of NPCs available to do whatever I want them to do.Lee Reilly, Dungeon Master
Working this way (describing features, delegating them to Copilot, and reviewing the resulting pull requests) meant I could spend less time on edge cases and boilerplate, and more time on the player experience, including adding easter eggs for players to discover. Iterating with Copilot let me stay in a game design mindset instead of constantly switching into implementation details. Because Copilot was handling most of the build and scaffolding, I could stay in the flow of designing mechanics, testing ideas, and figuring out what actually made the game fun.
Procedurally generated levels (with BSP)
At the heart of each dungeon design is a technique called Binary Space Partitioning (BSP), which is a great thing to casually mention alongside middle-out compression if you want to impress your friends and colleagues. It sounds intimidating, but the idea is surprisingly simple: keep splitting a space into smaller chunks until you have a bunch of rooms you can connect.
Why BSP works so well for roguelikes
Roguelikes need maps that feel:
- Structured (not completely random nonsense)
- Replayable (different every run)
- Navigable (no dead ends or impossible layouts)
BSP hits a sweet spot. It gives you:
- Clean, rectangular rooms
- Guaranteed connectivity
- Just enough randomness to feel organic
Here’s how it works…
#### 1. Start with a big empty space
Everything begins as one big rectangle: your entire dungeon.

#### 2. Split it (recursively)
We split the space into two regions.

Then split those again.

And again.
Each split can be horizontal or vertical.
#### 3. Stop when it gets too small
We keep splitting until regions are too small to fit a room.
That creates a bunch of “leaf” regions, the final building blocks.

#### 4. Turn each region into a room
Each leaf becomes a room, but not perfectly aligned. We randomize size and position slightly.

That slight randomness is what stops everything feeling too grid-like.
#### 5. Connect rooms with corridors
Now we connect rooms by walking back up the tree and linking siblings.

Each connection is an L-shape:
#### 6. End result: structured chaos
Put it all together and you get something like this:

- Rooms feel intentional
- Corridors make everything reachable
- Every run is different (but reproducible with a seed)
Why this lands so well
What I like about BSP is that it feels designed, even though it isn’t.
It avoids the two big problems of procedural generation: pure randomness (messy), and rigid grids (predictable, boring). Instead, you get something in between… and sometimes beautiful.
How to install and play it
If you want to see what your own codebase looks like as a dungeon, and you already have GitHub Copilot CLI installed, you can run:
gh extension install leereilly/gh-dungeons
After that, run gh dungeons to transform your repository into a custom dungeon, ready to be conquered. Control your hero with WASD, arrow keys, or Vim keys.
Your goal is to find the hidden door and escape from (and attack!) enemies over five levels. I’ve added fun features like fog of war that limit visibility, auto-attack, ability to track stats like kills and conquered levels, and more that you’ll have to discover yourself.
Danger zone!
If you’re feeling reckless, play it on crazy mode: you can set up a pre-commit hook that deletes your saved changes unless you beat the entire game.
⚠️ _WARNING: Do not do this unless you fully understand what this will do to your repository, you’ll lose saved work and probably some sanity as well._
# Create the pre-commit hook
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/bash
gh dungeons
if [ $? -ne 0 ]; then
echo "You died! Your changes have been stashed into oblivion..."
git stash && git stash drop stash@{0}
exit 1
fi
EOF
# Make it executable
chmod +x .git/hooks/pre-commit
# To be clear, you’ll lose all your uncommited changes if you enable this
# and fail to beat the dungeon, adventurer._(Editor’s note: Please, please, please do not do this. We are not responsible for any lost work. But Lee definitely is.)_
Take this with you
This started as a throwaway experiment, but it changed how I think about GitHub Copilot CLI.
I was able to MVP it quickly, iterate on the parts that mattered, and let Copilot handle the heavy lifting, things like BSP generation and even monsters and movement defined in a slightly cursed YAML file of Yendor.
- * *
Tags:
Written by
[Lee Reilly](https://github.blog/author/leereilly/)
Senior Program Manager, GitHub Developer Relations. Open source hype man, AI whisperer, hackathon and game jam wrangler. I write && manage programs, support dev communities, and occasionally ship something.
Table of Contents
More on [gaming](https://github.blog/tag/gaming/)
[Game Bytes · September 2023](https://github.blog/open-source/gaming/game-bytes/)
Game Bytes is our monthly series taking a peek at the world of gamedev on GitHub—featuring game engine updates, game jam details, open source games, mods, maps, and more. Game on!
[Lee Reilly](https://github.blog/author/leereilly/ "Posts by Lee Reilly")
Related posts

[Improving token efficiency in GitHub Agentic Workflows](https://github.blog/ai-and-ml/github-copilot/improving-token-efficiency-in-github-agentic-workflows/)
Agentic workflows that run on every pull request can quietly accumulate large API bills. Here’s how we instrumented our own production workflows, found the inefficiencies, and built agents to fix them.
[Landon Cox](https://github.blog/author/lpcox/ "Posts by Landon Cox")&[Mara Kiefer](https://github.blog/author/mnkiefer/ "Posts by Mara Kiefer")

[Agent pull requests are everywhere. Here’s how to review them.](https://github.blog/ai-and-ml/generative-ai/agent-pull-requests-are-everywhere-heres-how-to-review-them/)
A practical guide to reviewing agent-generated pull requests: what to look for, where issues hide, and how to catch technical debt before it ships.
[Andrea Griffiths](https://github.blog/author/andreagriffiths11/ "Posts by Andrea Griffiths")

[Validating agentic behavior when “correct” isn’t deterministic](https://github.blog/ai-and-ml/generative-ai/validating-agentic-behavior-when-correct-isnt-deterministic/)
How to build the “Trust Layer” for Github Copilot Coding Agents without brittle scripts or black-box judgements by using dominatory analysis.
[Gaurav Mittal](https://github.blog/author/g1910/ "Posts by Gaurav Mittal")&[Reshabh Kumar Sharma](https://github.blog/author/resharma/ "Posts by Reshabh Kumar Sharma")
Explore more from GitHub
Docs
Everything you need to master GitHub, all in one place.
GitHub
Build what’s next on GitHub, the place for anyone from anywhere to build anything.
Customer stories
Meet the companies and engineering teams that build with GitHub.
The GitHub Podcast
Catch up on the GitHub podcast, a show dedicated to the topics, trends, stories and culture in and around the open source developer community on GitHub.
We do newsletters, too
Discover tips, technical guides, and best practices in our biweekly newsletter just for devs.
Your email address
*Your email address
Subscribe
- [x] Yes please, I’d like GitHub and affiliates to use my information for personalized communications, targeted advertising and campaign effectiveness. See the GitHub Privacy Statement for more details.
Subscribe
Site-wide Links
[](https://github.com/)