What is it?
The Mandate Claude Code plugin (claude-mandate-plugin) enforces spend limits on every transaction Claude executes. It uses a two-phase approach: PostToolUse records validation tokens when the agent validates with Mandate, and PreToolUse blocks transaction commands that lack a valid token. Fail-closed, no network calls in the gate.
The plugin does not manage wallets. It gates the execution of transaction commands regardless of which wallet Claude uses: Bankr, Locus, Sponge, direct RPC calls, or MCP wallet tools.
Install
Two steps: add the marketplace, then install the plugin.How the two-phase gate works
The plugin registers three hooks: SessionStart, PostToolUse, and PreToolUse.Phase 1: PostToolUse (record validation tokens)
When Claude callsmandate validate (via CLI or API), the PostToolUse hook detects the successful validation and writes a token to a local state file. The token includes a timestamp and the validation result.
Phase 2: PreToolUse (block unvalidated transactions)
When Claude tries to execute a Bash command or MCP tool that looks like a transaction, the PreToolUse hook checks for a valid token. If no token exists or the token is older than 15 minutes, the hook returns a deny message with instructions to validate first. This is the enforcement boundary. Claude sees the block message and cannot proceed until it validates with Mandate. The gate runs entirely offline: no API calls, no network dependencies, purely a local file check.What triggers the gate?
The PreToolUse hook matches two categories of tool calls:MCP financial tools
Any MCP tool name containing transaction keywords is intercepted:transfer, send, pay, swap, trade, sell, buy, exchange, submit, sign_tx, broadcast, withdraw, deposit, bridge, execute, approve_tx. MCP read tools (get_, list_, balance, read_, fetch_, query_, search_, describe_) are allowed through.
Bash commands
Bash commands are checked for wallet CLI calls and transaction patterns:- Bankr CLI:
bankr prompt(with write keywords),bankr submit,bankr sign - Bankr API: URLs matching
api.bankr.bot/agent/prompt,agent/submit,agent/sign - Generic pattern: Transaction keywords (
transfer,send,swap, etc.) combined with an Ethereum address (0x+ 40 hex chars)
mandate validate, mandate login, etc.) are always allowed through.
The hook uses keyword matching, not semantic analysis. A Bash command like
echo "send 0xabc..." would trigger the gate even though it is not a real transaction. This is by design: false positives are safe, false negatives are not.Auto-scan on session start
The SessionStart hook scans the project codebase for unprotected wallet calls every time Claude starts a new session. It searches JavaScript and TypeScript files for patterns likewallet.transfer(), sendTransaction(), writeContract(), and checks whether Mandate SDK imports or this plugin protect them.
If unprotected calls are found, the scan prints a summary:
package.json or the plugin is installed, all calls are considered protected at the project level.
Registration
Register your agent with the CLI. This creates an agent identity and stores credentials locally.~/.mandate/credentials.json (chmod 600). The CLI reads the runtime key from this file automatically on subsequent calls.
Share the claimUrl from the output with the wallet owner. They link the agent to their Mandate dashboard to configure policies.
Example flow
Here is what a typical transaction looks like with the plugin active:- Claude decides to send funds. “I need to send 50 USDC to 0xRecipientAddress for the March invoice.”
-
Claude validates with Mandate.
The policy engine checks spend limits, allowlists, schedule, and scans the reason for prompt injection. Returns
allowed: true. - PostToolUse records the token. The plugin writes a validation token to the local state file.
-
Claude executes the transaction.
The PreToolUse hook fires, finds a valid token (less than 15 minutes old), and allows the command.
- Transaction completes. Claude reports the result to the user.
Mandate’s own tools are always allowed
The gate never blocks Mandate’s own commands:mandate validate, mandate login, mandate status, mandate event, mandate activate, mandate approve, mandate --llms. These must pass through for the validation flow to work.
Similarly, Mandate MCP tools (mcp__mandate__validate, mcp__mandate__register, etc.) are always allowed.
Next Steps
Integrations Overview
Compare all integration methods and find the right one for your stack.
Validate Transactions
Full guide to the validate endpoint, parameters, and response handling.
Codebase Scanner
Run the scanner in CI/CD to catch unprotected wallet calls before deployment.
CLI Reference
All CLI commands: login, validate, transfer, scan, and MCP server mode.