goga init
Interactive project initialization wizard, with optional template scaffolding.
Synopsis
goga init [TPL] [--ref REF]
goga init --upgrade [--ref REF]
Description
goga init initializes a new goga project. It runs in one of three modes depending on the arguments:
- Bare onboarding (
goga init) — launches an interactive questionnaire that walks you through setting up a new goga project. It collects configuration values and generates the necessary project files. Refuses to run when.goga/already exists ("Project already initialized"). - Scaffold then onboarding (
goga init <tpl>) — scaffolds boilerplate from a copier template first (a git URL, optionally carrying a#reffragment), then runs the onboarding questionnaire. Copier interactively asks template questions that are not answered programmatically. Onboarding is filesystem-conditional: questions whose artifacts the template already brought (.goga/config.yml,.goga/usages/conventions.md) are skipped. The already-initialized guard does not fire in this mode — a template may be applied to an existing tree. - Upgrade only (
goga init --upgrade) — migrates a previously scaffolded project to a newer template version via copierrun_update. No onboarding runs. The template source is read from the.goga/scaffold.ymlstate file written by an earliergoga init <tpl>; if that file is absent the command exits nonzero.
<tpl> and --upgrade are mutually exclusive: --upgrade updates state tied to a specific repository already recorded in .goga/scaffold.yml. --ref is meaningful only with <tpl> or --upgrade (a bare --ref is rejected).
Interactivity
The bare wizard is fully interactive. Press Ctrl+C at any time to abort.
With a template (goga init <tpl>), copier asks every template question that has no programmatic answer interactively. The project name is resolved from the git remote, falling back to a prompt, and supplied programmatically. A template question with neither a programmatic answer nor a default must be answered by the user — generation does not fail on it. The survey requires a TTY: in a non-interactive environment (CI, pipe) copier fails and the error cause is echoed to stderr. On migration (--upgrade) the survey is bypassed (defaults=True) — a new required template question without a default fails migration with a nonzero exit.
Modes
goga init branches on the presence of <tpl> and --upgrade:
| Invocation | Mode | Behavior |
|---|---|---|
goga init |
Bare onboarding | Interactive questionnaire; refuses if .goga/ exists. |
goga init <tpl> [--ref REF] |
Scaffold then onboarding | Copier run_copy from <tpl>, then the conditional questionnaire. |
goga init --upgrade [--ref REF] |
Upgrade | Copier run_update; no onboarding. Requires .goga/scaffold.yml. |
Questionnaire Flow
The wizard proceeds through the following steps in order. The entire survey is skipped when .goga/config.yml already exists (for example, when a copier template brought its own config) — ask_goga_config short-circuits and no file is (re)written.
-
Language -- Select the primary programming language. Choices:
python,golang,kotlin,swift,javascript. -
Base Convention -- Optionally download the default code conventions for the selected language from the goga-lang-conventions repository. Skipped when
.goga/usages/conventions.mdalready exists (for example, when a template brought its own conventions); the prefill is treated as(None, None). -
Codemanifest Usages -- Add additional named usages (code practice documentation entries). Each usage has a name and a file path.
-
Codemanifest Annotations -- Add custom annotations (global directives for the AI agent) that will be stored in the configuration.
-
Build Agent -- Confirm-gated (defaults to No). Decline to skip configuring a build agent (the
agentkey is then omitted from the generated config;goga buildraises a cleanClickExceptionif it later needs one). Accept to select an AI executor:claude,codex. -
Custom Dockerfile -- Optionally create a custom Dockerfile. When accepted, the suggested path is
.goga/Dockerfile(saved inside the project-scoped.goga/directory); press Enter to accept it or type a different path. The Dockerfile decision drives the next step (image semantics differ). -
Docker Image (depends on step 6):
-
If you created a Dockerfile, the image is built from it, so you are asked for two things:
- Base image (FROM) -- the baseline the Dockerfile extends. Available images depend on the chosen language (table below). This is written to the Dockerfile's
FROMline only; it is not stored inconfig.yml. - Built image name -- the name/tag for the image built from your Dockerfile (
goga buildrunsdocker build -t <image>). Free-form; defaults to<project-name>:latest, where<project-name>is derived from your gitoriginremote URL (basename with.gitstripped). When no git remote is available, no default is offered and the image name is required. Stored as the top-levelimageinconfig.yml.
- Base image (FROM) -- the baseline the Dockerfile extends. Available images depend on the chosen language (table below). This is written to the Dockerfile's
- If you did not create a Dockerfile, the image is a pre-built image to pull. Select it from the language-specific list (table below); it is stored as the top-level
imageinconfig.yml.
| Language | Images |
|---|---|
| python | qarium/goga-python-3.10:1.1 ... qarium/goga-python-3.14:1.1 |
| golang | qarium/goga-golang-1.23:1.1 ... qarium/goga-golang-1.26:1.1 |
| javascript | qarium/goga-node-22:1.1, qarium/goga-node-24:1.1 |
| kotlin | qarium/goga-kotlin-2.0:1.1 ... qarium/goga-kotlin-2.3:1.1 |
| swift | qarium/goga-swift-6.0:1.1 ... qarium/goga-swift-6.2:1.1 |
-
Environment Variables -- Configure environment variables for the build. Suggested keys are offered per agent (e.g.,
ANTHROPIC_DEFAULT_HAIKU_MODEL,ANTHROPIC_DEFAULT_SONNET_MODEL,ANTHROPIC_DEFAULT_OPUS_MODEL,ANTHROPIC_BASE_URL,ANTHROPIC_MODELfor Claude;CODEX_MODELfor Codex). You can also add arbitrary custom variables. -
Pipeline Agent -- Confirm-gated (defaults to No). Decline to skip configuring a pipeline agent (the
pipeline.agentkey is omitted; a per-stage workflow agent or afm's own default then covers the absent global agent). Accept to select an AI executor:claude,codex. Does not inherit the build agent from step 5 — build and pipeline are collected via independent confirm-gates, so they can diverge or both be left unset. -
Pipeline Environment Variables -- Configure environment variables for the pipeline container. Suggested keys are offered per agent (same shape as step 8). You can also add arbitrary
KEY=VALUEvariables. Omitted entirely when nothing is collected.
Generated Files
After the questionnaire completes, goga init creates:
.goga/config.yml-- Project configuration. Fields, in order:language, top-levelimage, optionaldockerfile(when a custom Dockerfile is requested),build(emitted only when it carries content — a non-None agent and/or a non-empty env),pipeline(likewise emitted only when it carries content), and optionalcodemanifest. A freshly-initialized project with no agent and no env omits bothbuildandpipeline; the consumer commands raise a cleanClickExceptionwhen an agent is actually needed..goga/usages/conventions.md-- (If base convention was downloaded) Language-specific code conventions..goga/Dockerfile-- (If requested) A Dockerfile whoseFROMline is the selected base image, written at the suggested path inside.goga/. When created, a top-leveldockerfile:entry (defaulting to.goga/Dockerfile) is also written to.goga/config.yml, and the top-levelimageholds the name of the image built from it (thedocker build -ttag) — sogoga build --update/goga pipeline --updatebuild the image locally instead of pulling it.
When goga init <tpl> is used, copier additionally writes:
.goga/scaffold.yml-- copier's state file recording the template source and the answers used.goga init --upgradereads this file to re-apply the recorded template, and exits nonzero if it is absent.
Examples
Run the initialization wizard:
goga init
Scaffold a project from a copier template, then run the conditional questionnaire:
# Latest commit on the template's default branch
goga init https://github.com/qarium/my-template.git
# Pin a specific ref via the URL fragment
goga init https://github.com/qarium/my-template.git#v1.0
# Override the ref explicitly (--ref wins over a fragment)
goga init https://github.com/qarium/my-template.git#v1.0 --ref main
Migrate a previously scaffolded project to a newer template version:
# Re-apply the recorded template at its current ref
goga init --upgrade
# Migrate to a specific target ref
goga init --upgrade --ref v2.0
Options
| Option/Argument | Type | Default | Purpose |
|---|---|---|---|
TPL (positional, optional) |
string | None | Copier template source — a git URL, optionally carrying a #ref fragment. Triggers scaffold-then-onboarding mode. Mutually exclusive with --upgrade. |
--upgrade |
flag | False | Migrate a previously scaffolded project via copier run_update; no onboarding. Mutually exclusive with <tpl>. |
--ref REF |
string | None | Override the git ref. With <tpl> it overrides the URL fragment; with --upgrade it sets the migration target ref. Requires <tpl> or --upgrade (a bare --ref is rejected). |
Exit Codes
| Code | Meaning |
|---|---|
0 |
Success — files generated (onboarding), template scaffolded, or migration applied. |
1 |
Error or user abort (Ctrl+C). Includes: project already initialized (bare init with .goga/ present); <tpl> and --upgrade given together (mutually exclusive); --ref given without <tpl> or --upgrade; copier scaffold/upgrade failure (bad template URL, git error, missing .goga/scaffold.yml on upgrade); or onboarding failure (a nonzero exit code from a delegate — Scaffold.generate/Scaffold.upgrade, InitLogic.run — is propagated verbatim). |