| Crates.io | miyabi-claudable |
| lib.rs | miyabi-claudable |
| version | 0.1.2 |
| created_at | 2025-11-22 07:26:00.243073+00 |
| updated_at | 2025-11-22 07:26:00.243073+00 |
| description | Claudable API client for Next.js frontend generation |
| homepage | |
| repository | https://github.com/ShunsukeHayashi/Miyabi |
| max_upload_size | |
| id | 1945007 |
| size | 122,096 |
Claudable API client for Next.js frontend generation
miyabi-claudable is a Rust client library for the Claudable API, enabling automated Next.js application generation through natural language descriptions.
✨ AI-Driven Frontend Generation
🔧 Worktree Integration
npm install and npm run buildmiyabi-agent-codegen🚀 Production-Ready
Add to your Cargo.toml:
[dependencies]
miyabi-claudable = { version = "0.1.1", path = "../miyabi-claudable" }
use miyabi_claudable::{ClaudableClient, GenerateRequest};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create client
let client = ClaudableClient::new("http://localhost:8080")?;
// Generate Next.js app
let request = GenerateRequest::new("Create a dashboard with charts and tables");
let response = client.generate(request).await?;
println!("Generated project: {}", response.project_id);
println!("Files created: {}", response.files.len());
Ok(())
}
use miyabi_claudable::{ClaudableClient, GenerateRequest, worktree};
use std::path::Path;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ClaudableClient::new("http://localhost:8080")?;
let request = GenerateRequest::new("Create a landing page");
let response = client.generate(request).await?;
// Write to worktree
let worktree_path = Path::new("/path/to/worktree");
let summary = worktree::write_files_to_worktree(worktree_path, &response).await?;
println!("Wrote {} files ({} lines)", summary.files_written, summary.total_lines);
// Install dependencies
worktree::install_dependencies(worktree_path).await?;
// Build Next.js app
worktree::build_nextjs_app(worktree_path).await?;
Ok(())
}
use miyabi_claudable::{ClaudableClient, GenerateRequest, GenerateOptions};
let request = GenerateRequest::new("Create an e-commerce site")
.with_agent("cursor")
.with_options(GenerateOptions {
typescript: true,
tailwind: true,
shadcn: true,
supabase: true, // Enable Supabase backend
});
let response = client.generate(request).await?;
ClaudableClientMain HTTP client for Claudable API.
new(api_url: impl Into<String>) -> Result<Self>
with_timeout(api_url: impl Into<String>, timeout_secs: u64) -> Result<Self>
generate(&self, request: GenerateRequest) -> Result<GenerateResponse>
health_check(&self) -> Result<bool>
GenerateRequestRequest to generate a Next.js application.
description: Natural language description of the appframework: Framework to use (default: "nextjs")agent: AI agent to use (default: "claude-code")options: Generation optionsnew(description: impl Into<String>) -> Self
with_agent(self, agent: impl Into<String>) -> Self
with_options(self, options: GenerateOptions) -> Self
GenerateResponseResponse from generate endpoint.
project_id: Unique project identifierfiles: Vec of generated filesdependencies: NPM dependencies to installstructure: Project directory structureGenerateOptionsOptions for code generation.
typescript: Use TypeScript (default: true)tailwind: Use Tailwind CSS (default: true)shadcn: Use shadcn/ui components (default: true)supabase: Use Supabase backend (default: false)write_files_to_worktree(worktree_path: &Path, response: &GenerateResponse) -> Result<WriteSummary>
install_dependencies(worktree_path: &Path) -> Result<()>
npm install in worktreebuild_nextjs_app(worktree_path: &Path) -> Result<()>
npm run build in worktreeverify_nextjs_structure(worktree_path: &Path) -> Result<bool>
# Optional: Claudable API key (for production)
CLAUDABLE_API_KEY=your_api_key_here
use miyabi_claudable::{ClaudableClient, ClaudableError};
match client.generate(request).await {
Ok(response) => println!("Success: {}", response.project_id),
Err(ClaudableError::ApiError(status, msg)) => {
eprintln!("API error {}: {}", status, msg);
}
Err(ClaudableError::Timeout(ms)) => {
eprintln!("Request timeout after {}ms", ms);
}
Err(ClaudableError::NpmInstallError(msg)) => {
eprintln!("npm install failed: {}", msg);
}
Err(e) => eprintln!("Unexpected error: {}", e),
}
cargo test --package miyabi-claudable
cargo test --package miyabi-claudable --lib
# Start Claudable first
docker-compose --profile claudable up -d
# Run tests including ignored ones
cargo test --package miyabi-claudable -- --ignored
| Module | Coverage |
|---|---|
| error.rs | 100% |
| types.rs | 100% |
| client.rs | 90% |
| worktree.rs | 95% |
| Overall | 96% ✅ |
use miyabi_claudable::ClaudableClient;
use miyabi_types::Task;
impl CodeGenAgent {
async fn generate_frontend_with_claudable(
&self,
task: &Task,
) -> Result<CodeGenerationResult> {
let client = ClaudableClient::new("http://localhost:8080")?;
// Extract description from task
let description = format!("{}\n\n{}", task.title, task.description);
let request = GenerateRequest::new(description);
// Call Claudable
let response = client.generate(request).await?;
// Integrate with worktree (if provided)
// ...
}
}
| 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 |
# Start with Docker Compose
docker-compose --profile claudable up -d
# Verify
curl http://localhost:8080/health
let request = GenerateRequest::new(
"Create a sales dashboard with:
- Line chart showing revenue over time
- Bar chart for product categories
- Data table with pagination
- Responsive design"
);
let response = client.generate(request).await?;
// → Generates TypeScript + Tailwind + shadcn/ui dashboard
let request = GenerateRequest::new(
"Create a SaaS landing page with:
- Hero section with CTA
- Features grid (6 items)
- Pricing table (3 tiers)
- Footer with links"
);
let response = client.generate(request).await?;
// → Generates full Next.js landing page
Problem: curl: (7) Failed to connect to localhost port 8080
Solution:
# Check if Claudable is running
docker ps | grep claudable
# Restart if needed
docker-compose --profile claudable up -d
Problem: ClaudableError::NpmInstallError
Solution:
# Check npm version
npm --version # Should be 8+
# Manual install
cd /path/to/worktree
npm install
See CONTRIBUTING.md for guidelines.
Apache-2.0
Version: 0.1.1
Status: ✅ Production Ready
Test Coverage: 96%
🤖 Generated with Claude Code