Build games with prompts. Ship them with Peridot.
MVP Status: Feature-complete. See
docs/mvp-status.mdfor detailed implementation status.Stability: Core features are stable. AI enhancements are provisional. See Stability section below.
PeridotCode is a Rust-first terminal AI game creation agent that helps developers turn prompts into playable game prototypes.
It is not a new game engine. It is a developer tool that combines:
- A terminal-first workflow,
- AI-powered prompt handling (with user-selected providers),
- Template-driven scaffold generation,
- And future-ready integration into the Peridot ecosystem.
PeridotCode currently focuses on one narrow, strong path:
- Terminal-first CLI/TUI
- Prompt intake
- Provider/model setup flow
- OpenRouter-first model support
- Playable Phaser 2D starter generation
- Safe local file generation
- Editable scaffold output
The MVP goal is simple:
prompt → scaffold → playable
PeridotCode is designed to become the creation layer of the Peridot ecosystem.
Today:
- Generate runnable game prototypes from prompts
Later:
- Add modular game systems (skills)
- Support more providers and models
- Support more templates/frameworks
- Prepare projects for PeridotVault integration
PeridotCode is in MVP (Minimum Viable Product) stage:
- Terminal UI and CLI commands
- OpenRouter provider integration
- Phaser 2D starter template generation
- File generation with safety checks
- Basic configuration management
- AI-enhanced intent classification
- OpenAI/Anthropic provider adapters
- Model catalog tier assignments
- Multi-step setup flow UI
- Full skill system
- Streaming responses
- Advanced error recovery
- Cost tracking
See docs/mvp-status.md for complete status details.
PeridotCode is:
- A terminal-first AI game creation agent
- A Rust-based developer tool
- A prompt-to-game prototype generator
- A model-agnostic workflow with user-configured providers
- A future on-ramp into PeridotVault
PeridotCode is not:
- A replacement for Unity, Godot, or Unreal
- A full visual editor
- A no-code builder for any kind of game
- A publishing platform by itself
- A fully autonomous game factory
- Rust Cargo workspace
- CLI entrypoint:
peridotcode - Terminal UI shell
- Provider/model configuration flow
- OpenRouter-first support
- Prompt intake
- Basic orchestration
- Template-driven generation
- First template: Phaser 2D starter
- Safe file writes
- File generation summaries
- Run instructions
- PeridotVault authentication
- Direct publishing to PeridotVault
- Multiple engine support
- Godot support in MVP
- Plugin marketplace
- Advanced multi-agent loops
- Billing and cost optimization
- Local model support in MVP
peridotcode/
├─ AGENTS.md
├─ README.md
├─ Cargo.toml
├─ Cargo.lock
├─ .gitignore
├─ .env.example
│
├─ docs/
│ ├─ prd.md # Product Requirements
│ ├─ mvp.md # MVP Scope Definition
│ ├─ architecture.md # Architecture Documentation
│ └─ roadmap.md # Future Roadmap
│
├─ crates/
│ ├─ cli/ # CLI entrypoint
│ ├─ tui/ # Terminal UI
│ ├─ core/ # Orchestration logic
│ ├─ model_gateway/ # Provider/model abstraction
│ ├─ template_engine/ # Template selection and rendering
│ ├─ fs_engine/ # Safe file operations
│ ├─ command_runner/ # Diagnostics and command execution
│ ├─ skills/ # Future skill system foundation
│ └─ shared/ # Common types and utilities
│
├─ templates/
│ └─ phaser-2d-starter/ # MVP template
│
└─ examples/
└─ generated-projects/ # Example outputs
Executable entrypoint and top-level command wiring. Thin layer that bootstraps the TUI.
Terminal UI rendering and interaction state management using ratatui. Handles all user interaction including setup flows.
Orchestration, planning, prompt flow, and project context logic. The "brain" that coordinates all operations.
NEW - Model/provider abstraction layer. Key components:
provider- Provider trait and registryconfig- Configuration structurescredentials- API key resolutioninference- Normalized request/response types
This crate allows PeridotCode to support multiple AI providers starting with OpenRouter.
Template selection and scaffold generation logic. Knows how to render templates into runnable projects.
Safe file read/write/diff/safety logic. Prevents accidental writes outside project boundaries.
Local diagnostics (doctor) and safe command execution helpers. Provides run instructions for generated projects.
Future modular skill abstractions and registries. Foundation-only in MVP.
Shared types (ProviderId, ModelId, TemplateId, etc.), constants, and small utilities. Has no dependencies on other workspace crates.
- OpenRouter - Primary supported provider
- Chat completions API
- Dynamic model listing with fallback
- Full error handling
- Recommended for MVP
These providers have basic implementations that work but lack advanced features:
-
OpenAI - Basic chat completions
- Static model list (no dynamic fetching)
- No streaming support
- No function calling / JSON mode
-
Anthropic - Basic message completions
- Static model list (no dynamic fetching)
- No streaming support
- No tool use support
- System messages handled via separate field (Anthropic-specific)
Limitations of minimal implementations:
- Static model lists only (no API fetching)
- No streaming support (MVP scope)
- No advanced features (function calling, vision, etc.)
- Basic error handling
- May have provider-specific quirks in message handling
- Gemini - Can be configured but not yet implemented
- Local models - Ollama, llama.cpp support for on-device inference
- Custom providers - Generic adapter for custom OpenAI-compatible endpoints
# OpenRouter (recommended, fully featured)
peridotcode provider add openrouter --api-key "env:OPENROUTER_API_KEY"
# OpenAI (basic implementation)
peridotcode provider add openai --api-key "env:OPENAI_API_KEY"
# Anthropic (basic implementation)
peridotcode provider add anthropic --api-key "env:ANTHROPIC_API_KEY"
# Note: Set --default flag to make a provider the default
peridotcode provider add openai --api-key "env:OPENAI_API_KEY" --defaultFor best results, use OpenRouter because:
- It's the most tested and feature-complete
- Provides access to multiple model families through one API
- Has the best error handling and model listing
- Uses OpenAI-compatible format (easier to integrate)
OpenAI and Anthropic adapters are provided for users who:
- Have existing API keys and prefer direct provider access
- Want to avoid OpenRouter as an intermediary
- Are okay with minimal implementations
PeridotCode organizes models into three tiers to help you choose without being overwhelmed:
| Tier | Symbol | Description | Use When |
|---|---|---|---|
| Recommended | ★ | Best models for PeridotCode workflows | You want reliable, well-tested results |
| Supported | ✓ | Work well but not primary recommendations | You have specific needs or preferences |
| Experimental | ⚠ | New, untested, or preview models | You want to try latest models (may have issues) |
Model Selection Guidance:
# See all models organized by tier
peridotcode model list
# See only recommended (best for most users)
peridotcode model list --recommended
# See supported alternatives
peridotcode model list --supported
# See experimental (use at your own risk)
peridotcode model list --experimentalOpenRouter (Primary Recommended Models):
★ Recommended - Start here:
anthropic/claude-3.5-sonnet- Best overall: Excellent quality at reasonable costopenai/gpt-4o-mini- Best value: Fastest and cheapest for simple tasksanthropic/claude-3-haiku- Best for iterations: Quick prototypinggoogle/gemini-flash-1.5- Best for large projects: 1M token context window
✓ Supported - For specific needs:
anthropic/claude-3-opus- Maximum quality (higher cost)openai/gpt-4o- OpenAI's best model (higher cost)openai/gpt-3.5-turbo- Budget option (limited context)
OpenAI (direct):
gpt-4o- High quality, moderate cost (Supported)gpt-4o-mini- Fast and inexpensive (Recommended if using OpenAI directly)
Anthropic (direct):
claude-3-opus-20240229- Highest quality (Supported)claude-3-sonnet-20240229- Good balance (Recommended if using Anthropic directly)claude-3-haiku-20240307- Fastest (Recommended if using Anthropic directly)
Models are also classified by cost to help you budget:
| Cost Tier | Indicator | Approximate Cost |
|---|---|---|
| Low | $ | ~$0.10-0.50 per 1M tokens |
| Moderate | $$ | ~$0.50-5.00 per 1M tokens |
| High | $$$ | ~$5.00+ per 1M tokens |
View cost information in the model list:
peridotcode model listPeridotCode uses a tiered model catalog to:
- Prevent choice overload - 3 clear tiers instead of an unbounded list
- Guide sensible defaults - Recommended models are well-tested
- Support future growth - Easy to add new models with appropriate tiers
- Enable task-specific recommendations (future) - Different models for scaffolding vs enhancement
PeridotCode is designed to be model-agnostic. Users configure their own API keys and choose their preferred models. The architecture supports adding new providers without changes to the core orchestration logic.
PeridotCode uses a layered configuration system:
- Command-line arguments (highest priority)
- Environment variables
- Project
.envfile (current directory) - User config file (platform-specific location)
- Default values (lowest priority)
Configuration is stored in TOML format at platform-specific locations:
| Platform | Path |
|---|---|
| Linux | ~/.config/peridotcode/config.toml |
| macOS | ~/Library/Application Support/peridotcode/config.toml |
| Windows | %APPDATA%\peridotcode\config.toml |
Create a config.toml file:
# Default provider and model
# These are used when you don't specify otherwise
default_provider = "openrouter"
default_model = "anthropic/claude-3.5-sonnet"
[providers.openrouter]
enabled = true
# Use "env:VARNAME" to reference environment variables
# This keeps secrets out of the config file
api_key = "env:OPENROUTER_API_KEY"
# Optional: override the base URL
base_url = "https://openrouter.ai/api/v1"
# Optional: default model for this provider
default_model = "anthropic/claude-3.5-sonnet"
# Optional: request timeout in seconds
timeout_seconds = 60
# You can configure multiple providers
[providers.openai]
enabled = false
api_key = "env:OPENAI_API_KEY"
base_url = "https://api.openai.com/v1"
default_model = "gpt-4o-mini"For quick setup, you can use environment variables directly:
# OpenRouter (MVP priority)
export OPENROUTER_API_KEY="sk-or-v1-..."
# Future providers (not yet implemented)
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GEMINI_API_KEY="..."For project-specific configuration, create a .env file in your project directory:
# In your project root
OPENROUTER_API_KEY=sk-or-v1-your-key-here
PERIDOT_PROVIDER=openrouter
PERIDOT_MODEL=anthropic/claude-3.5-sonnetPeridotCode will automatically load .env from the current working directory.
API keys can be specified in multiple ways:
-
Environment variable reference (recommended for security):
api_key = "env:OPENROUTER_API_KEY"
-
Direct key with prefix (not recommended, for testing only):
api_key = "key:sk-or-v1-your-actual-key"
-
Raw key (legacy, not recommended):
api_key = "sk-or-v1-your-actual-key"
Security Best Practices:
- ✅ Use
env:VARNAMEreferences in config files - ✅ Add
.envto.gitignoreto prevent committing secrets - ❌ Never commit API keys to version control
- ❌ Never hardcode API keys in source code
PeridotCode provides CLI commands for managing AI providers and models:
# List configured providers
peridotcode provider list
# List all available providers (including unconfigured)
peridotcode provider list --all
# Add a new provider
peridotcode provider add openrouter --api-key "env:OPENROUTER_API_KEY"
# Add with specific model and set as default
peridotcode provider add openrouter \
--api-key "env:OPENROUTER_API_KEY" \
--model "anthropic/claude-3.5-sonnet" \
--default
# Set default provider
peridotcode provider use openrouter
# Show current provider configuration
peridotcode provider show# List available models
peridotcode model list
# List only recommended models
peridotcode model list --recommended
# List models for a specific provider
peridotcode model list --provider openrouter
# Set default model
peridotcode model use anthropic/claude-3.5-sonnet
# Show current model configuration
peridotcode model show# 1. Add OpenRouter provider (MVP-ready)
peridotcode provider add openrouter \
--api-key "env:OPENROUTER_API_KEY" \
--default
# 2. View available models
peridotcode model list --recommended
# 3. Set your preferred model
peridotcode model use anthropic/claude-3.5-sonnet
# 4. Verify everything is configured
peridotcode doctor
# 5. Start creating games
peridotcodeWhen you first run PeridotCode without configuration, it will guide you through an interactive setup:
Automatic Setup Flow:
- Welcome - Brief introduction to PeridotCode
- Select Provider - Choose from available AI providers (OpenRouter recommended)
- Enter API Key - Input your API key directly or use environment variable reference
- Select Model - Choose your default model (e.g., Claude 3.5 Sonnet)
- Save Configuration - Settings are saved to your user config file
The TUI will guide you through setup if any of these are true:
- No configuration file exists
- No environment variables are set
- The configured provider is missing an API key
During setup, you can:
- Navigate with ↑/↓ arrows
- Select with Enter
- Go back with Esc
- Quit with 'q'
After successful setup, the main interface shows:
[Welcome] Ready | openrouter / anthropic/claude-3.5-sonnet | /path/to/project
Your provider and model are displayed in the status bar for easy reference.
PeridotCode validates configuration on startup and will prompt you to set up a provider if:
- No configuration file exists
- No environment variables are set
- The configured provider is missing an API key
Check your configuration:
# Show environment and provider status
peridotcode doctorThe doctor command will show:
- Node.js and npm installation status
- AI provider configuration status
- Missing dependencies or configuration issues
While MVP focuses on OpenRouter, the configuration system supports multiple providers for future expansion:
default_provider = "openrouter"
[providers.openrouter]
enabled = true
api_key = "env:OPENROUTER_API_KEY"
[providers.openai]
enabled = true
api_key = "env:OPENAI_API_KEY"
[providers.anthropic]
enabled = false
api_key = "env:ANTHROPIC_API_KEY"Enable/disable providers by changing the enabled field.
The OpenRouter adapter is fully implemented and supports:
- Chat completions - Send prompts and receive AI-generated responses
- Model listing - Fetch available models from OpenRouter API (with static fallback)
- Error handling - Clean error messages for common issues (invalid key, rate limits, etc.)
- Configuration - Full support for API keys, base URLs, timeouts, and default models
Recommended Models:
| Model ID | Description | Best For |
|---|---|---|
anthropic/claude-3.5-sonnet |
Claude 3.5 Sonnet | Game scaffolding (recommended) |
openai/gpt-4o-mini |
GPT-4o Mini | Fast prototyping |
anthropic/claude-3-haiku |
Claude 3 Haiku | Quick iterations |
google/gemini-flash-1.5 |
Gemini Flash 1.5 | Large context needs |
- Rust stable toolchain (1.78+)
- Cargo
- A provider API key for model-backed workflows (OpenRouter recommended for MVP)
- Node.js (only for running generated Phaser projects)
For MVP, start with OpenRouter:
- Sign up at openrouter.ai
- Generate an API key
- Set
OPENROUTER_API_KEYenvironment variable
git clone <your-repo-url>
cd peridotcodecp .env.example .env# Edit .env
OPENROUTER_API_KEY=your_key_herecargo buildcargo run -p peridot-cliOr with a specific command:
cargo run -p peridot-cli -- --help- Run
peridotcode - If no provider is configured, setup flow begins
- Choose OpenRouter as provider
- Provide API key (or confirm env var is set)
- Choose default model (e.g.,
anthropic/claude-3.5-sonnet) - Enter a prompt describing your game
- System generates a playable scaffold
- Review created files and follow run instructions
A developer should be able to do:
mkdir my-game
cd my-game
peridotcodeThen enter a prompt:
Make a 2D top-down adventure prototype with one map, basic movement, and simple UI.
PeridotCode will:
- Check provider configuration
- Classify the request
- Select the Phaser starter template
- Generate scaffold files
- Summarize created files
- Explain how to run the project
Generates:
- A minimal Phaser project
- Runnable development setup
- Small scene structure
- Simple placeholder game logic
- Editable code and assets structure
The generated result is easy to inspect, modify, and extend manually.
PeridotCode is a local developer tool and must behave safely.
Rules:
- Never write outside intended project boundaries
- Never auto-run destructive commands
- Always show created/modified file summaries
- Keep side effects explicit and reviewable
PeridotCode optimizes for:
- Clarity
- Safety
- Modularity
- One strong happy path
- Provider flexibility without chaos
Not for:
- Broad engine support in MVP
- Maximum autonomy
- Flashy but brittle generation
- Premature complexity
PeridotCode can grow into:
- Additional templates
- Multiple framework/engine targets
- Skill-based feature addition
- Peridot-specific integration modules
- Game packaging and shipping preparation
Current mission is still narrow:
Make prompt-to-playable prototype generation work well.
When in doubt, the project should support this outcome:
A developer can configure a model provider, enter a prompt, and receive a playable scaffold through a clean Rust terminal workflow.
docs/prd.md- Product Requirements Documentdocs/mvp.md- MVP Scope and Success Criteriadocs/architecture.md- Detailed ArchitectureAGENTS.md- Guidelines for AI assistants working on this codebase
MIT