Transform natural language prompts into playable games using Claude
promptplay is a creative playground that leverages the Claude Agent SDK to turn natural language descriptions into fully functional games. Describe the game you want to buildโa Snake game, Flappy Bird, a puzzle gameโand Claude will write the complete implementation for you.
Your Game Idea
โ
Web Form (index.html)
โ
/generate endpoint (server.py)
โ
Claude Agent SDK generates HTML/CSS/JS
โ
Saved to output.html
โ
Rendered in iframe on page ๐ฎ
Edit agent.py with your game idea
โ
python agent.py
โ
Claude generates complete game code
โ
Saved to output.html
โ
Open in browser ๐ฎ
The agent automatically wraps your game idea with strict instructions to ensure Claude returns only clean HTML/CSS/JavaScript code without explanations or tool usage.
- Python 3.10+
- An Anthropic API key (get one here)
# Clone the repository
git clone https://github.com/sausi-7/promptplay.git
cd promptplay
# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set up your API key
cp .env.example .env
# Edit .env and paste your ANTHROPIC_API_KEYStart the FastAPI server:
python server.py
# Server runs on http://localhost:8000Open your browser and describe your game idea. The generated game will render instantly in the page.
Pass a game idea directly or use the default tic-tac-toe prompt:
python agent.py "A cozy memory card game with three difficulty levels" --output output.html
# Streams progress and generated code, then saves output.html
open output.htmlUse --verbose to include detailed stream logs while Claude is generating.
For better games with clarifications:
python conversation_agent.py
# Interactive mode:
# 1. Describe your game idea
# 2. Answer Claude's clarifying questions
# 3. Get a tailored game
# 4. Request refinements if needed
# 5. Save with full conversation memory- โก Fast: 5-10 seconds
- ๐ฏ Simple: Just edit and run
- ๐ก Streaming: Shows progress and generated code as it arrives
- ๐ Use when: You have a clear idea and want it quickly
- ๐ Can't iterate: One generation per run
- ๐ฌ Interactive: Claude asks clarifying questions
- ๐ฎ Better quality: Games tailored to your specs
- ๐ง Refinable: Ask for changes, get improved versions
- ๐ Memory: Full conversation saved as JSON
- โฑ๏ธ Takes: 30-60 seconds + optional refinements
Example Conversational Flow:
You: "Make a puzzle game"
Claude: "What type of puzzle? (sliding, matching, word, logic?)"
You: "Matching cards with difficulty levels"
Claude: "Generated! Try it."
You: "Make it harder - fewer cards to match"
Claude: "Refined! Check it out."
Try these prompts by editing the game_idea string in agent.py (one-shot) or describing them to conversation_agent.py (conversational):
| Prompt | Output |
|---|---|
"Build me a snake game in single index.html" |
Classic Snake with keyboard controls |
"Create a Flappy Bird-style game" |
Bird dodging obstacles |
"Build a memory matching card game" |
Click-to-flip matching game |
"Make a simple Pong game" |
Two-player paddle game |
-
agent.py - Core game generation using Claude Agent SDK
build_prompt()- Wraps user ideas with strict instructions to ensure HTML-only outputgenerate_game_html()- Calls Claude to generate complete game codehtmlParser()- Extracts clean HTML from Claude's response
-
server.py - FastAPI web server with two endpoints
POST /generate- Accepts a game idea, runs the agent, returns success/failureGET /game- Serves the generatedoutput.htmlfileGET /- Serves the web UI
-
index.html - Web interface for submitting game ideas
- Form for entering game descriptions
- Iframe rendering of generated games
- Error handling and loading states
Edit the game_idea in agent.py:
game_idea = "Your detailed game description here"
html = await generate_game_html(game_idea)Change the model parameter in agent.py:
model="claude-opus-4-8" # For complex/3D games
model="claude-sonnet-4-6" # Balanced performance
model="claude-haiku-4-5-20251001" # Fast, lightweightEdit build_prompt() in agent.py to customize how game ideas are converted to instructions.
- Web UI to input prompts and play games directly
- FastAPI server with endpoints for game generation
- Iframe-based game rendering (no popup blockers)
- Multi-file game support (separate HTML, CSS, JS)
- Prompt gallery: community-submitted game ideas
- CLI flags to customize model, effort, and output
- Game examples directory with pre-generated games
- Streaming output for real-time generation feedback
- Game save/download functionality
- Share generated games via URL
We love contributions! Whether you're fixing bugs, adding features, or sharing cool game promptsโall are welcome.
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-game-idea) - Make your changes
- Commit with a clear message (
git commit -m "Add support for X") - Push to your fork and open a PR
See CONTRIBUTING.md for detailed guidelines.
- Add a new example prompt to the README
- Create a prompt template for different game genres
- Add error handling for API failures
- Write tests for the agent module
- Improve documentation
This project is licensed under the MIT Licenseโsee LICENSE for details.
Open an issue on GitHub or reach out to @sausi-7.
Built with โค๏ธ and the Claude Agent SDK