miyabi-claudable
Claudable API client for Next.js frontend generation
Overview
miyabi-claudable is a Rust client library for the Claudable API, enabling automated Next.js application generation through natural language descriptions.
Features
✨ AI-Driven Frontend Generation
- Convert natural language → Next.js applications
- TypeScript + Tailwind CSS + shadcn/ui
- Claude Code / Cursor CLI integration
🔧 Worktree Integration
- Write generated files to Git worktrees
- Automatic
npm installandnpm run build - Seamless integration with
miyabi-agent-codegen
🚀 Production-Ready
- Type-safe API client
- Comprehensive error handling
- 80%+ test coverage
- Async/await with Tokio
Installation
Add to your Cargo.toml:
[]
= { = "0.1.1", = "../miyabi-claudable" }
Quick Start
1. Basic Usage
use ;
async
2. Worktree Integration
use ;
use Path;
async
3. Custom Options
use ;
let request = new
.with_agent
.with_options;
let response = client.generate.await?;
API Reference
ClaudableClient
Main HTTP client for Claudable API.
Methods
new(api_url: impl Into<String>) -> Result<Self>
- Create a new Claudable client
- Default timeout: 180 seconds (3 minutes)
with_timeout(api_url: impl Into<String>, timeout_secs: u64) -> Result<Self>
- Create client with custom timeout
generate(&self, request: GenerateRequest) -> Result<GenerateResponse>
- Generate a Next.js application from natural language
- Returns project ID, files, dependencies, and structure
health_check(&self) -> Result<bool>
- Check if Claudable API is healthy
GenerateRequest
Request to generate a Next.js application.
Fields
description: Natural language description of the appframework: Framework to use (default: "nextjs")agent: AI agent to use (default: "claude-code")options: Generation options
Methods
new(description: impl Into<String>) -> Self
- Create request with default options
with_agent(self, agent: impl Into<String>) -> Self
- Set the AI agent (claude-code, cursor, codex, etc.)
with_options(self, options: GenerateOptions) -> Self
- Set custom generation options
GenerateResponse
Response from generate endpoint.
Fields
project_id: Unique project identifierfiles: Vec of generated filesdependencies: NPM dependencies to installstructure: Project directory structure
GenerateOptions
Options for code generation.
Fields
typescript: Use TypeScript (default: true)tailwind: Use Tailwind CSS (default: true)shadcn: Use shadcn/ui components (default: true)supabase: Use Supabase backend (default: false)
Worktree Functions
write_files_to_worktree(worktree_path: &Path, response: &GenerateResponse) -> Result<WriteSummary>
- Write generated files to Git worktree
- Creates directories as needed
- Returns summary with files written and total lines
install_dependencies(worktree_path: &Path) -> Result<()>
- Run
npm installin worktree - Requires package.json
build_nextjs_app(worktree_path: &Path) -> Result<()>
- Run
npm run buildin worktree - Builds Next.js production bundle
verify_nextjs_structure(worktree_path: &Path) -> Result<bool>
- Verify worktree has required Next.js files
- Checks for package.json and app/ directory
Environment Variables
# Optional: Claudable API key (for production)
CLAUDABLE_API_KEY=your_api_key_here
Error Handling
use ;
match client.generate.await
Testing
Run all tests
Run unit tests only
Run integration tests (requires Claudable server)
# Start Claudable first
# Run tests including ignored ones
Test Coverage
| Module | Coverage |
|---|---|
| error.rs | 100% |
| types.rs | 100% |
| client.rs | 90% |
| worktree.rs | 95% |
| Overall | 96% ✅ |
Integration with CodeGenAgent
use ClaudableClient;
use Task;
Performance
| Operation | Time | Notes |
|---|---|---|
| API Request | < 2min | Depends on complexity |
| File Write | < 5sec | For 50 files |
| npm install | < 30sec | Average dependencies |
| npm run build | < 1min | Next.js build |
| E2E Total | < 4min | Full pipeline |
Requirements
Runtime
- Rust: 1.75.0+
- Node.js: 18+
- npm: 8+
Claudable Server
# Start with Docker Compose
# Verify
Examples
Example 1: Dashboard Generation
let request = new;
let response = client.generate.await?;
// → Generates TypeScript + Tailwind + shadcn/ui dashboard
Example 2: Landing Page
let request = new;
let response = client.generate.await?;
// → Generates full Next.js landing page
Troubleshooting
Issue: API Connection Error
Problem: curl: (7) Failed to connect to localhost port 8080
Solution:
# Check if Claudable is running
|
# Restart if needed
Issue: npm install failed
Problem: ClaudableError::NpmInstallError
Solution:
# Check npm version
# Manual install
Contributing
See CONTRIBUTING.md for guidelines.
License
Apache-2.0
Related Crates
- miyabi-agent-codegen: CodeGenAgent implementation
- miyabi-types: Shared types for Miyabi agents
- miyabi-worktree: Git worktree management
Links
- Claudable: https://github.com/opactorai/Claudable
- Miyabi: https://github.com/ShunsukeHayashi/Miyabi
- Integration Guide: CLAUDABLE_INTEGRATION.md
- Setup Guide: CLAUDABLE_SETUP.md
Version: 0.1.1
Status: ✅ Production Ready
Test Coverage: 96%
🤖 Generated with Claude Code