Skip to content

kleene-games/kleene

Repository files navigation

Kleene - Adaptive AI Text Adventure Engine for Claude Code

Text adventures that actually adapt to your choices. Built specifically for Claude Code.

Unlike traditional choice-based games, Kleene responds to free-form actions and improvisation. The temperature system lets you control how much the AI adapts - from traditional branching (temp 0) to fully emergent storytelling (temp 10).

🎮 Get Started in 5 Minutes | 📖 Documentation | 🤝 Contributing

Quick Start

# Play a game
/kleene play

# Try the beginner-friendly Dragon Quest
/kleene play dragon_quest

# Start at temperature 0 (traditional), increase once comfortable
/kleene temperature 0

# Generate your own scenario
/kleene generate a cyberpunk heist

# Check your scenario for issues
/kleene analyze

👉 New to Kleene? Check out the Getting Started Guide


Installation

# Add the marketplace
/plugin marketplace add kleene-games/kleene

# Install the plugin
/plugin install kleene@kleene-games

Verify installation: Run /kleene to see the menu, then /kleene play to start your first game!


Playing Games

Basic Commands

Command What It Does
/kleene play Start a new game (shows scenario menu)
/kleene continue [scenario] Resume from save
/kleene temperature [0-10] Set adaptation level
/kleene foresight [0-10] Set hint specificity
/kleene parser [on|off] Toggle text adventure mode
/kleene save Save current game
/kleene rewind [target] Rewind to earlier point (T6.2.3, -1, --1)
/kleene export [mode] Export gameplay (transcript/summary/stats/branches/gallery)
/kleene gallery [on|off] Toggle educational meta-commentary

Temperature Guide

  • 0 (Verbatim): Scenario text exactly as written - traditional branching
  • 1-3 (Subtle): Faint echoes of your discoveries woven in
  • 4-6 (Balanced): Direct references to your exploration
  • 7-9 (Immersive): Rich integration + bonus options appear
  • 10 (Adaptive): Narrative fully shaped by your actions

Pro tip: Start every scenario at temp 0 to learn it, then replay at temp 10 for emergent magic.

Free-Form Actions

When playing at temp > 0, you can type anything instead of picking from options:

  • Explore: "I search the room for hidden doors"
  • Interact: "I try to befriend the guard"
  • Act: "I light the papers on fire"
  • Meta: "I want to leave this location"

The AI evaluates feasibility and generates responses that fit the scenario tone.


Features

For Players

  • Improvisation Support: Type any action—Claude interprets and responds dynamically
  • State Persistence: Save/load game states, pick up where you left off
  • Scene Tracking: Turn/Scene/Beat counters show precise gameplay position
  • Multi-Level Rewind: Jump back to any Turn.Scene.Beat (T6.2.3 notation)
  • Export System: Save gameplay as clean narrative or analytical summary
  • Gallery Mode: Educational meta-commentary on narrative techniques
  • Foresight Setting: Control how much the game reveals when you ask for hints
  • Parser Mode: Text adventure-style play—type commands like Zork
  • Auto-approval Hooks: Seamless gameplay without permission prompts
  • Pure Claude Code Integration: No separate app, plays in your terminal

For Creators

  • AI-Powered Generation: Create complete scenarios from a single theme prompt
  • YAML-based Format: Human-readable, version-controllable scenario files
  • Structural Validation: Analyze completeness across Bronze/Silver/Gold tiers
  • Decision Grid Framework: Built-in guidance for rich, non-binary storytelling
  • Preconditions & Consequences: Full game logic with inventory, traits, flags, relationships
  • Location State System: Per-location flags, properties, and environment conditions
  • Node/Location Preconditions: Gate story nodes and location access
  • Temporal System: Time-based gating with scheduled events
  • NPC Tracking: Move NPCs and check their locations

Create Your Own Scenarios

Kleene isn't just a game engine—it's a complete authoring toolkit:

  1. Generate: Start with a theme (/kleene generate "space station mystery")
  2. Edit: Scenarios are YAML files you can hand-edit or ask Claude to refine
  3. Validate: Check structural completeness (/kleene analyze my_scenario)
  4. Play: Test your creation immediately (/kleene play my_scenario)
  5. Share: Push to the community scenarios repo

Creating Scenarios

Option 1: Use the Generator

/kleene generate a space station mystery

# Or be more specific
/kleene generate a noir detective story set in 1940s Los Angeles

The AI creates a complete scenario with branching paths, endings, and proper structure.

Option 2: Write Your Own

  1. Check out scenarios/dragon_quest.yaml for inspiration
  2. Use templates in scenarios/TEMPLATES/
  3. Follow the Scenario Authoring Guide
  4. Validate with /kleene analyze your_scenario

Minimal scenario example:

name: "My Adventure"
description: "A brief description"

initial_character:
  name: "Hero"
  traits: { courage: 5, wisdom: 5 }
  inventory: []

start_node: intro

nodes:
  intro:
    narrative: |
      You stand at the beginning of your adventure...
    choice:
      prompt: "What do you do?"
      options:
        - id: brave
          text: "Be brave and enter"
          next_node: victory
        - id: flee
          text: "Run away"
          next_node: escape

endings:
  victory:
    narrative: "You conquered your fear!"
    type: victory

  escape:
    narrative: "You lived to fight another day."
    type: unchanged

See the complete format specification for all features.


Skills Reference

Skill Purpose
kleene-play Interactive gameplay with inline state management
kleene-generate Create scenarios from themes or expand existing ones
kleene-analyze Check narrative completeness and structure

Game Saves

Saves are stored at: ./saves/[scenario_name]/[timestamp].yaml

  • Auto-save: Created when you start a game
  • Manual save: /kleene save during gameplay
  • Resume: /kleene continue [scenario] lists available saves
  • Rewind: /kleene rewind T6.2.3 jumps to Turn 6, Scene 2, Beat 3
  • Save format v8: Includes scene/beat counters, location state, NPC tracking, scheduled events, foresight, and parser mode settings

Exporting Gameplay

Export your adventures as clean markdown files:

/kleene export                    # Default transcript mode
/kleene export summary            # Analysis with thematic notes
/kleene export --granularity=beat # Maximum detail
/kleene export branches           # Split by timeline

Export modes:

  • transcript (default): Clean narrative log
  • summary: Analysis with gallery notes
  • stats: Numbers only - trait/relationship evolution
  • branches: Split by timeline for rewind sessions
  • gallery: Meta-commentary only

Exports are saved to: ./exports/[scenario]_[timestamp].md


Bundled Scenarios

Dragon Quest (Beginner)

Classic fantasy adventure. Perfect for learning Kleene basics. Playtime: 15-20 minutes | Difficulty: Beginner

Zork I: The Great Underground Empire - Mini (Intermediate)

The legendary 1980 Infocom text adventure, adapted for Kleene. Explore the white house, descend into the Great Underground Empire, and collect treasures. Playtime: 20-30 minutes | Difficulty: Intermediate | Parser Mode Recommended


Why Kleene?

True Improvisation

Type anything. Don't just pick from options - describe what you want to do and the AI responds:

  • "I examine the dragon's scales closely"
  • "I try to sneak past while it's distracted"
  • "I offer it gold from my pouch"

The Temperature System (What Makes This Unique)

Same scenario, completely different experience:

  • Temperature 0: Traditional branching narrative
  • Temperature 5: Story adapts to your exploration
  • Temperature 10: Fully emergent storytelling - every playthrough is unique

Try playing Dragon Quest at temp 0, then replay at temp 10. Mind = blown.

Built for Claude Code

  • Native integration with seamless UX
  • Auto-saves during gameplay
  • Smart lazy loading for massive scenarios
  • No external dependencies

Two Scenarios Included

  • Dragon Quest (beginner) - Classic fantasy adventure to learn Kleene basics
  • Zork I: Mini (intermediate) - The legendary text adventure, reimagined

Create Your Own Adventures

  • Simple YAML format (no coding required)
  • Built-in scenario generator: /kleene generate haunted mansion
  • Validator ensures no dead ends: /kleene analyze
  • Templates to get you started quickly


Community


Documentation


Advanced: Framework Theory

Kleene is built on solid theoretical foundations for those who want to dive deep.

The Decision Grid

Every choice exists at the intersection of player intent and world response:

World Permits World Indeterminate World Blocks
Player Chooses Triumph Commitment Rebuff
Player Unknown Discovery Limbo Constraint
Player Avoids Escape Deferral Fate

Player Unknown captures both hesitation and improvised free-text actions. Limbo (center cell) is where side quests and improvisation thrive.

A narratively complete scenario ensures coverage across the grid. See Core Framework for deep technical details.


Third-Party Attribution

Zork I: The Great Underground Empire

The zork1-mini.yaml scenario is adapted from the original ZIL source code.

  • Original Creators: Tim Anderson, Marc Blank, Bruce Daniels, and Dave Lebling
  • Original Publisher: Infocom, Inc. (1980)
  • Source Repository: historicalsource/zork1
  • License: MIT License (c) 2025 Microsoft Corporation

The ZIL source was relicensed under MIT in November 2025 by Microsoft's OSPO, Team Xbox, and Activision. Per Microsoft: "The goal is not to modernize Zork but to preserve it as a space for exploration and education."


Copyright

Copyright (c) 2025 Mountain Ash Holdings Pty Ltd. All rights reserved.

For commercial licensing inquiries: nathaniel.ramm@discretedatascience.com

License

GNU Affero General Public License v3.0 - see LICENSE file for details.

Changelog

See CHANGELOG.md for version history and updates.


Made with ❤️ for Claude Code | Report Issues | Contribute

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages