Headless AI Agents Join Your Minecraft Server
Use cloud-code -p and codeex-exec flags to spin up persistent Claude and CodeX agents that respond to chat commands in Minecraft, gathering resources and following coordinates while you build.
Launch Persistent Headless Agents via CLI Flags
Run headless Claude instances with claude -p "query" to start non-interactive sessions using your Claude subscription (e.g., Max plan) without per-token API costs. Agents stay warm via hooks, avoiding cold starts. Key flags include:
--promptor-pfor inline system prompts (e.g.,claude -p --prompt "You are a pirate" "Hello mate"outputs pirate responses like "Ahoy there matey").- File-based prompts: Pass path to
prompt.mdfor custom system instructions. --modelto swap models (e.g.,claude -p --model claude-3-haiku-20240307 "hello"for faster/cheaper inference; supports Opus too).
For CodeX: codex-exec "yolo hello" launches on GPT-4o-mini with session IDs, token tracking (input/output/reasoning), and responses like "hello master standing by." OpenCode uses opencode run "hello" on GLM-4-9B. These create warm, loop-running instances ideal for long sessions.
This setup leverages browser-based tools (Claude Code, CodeX) for agent persistence, teaching token mechanics: monitor input/cache/output tokens and simulated costs (e.g., Claude pricing display) to optimize usage.
Bridge Agents for Multi-Agent Communication
Build a "headless bridge" to connect multiple warm instances (Claude, CodeX, OpenCode) into a shared chat. Select targets (@claude, @codex, @all) from a master interface:
- Broadcast: "Hey guys" → All respond (Claude: "Hello, how can I help?"; CodeX: "Master ready for task").
- Relay: "@claude say hello to @codex" → Claude messages CodeX, who replies "Hello back. We are all connected."
Scale dynamically: Add instances via manager (e.g., spawn claude-2, codex-2), auto-joining chat with confirmations. Use agent-to-agent relay to prevent loops (e.g., during group tasks like "Introduce yourselves" where all greet pairwise).
Monitor dashboard tracks per-agent metrics: 50 tokens used, input/cache/output/reasoning tokens, Claude pricing. Agents collaborate on projects like building a Snake game, revealing token/cache dynamics (reads/writes) for cost control.
Integrate Agents into Minecraft for Task Automation
On a private Minecraft Java 1.21.1 server (localhost:3001), launch agents via start server → spawn ClaudeBot/CodeX via warm claude -p/MCP-wrapped codex-exec. Agents read chat, execute commands:
- Navigation: "@team come to -64.4 152 8.7" (F3 coords) → Agents pathfind/run to position.
- Tasks: "@codex drop log" → Chops wood, drops item. "@team collect logs" → Farm wood while you craft workbench/planks/shelter.
- Exploration: "@team explore for sheep" → Scan/run to mobs (sheep for wool/beds to skip night). "@team kill horses for food" → Target/attack animals.
Agents persist across sessions (rejoin on context reset), cooperate (one farms while you build), and respond in chat. Keeps server fun solo: spam commands for materials, watch via spectator. Setup uses mod for chat reading/scanning; future videos detail full config.
Trade-offs: Agents slow/random spawn, occasional mission conflicts (e.g., log drop then sheep hunt), but enables hands-off farming for base-building.