kaggle-environments
AGENTS.md459 starsChanged 58 days agoApache-2.0View on GitHub
This document provides guidance for AI coding agents working with the kaggle-environments repository. It covers project structure, commands, code style, and architecture. For detailed how-to guides, see the skills in .agents/skills/: - create-environment -- step-by-step guide for building a new game environment (Python backend) - create-harness -- step-by-step guide for writing an LLM harness (connecting a language model to a game) - review-harness -- methodology for auditing an existing LLM harness for gameplay-impacting bugs - review-docs -- methodology for auditing…
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,700 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository17 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- create-environmentSkill
- create-harnessSkill
- create-playable-visualizerSkill
- create-visualizerSkill
- onboard-open-spiel-gameSkill
- review-docsSkill
- review-harnessSkill
- run-ablationSkill
- create-environmentSkill
- create-harnessSkill
- create-playable-visualizerSkill
- create-visualizerSkill
- onboard-open-spiel-gameSkill
- review-docsSkill
- review-harnessSkill
- run-ablationSkill
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 76
Test files mirror the environment structure.
- Distinctive: line 84
When building environments or visualizers, these files are useful references:
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agents Guide
This document provides guidance for AI coding agents working with the kaggle-environments repository. It covers project structure, commands, code style, and architecture.
For detailed how-to guides, see the skills in .agents/skills/:
- create-environment -- step-by-step guide for building a new game environment (Python backend)
- create-harness -- step-by-step guide for writing an LLM harness (connecting a language model to a game)
- review-harness -- methodology for auditing an existing LLM harness for gameplay-impacting bugs
- review-docs -- methodology for auditing an environment's README.md and AGENTS.md against its engine implementation
- create-visualizer -- step-by-step guide for building a web visualizer for any game (regular or OpenSpiel)
- onboard-open-spiel-game -- step-by-step guide for adding an OpenSpiel game (Python backend)
Project Overview
Kaggle Environments is a Python framework for evaluating episodes in competitive multi-agent environments. It provides a plugin-based system where game environments (e.g., ConnectX, RPS, Chess, Lux AI) are registered and run with configurable agents. The emphasis is on episode evaluation rather than agent training.
Common Commands
Testing
./run_tests.sh # Run all tests locally with uv
./run_tests.sh -k "rps" # Run tests matching a pattern
uv sync && uv run pytest tests/envs/rps/test_rps.py # Run a single test file
./run_tests.sh --docker # Run tests in Docker container
./run_tests.sh --multicontainer # Run multi-container integration testsLinting & Formatting
uv run ruff check --fix . # Lint with auto-fix
uv run ruff format . # Format code
pnpm format # Format TS/JS with prettierPre-commit hooks run ruff-check --fix and ruff-format automatically.
Package Management
uv sync # Install/sync Python dependencies
pnpm install # Install frontend dependenciesFrontend (from repo root)
pnpm dev # Run a visualizer dev server (interactive game picker)
pnpm build # Build a single visualizer (interactive picker)
pnpm build-all # Build all visualizers
pnpm test:e2e # Run Playwright end-to-end testsCode Style
- Python: 3.11+, line length 120, double quotes, space indentation. Import sorting via ruff (
extend-select = ["I"]). Build backend: flit. - TypeScript/JS: Formatted with prettier, linted with eslint.
- Git hooks: lefthook runs linters/formatters before committing.
Architecture
Core Framework (kaggle_environments/)
__init__.py-- Auto-discovers and registers all environments fromenvs/at import time. Exportsmake,evaluate,register,Agent.core.py--Environmentclass: the main runtime that manages specification validation, state machine (ACTIVE -> DONE/ERROR/INVALID/TIMEOUT), interpreter execution, and agent coordination.agent.py--Agentclass: wraps agent functions with timeout handling and error capture. Agents can be Python functions, file paths, URLs, inline strings, or fixed actions.utils.py-- Schema validation (via jsonschema),Struct(dot-access dicts), file utilities.main.py-- CLI entrypoint and Flask HTTP server.errors.py-- Exception hierarchy based on canonical error codes.
Environment Plugins (kaggle_environments/envs/<name>/)
Each environment is a self-contained directory. The main module (<name>.py) must export: specification, interpreter, renderer, html_renderer, and optionally agents. Discovery is automatic at import time.
The open_spiel_env is a special case: it wraps the OpenSpiel library and registers multiple game environments from an ENV_REGISTRY dict.
Tests (tests/envs/)
Test files mirror the environment structure. Tests use make() to create an environment, run() with agents, and assert on env.toJSON() (statuses, rewards, steps).
Web Visualizers
Each environment can have a Vite + TypeScript visualizer at envs/<name>/visualizer/default/. The pnpm workspace (pnpm-workspace.yaml) links web/* and all visualizer/* directories. web/core/ (@kaggle-environments/core) provides shared UI components, replay adapters, and playback controls used by all visualizers.
Key Reference Files
When building environments or visualizers, these files are useful references:
kaggle_environments/envs/rps/-- simplest complete environment (good starting template)kaggle_environments/envs/connectx/-- board game with shared observations and per-agent defaultskaggle_environments/schemas.json-- framework-level defaults for configuration, observation, statusweb/vite.config.base.ts-- shared Vite build config for all visualizersweb/tsconfig.base.json-- shared TypeScript configweb/core/src/index.ts-- all exports from@kaggle-environments/core
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

