# Handling Commands

> Patterns for handling commands, validating input, and filtering messages in XMTP agents.

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.

- Page: https://ss33.ai/skills/boomsystel-code/handling-commands-9198338041
- Publisher: boomsystel-code
- Category: [Software Development](https://ss33.ai/skills/category/software-development-t44z8z) › [APIs & backend](https://ss33.ai/skills/category/software-development-t44z8z/apis-and-backend-t0x840)
- License: MIT
- Source: https://github.com/boomsystel-code/openclaw-workspace/blob/3a2689d2ad49e5449d863e6dd071e100d0666ad9/skills/xmtp-agent/handling-commands/SKILL.md

## Skill

SKILL.md: https://ss33.ai/api/v1/ss33/download/boomsystel-code/handling-commands-9198338041

# XMTP commands and validation

Best practices for handling commands, validating input, and filtering messages.

## When to apply

Reference these guidelines when:
- Implementing slash commands
- Validating hex strings and addresses
- Filtering message types
- Using type guards instead of type assertions

## Rule categories by priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Validators | CRITICAL | `validators-` |
| 2 | Filters | HIGH | `filters-` |
| 3 | Type Guards | HIGH | `guards-` |

## Quick reference

### Validators (CRITICAL)
- `validators-hex` - Use validHex() for hex string validation
- `validators-address` - Validate Ethereum addresses

### Filters (HIGH)
- `filters-message-types` - Filter by message type
- `filters-sender` - Filter out self-messages
- `filters-content` - Check for defined content

### Type Guards (HIGH)
- `guards-codec` - Use usesCodec() instead of type assertions
- `guards-content-type` - Use filter helpers for type safety

## How to use

Read individual rule files for detailed explanations:

```
rules/validators-hex.md
rules/filters-message-types.md
rules/guards-codec.md
```
