Forge is a command‑line tool that helps you manage database migrations, environment configuration, and project scaffolding from a single, opinionated CLI.
It is built with Go and designed to be simple to integrate into your workflow, while staying powerful enough for real projects.
-
Database migrations
- Apply pending migrations in order (
forge db migrate). - Roll back the last batch of migrations (
forge db rollback). - Track applied migrations in the database using a dedicated
migrationstable. - Generate SQL migration files from stubs (
forge db make:sql <name>).
- Apply pending migrations in order (
-
Migration templates
- Generate
.sqlfiles from stub templates (e.g.create_table_users). - Built‑in stub support (e.g.
create_table,update_table) with priority for user‑defined stubs indatabase/stubs.
- Generate
-
Environment management
- Initialize
.env.forgewith Forge-specific variables (forge init). - Show the current Forge config file (
forge env).
- Initialize
-
Project scaffolding
- Interactive wizard to create a new project:
- Go project skeleton (
--lang go) - Node.js project (
--lang node) - TypeScript project (
--lang ts) - Empty project (
--lang empty) - From Git repository template (
--from <url>)
- Go project skeleton (
- Optional
--git-initto initialize a git repo right after scaffolding.
- Interactive wizard to create a new project:
-
Git integration
- Add git to an existing project and configure a remote:
forge project git:add- Supports
--dirand--remoteflags.
- Creates an initial commit if there are no commits yet.
- Add git to an existing project and configure a remote:
-
Upgrade
forge upgradedownloads the latest release from GitHub and replaces the current binary (in‑place update).
-
Plugin support
- Load local project plugins from
.forge/pluginsand global plugins from~/.forge/plugins. - Create plugin scaffolds with
forge plugins create <vendor>/<name>. - Build source-based Go plugins with
forge plugins build <vendor>/<name>. - Install a local plugin globally with
forge plugins install <vendor>/<name>. - Auto-build Go plugins declared with
"source": "src"before execution.
- Load local project plugins from
You can install Forge either from a GitHub release (recommended) or from source.
Go to your repository releases page:
https://github.com/acolev/forge/releases/latest
Pick the binary for your OS/architecture. With the default release naming pattern:
forge-darwin-arm64– macOS (Apple Silicon)forge-darwin-amd64– macOS (Intel)forge-linux-amd64– Linux x86_64
curl -L https://github.com/acolev/forge/releases/latest/download/forge-darwin-arm64 -o /usr/local/bin/forge
chmod +x /usr/local/bin/forge
forge --helpcurl -L https://github.com/acolev/forge/releases/latest/download/forge-darwin-amd64 -o /usr/local/bin/forge
chmod +x /usr/local/bin/forge
forge --helpcurl -L https://github.com/acolev/forge/releases/latest/download/forge-linux-amd64 -o /usr/local/bin/forge
chmod +x /usr/local/bin/forge
forge --helpIf you prefer to avoid
sudo/root, you can install Forge into a directory in your$HOME, such as~/bin, and add it to yourPATH.
Example:
mkdir -p ~/bin
curl -L https://github.com/acolev/forge/releases/latest/download/forge-darwin-arm64 -o ~/bin/forge
chmod +x ~/bin/forge
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
forge --helpgit clone https://github.com/acolev/forge.git
cd forge
go mod tidy
go build -o forge ./cmd/main.go
# Move the binary to a directory in your PATH, for example:
mv forge /usr/local/bin/forgeOnce Forge is installed, you can upgrade to the latest release with:
forge upgradeThis will:
- Fetch the latest release from GitHub.
- Download the binary asset matching your OS/architecture (e.g.
forge-darwin-arm64). - Replace the current
forgebinary in place.
If Forge is installed in a system directory (e.g.
/usr/local/bin), you may need to run:sudo forge upgrade
You can also repeat the install from GitHub Releases steps with a newer version:
- Download the new binary.
- Replace your existing
forgebinary. - Make sure it is executable.
General pattern:
forge <group> <command> [flags]Examples:
forge db migrateforge db rollbackforge db make:sql create_table_usersforge seed make usersforge seed upforge project createforge project git:addforge upgradeforge plugins create bookly/migrateforge plugins build bookly/migrateforge plugins install bookly/migrate
Create or update the .env.forge file for Forge-specific settings:
forge initTypical responsibilities:
- Create
.env.forgeif it does not exist. - Ensure Forge variables are present without colliding with application env.
Example:
FORGE_DB_DSN=sqlite://database/database.db
FORGE_PLUGINS_DIR=.forge/pluginsDisplay the current Forge config file contents, or resolved defaults if the file does not exist:
forge envForge supports both local and global plugins:
- Local plugins live in
.forge/plugins - Global plugins live in
~/.forge/plugins - Local is the default for
createandbuild
Create a local Go plugin:
forge plugins create bookly/migrateThis creates:
.forge/plugins/bookly/migrate/plugin.json
.forge/plugins/bookly/migrate/src/go.mod
.forge/plugins/bookly/migrate/src/main.go
Build a local plugin:
forge plugins build bookly/migrateBuild a global plugin:
forge plugins build bookly/migrate --globalInstall a local plugin into the global plugin directory:
forge plugins install bookly/migrateIf a plugin manifest declares:
{
"lang": "go",
"entry": "migrate",
"source": "src"
}Forge will build the platform-specific binary automatically before running the plugin.
Current hooks exposed by Forge:
db.migrate.beforedb.migrate.afterproject.create.beforeproject.create.after
Example hook scaffold:
forge plugins create bookly/migrate --hook db.migrate.beforeThis creates a plugin manifest with:
{
"hooks": {
"db.migrate.before": {
"command": "db-migrate-before"
}
}
}Notes:
- Hook payloads are not forwarded to plugins yet.
- For Go plugins, Forge auto-builds the binary before executing the hook.
Forge manages migrations stored in ./database/migrations and tracks them in a migrations database table.
Create a new SQL migration file using a naming convention and optional stub:
forge db make:sql create_table_usersThis will generate a file like:
database/migrations/1763632453_create_table_users.sql
The file will have the following structure:
-- UP
-- your SQL goes here
-- DOWN
-- your rollback SQL goes hereIf a stub exists for the prefix (for example create_table.stub.sql in database/stubs), Forge will use it and replace placeholders like {table_name}.
User‑defined stubs in database/stubs have priority over built‑in ones.
Run all pending migrations in ascending order:
forge db migrateForge will:
- Read all
.sqlfiles fromdatabase/migrations. - Check which ones are not yet applied (via the
migrationstable). - Execute the
-- UPsection of each pending migration. - Store the migration file name and batch number in the
migrationstable.
Rollback the last batch of applied migrations:
forge db rollbackForge will:
- Find the highest
batchnumber in themigrationstable. - For all migrations in that batch:
- Read the corresponding file.
- Execute the
-- DOWNsection. - Remove migration records from the
migrationstable.
Forge stores YAML seed files in ./database/seeds.
Available commands:
forge seed make users
forge seed up
forge seed run --only=users
forge seed status
forge seed resetCreate a fixture seed scaffold:
forge seed make usersCreate other types:
forge seed make roles --type sql
forge seed make bootstrap --type goFixture seeds support either explicit rows or generated rows via count + template.
Example:
name: users
type: fixture
table: users
count: 10
template:
name: "fake:full_name"
email: "fake:email"
phone: "fake:phone"
is_active: "fake:bool"Built-in fake tokens:
fake:first_namefake:last_namefake:full_namefake:emailfake:companyfake:phonefake:sentencefake:uuidfake:boolfake:int:min:max
Example:
template:
age: "fake:int:18:65"
company: "fake:company"Apply all pending seeders:
forge seed upApply only selected seeders:
forge seed run --only=users,rolesShow executed seeders:
forge seed statusReset only seeder execution state:
forge seed resetOnly migrations that have a valid
-- DOWNsection can be rolled back.
Forge can bootstrap new projects via forge project create.
forge project createYou will be guided through a wizard:
-
Choose project type:
- Go project
- Node.js project
- TypeScript project
- Empty project
- From Git repository URL
-
Project name:
- Default: derived from the Git URL or
forge-project.
- Default: derived from the Git URL or
-
Target directory:
- Default:
./<project-name>. - If you enter
., Forge will use the current directory (no need for it to be empty, but use with care).
- Default:
-
Optionally, if you created the project with
--git-init, Forge will initialize a git repository inside the project.
You can skip the wizard by passing flags:
forge project create --lang go --name my-api --dir ./services/my-api --git-initforge project create --lang node --name my-appforge project create --lang ts --name my-ts-appforge project create --lang empty --name sandboxforge project create --from https://github.com/user/template.git --name booking-apiIn template mode Forge will:
- Clone the repository into a temporary directory.
- Remove the
.gitfolder from the template. - Copy files into your target directory.
- Optionally initialize a new git repository (
--git-init).
Command:
forge project git:addWithout flags, Forge will:
- Use the current directory as the project root.
- Initialize git if
.gitfolder is missing. - Run
git add .. - Create an initial commit if there are no commits yet.
- Ask for a remote URL and add it as
origin. - Ask if it should push the initial commit to
origin main.
forge project git:add --dir ./services/api --remote git@github.com:you/api.gitFlags:
--dir— project directory (default: current directory).--remote— remote URL fororigin. If omitted, Forge will ask interactively.
-
cmd/
Entry point for the CLI (main.go). -
internal/migrations/
Migration logic (create, run, rollback). -
internal/project/
Project scaffolding (project create,project git:add). -
internal/plugins/
Plugin loading and registration. -
internal/selfupdate/
Upgrade logic (upgradecommand).
-
Fork the repository.
-
Create a new branch:
git checkout -b feature/my-feature
-
Make your changes.
-
Run tests / build:
go test ./... go build ./cmd/main.go -
Commit and push:
git commit -am "Add my feature" git push origin feature/my-feature -
Open a Pull Request.
This project is licensed under the MIT License.
See the LICENSE file for details.