forge

module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT

README

Forge

Forge is a code-generation framework and CLI for building production Go + Next.js applications where everything communicates over Connect RPC. You describe your API once in protobuf; Forge generates the handlers, ORM, database wiring, frontend hooks, and the deploy manifests around it — and keeps regenerating them without clobbering your business logic.

It is purpose-built for LLM-driven development: a single, consistent interface pattern runs through the whole stack, so services are trivial to mock, wrap in middleware, and swap out.

What Forge gives you

  • Proto is the single source of truth. API contracts, ORM models, and typed frontend hooks all derive from your .proto files via forge generate.
  • Generated vs. hand-written code stay separated. Generated output lives in gen/ and *_gen.go; your logic lives in handler files and pkg/app/. Regeneration never overwrites the code you own.
  • Migrations own the schema. The database schema comes from SQL migrations; proto drives the ORM layer above them.
  • Deploy is target-agnostic. Workloads are authored once as a KCL forge.Service and projected onto Kubernetes today (compose / host / others via adapters). See docs/design/ for the design records.
  • Batteries for agents. A rich skill catalog (forge skill list) encodes the project conventions that forge lint enforces.

Install

# Build the binary into ./bin/forge
task build

# Or install onto $PATH (into $GOBIN)
task install
forge version

# Run straight from source without installing
go run ./cmd/forge version

Quick start

# Scaffold a new project (service / CLI / library)
forge new my-app
cd my-app

# Add a service, then regenerate the stack from proto
forge add service billing
forge generate

# The triple gate before you call a change done:
forge generate && forge lint && go build ./... && go test ./...

# Bring the whole local dev loop up (build + deploy + host + frontend)
forge up

Run forge --help for the full command surface (add, generate, db, deploy, migrate, pack, mcp, and more), or forge <command> --help for any one of them.

Conventions & skills

Forge ships an extensive skill catalog covering architecture, proto, db, api, services, testing, frontend, deploy, and debugging. The conventions they describe are enforced by forge lint, so prefer loading a skill before guessing:

forge skill list            # discover what's available
forge skill load <name>     # read one

reliant.md at the repo root captures the critical rules and testing tiers in brief.

Repository layout

forge/
├── cmd/forge/     # CLI entrypoint (package main)
├── internal/      # CLI implementation, generators, packs, templates
├── kcl/           # KCL module: typed schemas + manifest render layer
├── pkg/           # Reusable libraries projects import (serverkit, etc.)
├── proto/         # Forge's own proto annotations (forge/v1)
├── components/    # UI component library shipped to scaffolded frontends
├── docs/          # ADRs (docs/adr) and design records (docs/design)
├── examples/      # Runnable examples
├── forge.yaml     # Project manifest
└── Taskfile.yml   # Automation entrypoints

Development

task deps           # install Go (and frontend) dependencies
task test:short     # inner-loop tests: whole repo in seconds
task test           # full unit suite with -race
task lint           # golangci-lint + buf
task fmt            # goimports + go mod tidy

See CONTRIBUTING.md for the full dev loop, pre-commit hooks, and PR process, and reliant.md for the testing tiers and project conventions.

License

MIT — see LICENSE.

Directories

Path Synopsis
Package cli provides the public entry point for embedding Forge's CLI as a subcommand in other cobra-based CLIs.
Package cli provides the public entry point for embedding Forge's CLI as a subcommand in other cobra-based CLIs.
cmd
contractlint command
forge command
forge-mcp command
Command forge-mcp is a standalone Model Context Protocol stdio server that hosts a forge project's gen/mcp/manifest.json — every Connect RPC becomes an MCP tool.
Command forge-mcp is a standalone Model Context Protocol stdio server that hosts a forge project's gen/mcp/manifest.json — every Connect RPC becomes an MCP tool.
internal
buildinfo
Package buildinfo exposes the forge binary's version metadata to packages that cannot depend on internal/cli (to avoid import cycles).
Package buildinfo exposes the forge binary's version metadata to packages that cannot depend on internal/cli (to avoid import cycles).
buildtarget
Package buildtarget owns the per-service build dispatch for services whose source lives outside the project's Go module — sibling repos, third-party binaries, language runtimes forge doesn't natively build.
Package buildtarget owns the per-service build dispatch for services whose source lives outside the project's Go module — sibling repos, third-party binaries, language runtimes forge doesn't natively build.
checksums
Package checksums owns forge's file-ownership machinery: which bytes does forge certify as its own render, which files has the user taken over, and what may a generate run overwrite.
Package checksums owns forge's file-ownership machinery: which bytes does forge certify as its own render, which files has the user taken over, and what may a generate run overwrite.
cli
`forge generate accept-fork <path>...` — DEPRECATED alias for `forge disown`.
`forge generate accept-fork <path>...` — DEPRECATED alias for `forge disown`.
cli/add
Package add holds the `forge add` command group — the verbs that scaffold a new component (service / worker / operator / binary / frontend / webhook / package / adapter / library / handler-file / rpc / entity / crd / scenario) into an existing forge project.
Package add holds the `forge add` command group — the verbs that scaffold a new component (service / worker / operator / binary / frontend / webhook / package / adapter / library / handler-file / rpc / entity / crd / scenario) into an existing forge project.
cli/audit
Package audit holds the `forge audit` command group — a comprehensive snapshot of project state designed to orient an LLM (or human) without forcing them to grep ten different directories.
Package audit holds the `forge audit` command group — a comprehensive snapshot of project state designed to orient an LLM (or human) without forcing them to grep ten different directories.
cli/audittype
Package audittype holds the small, neutral value types shared by the `forge audit` command group (internal/cli/audit) and the internal/cli code that contributes audit categories it cannot compute without package-cli internals (the KCL-entity-typed ingress / external-builds categories, and friction.go's auditFriction).
Package audittype holds the small, neutral value types shared by the `forge audit` command group (internal/cli/audit) and the internal/cli code that contributes audit categories it cannot compute without package-cli internals (the KCL-entity-typed ingress / external-builds categories, and friction.go's auditFriction).
cli/backlog
Package backlog holds the `forge backlog` command group — list / add / close / open / migrate over the structured FORGE_BACKLOG.md.
Package backlog holds the `forge backlog` command group — list / add / close / open / migrate over the structured FORGE_BACKLOG.md.
cli/cmdutil
Package cmdutil holds cross-cutting helpers shared by forge's own CLI across MORE THAN ONE command group (internal/cli and its dir-nested subpackages).
Package cmdutil holds cross-cutting helpers shared by forge's own CLI across MORE THAN ONE command group (internal/cli and its dir-nested subpackages).
cli/component
Package component holds the `forge component` command group — list, search, and install UI components from forge's built-in component library.
Package component holds the `forge component` command group — list, search, and install UI components from forge's built-in component library.
cli/debug
Package debug holds the `forge debug` command group — a Delve-backed interactive debugger driver (start / break / continue / eval / ...).
Package debug holds the `forge debug` command group — a Delve-backed interactive debugger driver (start / break / continue / eval / ...).
cli/factory
Package factory carries the shared dependency set ("the factory") threaded through forge's own CLI command tree, plus the command REGISTRY that lets dir-nested command-group subpackages (internal/cli/add, internal/cli/lint, ...) attach to the root without a group↔root import cycle.
Package factory carries the shared dependency set ("the factory") threaded through forge's own CLI command tree, plus the command REGISTRY that lets dir-nested command-group subpackages (internal/cli/add, internal/cli/lint, ...) attach to the root without a group↔root import cycle.
cli/lint
Package lint holds the `forge lint` command group — the project linter pipeline (golangci / buf / frontend / forge-convention / scaffold / migration-safety / wire-coverage / authz-completeness …) plus the targeted single-rule flags and the --json aggregator.
Package lint holds the `forge lint` command group — the project linter pipeline (golangci / buf / frontend / forge-convention / scaffold / migration-safety / wire-coverage / authz-completeness …) plus the targeted single-rule flags and the --json aggregator.
cli/pack
Package pack holds the `forge pack` command group — manage installable packs (list / install / remove / info).
Package pack holds the `forge pack` command group — manage installable packs (list / install / remove / info).
cliutil
Package cliutil holds small helpers shared across forge's CLI surface.
Package cliutil holds small helpers shared across forge's CLI surface.
cluster
Package cluster owns the render-KCL → kubectl-apply → wait-rollouts pipeline that `forge deploy`, `forge cluster reload`, and the deploy phase of `forge up` all execute.
Package cluster owns the render-KCL → kubectl-apply → wait-rollouts pipeline that `forge deploy`, `forge cluster reload`, and the deploy phase of `forge up` all execute.
codegen
Package codegen — config_k_gen.go is the MIGRATION half of the config-as-KCL story: it projects an existing per-env `config.<env>.yaml` into the user-owned KCL values file `deploy/kcl/<env>/config.k`.
Package codegen — config_k_gen.go is the MIGRATION half of the config-as-KCL story: it projects an existing per-env `config.<env>.yaml` into the user-owned KCL values file `deploy/kcl/<env>/config.k`.
config
forge:exclude-contract
forge:exclude-contract
contractcheck
Package contractcheck inspects a project's internal/ tree for contract-shape violations.
Package contractcheck inspects a project's internal/ tree for contract-shape violations.
debug
Package debug wraps a Delve debugger so forge can drive a debugging session from the CLI / MCP layers.
Package debug wraps a Delve debugger so forge can drive a debugging session from the CLI / MCP layers.
deploytarget
Package deploytarget owns the per-service deploy dispatch — the surface that maps a rendered KCL Service.deploy block to a concrete pipeline that ships the service somewhere.
Package deploytarget owns the per-service deploy dispatch — the surface that maps a rendered KCL Service.deploy block to a concrete pipeline that ships the service somewhere.
devstack
forge:exclude-contract devstack is CLI-internal dev-stack orchestration glue (dev-block wiring, git-facts, lockfile) for `forge up`, not a contract-shaped service the bootstrap wires.
forge:exclude-contract devstack is CLI-internal dev-stack orchestration glue (dev-block wiring, git-facts, lockfile) for `forge up`, not a contract-shaped service the bootstrap wires.
docs
Package docs renders project documentation (markdown / hugo) from the project config, proto descriptors, and contract.go interfaces.
Package docs renders project documentation (markdown / hugo) from the project config, proto descriptors, and contract.go interfaces.
doctor
Package doctor runs health checks against a forge project's development stack: docker-compose services, app endpoints, the telemetry backends bundled in the lgtm container, and the Delve debugger when --debug is active.
Package doctor runs health checks against a forge project's development stack: docker-compose services, app endpoints, the telemetry backends bundled in the lgtm container, and the Delve debugger when --debug is active.
envutil
Package envutil holds the small, shared environment-handling helpers the build, deploy, and host-launch paths all need: a minimal .env parser and two env-overlay merges whose precedence is encoded in the name.
Package envutil holds the small, shared environment-handling helpers the build, deploy, and host-launch paths all need: a minimal .env parser and two env-overlay merges whose precedence is encoded in the name.
generator
Package generator: checksums shim.
Package generator: checksums shim.
generator/contract
Package contract drives the four *_gen.go files (mock, middleware, tracing, metrics) emitted from a single hand-written contract.go.
Package contract drives the four *_gen.go files (mock, middleware, tracing, metrics) emitted from a single hand-written contract.go.
hostlaunch
Package hostlaunch composes exec.Cmds for host-mode services and frontends, plus the small env-file helpers both call sites need.
Package hostlaunch composes exec.Cmds for host-mode services and frontends, plus the small env-file helpers both call sites need.
installkit
Package installkit holds the small set of genuinely-shared rendering primitives used by `internal/packs`.
Package installkit holds the small set of genuinely-shared rendering primitives used by `internal/packs`.
kclplugin
forge:exclude-contract kclplugin is KCL-plugin framework glue (registers a jwk resolver plugin with the KCL runtime), not a contract-shaped service.
forge:exclude-contract kclplugin is KCL-plugin framework glue (registers a jwk resolver plugin with the KCL runtime), not a contract-shaped service.
kclrender
Package kclrender is the single seam through which forge evaluates KCL.
Package kclrender is the single seam through which forge evaluates KCL.
linter/authzlint
Package authzlint is the generate-time completeness gate for forge's descriptor-driven authorization.
Package authzlint is the generate-time completeness gate for forge's descriptor-driven authorization.
linter/finding
Package finding is the single canonical home for the lint-finding vocabulary shared by every internal linter (forgeconv, scaffolds, migrationlint, frontendpacklint).
Package finding is the single canonical home for the lint-finding vocabulary shared by every internal linter (forgeconv, scaffolds, migrationlint, frontendpacklint).
linter/forgeconv
Package forgeconv implements lint rules that enforce forge codegen conventions on proto files.
Package forgeconv implements lint rules that enforce forge codegen conventions on proto files.
linter/frontendpacklint
Package frontendpacklint provides a soft-rule analyzer that flags frontend pack templates importing third-party UI libraries directly instead of wrapping the forge base component library.
Package frontendpacklint provides a soft-rule analyzer that flags frontend pack templates importing third-party UI libraries directly instead of wrapping the forge base component library.
linter/scaffolds
Package scaffolds — `forge lint --check-workarounds` rule.
Package scaffolds — `forge lint --check-workarounds` rule.
mcpbridge
Package mcpbridge is a Model Context Protocol stdio server that reads a forge project's gen/mcp/manifest.json and exposes every RPC tool the manifest declares to an MCP client (Claude Code, Claude Desktop, the official MCP Inspector, Cline, etc.).
Package mcpbridge is a Model Context Protocol stdio server that reads a forge project's gen/mcp/manifest.json and exposes every RPC tool the manifest declares to an MCP client (Claude Code, Claude Desktop, the official MCP Inspector, Cline, etc.).
packs
Package packs implements the pack system: pre-built, opinionated implementations that Forge can install into a project.
Package packs implements the pack system: pre-built, opinionated implementations that Forge can install into a project.
projectstore
Package projectstore is the single read+mutate surface for a forge project's state.
Package projectstore is the single read+mutate surface for a forge project's state.
schemadef
Package schemadef projects a project's APPLIED database schema — db/migrations/*.up.sql executed in order against a REAL ephemeral postgres — into a typed model that code generation consumes.
Package schemadef projects a project's APPLIED database schema — db/migrations/*.up.sql executed in order against a REAL ephemeral postgres — into a typed model that code generation consumes.
secrets
Package secrets resolves declared secret REFERENCES (which live in git: EnvVar.secret_ref / secret_key) to secret VALUES (which never live in git) for one environment.
Package secrets resolves declared secret REFERENCES (which live in git: EnvVar.secret_ref / secret_key) to secret VALUES (which never live in git) for one environment.
statefile
Package statefile is the one place forge's JSON-record-under-.forge/state helpers live.
Package statefile is the one place forge's JSON-record-under-.forge/state helpers live.
templates
Package templates owns the embedded forge template tree and renders it into scaffolded code.
Package templates owns the embedded forge template tree and renders it into scaffolded code.
pkg module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL