Skip to content
cccskills
FreePublished on GitHub

building-agents

Core 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.

The English summary is being prepared. Showing the original description.

See how to install

Files included (7)

  • SKILL.md2.9 KB
  • rules/events-lifecycle.md860 B
  • rules/events-text.md913 B
  • rules/middleware-basics.md1.3 KB
  • rules/middleware-command-router.md1.2 KB
  • rules/setup-environment.md716 B
  • rules/setup-from-env.md1.1 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

XMTP agent basics

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

PriorityCategoryImpactPrefix
1SetupCRITICALsetup-
2EventsHIGHevents-
3MiddlewareMEDIUMmiddleware-
4FiltersMEDIUMfilters-

Quick reference

Setup (CRITICAL)

  • setup-environment - Configure environment variables for agent
  • setup-from-env - Create agent using Agent.createFromEnv()
  • setup-manual - Manual agent creation with signer

Events (HIGH)

  • events-text - Handle text messages
  • events-lifecycle - Handle start/stop events
  • events-conversation - Handle new DM and group conversations
  • events-message-types - Handle different message types (reaction, reply, attachment)

Middleware (MEDIUM)

  • middleware-basics - Create and register middleware
  • middleware-error-handling - Handle errors in middleware chain
  • middleware-command-router - Use CommandRouter for slash commands

Filters (MEDIUM)

  • filters-message-types - Filter by message type
  • filters-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

VariablePurposeExample
XMTP_WALLET_KEYPrivate key for wallet0x1234...abcd
XMTP_DB_ENCRYPTION_KEYDatabase encryption key0xabcd...1234
XMTP_ENVNetwork environmentdev or production
XMTP_DB_DIRECTORYDatabase directory./data

How to use

Read individual rule files for detailed explanations:

rules/setup-environment.md
rules/events-text.md
rules/middleware-basics.md

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Interactive button-based UI for XMTP agents following XIP-67. Use when creating menus, confirmation dialogs, selection options, or any button-based interaction. Triggers on inline actions, buttons, menus, or ActionBuilder.

The English summary is being prepared. Showing the original description.

xmtplabs/xmtp-agent-examples53Updated Feb 21, 2026

File attachment handling for XMTP agents. Use when sending or receiving images, files, or any encrypted remote attachments. Triggers on file upload, image sending, or remote attachment handling.

The English summary is being prepared. Showing the original description.

xmtplabs/xmtp-agent-examples53Updated Feb 21, 2026

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.

The English summary is being prepared. Showing the original description.

xmtplabs/xmtp-agent-examples53Updated Feb 21, 2026

Token transactions and wallet integration for XMTP agents. Use when sending USDC, creating transaction requests, or handling transaction confirmations. Triggers on USDC transfer, wallet calls, or transaction reference.

The English summary is being prepared. Showing the original description.

xmtplabs/xmtp-agent-examples53Updated Feb 21, 2026

Group conversation management for XMTP agents. Use when creating groups, managing members, setting permissions, or sending welcome messages. Triggers on group creation, member management, or permissions.

The English summary is being prepared. Showing the original description.

xmtplabs/xmtp-agent-examples53Updated Feb 21, 2026

ENS and Web3 identity resolution for XMTP agents. Use when resolving domain names, extracting mentions, or fetching Farcaster profiles. Triggers on ENS resolution, Farcaster lookup, or mention extraction.

The English summary is being prepared. Showing the original description.

xmtplabs/xmtp-agent-examples53Updated Feb 21, 2026

See all skills by xmtplabs

Report a problem with this skill