Using Hybrid
Master the Hybrid CLI and development workflow for building and managing your agents.
Key Management
Generating XMTP Keys
Create new keys for your agent:
npx hybrid keysThis generates:
- Wallet private key - For XMTP identity and signing
- XMTP DB encryption key - For message database encryption
Keys are displayed in the terminal. Save them to your .env file manually or use the --write flag:
Automatically Writing Keys to .env
npx hybrid keys --writeThis automatically writes the keys to your .env file:
# Generated by hybrid keys --write
XMTP_WALLET_KEY=0x1234567890abcdef...
XMTP_DB_ENCRYPTION_KEY=abcdef1234567890...Key Security Best Practices
Do:- Store keys in environment variables
- Use different keys for development and production
- Keep backup copies in secure storage
- Add
.envto your.gitignore
- Commit keys to version control
- Share keys in plain text
- Use the same keys across multiple agents
- Store keys in client-side code
Development Workflow
Development Server
Start your agent in development mode:
npx hybrid devFeatures:
- Hot reload - Automatic restart on code changes
- Debug logging - Detailed console output
- XMTP integration - Connects to XMTP network automatically
The dev server:
- Compiles TypeScript in watch mode
- Runs your agent
- Listens for XMTP messages
- Restarts on file changes
Building Projects
Build your TypeScript project:
npx hybrid buildThis compiles your TypeScript code to JavaScript in the dist directory.
Project Cleanup
Clean build artifacts:
npx hybrid cleanRemoves:
distdirectory- Temporary build files
Framework Upgrades
Upgrade all Hybrid packages to the latest version:
npx hybrid upgradeThis will:
- Update all
@hybrd/*andhybridpackages - Check for latest versions
- Update your
package.json
XMTP Network Operations
Wallet Registration
Register your agent's wallet with the XMTP production network:
npx hybrid registerThis process:
- Reads your
XMTP_WALLET_KEYfrom environment - Creates an XMTP identity
- Registers the wallet on the XMTP network
- Confirms successful registration
Note: Registration is only needed for production. Development works without registration.
Revoking Installations
Remove specific XMTP installation by inbox ID:
npx hybrid revoke <inboxId>Revoke all installations for your wallet:
npx hybrid revoke:allUse cases:
- Security breach - Immediately revoke compromised installations
- Key rotation - Revoke old installations before using new keys
- Testing cleanup - Remove test installations
Available Commands
| Command | Description |
|---|---|
npx hybrid dev | Start development server with watch mode |
npx hybrid build | Build the TypeScript project |
npx hybrid clean | Remove dist directory |
npx hybrid upgrade | Upgrade all hybrid packages to latest |
npx hybrid keys | Generate XMTP wallet and encryption keys |
npx hybrid keys --write | Generate and save keys to .env file |
npx hybrid register | Register wallet with XMTP production network |
npx hybrid revoke <inboxId> | Revoke specific XMTP installation |
npx hybrid revoke:all | Revoke all XMTP installations for wallet |
Alias Commands
You can use the shorter hy alias for all commands:
hy dev # Same as: npx hybrid dev
hy keys # Same as: npx hybrid keys
hy build # Same as: npx hybrid build
hy up # Same as: npx hybrid upgradeEnvironment Variables
Required Environment Variables
# XMTP Configuration
XMTP_WALLET_KEY=0x... # Required: Your XMTP wallet private key
XMTP_DB_ENCRYPTION_KEY=... # Required: Database encryption key
# AI Provider
OPENROUTER_API_KEY=... # Required: Your AI provider API keyOptional Environment Variables
# Server Configuration
PORT=8454 # Optional: HTTP server port (default: 8454)
# XMTP Network
XMTP_ENV=production # Optional: XMTP environment (default: production)
# Blockchain Tools (if using)
PRIVATE_KEY=0x... # Optional: For sending transactions
RPC_URL=https://... # Optional: Custom RPC endpointDevelopment Best Practices
Project Structure
my-agent/
├── src/
│ └── agent.ts # Your agent configuration
├── .env # Environment variables (not in git)
├── .gitignore # Ignore .env and node_modules
├── package.json
└── tsconfig.jsonLocal Testing
- Generate keys:
npx hybrid keys --write - Add your API keys to
.env - Start development:
npx hybrid dev - Message your agent via XMTP (address shown in terminal)
Deployment
- Build your project:
npx hybrid build - Set environment variables in your hosting platform
- Register wallet (production):
npx hybrid register - Deploy to your hosting platform
- Monitor logs for agent activity
Next Steps
- Learn about Agent Configuration for customizing behavior
- Explore Behaviors for message processing
- Check out Blockchain Tools for crypto functionality
- See XMTP Tools for messaging capabilities