# Afk Play

> AFK Play mode — AI autonomously plays a web game. Use when the user says "afk:play", "대신 플레이해줘", "play <game> for me", or asks AI to control a web game automatically.

- Skill: `lilmgenius/afk-play` (Agent Skill)
- Install (CLI): `npx skillmds@latest add lilmgenius/afk-play`
- Raw SKILL.md: https://api.skillmd.com/api/skills/lilmgenius/afk-play/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: lilmgenius (https://skillmd.com/u/lilmgenius)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/lilmgenius/afk-play

---


# AFK Play Mode

You are AFK in **PLAY MODE**. You will autonomously play the web game by reading its state and controlling it.

## Mandatory First Step

BEFORE anything else, you MUST call a tool to read the actual game state.
Do NOT describe what you will do. Do NOT give advice. CALL THE TOOL NOW.

```
mcp__chrome_devtools__evaluate_script  ← run Eye Script from games/<game>.md
mcp__chrome_devtools__take_snapshot    ← if evaluate_script fails
```

## Loop

Repeat until game over or user stops you:

1. **Eye**: Call `evaluate_script` with the Eye Script from `games/<game>.md`
2. **Analyze**: Parse board state, apply strategy from `games/<game>.md`
3. **Hand**: Call `press_key` or `evaluate_script` with Hand Script
4. **Verify**: Call `evaluate_script` again to confirm state changed
5. **Repeat**

## Game Files

- `games/2048.md` → URL: https://play2048.co, Eye+Hand scripts included
- `games/minesweeper.md` → URL: https://minesweeperonline.com, Eye+Hand scripts included
- `games/_template.md` → for unknown games: web search → auto-create GAME.md

## Unknown Game

If no GAME.md exists:
1. Web search: `"<game name> strategy guide DOM selectors"`
2. `take_snapshot` to find actual DOM structure
3. Create `games/<name>.md` from `games/_template.md`
4. Start playing

## Chrome Extension Overlay (WebSocket)

After each action, send status to the Chrome Extension overlay:

```javascript
// Run via evaluate_script to update Play badge
evaluate_script(`
  (() => {
    const ws = new WebSocket('ws://localhost:38377');
    ws.onopen = () => {
      ws.send(JSON.stringify({
        mode: 'play',
        message: '[CURRENT ACTION e.g. ArrowDown — merging tiles]',
        target: {
          selector: '[CSS SELECTOR OPTIONAL]',
          row: 5,
          col: 5,
          x: 640,
          y: 360,
          rect: { x: 620, y: 340, width: 40, height: 40 }
        }
      }));
      setTimeout(() => ws.close(), 300);
    };
  })()
`)
```

## Rules

- One action at a time — always observe result before next action
- Stuck 5 turns: try different strategy direction
- Stuck 15 turns: web search for better guide, update GAME.md
- Update `games/<game>.md` Learned Patterns with successful sequences
- Use Eye skill (`skills/eye/SKILL.md`) for reading
- Use Hand skill (`skills/hand/SKILL.md`) for controlling

