Factorio Live Mod Agent


Exports live game state (tech tree, production stats, logistics networks, player inventories, placed buildings, and a RecipeExporter-compatible recipe/prototype dump) as JSON/NDJSON under script-output for a local CLI or AI agent to read. Designed to be near-zero cost when disabled and cheap when enabled: no on_tick polling, engine-aggregated reads over full scans, and an incrementally-maintained building index instead of periodic full scans.

Utilities
a day ago
2.0
8
Owner:
jhjaggars
Source:
https://github.com/jhjaggars/flma
Homepage:
N/A
License:
MIT
Created:
10 days ago
Latest Version:
0.3.6 (a day ago)
Factorio version:
2.0
Downloaded by:
8 users

Factorio Live Agent

Ask an AI agent questions about your running game — no alt-tabbing to check the
tech tree, no pausing to eyeball a production graph.

"What am I researching and how far along is it?"
"What's my iron plate production rate vs. consumption?"
"How many logistic bots are idle on Nauvis?"
"Where are my rocket silos?"

flma exports live game state — tech tree, production statistics, logistics
network contents, player inventories, placed buildings — to small JSON/NDJSON
files under script-output/flma/. A companion CLI reads those files, and an
AI agent (Claude Code, or anything else that can run a shell command) drives
the CLI. The mod itself has no network access and no external
dependencies
— it only writes files to your own disk.

Why files, not RCON?

RCON requires hosting the game — a client joining someone else's server
can't reach back into it to run commands. Writing files works in every
configuration: single-player, hosting, or joining someone else's server. And
because Factorio multiplayer is deterministic lockstep, this mod has to run
on every peer anyway (its checksum is part of mod sync) — so every player
who wants live data just points their own local tooling at their own local
export. No central server component, no port to open.

What it exports

Data File Notes
Tech tree tech.json current research, progress, queue, full prerequisite graph
Production stats production.json per-item/fluid lifetime totals and live per-minute rates
Logistics networks logistics.json contents, robot counts
Player inventories inventories.json opt-in, off by default (more sensitive than aggregate stats)
Placed buildings buildings.ndjson opt-in; incrementally tracked, not scanned — see below
Recipes/prototypes recipes.json full recipe/item/machine/technology dump, RecipeExporter-compatible

Full field-by-field format is documented in
SCHEMA.md in the
repo — useful if you want to write your own consumer instead of using the
bundled CLI.

Example session

The bundled CLI is what an agent runs under the hood — here's what it looks
like run by hand:

$ flma-planner status
recipes.db     : ~/code/recipe-mcp/recipes.db  (312 technologies)
flma live data : ~/.factorio/script-output/flma
  tech        : 3s ago
  production  : 3s ago
  logistics   : 8s ago
  buildings   : 41s ago
force 'player'   : 87 technologies known, current research: automation-3

$ flma-planner research
force 'player' — current research: automation-3
  progress: 42.7%
  queue (2): automation-3, logistic-system

$ flma-planner production --kind items
force 'player', surface 'nauvis'

items (produced +/consumed -, per minute):
  copper-plate                                  +   842.0  -   790.5
  iron-plate                                    +  1200.0  - 1150.2

It also includes a factory-planner (machine counts, raw inputs, belt counts
for a target production rate) that cross-references your live save so it
can tell you what you already have surplus of, not just textbook ratios.

Getting started

  1. Enable exporting. Mod settings → Map → turn on flma-export-enabled.
    That's the master switch; everything else is opt-in on top of it.
  2. Confirm it's writing. ~/.factorio/script-output/flma/ should appear
    with a current-save.json pointer inside.
  3. Install the CLI (no Factorio-side install needed beyond the mod
    itself):
    bash uvx --from git+https://github.com/jhjaggars/flma flma-planner research
  4. Point an agent at it. For Claude Code, clone the
    repo — it ships an AgentSkill that
    teaches the full command surface — and ask it what you're researching.

Performance

This mod runs on every peer in multiplayer (server included — its checksum
is part of mod sync), so it's built to cost close to nothing:

  • No on_tick handler — only a configurable on_nth_tick (default every
    ~5s), and only while flma-export-enabled is on.
  • Tech/production/logistics reads use the engine's own aggregated
    statistics (LuaFlowStatistics, logistic network contents) — cost scales
    with the number of item types, not the number of entities on the map.
  • Building tracking (opt-in) doesn't scan the map on a schedule. A one-time
    baseline scan (time-sliced across ticks, so a megabase never causes a
    single-tick spike) is followed by an incremental index updated only on
    build/mine events.
  • Turning flma-export-enabled off tears down every registered handler —
    disabled means zero overhead, not an early-return inside a live one.

Settings (Mod settings → Map)

Setting Default Purpose
flma-export-enabled off Master switch
flma-tick-interval 300 ticks (~5s) How often scheduled exports run
flma-export-inventories off Player inventory contents
flma-export-buildings off Placed-building tracking
flma-buildings-compact-threshold 20000 Event-log lines before the building log is compacted

Links