Introduction
Tiny Claw’s plugin system allows you to extend its capabilities by adding new channels, LLM providers, and tools. The plugin architecture is designed to be simple, type-safe, and discoverable.Plugin Types
Tiny Claw supports three types of plugins:Channel Plugins
Channel plugins connect external messaging platforms (Discord, Slack, web chat, etc.) to the Tiny Claw agent loop. They handle incoming messages from users and deliver responses back through the platform. Examples:@tinyclaw/plugin-channel-discord- Discord bot integration@tinyclaw/plugin-channel-friends- Web-based friends chat
Provider Plugins
Provider plugins add new LLM providers to the routing system. They implement theProvider interface to communicate with different AI model APIs.
Examples:
@tinyclaw/plugin-provider-openai- OpenAI GPT models- Built-in Ollama provider
Tools Plugins
Tools plugins contribute additional capabilities to the agent by adding new tools that can be invoked during conversations. Examples:- File system operations
- API integrations
- Custom business logic
Plugin Architecture
Common Plugin Interface
All plugins share common metadata fields:npm package name (e.g.,
@tinyclaw/plugin-channel-discord)Human-readable name shown at startup (e.g., “Discord”)
Short description displayed during plugin loading
Plugin type discriminant
Semantic version of the plugin
Discovery and Loading
Plugins are discovered through the configuration system, not filesystem scanning:- Plugins are registered in
configunderplugins.enabledarray - At boot time, Tiny Claw dynamically imports each package by name
- The default export must be a valid plugin object
- Failed imports are logged and skipped (non-fatal)
Lifecycle Flow
- Boot: Configuration loads
plugins.enabledlist - Import: Dynamic import of each package
- Validation: Check plugin structure and type
- Registration: Group by type (channels, providers, tools)
- Pairing Tools: Merge pairing tools into agent context
- Initialization: Call type-specific initialization methods
- Runtime: Plugins interact with core system
- Shutdown: Cleanup via
stop()methods
Pairing Flow
Many plugins support a conversational pairing flow:- Plugin is added to
plugins.enabled(manually or via agent) - Plugin provides pairing tools via
getPairingTools()method - These tools appear in the agent’s tool list
- User asks the agent to configure the plugin
- Agent invokes pairing tools to store credentials and enable features
- Agent restarts to load the fully configured plugin
Example Pairing
Plugin Development Workflow
1. Choose Your Plugin Type
Decide whether you’re building a channel, provider, or tools plugin based on your use case.2. Set Up Project Structure
3. Install Dependencies
4. Implement the Interface
Create your plugin following the appropriate interface (see type-specific guides).5. Build and Test
Add a build script and compile your plugin:6. Local Testing
Test locally before publishing:7. Publish to npm
Once tested, publish your plugin:Best Practices
Error Handling
- Always wrap async operations in try-catch blocks
- Return user-friendly error messages from tools
- Log errors using
@tinyclaw/loggerfor debugging - Fail gracefully - don’t crash the entire system
Security
- Never log or expose secrets
- Use
SecretsManagerInterfacefor credential storage - Validate all user inputs in tool parameters
- Follow the principle of least privilege
Performance
- Keep initialization fast - defer heavy operations
- Use connection pooling for external services
- Implement proper cleanup in
stop()methods - Avoid blocking the event loop
Compatibility
- Specify peer dependencies correctly
- Test against multiple Tiny Claw versions
- Document breaking changes in your changelog
- Follow semantic versioning
Type Safety
All plugins are fully typed using TypeScript interfaces from@tinyclaw/types. This provides:
- Compile-time type checking
- IDE autocomplete and IntelliSense
- Runtime validation during plugin loading
- Clear API contracts
Examples
Explore the built-in plugins for reference implementations:- Discord Channel:
/workspace/source/plugins/channel/plugin-channel-discord - Friends Chat:
/workspace/source/plugins/channel/plugin-channel-friends - OpenAI Provider:
/workspace/source/plugins/provider/plugin-provider-openai
Next Steps
Channel Plugins
Build messaging platform integrations
Provider Plugins
Add new LLM providers
Tools Plugins
Extend agent capabilities