XMTP agent basics
SkillCommunicationCore XMTP Agent SDK setup and patterns. Use when creating new agents, handling messages, setting up middleware, or configuring environment variables. Triggers on agent setup, XMTP configuration, message handling, or middleware implementation.
Use XMTP agent basics in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add XMTP agent basics and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the XMTP agent basics skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; ahel provides instructions and does not run this skill.
No other account needed.
Add ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
What this skill tells your AI
The instructions your AI receives, as published by xmtplabs/xmtp-agent-examples in skills/building-agents/SKILL.md and read by ahel’s review.
Build event-driven, middleware-powered messaging agents on the XMTP network using the @xmtp/agent-sdk.
When to apply
Reference these guidelines when:
- Creating a new XMTP agent
- Setting up environment variables
- Handling text messages and events
- Implementing middleware
- Using filters and context helpers
Rule categories by priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Setup | CRITICAL | setup- |
| 2 | Events | HIGH | events- |
| 3 | Middleware | MEDIUM | middleware- |
| 4 | Filters | MEDIUM | filters- |
Quick reference
Setup (CRITICAL)
setup-environment- Configure environment variables for agentsetup-from-env- Create agent using Agent.createFromEnv()setup-manual- Manual agent creation with signer
Events (HIGH)
events-text- Handle text messagesevents-lifecycle- Handle start/stop eventsevents-conversation- Handle new DM and group conversationsevents-message-types- Handle different message types (reaction, reply, attachment)
Middleware (MEDIUM)
middleware-basics- Create and register middlewaremiddleware-error-handling- Handle errors in middleware chainmiddleware-command-router- Use CommandRouter for slash commands
Filters (MEDIUM)
filters-message-types- Filter by message typefilters-sender- Filter out self-messages
Installation
npm install @xmtp/agent-sdk
# or
yarn add @xmtp/agent-sdk
SDK 2.0+ uses unified exports: import everything from @xmtp/agent-sdk (no /debug, /middleware, /user, /util subpaths).
Quick start
import { Agent, getTestUrl } from "@xmtp/agent-sdk";
// Create agent using environment variables
const agent = await Agent.createFromEnv();
// Handle text messages
agent.on("text", async (ctx) => {
await ctx.conversation.sendText("Hello from my XMTP Agent!");
});
// Log when ready
agent.on("start", () => {
console.log(`Agent online: ${getTestUrl(agent.client)}`);
});
await agent.start();
Environment variables
| Variable | Purpose | Example |
|---|---|---|
XMTP_WALLET_KEY | Private key for wallet | 0x1234...abcd |
XMTP_DB_ENCRYPTION_KEY | Database encryption key | 0xabcd...1234 |
XMTP_ENV | Network environment | dev or production |
XMTP_DB_DIRECTORY | Database directory | ./data |
How to use
Read individual rule files for detailed explanations:
rules/setup-environment.md
rules/events-text.md
rules/middleware-basics.md
Signals
- GitHub stars
- 54
- Forks
- 23
- Last commit
- Feb 2026
ahel review
K1binfo
installs-packages
Automated review, not a security audit. Ruleset v1+k2.
Advanced
- Item type
- skill
- Key
building-agents-xmtplabs- Source
- github.com/xmtplabs/xmtp-agent-examples
github.com/xmtplabs/xmtp-agent-examples
More in Communication
Skill · anthropics
More in Communicationerror-handling
Skill · affaan-m
More in Communicationwait-what
Skill · mattpocock
More in Communicationemails
Skill · coreyhaines31
More in Communicationazure-messaging
Skill · microsoft
More in Communicationinvestor-outreach
Skill · affaan-m
More in Communication