The Spring Boot CLI that Spring forgot to build
Documentation · Releases · Report Bug · Discussions
Table of Contents
You start a Spring Boot project with Spring Initializr. Great. Now what?
Every new feature means the same tedious ritual:
- Create
UserEntity.java - Create
UserRepository.java - Create
UserService.java - Create
UserServiceImpl.java - Create
UserController.java - Create
UserRequest.java - Create
UserResponse.java - Create
UserMapper.java
8 files. Every. Single. Time.
Copy-paste from existing code. Fix the class names. Fix the imports. Miss something. Debug. Repeat.
haft generate resource UserDone. All 8 files. Properly structured. Matching your project's existing patterns.
Haft doesn't just generate boilerplate — it learns from your codebase and generates code that matches your existing conventions.
| Detection | What It Does |
|---|---|
| Architecture Pattern | Layered, Feature/Package-by-Feature, Hexagonal, Clean, Modular |
| Feature Style | Flat (user/UserController.java) vs Nested (user/controller/UserController.java) |
| DTO Naming | UserRequest/UserResponse vs UserDTO |
| ID Type | Long vs UUID with correct annotations |
| Lombok Usage | @Data, @Builder, @NoArgsConstructor, @AllArgsConstructor |
| Mapper Type | MapStruct, ModelMapper, or manual mapping |
| Base Entity | Extends your BaseEntity if detected |
| Validation Style | Jakarta (jakarta.validation) vs Javax (javax.validation) |
| Swagger/OpenAPI | Adds @Operation, @Tag annotations if detected |
| Database Type | JPA, MongoDB, Cassandra, R2DBC |
First run scans your project and caches the profile to .haft/profile.json. Subsequent runs are instant.
# First run (~200ms) - scans and caches
haft generate resource User
# Second run (~10ms) - uses cache
haft generate resource Product
# Force re-scan if needed
haft generate resource Order --refresh| Spring Initializr | Haft | |
|---|---|---|
| Project Bootstrap | ✅ | ✅ |
| Works Offline | ❌ | ✅ |
| Resource Generation | ❌ | ✅ |
| Intelligent Detection | ❌ | ✅ |
| Architecture Aware | ❌ | ✅ |
| Test Generation | ❌ | ✅ |
| Dependency Management | ❌ | ✅ |
| Interactive TUI | ❌ | ✅ |
| Lifecycle Companion | ❌ | ✅ |
Haft works completely offline. No web browser. No internet dependency. Just you and your terminal.
curl -fsSL https://raw.githubusercontent.com/KashifKhn/haft/main/install.sh | bashNote: You can inspect the install.sh script before running it. We prioritize security and transparency.
Linux
# AMD64
curl -L https://github.com/KashifKhn/haft/releases/latest/download/haft-linux-amd64.tar.gz | tar xz
sudo mv haft-linux-amd64 /usr/local/bin/haft
# ARM64
curl -L https://github.com/KashifKhn/haft/releases/latest/download/haft-linux-arm64.tar.gz | tar xz
sudo mv haft-linux-arm64 /usr/local/bin/haftmacOS
# Intel
curl -L https://github.com/KashifKhn/haft/releases/latest/download/haft-darwin-amd64.tar.gz | tar xz
sudo mv haft-darwin-amd64 /usr/local/bin/haft
# Apple Silicon
curl -L https://github.com/KashifKhn/haft/releases/latest/download/haft-darwin-arm64.tar.gz | tar xz
sudo mv haft-darwin-arm64 /usr/local/bin/haftWindows
Invoke-WebRequest -Uri "https://github.com/KashifKhn/haft/releases/latest/download/haft-windows-amd64.zip" -OutFile "haft.zip"
Expand-Archive -Path "haft.zip" -DestinationPath "."
Move-Item "haft-windows-amd64.exe" "$env:LOCALAPPDATA\Microsoft\WindowsApps\haft.exe"Or download manually from Releases.
Go
go install github.com/KashifKhn/haft/cmd/haft@latestFrom Source
git clone https://github.com/KashifKhn/haft.git
cd haft
make build
sudo mv bin/haft /usr/local/bin/Shell Completions
Enable tab completions for your shell:
# Bash
haft completion bash > /etc/bash_completion.d/haft
# Zsh
haft completion zsh > "${fpath[1]}/_haft"
# Fish
haft completion fish > ~/.config/fish/completions/haft.fish
# PowerShell
haft completion powershell > haft.ps1haft initAn interactive wizard guides you through project setup:
? Project name: my-api
? Group ID: com.example
? Java version: 21
? Spring Boot: 3.4.1
? Dependencies: web, data-jpa, lombok, validation
cd my-app
# Generate a complete CRUD resource
# Haft automatically detects your architecture and conventions
haft generate resource UserGenerated files match your project structure:
# If your project uses Feature/Package-by-Feature (flat style):
user/
├── UserController.java
├── UserService.java
├── UserServiceImpl.java
├── UserRepository.java
├── User.java
├── UserMapper.java
└── dto/
├── UserRequest.java
└── UserResponse.java
# If your project uses Layered architecture:
controller/UserController.java
service/UserService.java
service/impl/UserServiceImpl.java
repository/UserRepository.java
entity/User.java
dto/UserRequest.java
dto/UserResponse.java
mapper/UserMapper.java
# Generate resource + unit/integration tests
haft generate resource Product
# Skip test generation
haft generate resource Payment --skip-testsGenerated test files:
# ServiceTest - Unit tests with Mockito
# ControllerTest - Integration tests with MockMvc
# RepositoryTest - Integration tests with @DataJpaTest
# EntityTest - Unit tests for entity
haft generate controller Product # haft g co Product
haft generate service Order # haft g s Order
haft generate repository Payment # haft g repo Payment
haft generate entity Customer # haft g e Customer
haft generate dto Invoice # Request + Response DTOs# Interactive selection of security types
haft generate security
# Generate JWT authentication
haft generate security --jwt
# Generate session-based authentication
haft generate security --session
# Generate OAuth2 authentication (Google, GitHub, Facebook)
haft generate security --oauth2
# Generate all security types
haft generate security --allGenerated files for JWT:
security/
├── SecurityConfig.java
├── JwtUtil.java
├── JwtAuthenticationFilter.java
├── AuthenticationController.java
├── CustomUserDetailsService.java
└── dto/
├── AuthRequest.java
├── AuthResponse.java
├── RegisterRequest.java
└── RefreshTokenRequest.java
# Interactive search picker
haft add
# Browse by category
haft add --browse
# Add using shortcuts (330+ available)
haft add lombok validation jwt
# Add using Maven coordinates (auto-verified)
haft add org.mapstruct:mapstruct
# Remove dependencies
haft remove lombok
haft remove # Interactive pickerhaft dev serve # Start with hot-reload
haft dev build # Build project
haft dev test # Run tests
haft dev clean # Clean artifactshaft info # Project information
haft info --loc # With lines of code
haft routes # List REST endpoints
haft routes --files # With file locations
haft stats # Code statistics
haft stats --cocomo # COCOMO cost estimates- Intelligent Detection — Learns from your codebase patterns
- Architecture Aware — Supports Layered, Feature, Hexagonal, Clean, Modular
- Test Generation — Unit and integration tests with Mockito, MockMvc
- Profile Caching — Instant subsequent runs with
.haft/profile.json - Interactive TUI — Beautiful terminal interface with keyboard navigation
- Offline First — No internet required, all metadata bundled
- Smart Defaults — Sensible defaults that match industry standards
- Back Navigation — Made a mistake? Press
Escto go back - Dependency Search — Find any dependency with
/ - Maven Central Verification — Auto-verify and fetch latest versions
| Key | Action |
|---|---|
↑ ↓ |
Navigate |
Enter |
Select |
Esc |
Go back |
Space |
Toggle |
/ |
Search |
Tab |
Next category |
0-9 |
Jump to category |
Haft automatically detects and generates code for:
| Architecture | Description |
|---|---|
| Layered | Traditional controller/, service/, repository/, entity/ |
| Feature | Package-by-feature with nested or flat structure |
| Hexagonal | Ports & Adapters with adapter/, application/, domain/ |
| Clean | Clean Architecture with usecase/, gateway/, infrastructure/ |
| Modular | Modular monolith with api/, internal/ |
- Project initialization wizard
- All Spring Initializr dependencies
- Maven & Gradle support
- Intelligent architecture detection
- Test generation
- Profile caching
-
haft generate resource— Full CRUD generation -
haft add/haft remove— Dependency management -
haft dev— Development commands -
haft info/haft routes/haft stats— Project analysis - Shell completions (bash, zsh, fish, powershell)
- Security configuration (JWT, Session, OAuth2)
- Custom templates
- Neovim integration
- VS Code extension
- IntelliJ plugin
- Go - High-performance compiled binary.
- Bubble Tea - The TUI framework.
- Cobra - CLI command structure.
Contributions are welcome. See CONTRIBUTING.md for guidelines.
MIT License. See LICENSE for details.
Built for developers who value their time
