ForgeKit
ForgeKit
Go Backend Generator
Build β’ Extend β’ Ship
Generate production-ready Go REST APIs with a clean hexagonal architecture.
ForgeKit is a developer CLI written in Go that helps you bootstrap backend REST APIs without manually creating the same project structure, configuration, database integration, Docker files, migrations, and tests every time.
The goal is simple:
forgekit init my-api
and get a structured Go backend ready for development.
β¨ Features
- Generate Go REST APIs
- Hexagonal architecture
- PostgreSQL integration
- Docker and Docker Compose
- Database migrations
- Environment configuration
- Automatic tests
- Automatic Go formatting
- Architecture validation
- Development environment diagnostics
- Project analysis with scoring
- Human-readable or JSON output
- Extensible CLI architecture
- Feature system (
forgekit add / forgekit remove) for extending generated projects
- JWT authentication infrastructure (
forgekit add auth)
- CORS middleware (
forgekit add cors)
- Structured logging (
forgekit add logging)
- Swagger/OpenAPI documentation (
forgekit add swagger)
- CI/CD integration with
--ci mode
- Project diagnostics with
forgekit doctor
- Feature version tracking and rollback
Installation
Linux (Debian/Ubuntu) β Recommended (APT)
Install ForgeKit from the official APT repository:
# 1. Add the ForgeKit GPG key (Deb822 format)
curl -fsSL https://demetrius-ch.github.io/forgekit/forgekit-archive-keyring.gpg \
| sudo gpg --dearmor -o /usr/share/keyrings/forgekit-archive-keyring.gpg
# 2. Add the APT repository
echo "deb [signed-by=/usr/share/keyrings/forgekit-archive-keyring.gpg] https://demetrius-ch.github.io/forgekit stable main" \
| sudo tee /etc/apt/sources.list.d/forgekit.sources
# 3. Update and install
sudo apt update
sudo apt install forgekit
# 4. Verify installation
forgekit version
Note: The package also provides forge as a backward-compatibility alias. Both forgekit and forge commands work identically.
Uninstall:
sudo apt remove forgekit
# Optionally remove the repository and key
sudo rm /etc/apt/sources.list.d/forgekit.sources /usr/share/keyrings/forgekit-archive-keyring.gpg
sudo apt update
Linux (Debian/Ubuntu) β Manual .deb download
Download the latest .deb package from GitHub Releases:
# Replace VERSION with the desired version (e.g., 0.3.0)
VERSION=0.3.0
wget https://github.com/Demetrius-ch/forgekit/releases/download/v${VERSION}/forgekit_${VERSION}_linux_amd64.deb
sudo dpkg -i forgekit_${VERSION}_linux_amd64.deb
forgekit version
Uninstall:
sudo apt remove forgekit
From source
Requirements:
- Go 1.22+
- Git
- Docker (required for the generated project's Docker workflow)
Clone the repository:
git clone git@github.com:Demetrius-ch/forgekit.git
cd forgekit
Build ForgeKit:
go build -o forgekit ./cmd/forge
Install it globally:
go install ./cmd/forge
Verify the installation:
forgekit version
Binary (Linux)
Download the static binary from GitHub Releases:
# Replace VERSION with the desired version (e.g., 0.3.0)
VERSION=0.3.0
wget https://github.com/Demetrius-ch/forgekit/releases/download/v${VERSION}/forgekit_${VERSION}_linux_amd64.tar.gz
tar -xzf forgekit_${VERSION}_linux_amd64.tar.gz
sudo mv forgekit /usr/local/bin/
forgekit version
Verify checksums (SHA256):
wget https://github.com/Demetrius-ch/forgekit/releases/download/v${VERSION}/checksums.txt
sha256sum -c checksums.txt
Usage
The primary command is forgekit. The forge alias is also available for backward compatibility.
Initialize a project
forgekit init my-api
ForgeKit interactively asks for the project configuration and generates the backend.
You can also use non-interactive mode:
forgekit init my-api \
--module github.com/example/my-api \
--port 8080 \
--db-name my_api \
--non-interactive
Specify a target directory:
forgekit init my-api --dir /tmp/my-api
Preview the files without creating them:
forgekit init my-api --dry-run
Generated project
A generated project follows a structure similar to:
my-api/
βββ cmd/
β βββ server/
β βββ main.go
β
βββ internal/
β βββ application/
β β βββ health/
β β βββ user/
β β
β βββ domain/
β β βββ health.go
β β βββ user.go
β β
β βββ infrastructure/
β β βββ config/
β β βββ postgres/
β β
β βββ transport/
β βββ http/
β βββ handler/
β βββ router.go
β
βββ migrations/
β βββ 000001_init.up.sql
β βββ 000001_init.down.sql
β
βββ docker/
β βββ Dockerfile
β βββ docker-compose.yml
β
βββ tests/
βββ .env.example
βββ .gitignore
βββ forge.yaml
βββ Makefile
βββ README.md
βββ go.mod
βββ go.sum
After installing features (e.g., forgekit add auth), the structure extends with:
my-api/
βββ internal/
β βββ auth/
β βββ jwt.go
β βββ middleware.go
βββ .forge/
β βββ features.yaml
βββ .env.example (extended with JWT_SECRET)
Architecture
ForgeKit generates a backend organized around hexagonal architecture.
ββββββββββββββββββββββββ
β HTTP API β
β Transport Layer β
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Application β
β Services β
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Domain β
β Business Logic β
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Infrastructure β
β PostgreSQL / Config β
ββββββββββββββββββββββββ
The objective is to keep business logic independent from infrastructure and transport concerns.
Run the generated API with Docker
Enter the generated project:
cd my-api
Copy the environment configuration:
cp .env.example .env
Start the complete stack:
docker compose -f docker/docker-compose.yml up --build
The stack includes:
- PostgreSQL
- Database migrations
- Go API
The API is available by default on:
http://localhost:8080
Test the health endpoint:
curl http://localhost:8080/health
Expected response:
{
"service": "my-api",
"status": "ok"
}
Extend a generated project with forgekit add
ForgeKit introduces an extensible feature system to add capabilities to existing projects.
List available features
forgekit add --list
Output:
ForgeKit Features
ββββββββββββββββββββββββββββββββ
auth 1.0.0 β Infrastructure d'authentification JWT (middleware, validation de token)
cors 1.0.2 β Middleware CORS pour les requΓͺtes cross-origin
logging 1.0.0 β Logging structurΓ© et middleware HTTP
swagger 1.0.1 β Documentation OpenAPI/Swagger
Each feature shows its name, version, description, and dependencies (if any).
Preview a feature installation (plan mode)
forgekit add auth --plan
Output:
ForgeKit Plan
ββββββββββββββββββββββββββββββββ
Feature: auth
Version: 1.0.0
Changes:
+ internal/auth/jwt.go
+ internal/auth/middleware.go
Dependencies:
β github.com/golang-jwt/jwt/v5 v5.2.0
Environment:
β JWT_SECRET=your-secret-key-change-in-production
No files were modified.
The --plan (or --dry-run) flag shows what would be created/modified/deleted without making any changes.
Install a feature
forgekit add auth
Output:
ForgeKit Add
ββββββββββββββββββββββββββββββββ
β Projet ForgeKit dΓ©tectΓ©
β Feature "auth" trouvΓ©e
β PrΓ©requis validΓ©s
β Plan validΓ©
Installation...
β Fichiers installΓ©s
β DΓ©pendances installΓ©es
β Projet validΓ©
ββββββββββββββββββββββββββββββββ
β Feature "auth" installΓ©e avec succΓ¨s
The auth feature adds:
internal/auth/jwt.go β JWT token generation and validation
internal/auth/middleware.go β HTTP middleware for authentication
- Dependency:
github.com/golang-jwt/jwt/v5
- Environment variable:
JWT_SECRET in .env.example
- Tracks installation in
.forge/features.yaml
Idempotency
Running forgekit add auth twice is safe:
$ forgekit add auth
β Feature "auth" installΓ©e avec succΓ¨s
$ forgekit add auth
β Feature "auth" dΓ©jΓ installΓ©e
JSON output
All commands support --format json for machine-readable output:
forgekit add --list --format json
forgekit add auth --dry-run --format json
Quiet mode
Suppress non-essential output:
forgekit add auth --quiet
Remove a feature
forgekit remove auth
Before removal, ForgeKit checks:
- Feature is installed
- No other installed features depend on it
- Detects user modifications to feature files
Output:
ForgeKit Remove
ββββββββββββββββββββββββββββββββ
β Projet ForgeKit dΓ©tectΓ©
β Feature "auth" trouvΓ©e
β Aucune feature dΓ©pendante
Suppression...
β Fichiers supprimΓ©s
β DΓ©pendances retirΓ©es
β Projet validΓ©
ββββββββββββββββββββββββββββββββ
β Feature "auth" supprimΓ©e avec succΓ¨s
Preview removal with --plan:
forgekit remove auth --plan
JSON output
All commands support --format json for machine-readable output:
forgekit add --list --format json
forgekit add auth --plan --format json
forgekit remove auth --format json
forgekit doctor --format json
forgekit analyze --format json
Example JSON output:
{
"schema_version": "1",
"tool": "forgekit",
"version": "0.3.0",
"command": "add",
"features": [
{"name": "auth", "version": "1.0.0", "description": "..."},
{"name": "cors", "version": "1.0.2", "description": "..."}
]
}
Quiet mode
Suppress non-essential output:
forgekit add auth --quiet
Validate a generated project
ForgeKit provides several commands to help developers verify their project.
Doctor
Check the development environment and project health:
forgekit doctor
Output includes:
- ForgeKit version
.forge signature validation (valid, legacy, absent, invalid)
- Installed feature versions (vs registry)
- Go, Git, Docker availability
- PostgreSQL configuration
- Project structure (go.mod, .env, docker-compose.yml)
- Architecture rules, security, dependencies, documentation
CI mode (non-interactive, deterministic, exit codes):
forgekit doctor --ci
Exit codes: 0 = success, 1 = warnings/errors, 2 = execution error
JSON output:
forgekit doctor --format json
Check
Validate architectural conventions:
forgekit check
Analyze
Analyze the project structure and practices across categories:
- Architecture
- Tests
- Security
- Configuration
- Docker
- Documentation
forgekit analyze
Output shows category scores (0-100), global score, and recommendations.
CI mode (non-interactive, deterministic, exit codes):
forgekit analyze --ci
Exit codes: 0 = success, 1 = issues detected, 2 = execution error
JSON output:
forgekit analyze --format json
Run tests
Inside the generated project:
go test ./...
Run static analysis
go vet ./...
CLI
Display the available commands:
forgekit --help
Available commands include:
add
analyze
check
completion
config
doctor
init
inspect
remove
version
Global options:
--debug
--format
--quiet
CI modes (non-interactive, deterministic, exit codes 0/1/2):
forgekit doctor --ci
forgekit analyze --ci
JSON output can be requested with:
forgekit --format json doctor
forgekit --format json analyze
forgekit add --list --format json
forgekit add auth --plan --format json
forgekit remove auth --format json
Feature system architecture
ForgeKit introduces a generic feature infrastructure in internal/feature/:
- Feature interface β Defines
Name(), Description(), Version(), Check(), Plan(), Apply()
- FeatureDependencies (optional) β Declares dependencies via
DependsOn() []string
- FeatureRemover (optional) β Supports removal via
Remove()
- ProjectContext β Project metadata (root, module, Go version, type)
- Manifest β Feature resources (dependencies, files, environment variables)
- Plan β Computed installation/removal plan with conflict detection
- Registry β Feature registration and dependency resolution (topological sort)
- Detector β Validates ForgeKit project structure (ForgeKit, legacy, external compatible, invalid)
- Installer β Applies plans with rollback support and idempotent operations
- Installed tracking β
.forge/features.yaml records installed features with versions
Feature dependencies
Features can declare dependencies on other features:
func (MyFeature) DependsOn() []string {
return []string{"auth"} // auth must be installed first
}
When installing a feature with dependencies:
- Dependencies are automatically resolved and installed first
- Topological sort ensures correct installation order
- Circular dependencies are detected and rejected
Current feature dependency graph:
auth (no deps)
βββ cors (depends on auth)
βββ logging (depends on auth)
βββ swagger (depends on cors)
.forge system
The .forge/ directory tracks project metadata and installed features:
.forge/
βββ forge.yaml # Project metadata (version, schema, project name, type)
βββ features.yaml # Installed features with versions and timestamps
Signature validation (used by doctor, analyze, inspect):
- Valid: Both
forge.yaml and features.yaml present, schema compatible
- Legacy: Only
features.yaml (v0.1.x projects)
- Absent: No
.forge directory (external projects)
- Invalid: Directory exists but missing required files or schema incompatible
Adding a new feature
- Implement the
Feature interface in internal/feature/<name>/
- Add template files in
internal/template/api/internal/<name>/
- Register the feature in
internal/cli/commands.go in newAddCommand() and newRemoveCommand()
Rollback System
ForgeKit includes a rollback mechanism to restore project state when feature installation fails.
How it works
-
Before installation: A complete snapshot is taken of:
go.mod and go.sum
.env.example
.forge/ directory (metadata and features.yaml)
-
On failure: Automatic rollback restores all captured files
-
Verification: Post-rollback verification ensures state matches the snapshot
Capabilities
| Can Rollback |
Cannot Rollback |
go.mod / go.sum content |
Go module cache (GOMODCACHE) |
.env.example file content |
Docker container state |
.forge/forge.yaml metadata |
External databases |
.forge/features.yaml installed features |
Git history |
Feature-generated files (internal/*) |
System packages (apt/brew) |
|
gofmt whitespace changes |
Limitations
- Not transactional: External operations (
go get, go mod tidy, Docker) cannot be fully undone
- Module cache:
go get downloads modules to GOMODCACHE which persists
- Docker: Container state, volumes, and networks are not managed
- External services: PostgreSQL databases, Redis, etc. are outside ForgeKit's control
- Git: Commits, tags, branches are not modified by ForgeKit
Manual rollback
If automatic rollback fails, restore from snapshot:
# Manual restoration from backups
cp go.mod.bak go.mod
cp go.sum.bak go.sum
rm -rf .forge
# Then restore from your backups
Limitations
Current v0.3.0 limitations:
- No feature version upgrade path (manual intervention required)
- Features must be registered in the CLI binary (no plugin system yet)
- External project support is limited to compatible Go projects with Chi router
- Rollback cannot undo external operations (Go module cache, Docker, databases)
β‘ Why ForgeKit?
Creating a backend from scratch often means repeating the same work:
Create directories
β
Create Go modules
β
Configure HTTP server
β
Configure PostgreSQL
β
Create migrations
β
Create Docker files
β
Create tests
β
Configure environment
β
Check architecture
β
Format code
β
Run tests
ForgeKit turns this repetitive process into:
forgekit init my-api
And extends it with features:
forgekit add auth
The developer can then focus on the actual business logic.
Project philosophy
ForgeKit is not intended to hide Go from developers.
It is intended to eliminate repetitive boilerplate while keeping the generated project:
- readable
- conventional
- testable
- maintainable
- extensible
- understandable by any Go developer
The generated project belongs to the developer. ForgeKit does not create a proprietary runtime or lock the project into a framework.
π£ Roadmap
v0.1.0
- Go REST API generation
- Hexagonal architecture
- PostgreSQL
- Docker
- Database migrations
- Project tests
-
forge doctor
-
forge check
-
forge analyze
v0.2.0
- Feature system (
forge add)
- JWT authentication (
forge add auth)
- Idempotent feature installation
- Dry-run support
- JSON/quiet output modes
- Redis integration
- Swagger/OpenAPI generation
- Additional database options
- More project templates
- Better project analysis
- More automated architecture rules
Future
Potential directions:
- Plugin system
- More backend architectures
- Microservice templates
- CI/CD generation
- Cloud deployment templates
- Templates for other ecosystems
Contributing
Contributions are welcome.
Fork the repository, create a branch, make your changes, and open a pull request.
Before submitting a pull request, run:
gofmt -w .
go test ./...
go vet ./...
go build ./...
License
See the repository license for details.
Support the project
If ForgeKit is useful to you, consider starring the repository on GitHub.
Issues, feature requests, documentation improvements, and pull requests are welcome.
Changelog
v0.2.0 (2026-08-10)
- Added
forge add command with extensible feature system
- Implemented
forge add auth for JWT authentication infrastructure
- Added
--list, --dry-run, --format json, --quiet flags
- Added progress display with spinners and colored output
- Added
.forge/features.yaml for tracking installed features
- Added rollback mechanism for failed installations
- Added comprehensive unit tests for feature system
- Updated generated project structure with
internal/auth/
v0.1.2
- Initial release with
forge init, forge doctor, forge check, forge analyze
- Hexagonal architecture scaffolding
- PostgreSQL, Docker, migrations, tests
ForgeKit β Build the backend, not the boilerplate.