A powerful command-line tool for managing Crystal web applications built with the Amber Framework. This CLI provides generators, database management, development utilities, and more to streamline your Amber development workflow.
The comprehensive documentation includes detailed guides, examples, and API references generated from the codebase.
macOS & Linux via Homebrew:
brew tap amberframework/amber_cli
brew install amber_cliFrom Source:
git clone https://github.com/amberframework/amber_cli.git
cd amber_cli
shards install
crystal build src/amber_cli.cr -o amber --release
crystal build src/amber_lsp.cr -o amber-lsp --release
sudo mv amber amber-lsp /usr/local/bin/Windows: Use WSL2 or a virtual machine. Native Windows support is not currently available.
# Create a new Amber application
amber new my_blog
# Navigate to your app
cd my_blog
# Set up the database
amber database create
amber database migrate
# Start the development server
amber watchYour application will be available at http://localhost:3000
| Command | Description | Example |
|---|---|---|
new |
Create a new Amber application | amber new my_app -d pg -t slang |
generate |
Generate application components | amber generate model User name:String |
database |
Database operations and migrations | amber database migrate |
watch |
Development server with auto-reload | amber watch |
routes |
Display application routes | amber routes --json |
exec |
Execute Crystal code in app context | amber exec 'puts User.count' |
encrypt |
Manage encrypted environment files | amber encrypt production |
pipelines |
Show pipeline configuration | amber pipelines |
setup:lsp |
Configure the Amber LSP for Claude Code | amber setup:lsp |
Run amber --help or amber [command] --help for detailed usage information.
- Built-in generators for models, controllers, views, and more
- Configurable custom generators with YAML/JSON configuration
- Intelligent word transformations (snake_case, PascalCase, pluralization)
- Template-based file generation with variable substitution
- Full migration support with rollback capabilities
- Multi-database support (PostgreSQL, MySQL, SQLite)
- Database seeding and status reporting
- Environment-specific configuration
- File watching with automatic rebuild and restart
- Interactive code execution within application context
- Route analysis and pipeline inspection
- Environment file encryption for security
- Built-in Language Server Protocol (LSP) server for Claude Code integration
- 15 convention rules that catch framework mistakes as you type
- Custom YAML-based rules for project-specific conventions
- One command to set up:
amber setup:lsp
- Plugin system for extending functionality
- Command registration system for custom commands
- Template engine for flexible file generation
- Configuration-driven behavior
- Built entirely with Crystal's standard library
- No external CLI frameworks or template engines
- Fast compilation and lightweight binary
- Base command class for consistent behavior
- Command registry for easy extension
- Built-in option parsing and validation
- Comprehensive error handling
- ECR-based template processing
- Variable substitution with transformations
- Conditional file generation
- Post-generation command execution
Amber ships with a diagnostics-only Language Server that integrates with Claude Code. When you develop with Claude Code, the LSP runs in the background and automatically catches framework convention violations — wrong controller names, missing methods, bad inheritance, file naming issues, and more. Claude sees these diagnostics and self-corrects without you having to notice or intervene.
This is the recommended way to develop with Amber. The LSP turns Claude Code from a general-purpose coding assistant into one that understands Amber's conventions natively.
# From your Amber project directory:
amber setup:lspThis creates three files:
| File | Purpose |
|---|---|
.lsp.json |
Tells Claude Code where the LSP binary is and what files it handles |
.claude-plugin/plugin.json |
Plugin manifest so Claude Code discovers the LSP |
.amber-lsp.yml |
Rule configuration — customize severity, disable rules, add custom rules |
Then open Claude Code in your project. The LSP activates automatically.
The LSP ships with 15 built-in rules covering controllers, jobs, channels, pipes, mailers, schemas, routing, file naming, directory structure, and more. Every rule maps to an Amber convention — if Claude generates a controller that doesn't end with Controller, or a job without a perform method, the LSP flags it immediately.
You can define project-specific rules in .amber-lsp.yml using regex patterns. No recompilation needed:
custom_rules:
- id: "project/no-puts"
description: "Do not use puts in production code"
severity: warning
applies_to: ["src/**"]
pattern: "^\\s*puts\\b"
message: "Avoid 'puts' in production code. Use Log.info instead."If amber-lsp is not on your PATH, the setup:lsp command will offer to build it:
cd ~/open_source_coding_projects/amber_cli
crystal build src/amber_lsp.cr -o bin/amber-lsp --releaseFor full documentation on all 15 rules, configuration options, and custom rule syntax, see the LSP Setup Guide.
# Create model, controller, views, and migration
amber generate scaffold Post title:String content:Text published:Bool
# Or generate individually
amber generate model Post title:String content:Text
amber generate controller Posts
amber generate migration add_published_to_posts published:Bool# Watch with custom build commands
amber watch --build "crystal build src/app.cr --release" --run "./app"
# Execute code in application context
amber exec 'Post.where(published: true).count'
# Encrypt production environment
amber encrypt production --editor vim# Create and set up database
amber database create
amber database migrate
amber database seed
# Check migration status
amber database status
# Rollback last migration
amber database rollbackAmber CLI uses several configuration files:
.amber.yml- Project-specific settingsconfig/environments/- Environment configurationsgenerator_configs/- Custom generator definitions
Example .amber.yml:
database: pg
language: slang
model: granite
watch:
run:
build_commands:
- "crystal build ./src/my_app.cr -o bin/my_app"
run_commands:
- "bin/my_app"
include:
- "./config/**/*.cr"
- "./src/**/*.cr"We welcome contributions! Please read our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b my-new-feature) - Write tests for your changes
- Ensure all tests pass (
crystal spec) - Follow Crystal's code formatting (
crystal tool format) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a Pull Request
- Crystal 1.0+ (latest stable recommended)
- Git (for project templates)
- Database (PostgreSQL, MySQL, or SQLite)
Common issues and solutions:
Database connection errors:
# Verify database is running and check config
amber database statusGeneration failures:
# Check template availability
amber generate --listWatch mode not working:
# Show current configuration
amber watch --infoFor more detailed troubleshooting, see the full documentation.
This project is licensed under the MIT License - see the LICENSE file for details.
- Amber Framework - The Crystal web framework
- Crystal Language - The programming language
- All the amazing contributors