minecraft-claude-bot
A single-file Mineflayer bot driven by the Anthropic API. Around five hundred lines, no framework, no abstraction layer — the entire perception → decision → action loop visible in one place.
Origin
Built to answer one question: how minimal can an autonomous LLM-driven game agent be? Most agent demonstrations lean on a framework that hides the loop. This one is a single bot.js you can read top to bottom in fifteen minutes.
The point is not the bot's competence at the game — it is the visibility of the assembly. Perception, decision, and action are each plain functions, and the data they pass between each other is in scope on every line.
The loop
Perception
Every DECISION_INTERVAL milliseconds (8 seconds by default), the bot bundles recent events — chat, damage, mob proximity, inventory deltas — with its current state: health, hunger, position, time of day.
Decision
The bundle is sent to Claude (claude-haiku-4-5) with a short conversation history. Claude returns a natural-language reply and selects one action from a small vocabulary. The system prompt is part of the readable source, not an external config file.
Action
Mine wood, stone, or ore; explore; follow the player; flee; eat the best food in inventory; place torches at night; chat. Each maps to a Mineflayer routine and feeds its result back as the next perception input.
Conversation
Player chat in Minecraft is routed through the same decision loop. The same Claude call that picks the next action also generates the bot's reply. There is no separate chat handler.
The turn cycle
The whole bot, conceptually, is this:
Everything else — the hostile-mob table, the food ranking, the action vocabulary — is data, defined inline above the loop.
Why it is public
Reference implementations have a different job from production tools. Their value is in being readable end to end, not in being feature-complete.
If you want to see exactly how an LLM-driven game agent assembles — perception, decision, action — without a framework abstracting any of the steps, this is that. Lift the loop, change the model, swap the action vocabulary; everything is in one file.
minecraft-claude-bot on GitHub
One bot.js, a small README, and a start script. That is the whole project.