Skip to content

Integrate BetPlug with Claude Code or by hand

The BetPlug plugin for Claude Code builds a signed sandbox integration in your own codebase: wallet, webhooks, games and tests. The same steps work by hand with the SDKs for TypeScript, Go, Python and PHP.

Three steps to your first sandbox round

Test keys come from the console. The plugin is not published yet: it is on no public registry, and until it is, it loads from a local copy of the BetPlug source.

  1. Create your account (now)

    Sign up in the console. You get a test API key and its signing secret, shown once.

  2. Load the plugin (not yet)

    Point Claude Code at the plugin directory, or add it as a local marketplace.

    Terminal
    claude --plugin-dir ./claude-plugin
    Inside Claude Code
    /plugin marketplace add ./claude-plugin
    /plugin install betrail@betrail
  3. Run the integration (not yet)

    In your project, start the guided build. It never takes a secret as an argument.

    Inside Claude Code
    /betrail-integrate

What the integration builds

/betrail-integrate runs seven steps in this order; the last runs the tests that hold the others in place.

  1. Writes .env.example

    The names of your API key and secrets, without their values. No secret is written to source or to git.

  2. Signs every request

    HMAC-SHA256 over the method, path, time, a one-time nonce and the body, tested against published vectors.

  3. Mounts your wallet routes

    Balance, debit, credit and rollback, each keyed on the transaction id, with the right answer for every refusal.

  4. Mounts your webhook receiver

    Checks the signature on the raw body before reading it, and drops repeats by their id.

  5. Wires the games

    A launch token for the embedded client, or rounds from your server, with amounts as exact decimal strings.

  6. Checks fairness end to end

    Rotates a player’s seeds and verifies a settled round against its record.

  7. Runs the tests

    Bad signatures, replayed nonces, retried requests, refused rollbacks and a verified round.

Check the plugin before you load it

Load it only from a copy of the BetPlug source, never from a registry or a marketplace that claims to be BetPlug, and compare these values with its manifest first.

  • It ships no hooks, so it never runs a shell command on its own.
  • Its MCP tools sign in with your console account and reach sandbox only. You approve their access and can revoke it under Security.
  • Test keys only: a live key never goes to an agent.
Plugin directory
./claude-plugin
Install name
betrail@betrail
Plugin version
0.1.0
MCP server
https://mcp.betrail.example/mcp
MCP address in the plugin
${BETRAIL_MCP_URL:-https://mcp.betrail.example/mcp}
MCP package
@betrail/mcp 0.2.0
Guide
https://betrail.example/docs/claude-code

Or build it by hand

SDKs for TypeScript, Go, Python and PHP and reference casinos in Next.js, Go and Laravel exist, but like the plugin they are not published yet. The guides describe every call, so you can build against the API directly today.