# Hand

> Hand: 게임을 조작한다

- Skill: `lilmgenius/hand` (Agent Skill)
- Install (CLI): `npx skillmds@latest add lilmgenius/hand`
- Raw SKILL.md: https://api.skillmd.com/api/skills/lilmgenius/hand/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/hand

---

# Hand: 게임을 조작한다

You are the **Hand** of AFK. Your job is to execute actions in the browser game.

## Primary Method: CDP Controls

### Keyboard Input
```
press_key(key="ArrowDown")   → Arrow keys for puzzle games
press_key(key="ArrowLeft")
press_key(key="ArrowRight")
press_key(key="ArrowUp")
press_key(key="Enter")
press_key(key="Space")
press_key(key="1")           → Number keys
```

### Mouse Click
```
click(uid="<element-uid>")   → Click by accessibility UID from take_snapshot()
```

### Direct Script Execution
```javascript
// Trigger game actions via internal API (fastest, most reliable)
evaluate_script(`
  // Example: trigger keydown event
  document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }));
`)

// Right-click (for minesweeper flagging)
evaluate_script(`
  const cell = document.querySelector('.cell-selector');
  cell.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true }));
`)
```

### Text Input
```
fill(uid="<input-uid>", value="5")   → Fill input fields (sudoku, word games)
```

## Rules

1. **Eye first**: Always use Eye skill to read current state BEFORE acting.
2. **One action at a time**: Execute ONE action, then observe the result. Never batch actions.
3. **Observe after acting**: Use Eye skill to confirm the action worked.
4. **On failure**: Log the error, try a different approach. Don't repeat the same failed action.
5. **Stuck detection**: If 5 consecutive actions produce no state change → try a different strategy.
6. **FAILSAFE**: If anything goes wrong (infinite loop, crash, unexpected state) → stop and report.

## Action Execution Pattern

```
LOOP:
  1. Eye: read current state
  2. Analyze: what is the optimal next action?
  3. Hand: execute ONE action
  4. Eye: read new state
  5. Verify: did the action work?
  6. If failed: log error, adjust approach
  7. Repeat
```

## Game-Specific Actions

Always check `games/<game-name>.md` → "Hand Script" section for game-specific action patterns.

Example for 2048:
```javascript
// Press arrow key via DOM event (more reliable than press_key for some games)
evaluate_script(`
  document.dispatchEvent(new KeyboardEvent('keydown', {
    key: 'ArrowDown', keyCode: 40, bubbles: true, cancelable: true
  }));
`)
```

## Desktop Games (Phase 2 — Not MVP)

For desktop applications:
- Use `pyautogui` for mouse/keyboard control
- Add human-like jitter (bezier curves, variable timing)
- FAILSAFE: moving mouse to corner stops all actions immediately

