Compoder CLI - AI-Powered Component Code Generator Command Line Interface
The CLI is automatically built when you install the main Compoder project:
npm installInitialize Compoder configuration for your project:
npx compoder initThis command will:
- Select a Codegen: Choose from available code generators with an interactive list
- Select AI Clients: Choose which AI clients to configure (Cursor, Claude Code)
- Generate Configuration: Create
.compoderrcfile in your project root - Setup AI Rules: Generate rule files for selected AI clients
For all projects:
.compoderrc: Project configuration file containing selected codegen and AI clients
For Cursor:
.cursor/rules/compoder/[codegen-name]/index.mdc: Main orchestration file.cursor/rules/compoder/[codegen-name]/step1.md: Component design phase rules.cursor/rules/compoder/[codegen-name]/step2.md: Component implementation phase rules
--api-base-url <url>: Base URL for the Compoder API (default: http://localhost:3000)
# Initialize with custom API URL
npx compoder init --api-base-url http://localhost:3001After initialization, you can reference the generated rules in your AI client:
In Cursor:
- Open your project in Cursor
- Reference the rule:
@compoder/[codegen-name] - The AI will follow the two-step workflow:
- Step 1: Design the component (extract requirements, identify needed components)
- Step 2: Implement the component (generate code files)
Update Compoder rules based on the .compoderrc configuration:
npx compoder updateThis command will:
- Check Configuration: Verify that
.compoderrcexists in the current directory - Read Configuration: Load the codegen and AI clients from
.compoderrc - Fetch Latest Rules: Get the latest codegen configuration from the API
- Regenerate Rule Files: Update all rule files for configured AI clients
Use compoder update when:
- The codegen configuration has been updated on the server
- You want to sync your local rules with the latest version
- Rule files were accidentally modified or deleted
--api-base-url <url>: Base URL for the Compoder API (default: http://localhost:3000)
# Update with default API URL
npx compoder update
# Update with custom API URL
npx compoder update --api-base-url http://localhost:3001Start an MCP (Model Context Protocol) server for Compoder components:
npx compoder mcp server--api-base-url <url>: Base URL for the Compoder API (default: http://localhost:3000)--debug: Enable debug logging
# Start MCP server with custom API URL and debug logging
npx compoder mcp server --api-base-url http://localhost:3001 --debugTo use the MCP server with an MCP client, add the following configuration:
{
"mcpServers": {
"compoder": {
"command": "npx",
"args": ["compoder", "mcp", "server"]
}
}
}The MCP server exposes three tools:
Get a list of all available codegens with their titles and descriptions.
Parameters: None
Returns: Markdown formatted list of all available code generators with their names and descriptions.
Get a list of all components for the specified codegen in markdown format.
Parameters:
codegenName(string): Name of the codegen to get components for
Returns: Markdown formatted list of all available components organized by library.
Get detailed API documentation for specific components.
Parameters:
codegenName(string): Name of the codegenlibraryName(string): Name of the component librarycomponentNames(array): Array of component names to get details for
Returns: Detailed API documentation for the requested components.
npm run cli:buildnpm run cli:devcli/
├── src/
│ ├── index.ts # CLI entry point
│ ├── commands/ # Command implementations
│ │ ├── init/ # Init command
│ │ │ └── index.ts # Init command implementation
│ │ ├── update/ # Update command
│ │ │ └── index.ts # Update command implementation
│ │ └── mcp/ # MCP related commands
│ │ ├── index.ts # MCP command definitions
│ │ ├── server.ts # MCP server implementation
│ │ └── tools/ # MCP tools
│ ├── shared/ # Shared utilities
│ │ ├── types.ts # Type definitions
│ │ ├── api-client.ts # API client
│ │ ├── utils.ts # Utility functions
│ │ ├── file-utils.ts # File operation utilities
│ │ └── prompt-generator.ts # Rule file generators
│ └── config/ # Configuration
│ └── default.ts # Default configuration
├── dist/ # Compiled output
├── package.json # CLI dependencies
└── tsconfig.json # TypeScript configuration
COMPODER_API_URL: Base URL for the Compoder APICOMPODER_MCP_PORT: Default port for MCP serverCOMPODER_MCP_HOST: Default host for MCP serverDEBUG: Enable debug logging
The CLI includes comprehensive error handling:
- API connection errors
- Invalid codegen names
- Missing component libraries
- Network timeouts
All errors are logged with appropriate context and exit codes.
| Command | Description |
|---|---|
compoder init |
Initialize Compoder configuration for your project |
compoder update |
Update rules based on .compoderrc configuration |
compoder mcp server |
Start MCP server for component documentation |
The CLI architecture supports easy extension with additional commands:
compoder generate- Code generation commandscompoder deploy- Deployment commandscompoder config- Configuration management