Creating Extensions
This guide walks you through creating your own Radium extension from scratch.
Extension Manifestβ
Every extension must have a radium-extension.json manifest file at its root. This file defines the extension's metadata and components.
Basic Manifest Structureβ
{
"name": "my-extension",
"version": "1.0.0",
"description": "A brief description of what this extension does",
"author": "Your Name",
"components": {
"prompts": [],
"mcp_servers": [],
"commands": [],
"hooks": []
},
"dependencies": []
}
Required Fieldsβ
- name: Extension name (alphanumeric, dashes, underscores only; must start with a letter)
- version: Semantic version (e.g.,
1.0.0,2.1.3) - description: Brief description of the extension
- author: Author name or contact information
Component Pathsβ
Component paths support glob patterns:
{
"components": {
"prompts": ["prompts/*.md", "prompts/frameworks/*.md"],
"mcp_servers": ["mcp/*.json"],
"commands": ["commands/*.toml", "commands/deploy/*.toml"],
"hooks": ["hooks/*.toml"]
}
}
Dependenciesβ
Declare other extensions your extension depends on:
{
"dependencies": ["required-extension-1", "required-extension-2"]
}
Dependencies are automatically installed when you install an extension with the --install-deps flag.
Directory Structureβ
Create the following directory structure:
my-extension/
βββ radium-extension.json
βββ prompts/ # Optional: Agent prompts
βββ mcp/ # Optional: MCP server configs
βββ commands/ # Optional: Custom commands
βββ hooks/ # Optional: Hook configs
βββ README.md # Recommended: Documentation
Component Typesβ
Promptsβ
Prompts are markdown files containing agent prompt templates. Place them in the prompts/ directory:
prompts/
βββ code-review-agent.md
βββ documentation-agent.md
Example prompt file:
# Code Review Agent
You are an expert code reviewer. Analyze the provided code and provide constructive feedback.
## Guidelines
- Focus on code quality and best practices
- Suggest improvements with examples
- Be respectful and constructive
MCP Serversβ
MCP server configurations are JSON files that define how to connect to Model Context Protocol servers. Place them in the mcp/ directory:
mcp/
βββ my-mcp-server.json
Example MCP server config (note: this is a simplified example; actual MCP configs use TOML format in the workspace):
{
"name": "my-mcp-server",
"transport": "stdio",
"command": "mcp-server",
"args": ["--config", "config.json"]
}
Note: MCP server configurations in extensions are loaded and merged with the workspace MCP configuration. See the MCP documentation for full configuration format.
Commandsβ
Custom commands are TOML files defining executable commands. Place them in the commands/ directory:
commands/
βββ deploy.toml
Example command file:
name = "deploy"
description = "Deploy application to production"
command = "deploy.sh"
args = ["--env", "production"]
Commands from extensions are namespaced with the extension name (e.g., my-extension:deploy).
Hooksβ
Hooks are TOML files that configure native libraries or WASM modules. Place them in the hooks/ directory:
hooks/
βββ logging-hook.toml
Example hook file:
name = "logging-hook"
type = "native"
library = "liblogging.so"
Validation Rulesβ
Extension Nameβ
- Must start with a letter
- Can contain letters, numbers, dashes, and underscores
- Must be unique (case-sensitive)
Examples:
- β
my-extension - β
extension_123 - β
123-extension(starts with number) - β
my extension(contains space)
Version Formatβ
Must follow semantic versioning (semver):
- Format:
MAJOR.MINOR.PATCH - Examples:
1.0.0,2.1.3,0.1.0
Component Pathsβ
- Paths cannot be empty
- Glob patterns are supported
- Paths are relative to the extension root
Creating Your First Extensionβ
- Create the directory structure:
mkdir my-extension
cd my-extension
mkdir -p prompts mcp commands hooks
- Create the manifest (
radium-extension.json):
{
"name": "my-extension",
"version": "1.0.0",
"description": "My first Radium extension",
"author": "Your Name",
"components": {
"prompts": ["prompts/*.md"],
"commands": ["commands/*.toml"]
},
"dependencies": []
}
- Add components:
Create a prompt file (prompts/my-agent.md):
# My Custom Agent
This is a custom agent prompt.
- Test installation:
rad extension install ./my-extension
rad extension list
rad extension info my-extension
- Verify components are loaded:
# Check if prompts are discoverable
rad agents list
# Check if commands are available
rad commands list
Best Practicesβ
Namingβ
- Use descriptive, lowercase names with dashes
- Avoid generic names that might conflict
- Consider prefixing with your organization/username
Versioningβ
- Start with
1.0.0for initial release - Follow semantic versioning for updates
- Increment version when making changes
Documentationβ
- Include a
README.mdexplaining what the extension does - Document all components and their purpose
- Provide usage examples
- List any dependencies or requirements
Testingβ
- Test installation from local directory
- Verify all components are discoverable
- Test with different Radium versions if possible
- Check for conflicts with other extensions
Distributionβ
- Package as
.tar.gzor.zipfor distribution - Include all necessary files
- Ensure manifest is valid JSON
- Test installation from archive
Troubleshootingβ
Manifest Validation Errorsβ
Error: invalid extension name
- Check name starts with a letter
- Ensure no spaces or special characters (except dashes/underscores)
Error: invalid version format
- Use semantic versioning format:
MAJOR.MINOR.PATCH - Examples:
1.0.0,2.1.3
Error: missing required field
- Ensure all required fields are present:
name,version,description,author
Component Discovery Issuesβ
Components not found:
- Verify component directories exist
- Check glob patterns match actual file paths
- Ensure file extensions are correct:
- Prompts:
.md - MCP:
.json - Commands:
.toml - Hooks:
.toml
- Prompts:
Components not loading:
- Check file formats are valid
- Verify paths in manifest match directory structure
- Ensure files are not empty
Installation Issuesβ
Installation fails:
- Check manifest is valid JSON
- Verify all required fields are present
- Ensure extension name is unique
- Use
--overwriteif reinstalling
Dependencies not installing:
- Ensure dependency names match exactly
- Check dependencies are installed first
- Use
--install-depsflag
Next Stepsβ
- See Architecture for technical details
- Check examples for sample extensions
- Review CLI commands for usage