xiaohongshu
xiaohongshu
This skill should be used when implementing "gamemaster agents", "spawn player agents", "coordinate multiple agents", "parallel agent execution", "game orchestration patterns", or building multi-agent systems where one agent orchestrates others. Provides comprehensive guidance for creating game-t...
Full skill instructions
This skill provides guidance for implementing multi-agent game coordination systems where a central gamemaster agent orchestrates multiple player agents running in parallel. The gamemaster acts as an impartial rule enforcer while player agents act competitively to win.
The gamemaster is a central orchestrator agent responsible for:
Key characteristic: The gamemaster is impartial—it does not try to win, only to enforce rules fairly.
Player agents are competitive agents that:
Key characteristic: Player agents try to win within the rules.
Use the Task tool to spawn agents dynamically with custom prompts:
Use Task tool with:
- subagent_type: "general-purpose"
- model: "haiku" (for speed and cost efficiency)
- prompt: Custom prompt with game context
- run_in_background: true (for parallel execution)
This allows creating agents with:
Phase 1: Initialization
games/<game-name>/RULES.mdgames/<game-name>/state/Phase 2: Turn Loop
state/turn-signal.jsonstate/player-actions/<player-id>.jsonPhase 3: Conclusion
games/<game-name>/logs/games/<game-name>/traces/The gamemaster agent needs:
To initialize a game session:
// Read YAML frontmatter and markdown body
const rules = await Read("games/<game-name>/RULES.md");
const config = parseYAMLFrontmatter(rules);
mkdir -p games/<game-name>/state/player-actions
// Write initial state
const gameState = {
game: config.name,
players: generatePlayers(config.players),
deck: initializeDeck(config.deck_composition),
discardPile: [],
currentPlayer: 0,
direction: 1, // 1 for clockwise, -1 for counter-clockwise
turnNumber: 1,
gameActive: true
};
Write("games/<game-name>/state/game-state.json", JSON.stringify(gameState, null, 2));
// Deal cards to players
dealCardsToPlayers(gameState, config.cards_per_player);
// Signal first player's turn
const turnSignal = {
currentPlayer: gameState.players[0].id,
turnNumber: 1,
availableActions: ["play", "draw"],
visibleState: getVisibleState(gameState, gameState.players[0].id)
};
Write("games/<game-name>/state/turn-signal.json", JSON.stringify(turnSignal, null, 2));
When processing a player's turn:
// Hook will trigger gamemaster when action file appears
const action = await Read(`games/<game-name>/state/player-actions/${playerId}.json`);
// Check if action is legal according to rules
if (!isValidAction(action, gameState, playerId)) {
// Handle invalid action (reject, request retry, penalize)
handleInvalidAction(playerId, action, gameState);
return;
}
// Update game state based on action
applyAction(action, gameState);
// Check for special card effects
if (action.card.type === "action") {
applySpecialEffect(action.card, gameState);
}
if (checkWinCondition(gameState, playerId)) {
concludeGame(gameState, playerId);
return;
}
// Determine next player (consider Skip, Reverse effects)
const nextPlayer = determineNextPlayer(gameState);
const turnSignal = {
currentPlayer: nextPlayer.id,
turnNumber: gameState.turnNumber + 1,
availableActions: getAvailableActions(gameState, nextPlayer.id),
visibleState: getVisibleState(gameState, nextPlayer.id)
};
Write("games/<game-name>/state/turn-signal.json", JSON.stringify(turnSignal, null, 2));
When a turn signal is written, spawn the appropriate player agent:
Task tool invocation:
- subagent_type: "general-purpose"
- model: "haiku"
- description: "Player agent turn"
- prompt: `You are Player ${playerId} in a game of ${gameName}.
GAME RULES:
${gameRules}
YOUR CURRENT HAND:
${JSON.stringify(playerHand, null, 2)}
VISIBLE GAME STATE:
${JSON.stringify(visibleState, null, 2)}
OBJECTIVE: Choose the best legal action to help you win the game. You are competitive and want to win.
Analyze the current situation, consider your available actions, and choose the optimal play. Write your decision to games/${gameName}/state/player-actions/${playerId}.json in the following format:
{
"playerId": "${playerId}",
"action": "play" | "draw",
"card": { "color": "Red", "value": "7" } // if action is "play"
"reasoning": "Brief explanation of your choice"
}
Use the Write tool to save your decision.`
- run_in_background: false (wait for player decision)
Provide players with:
Full information:
Partial information:
Hidden information:
Instruct player agents to:
For simultaneous turns or phases:
// Spawn multiple agents in parallel
const playerAgentTasks = players.map(player => {
return Task({
subagent_type: "general-purpose",
model: "haiku",
prompt: generatePlayerPrompt(player, gameState),
run_in_background: true // Run in parallel
});
});
// Wait for all agents to complete
const results = await Promise.all(playerAgentTasks.map(task =>
TaskOutput({ task_id: task.id })
));
// Process all actions
results.forEach((result, index) => {
processPlayerAction(players[index], result);
});
Create different player strategies by varying prompts:
const strategies = {
aggressive: "Play aggressively. Use action cards immediately to disrupt opponents.",
defensive: "Play conservatively. Save action cards for defensive situations.",
balanced: "Balance offense and defense. Adapt to the game situation."
};
// Assign random or specific strategies
const playerPrompt = generatePlayerPrompt(player, gameState, strategies.aggressive);
Handle player agent failures gracefully:
try {
const playerDecision = await spawnPlayerAgent(player, gameState);
} catch (error) {
// Agent failed - options:
// 1. Retry with same agent
// 2. Make random legal move
// 3. Skip turn with penalty
// 4. End game
handlePlayerAgentFailure(player, error, gameState);
}
Coordinate with file-based communication:
Gamemaster writes:
games/<game-name>/state/game-state.json - Authoritative stategames/<game-name>/state/turn-signal.json - Turn notificationsgames/<game-name>/logs/game-<timestamp>.json - Completed gamesgames/<game-name>/traces/game-<timestamp>.md - Detailed tracesPlayer agents write:
games/<game-name>/state/player-actions/<player-id>.json - Action decisionsBoth read:
games/<game-name>/RULES.md - Game rules and configurationHooks coordinate file-based communication:
PostToolUse(Write) hook detects file changes:
turn-signal.json written → Spawn player agent for that turnplayer-actions/<player-id>.json written → Trigger gamemaster validationSee hook-sync skill for detailed hook implementation patterns.
✅ DO:
❌ DON'T:
✅ DO:
❌ DON'T:
✅ DO:
❌ DON'T:
For detailed implementation patterns, consult:
references/agent-spawning-patterns.md - Detailed Task tool patterns, error handling, parallel executionreferences/gamemaster-implementation.md - Complete gamemaster architecture, validation strategies, state managementWorking examples in examples/:
gamemaster-prompt.md - Example gamemaster system promptplayer-prompt.md - Example player agent prompt templateAgents not spawning:
Players making invalid moves:
Coordination issues:
Performance problems:
For comprehensive multi-agent coordination in game testing contexts, combine this skill with file-protocol (communication) and hook-sync (event triggering).
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience