Skip to content

xmtplabs/xmtp-agent-examples / skills/handling-commands

handling-commands

Verified

Patterns for handling commands, validating input, and filtering messages in XMTP agents. Use when implementing slash commands, validators, or message filters. Triggers on command handling, input validation, or type guards.

FileKindSize
SKILL.mdskill md1.6 KB
rules/filters-message-types.mdmarkdown1.1 KB
rules/guards-codec.mdmarkdown1.1 KB
rules/validators-hex.mdmarkdown942 B

rules/validators-hex.md

View on GitHub
---
title: Use validHex for hex string validation
impact: CRITICAL
tags: validators, hex, type safety
---

## Use validHex for hex string validation

Use the `validHex` validator instead of type assertions to maintain runtime safety.

**Incorrect (type assertion):**

```typescript
// Bad: Using type assertions for hexadecimal strings
await getERC20Balance({
  chain: CHAIN,
  tokenAddress: USDC_ADDRESS,
  address: agentAddress as `0x${string}`,
});
```

**Correct (use validHex):**

```typescript
import { getERC20Balance, validHex } from "@xmtp/agent-sdk";

// Good: Using the validHex validator to guarantee hexadecimal strings
await getERC20Balance({
  chain: CHAIN,
  tokenAddress: USDC_ADDRESS,
  address: validHex(agentAddress),
});
```

**Why this matters:**

- Type assertions only work at compile time
- `validHex` validates at runtime and throws if invalid
- Prevents bugs from invalid hex strings reaching blockchain operations
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall