Complete installation and usage guide for Spec Forge.
- Go 1.26 — Required for all frameworks
- Java + Maven/Gradle — For Spring Boot projects
- protoc + plugins — For gRPC projects
go install github.com/spencercjh/spec-forge@latestVerify installation:
spec-forge --help# Generate from any supported project (auto-detects framework)
spec-forge generate ./path/to/projectOutput is written to the project's output directory (default: project root). For gRPC/protoc, the filename follows <service>.openapi.yaml.
AI enrichment runs automatically when enrich.provider and enrich.model are configured:
export OPENAI_API_KEY="sk-xxx"
spec-forge generate ./path/to/project --language zhTo disable enrichment during generation:
spec-forge generate ./path/to/project --language zh --skip-enrich# From project root
spec-forge generate .
# Output: target/openapi.json (Maven) or build/openapi.json (Gradle)Requirements:
pom.xmlorbuild.gradlepresent- Spring Boot 2.x or 3.x
# From project root
spec-forge generate .
# No annotations needed — AST-based analysisRequirements:
go.modwithgindependency- Routes registered in
main()or init functions
# From project root
spec-forge generate .Requirements:
goctlinstalled:go install github.com/zeromicro/go-zero/tools/goctl@latest.apidefinition files
# Install protoc plugin first
go install github.com/sudorandom/protoc-gen-connect-openapi@latest
# Then generate
spec-forge generate .Requirements:
protocinstalled.protofiles with service definitions
Create .spec-forge.yaml in your current working directory:
# AI Enrichment
enrich:
enabled: true
provider: openai # openai, anthropic, ollama, custom
model: gpt-4o
apiKeyEnv: OPENAI_API_KEY
language: zh # zh, en, ja, etc.
timeout: 60s
# Output
output:
dir: ./openapi
format: yaml # yaml or jsonImportant: Spec Forge reads .spec-forge.yaml from the current working directory, not the project directory. If you run spec-forge generate ./path/to/project, ensure the config file is in your current directory, not ./path/to/project.
Priority: CLI flags > Environment variables > Config file > Defaults
# Basic
spec-forge generate ./project
# With enrichment (requires enrich.provider and enrich.model configured)
spec-forge generate ./project --language zh
# Disable enrichment
spec-forge generate ./project --language zh --skip-enrich
# Custom output path (format auto-detected from extension)
spec-forge generate ./project --output ./specs/api.yaml
spec-forge generate ./project --output ./specs/api.json
# Custom output directory (uses default filename)
spec-forge generate ./project --output-dir ./specs
# Verbose logging
spec-forge generate ./project -v# Enrich existing OpenAPI spec
spec-forge enrich ./openapi.json --provider openai --model gpt-4o
# With custom provider (DeepSeek example)
LLM_API_KEY="sk-xxx" spec-forge enrich ./openapi.json \
--provider custom \
--custom-base-url https://api.deepseek.com/v1 \
--model deepseek-chat
# Disable streaming for faster concurrent processing
spec-forge enrich ./openapi.json --no-stream# Publish to ReadMe.com
README_API_KEY="rdme_xxx" spec-forge publish ./openapi.json --to readme --readme-slug my-api
# Or with full pipeline
README_API_KEY="rdme_xxx" spec-forge generate ./project --publish-target readme| Variable | Purpose |
|---|---|
OPENAI_API_KEY |
OpenAI API key |
ANTHROPIC_API_KEY |
Anthropic API key |
LLM_API_KEY |
Default for custom providers |
README_API_KEY |
ReadMe.com API key |
Ensure $GOPATH/bin is in your PATH:
export PATH=$PATH:$(go env GOPATH)/bin- Check
springdoc-openapiis in dependencies - For multi-module projects, ensure
spring-boot-maven-pluginhas start/stop goals - Try running with
-vfor verbose output
- Ensure routes are registered in
main()or package init - Check that
ginimport is present ingo.mod
go install github.com/sudorandom/protoc-gen-connect-openapi@latestEnsure $GOPATH/bin is in your PATH.
- Configuration Guide — All options explained
- AI Enrichment — LLM setup and custom prompts
- Publishing — ReadMe.com and other platforms
- Framework guides: Spring Boot, Gin, go-zero, gRPC