
From Prompt to Play: Building a Chess Game with Amazon Q CLI
Explore how Amazon Q CLI helps developers build applications faster by turning conversation into code - chess edition
Mouna Neelakanta
Amazon Employee
Published May 25, 2025
Last Modified May 26, 2025
When you're married to another developer, date nights can look a bit different. We've competed with each other on LeetCode, built apps together, and learned new technology. Last weekend, we decided to use Amazon Q CLI to build a Chess game. Amazon Q CLI transforms your terminal into an AI-powered coding companion, helping you to build applications faster by converting natural language prompts into working code.
Why just play when you can build and play? Here's how we did it, step by step.
Q CLI doesn't support Windows yet, so we decided to set up WSL to install and run it. See this link for Operating systems supported. The steps in the video are covered in the official Amazon Q Developer CLI installation documentation for windows.
The initial implementation generated by Q CLI comprised of three core files:
index.html
: Structured the 8*8 chessboard using HTML elementschess.js
: Implemented custom game logic, including piece movements, turn management and basic move validationstyle.css
: Styled the board and pieces for visual clarity with plain CSS

We were able to play the game straightaway by opening the
index.html
file in the browser. Here's what it looked like without any changes to Q CLI's output.Taking a closer look, it's clear that the Q CLI's implementation incorporates the fundamental rules of chess.
chess.js
establishes an 8x8 board representation, proper piece placement with Unicode characters for the pieces themselves. All six chess piece types have the correct movement patterns, turn-based play is enforced, piece selections are highlighted, and validation stops illegal moves.However advanced features like castling, en passant captures, and checkmate detection were missing. It's time to ask Q CLI to improve our code.
Rather than asking Q CLI to implement the missing movement patterns and checkmate detection directly, let's use an existing open source library. Chess rules are complex and require detailed rule based logic. Open source libraries like Chess.js offer battle-tested solution. They come with built-in edge case handling and comprehensive test coverage. This approach eliminates the need to write, test and debug numerous scenario ourselves, resulting in a simpler codebase.
Let's get Q CLI to refactor the codebase to use chess.js.
Let's test checkmate detection, using the Fool's Mate pattern.
Now that we have all the missing movement patterns and checkmate detection, the user experience could use an improvement. Instead of managing DOM elements manually, lets use the open source library Chessboard.js to update the design. This syncs seamlessly with chess.js and includes drag and drop piece movements, automatic position syncing on valid moves and responsive layout for mobile and desktop.
That looked good enough for us. With the build part of date night complete, it was time to move on to playing. (I was a school chess champion in my 2nd grade, so it will be tough competition for my husband!)
TL;DR 40 minutes 59 seconds later, it was a stalemate!
- From Prompt to Playable: For anyone who loves building things, Amazon Q CLI offers a fun way to bring your ideas to life. We started with a basic chess implementation and gradually transformed it into a fully functional game – all while having a great time!
- Build, Inspect and Improve: As we inspected the Q CLI output, we replaced the custom-built game logic with established open-source libraries, saving time and improving maintainability. This ensured that we were happy with the code that was generated
- Prompt Engineering is a skill: Our prompts evolved as we built, inspected and improved the codebase. Being more specific like "Improve the game by using open source library - chess.js" yielded better results.
Finally, 2nd Grade school champion skills are only good enough for a stalemate ;)
Now that we've successfully built our working chess game (and had a blast doing it on our date nights!), here's what we're planning to explore:
- Deploy the Game with AWS Amplify
- Add an AI opponent by integrating Stockfish
- Add a AI assistant to help players improve their game through move suggestions
- Enable Multiplayer with WebSockets
- Track Scores and Create Leaderboard to make the game competitive
- Voice Commands with Amazon Lex or Alexa to introduce hands-free play
- Turn it into a Progressive Web App (PWA) for mobile play
Stay Tuned!
We're excited to announce a special AWS Challenge that puts your creativity and coding skills to the test. From May 20th to June 20th, 2025, we're inviting developers to explore the power of Amazon Q CLI through game development and score a T-shirt.
Who knows? You might just turn your next coding session into an entertaining gaming night like we did!

Happy coding (and chess playing)! ♟
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.