This guide provides a detailed technical explanation of every command available in Go-Arch.
Usage: go-arch setup
Prepares your environment. It is designed to be the first command a new Go developer runs.
- OS Detection: Identifies if you are on Linux, macOS, or Windows.
- Toolchain: Verifies if
gois installed and available in the PATH. - Utilities: Suggests and assists with the installation of
Air(Live Reloading).
Usage: go-arch new [project-name]
The main entry point for scaffolding. It triggers an interactive wizard.
- Module Name: The Go namespace (e.g.,
github.com/user/repo). - Architecture: Choice between Minimalist, Standard, or Hexagonal (can be overridden via External Templates).
- DB Driver: Pre-configures specific repository boilerplate (PostgreSQL, MySQL, MongoDB).
- Use Docker: Optional generation of
Dockerfileanddocker-compose.yaml. - Telemetry: Optional integration of OpenTelemetry with support for multiple backends (Jaeger, Zipkin, SigNoz, etc.).
- gRPC Support: Scaffolds a complete gRPC server including
.protocontracts and automation through a Makefile.
Since scaffold_prod_v1, every generated project runs as a small stdlib CLI:
./main # start the HTTP server (same as ./main server)
./main server # explicit server start
./main migrate # apply pending DB migrations (PostgreSQL/MySQL only)
./main version # print version
./main whatever # unknown subcommand → usage + exit 2Typed runtime configuration lives in internal/config (reads SERVER_PORT, APP_ENV, DATABASE_URL); migrations live in internal/dbmigrate (embedded SQL, idempotent).
Usage: go-arch generate [type] [Name]
Injects new components into an existing project. It is Context-Aware: it reads your .go-arch.yaml to know which folder structure to follow.
go-arch generate <name> resolves through a three-tier lookup, first match wins:
- Pack generator — if your project uses a template pack (
.go-arch.yamltemplate:field) and the pack declares a generator named<name> - Builtin generator — CLI-registered builtin generators
- Component types — the built-in code generators below
go-arch generate --list
# express:
# docker Scaffold Docker setup for the project
# auth Add authentication middleware
# builtin:
# no builtin generators registered
# component types:
# service, repository, handler, crud, page, componentOutput is grouped by source and sorted within each group.
service: Creates the business logic layer.repository: Creates the interface and the implementation (SQL/NoSQL).handler: Creates the HTTP/API entry point.crud: Full Automation.- Generates Model, Service, Repository, and Handler.
- In a Hexagonal project, it correctly places items in
domain,ports, andadapters. - In a Standard project, it uses
model,service,repository, andhandler.
Usage: go-arch serve
Runs your application with a developer-first approach.
- Air Integration: It looks for an
.air.tomlin the root. If found (andairis installed), it runs with Hot-Reload. - Native Fallback: If
airis not available, it executesgo run main.goorgo run cmd/api/main.godepending on the layout.
Usage: go-arch template <install|list|remove|update>
Manages installable template packs from Go module proxies. Packs provide a self-contained set of templates that define the project layout, files, and optional hooks.
Usage: go-arch template install <module>[@<version>]
Fetches a pack module via go mod download -json, validates the manifest, and materializes it under ~/.go-arch/packs/<name>@<version>/. If no @version is provided, @latest is used.
go-arch template install github.com/org/go-arch-express@1.0.0If the pack declares hooks, a trust warning is printed and the CLI prompts for explicit confirmation before enabling them.
Usage: go-arch template list
Lists all installed packs sorted by name:
go-arch template list
# echo@0.5.0
# express@1.0.0Usage: go-arch template remove <name>[@<version>]
Removes an installed pack. Without @version, the latest installed version is removed. With a specific version, only that version is removed.
Usage: go-arch template update <name>
Re-fetches the @latest version of a pack. Previously installed older versions are preserved. If the new version declares hooks, the trust warning is re-prompted.
go-arch template update expressUsage: go-arch check
Validates the project's Architectural Health. This command is intended to be used during development and in CI/CD pipelines.
- Structural Integrity: Checks if the required folders for your selected architecture exist.
- Dependency Guard (Layer Leaking): Scans Go imports to ensure layers are correctly decoupled (e.g., Domain must not import Adapters).
- Exit Codes: Returns
1if violations are found, making it compatible with automation tools.
Usage: go-arch workspace <upgrade|check>
Operates on multiple services defined in a go-arch.workspace.yaml at the monorepo root. See Workspaces for the full reference.
workspace upgrade— upgrades every service in declaration order (dry-run by default;--yesapplies). Continue-on-error with per-service summary.workspace check— runs the architecture check for every service with per-service summary.--service <name>(ongenerate,check,upgrade) — target a single service from anywhere inside the monorepo.
go-arch workspace upgrade
go-arch workspace upgrade --yes
go-arch workspace check
go-arch generate crud User --service ordersUsage: go-arch mcp
Launches the Model Context Protocol (MCP) server over standard I/O (stdio).
- JSON-RPC 2.0: Implements the MCP protocol for seamless integration with AI coding agents (such as OpenCode or Claude Desktop).
- Stderr Routing: Automatically redirects standard UI logs to stderr to protect the integrity of the JSON-RPC stdout communication channel.
Every CLI command has a corresponding MCP tool for agents:
| CLI command | MCP tool | Purpose |
|---|---|---|
go-arch new |
new_project |
Scaffold a new project with layout, DB, Docker, observability, gRPC, and templ+HTMX options |
go-arch generate |
generate_component |
Generate service/repository/handler/crud/page/component, or run pack generators with generatorArgs |
go-arch generate --list |
list_generators |
List available generators (pack, builtin, component types) for the current project |
go-arch check |
check_architecture |
Validate the project structure and import rules |
go-arch template install |
install_template |
Install a template pack from a Go module. allowHooks: true enables hooks/generators that run commands (default: disabled — safe) |
go-arch template list |
list_packs |
List installed template packs with versions |
go-arch template remove |
remove_pack |
Remove an installed pack (bare name resolves the latest version) |
go-arch template update |
update_pack |
Update an installed pack to its latest version. allowHooks: true re-enables command-running hooks |
go-arch workspace list |
workspace_list |
List services in a workspace (name, path, template) |
go-arch workspace upgrade |
workspace_upgrade |
Upgrade all workspace services (dry-run by default; apply: true commits). Chdir-free via root injection |
go-arch workspace check |
workspace_check |
Run the architecture check for all workspace services |
go-arch upgrade --service X |
upgrade_project (service+workspacePath) |
Upgrade a single workspace service chdir-free |
go-arch serve |
serve_project |
Return the exact run command (air or go run <mainPath>) — agents never start a long-running server over MCP |
go-arch setup |
setup_environment |
Detect Go/air presence; with install: true installs only air (user-level, no sudo). The Go toolchain itself is never installed by the tool |
serve_project is check-only by design: MCP is request/response, so a tool that blocks on a live server would hang the agent. Agents run the returned command themselves and test the project over HTTP.
setup_environment follows a consent pattern: the agent asks the human for permission, then calls with install: true (installs air) or hands the exact install command over.
Usage: go-arch doctor
Runs environment diagnostics and reports issues found:
- Go toolchain: checks
go versionis available. - air (hot-reload): checks whether
airis installed (if not,go-arch servefalls back togo run). - git: checks whether
gitis installed. - Platform: reports OS/architecture.
- Project config: validates the
.go-arch.yaml(skipped with a finding when not in a go-arch project).
Exits non-zero when any check fails, so it is safe to use in scripts and CI.
Usage: go-arch version
Prints the build version. When built via GoReleaser (tagged release), the version is injected automatically. Local development builds print dev.
Usage: go-arch update
Self-update: downloads the latest go-arch release from GitHub, verifies its SHA-256 checksum, and atomically replaces the currently running binary.
- Already up to date: prints the latest version and exits 0.
- Checksum verification: refuses to replace the binary on a mismatch.
- Permission denied (e.g.
/usr/local/binwithout write access): prints the exactsudo <binary> updatecommand to run. - Supports Linux, macOS, and Windows (amd64/arm64). Not available for local
devbuilds that predate this command — re-rungo install github.com/SalvucciFacundo/go-arch/v2@latestonce.
The CLI is stateless, meaning it doesn't store your project data in a database. Instead, it uses this YAML file as the Source of Truth.
- Architecture Locking: Prevents generating components that don't match the project's initial architecture.
- Namespace Consistency: Ensures all new files use the correct
module namein their imports.
If you want to change how generate creates code, remember you can create your own templates in .go-arch/templates/ (check ARCHITECTURE.md for details).