Open source · MIT license

Spec-driven code generation with a deterministic API plane

Write a markdown spec. Run forge build. Forge compiles typed Spec API primitives into a task graph, routes work to specialist models, and exposes builds, tasks, contracts, artifacts, events, model routing, and verification through a local REST API.

0.1
Spec API version
20+
REST endpoints
SSE
Event streams
my-app — forge serve
$ forge serve --port 4123

Forge API plane listening on 127.0.0.1:4123
  GET  /api/health
  POST /api/spec/validate
  POST /api/spec/compile
  POST /api/builds
  GET  /api/builds
  GET  /api/tasks
  GET  /api/contracts
  GET  /api/artifacts
  GET  /api/events/stream

$ curl -s -X POST http://127.0.0.1:4123/api/builds

Build job
  id: build_20260527_142830
  status: running
  source: compiled Spec API task graph

$ curl -N http://127.0.0.1:4123/api/events/stream?once=true

  event: task.started backend.clients
  event: contracts.updated 5 endpoints
  event: verification.passed

Everything is queryable: state, contracts, artifacts, audit, models.

How it works

Three steps to a working codebase

No prompt engineering. No copy-pasting. Describe what you want, validate it locally, and run the build.

01

Install and scaffold

Install Forge, pick a template, and get a project directory with a pre-configured .forge/ folder.

02

Write a Spec API file

Edit .forge/spec.md with typed primitives for models, APIs, UI bindings, tests, and deploy targets.

03

Compile and build

Run forge spec compile or forge build. Forge creates the task graph locally, routes each task, and verifies the result.

.forge/spec.md
# Project: Task Tracker .project spec_api_version: 0.1 type: web_app stack: react_fastapi_sqlite .db.model Task fields: title: string required completed: boolean .api.resource tasks model: Task actions: list, create, update, delete auth: required .ui.table task_list source: GET /api/tasks columns: title, completed
Spec API builds skip broad planning. Forge parses these primitives and compiles deterministic task IDs before any model is called. See the Spec API reference.
$ forge spec validate $ forge spec compile --output .forge/compiled-spec.json $ forge build -p ollama

API plane

Operate Forge through local REST endpoints

Run forge serve to expose the same build machinery behind a JSON API. External tools can validate specs, launch builds, inspect task state, stream events, route model calls, export contracts, and run deterministic verification.

CLI and API share state. forge build and POST /api/builds operate on the same project files under .forge/.
01

Validate before work starts

POST /api/spec/validate and POST /api/spec/compile turn markdown primitives into diagnostics and task graphs.

02

Control builds and tasks

POST /api/builds, GET /api/tasks, task run, and task retry endpoints make builds scriptable.

03

Observe every artifact

Contracts, artifacts, events, audit logs, model health, and OpenAPI export stay queryable while the build runs.

.forge/spec.md Spec compiler Task graph Build jobs Contracts + events + artifacts
$ forge serve --port 4123 $ curl -s http://127.0.0.1:4123/api/health $ curl -s -X POST http://127.0.0.1:4123/api/builds $ curl -N http://127.0.0.1:4123/api/events/stream?once=true
{ "status": "accepted", "job": { "id": "7f3a91c2d0", "kind": "build", "status": "queued" } }
POST/api/spec/validate

Parse Spec API directives and return diagnostics.

POST/api/spec/compile

Create a deterministic task graph.

POST/api/builds

Start a build job from the current project.

GET/api/tasks

Inspect task state and dependencies.

POST/api/tasks/{id}/run

Run a single dependency-ready task.

POST/api/tasks/{id}/retry

Retry a failed task with the same controls.

GET/api/contracts

Read backend API, model, and event contracts.

GET/api/contracts/openapi

Export current API contracts as OpenAPI.

POST/api/verify

Run deterministic verification checks.

POST/api/models/route

Resolve the configured model chain for a role.

GET/api/events/stream

Stream build events over Server-Sent Events.

GET/api/audit

Inspect control-plane and build audit logs.


Agent pipeline

Four layers, one workflow

Forge passes machine-readable artifacts between Spec API compilation, building, review, and verification. The API plane stays small, while builder specializations handle the implementation slices.

1Spec compiler primitives → deterministic task graph
2
Builderspecialized
setup   project structure, manifests, base files
backend API routes, data layer, contracts
frontendcontract-aware UI generation
ci/deployGitHub Actions, Dockerfile, platform config
3Reviewer cross-file review + rework requests
4Verifier deterministic checks + machine-readable pass/fail
ArtifactBus + ArtifactStore + ContractRegistry — Forge persists typed artifacts (task graphs, build outputs, review findings, verification results) to a shared thread-safe store and durable `.forge/` snapshots. Frontend reads exact endpoint shapes from backend contracts.
Agentic Firewall — every write is validated before touching disk. Agents cannot write outside the project root, touch .env, or embed eval(). All decisions are logged.
AgentResponsibility
planner Still supports legacy free-form specs. Spec API projects use the deterministic compiler before model execution.
builder Owns implementation through specializations like setup, backend, frontend, ci, deploy, and integration.
reviewer Reads all code from the bus, validates cross-file consistency, and emits structured findings plus rework requests.
verifier Runs deterministic post-review checks and produces machine-readable verification results for the orchestrator and policy layer.

Templates

Start from a blueprint

Each template ships with a pre-filled spec, build rules, and a firewall policy for its stack.

web-appReact + Vite, FastAPI, SQLite, Tailwind
api-onlyFastAPI, Pydantic, SQLite — no frontend
ai-appReact + FastAPI with OpenAI or Anthropic
chrome-extChrome Manifest V3, vanilla JS or React
cli-toolPython CLI, Click or Typer, Rich output
data-vizStreamlit or React with Plotly / Recharts
slack-botPython, slack-bolt, FastAPI handler
discord-botPython, discord.py, slash commands
$ forge new my-app -t web-app $ forge templates # list all templates

Features

Built for iteration

Forge treats building software as a process, not a single LLM call.

Structured API contracts

Backend publishes machine-readable endpoint schemas. Frontend consumes them. No more POST /api/users vs POST /users mismatches. Contracts persist to .forge/contracts.json across builds.

Local API plane

Builds, tasks, contracts, artifacts, audit logs, model routing, and event streams are available through forge serve.

Parallel execution

Independent builder lanes like backend, ci, and deploy run concurrently through a dependency-aware scheduler.

Self-correcting review

Reviewer finds a bug in your backend? The rework goes back to the builder with the right specialization and affected files. One retry per file, tracked for observability.

Any LLM provider

Anthropic, OpenAI, Together, Groq, or local Ollama. Set an env var, switch with --provider.

Incremental features

Add to an existing project. Contracts from previous builds are loaded so new code knows what endpoints exist.

$ forge build --feature "add JWT refresh tokens"

Resumable + auditable

State, artifacts, contracts, and verification output are persisted under .forge/ so builds can be resumed and inspected.


Get started in under a minute

Core install stays lightweight. Provider SDKs remain opt-in, and the CLI and API plane share the same project state under .forge/.

$ pip install forge-ai $ pip install "forge-ai[build]" # provider SDK extras $ export ANTHROPIC_API_KEY=sk-ant-... # or OPENAI_API_KEY, TOGETHER_API_KEY, GROQ_API_KEY $ forge new my-app -t web-app $ cd my-app $ $EDITOR .forge/spec.md $ forge spec validate $ forge build $ forge serve --port 4123 # optional local API plane $ forge dev