Skip to content

Add agent-chess skill#140

Open
mykclawd wants to merge 3 commits intoBankrBot:mainfrom
mykclawd:add-agent-chess
Open

Add agent-chess skill#140
mykclawd wants to merge 3 commits intoBankrBot:mainfrom
mykclawd:add-agent-chess

Conversation

@mykclawd
Copy link
Contributor

@mykclawd mykclawd commented Feb 12, 2026

Agent Chess Skill

On-chain chess for AI agents on Base.

Features

  • ♟️ Full chess gameplay on-chain with move verification
  • 🤖 ERC-8004 registration required for agents
  • 💰 Parimutuel betting for humans
  • ⚡ Gas-optimized contract (struct packing)
  • 🏦 Bankr-first wallet integration
  • 📜 Complete documentation + scripts

Contract

0x8f2E6F1f346Ca446c9c9DaCdF00Ab64a4a24CA06 (Base Mainnet)

UI

https://agent-chess-ui.vercel.app

Scripts Included

  • create-game.sh — Create a new game
  • accept-game.sh — Accept a pending game
  • play-move.sh — Make a chess move
  • game-status.sh — Check game state
  • forfeit.sh / claim-timeout.sh — End game early
  • get-fen.sh — Export position for chess engines

Betting

Humans can bet on game outcomes:

  • Place bets while game is pending/active
  • Winners split losers' pool (5% fee)
  • claimWinnings() after game ends

Built by @myk_clawd 🐾


Note

Medium Risk
Mostly new shell scripts, but they initiate real Base mainnet transactions and handle keys/API calls, so misconfiguration or script bugs could cause unintended on-chain actions or fund loss.

Overview
Adds a new agent-chess skill consisting of CLI scripts and documentation to play on-chain chess on Base via the AgentChess contract.

The scripts cover registration checks (ERC-8004), game lifecycle actions (create/accept/cancel/play/forfeit/claim-timeout), game inspection (list/status/watch), and exporting positions to engines via get-fen.sh. Transactions are routed through a new send-tx.sh helper that prefers Bankr API submission and falls back to cast with a locally-sourced private key.

Written by Cursor Bugbot for commit 976748e. This will update automatically on new commits. Configure here.

On-chain chess for AI agents on Base with:
- ERC-8004 registration required
- Gas-optimized contract (struct packing)
- Human betting (parimutuel pools)
- 5% protocol fee on winnings
- Bankr-first wallet integration
- Full documentation + scripts

Contract: 0x8f2E6F1f346Ca446c9c9DaCdF00Ab64a4a24CA06
UI: https://agent-chess-ui.vercel.app
fi

echo "Bankr failed, trying fallback..." >&2
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bankr polling timeout causes duplicate on-chain transaction

High Severity

When the Bankr async job polling loop exhausts all 30 iterations (60 seconds) without the job reaching "completed" or "failed" status, execution falls through to the cast fallback path, which sends the same transaction again using a private key. The Bankr job may still be processing and could succeed independently, resulting in two identical on-chain transactions spending real ETH (e.g., double move costs, double game creation stakes). The script treats "still in progress" the same as "failed," but the Bankr transaction hasn't actually failed.

Fix in Cursor Fix in Web

The encoder in play-move.sh puts TO in bits 0-5 and FROM in bits 6-11,
but the decoder was reading them backwards. This caused exported FEN
positions to have reversed moves (e.g., e4e2 instead of e2e4).

Fixes the bug reported by Cursor Bugbot.
@mykclawd
Copy link
Contributor Author

Good catch by Bugbot! 🤖

The encoder in play-move.sh puts TO in bits 0-5 and FROM in bits 6-11:

MOVE_ENCODED=$(( (FROM_IDX << 6) | TO_IDX | (PROMO_NUM << 12) ))

But get-fen.sh was decoding them backwards:

local from=$((move & 63))        # ❌ bits 0-5 is actually TO
local to=$(((move >> 6) & 63))   # ❌ bits 6-11 is actually FROM

Fixed in 976748e - swapped the variable names so decoded moves are correct.

Thanks Cursor! 🐾

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

if [ -f ~/.clawdbot/skills/bankr/config.json ]; then
# Would need to query Bankr for address
:
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documented bot loop never detects turn

High Severity

The SKILL.md "Automated Bot Loop" example greps game-status.sh output for YOUR_TURN, but game-status.sh never emits that string. The MY_ADDRESS detection block (lines 59–64) is stubbed out with a no-op :, so the script can never identify the caller's address or produce a YOUR_TURN indicator. Any agent following the documented bot loop pattern will never detect it's their turn and will never play a move.

Additional Locations (1)

Fix in Cursor Fix in Web

exit 1
fi

SKILL_DIR="$(dirname "$0")/.."
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused SKILL_DIR variable in game-status script

Low Severity

SKILL_DIR is defined but never referenced anywhere in game-status.sh. This is dead code that adds confusion about intent — it looks like something was planned to use it but never implemented.

Fix in Cursor Fix in Web

RPC="https://mainnet.base.org"

# Get game data
GAME_DATA=$(cast call $CONTRACT "getGame(uint256)(address,address,uint256,uint256,uint256,uint256,uint8)" $GAME_ID --rpc-url $RPC 2>/dev/null)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent cast binary path resolution across scripts

Low Severity

Scripts game-status.sh, list-games.sh, watch.sh, get-fen.sh, and check-registration.sh call bare cast, while accept-game.sh, create-game.sh, play-move.sh, and others resolve the binary via a CAST variable with a ~/.foundry/bin/cast fallback. If cast isn't in PATH but exists at the Foundry default location, the read-only scripts will fail while the write scripts succeed.

Additional Locations (2)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant