factorio-sensei

A Rust CLI that connects Claude to a live Factorio game via RCON, giving real-time coaching based on actual game state.

Features

  • Live game state access: 10 tools query inventory, production stats, power grid, research, nearby entities, and more
  • Two interfaces: Terminal REPL with colored markdown, and in-game /sensei chat command via bundled Lua mod
  • Built-in knowledge base: Exact Factorio 2.x ratios, belt throughputs, inserter speeds, power formulas, and crafting math
  • Read-only by design: Observes and advises only β€” never executes game actions

Architecture

Factorio (RCON) ←→ factorio-sensei (Rust) ←→ Claude (Anthropic API)

Each tool implements the Rig Tool trait β€” generating Lua scripts, executing them via RCON, and returning structured JSON. Claude autonomously decides which tools to call based on the question.

Technical Highlights

  • Built on rig-core for LLM agent orchestration with multi-tool-call support
  • Custom factorio-rcon async Rust crate handling Factorio’s RCON quirks (single auth response, TCP fragmentation, i32 length validation)
  • Uses Factorio 2.x’s helpers.table_to_json() for Lua-to-JSON conversion
  • Knowledge documents embedded in the binary at compile time