# Devflow Init How `devflow init` chooses between its two setup modes, gates each wizard step, and seeds a re-init from prior state. ## Two-Mode Init Working memory is off on a new install. Re-init keeps the current value. Without `--memory`, `--reset` turns working memory off. To turn it on, run `devflow memory --enable`. The note has a limit of 8,192 bytes. Use one worktree for each parallel session. **Two-Mode Init**: `devflow init` offers Recommended (sensible defaults, quick setup) or Advanced (full interactive flow) after plugin selection. `--recommended` / `--advanced` CLI flags for non-interactive use. Recommended applies: ambient ON, curation ON, rules ON, HUD ON, default-ON flags, .claudeignore ON, auto-install safe-delete if trash CLI detected, user-mode security deny list, viewMode preserved from existing settings.json. Both init paths apply seeded flag values non-interactively — fresh install: registry defaults; re-init: existing manifest values preserved, defaults adopted only for newly-added flags, except that a guarded setting flag whose key already holds a value devflow did not write (a user's own `subagentPromptCacheTtl`) is adopted off so the value stays, and `--reset` applies the factory default; `view-mode` resolved from existing settings.json at seed time — and emit an outcome line pointing to `devflow flags` for customization. Advanced path adds a proxy prompt (external model routing — default OFF, requires Codex auth; never part of Recommended defaults). Use `--curation/--no-curation` to toggle curation independently. The old flags `--learning` and `--no-learning` no longer exist and fail as unknown options. Use `--rules/--no-rules` to toggle rules independently. Use `--proxy/--no-proxy` to set external model routing (Advanced-only; init runs preflight on enable). Use `--compliance `/`--no-compliance` to set compliance non-interactively (enable with comma-separated framework IDs or disable preserving frameworks; default: off; `--compliance`/`--no-compliance` bypasses the wizard entirely). The compliance wizard step (select which regulatory frameworks to install — GDPR, HIPAA, PCI DSS, SOC 2, ISO 27001, SOX) runs in **both** init paths via `shouldRunComplianceStep`: Advanced always runs it; Recommended only runs it when the user reached the mode-select prompt interactively (`modePromptShown=true`) — `--recommended` flag and non-TTY invocations preserve their promptless contracts. The step shows a "Current setting:" note for re-init legibility, uses a `p.select` (Yes/No) instead of a confirm to avoid Enter-through ambiguity, and emits an outcome line for unambiguous state visibility. **Attribution wizard step** (D27): the `suppress-attribution` question is **Advanced-only** — `shouldRunAttributionStep` returns true only for `mode === 'advanced'` with a TTY, a deliberate divergence from `shouldRunComplianceStep` (which also runs on interactive Recommended). Recommended **never** asks; it silently applies the seeded value (fresh install: off). The step runs after the compliance step: Yes writes `{"commit":"","pr":""}` to suppress Claude attribution in git history, No preserves attribution labels; seeded from settings.json (exact devflow shape → true) then manifest then false; no CLI override path (toggle via `devflow flags --enable/--disable suppress-attribution`); shape-guarded deletion means a user's custom attribution value is never erased. **Tracker wizard step**: `shouldRunTrackerStep` gates the issue-tracker provider question on the same predicate as the compliance step — Advanced always runs it (a non-TTY Advanced invocation has already exit-1'd), Recommended only when the Setup-mode `p.select` actually ran (`modePromptShown=true`), so the `--recommended` flag and every non-TTY invocation stay promptless. `devflow init --tracker ` sets the machine's default provider non-interactively (a repository's committed `.devflow/project.json` can select its own) and suppresses the prompt on **both** paths (`hasCliOverride` short-circuits first); the value is parsed at the boundary before any prompt, so `--tracker jira-cloud` exits rather than silently resolving. There is no `--no-tracker` (D-E): `--tracker github` is the default, and a flag whose only meaning is "⇒ github" would be a second spelling of an existing value. `--reset` collapses the provider to `github`; every provider's conventions file under `~/.devflow/tracker/` stays, because each provider keeps its own. Every init run re-arms every provider's inference attempt counter. **State-aware re-init**: on re-init the wizard reads the prior manifest and settings.json and pre-seeds every prompt with existing values (the config supplies only `reviewPublication`), skipping the Recommended/Advanced question entirely. init records memory, curation and knowledge in the manifest — machine-wide switches over every project — and seeds them from the manifest on re-init. It writes only `reviewPublication` to `.devflow/config.json` and keeps every other key in the file, a per-repo `tracker` override included, even under `--reset`; the retired `memory`, `learning`, `knowledge`, `decisions` and `autoCommit` keys are dropped. --hud-only over an existing install changes only features.hud in the manifest. --security none removes the deny list from user AND managed settings. `reviewPublication` has no prompt, so init takes it from the reset-gated config snapshot rather than re-reading the file: a re-init keeps the project's `auto`, `full` or `off`, and `--reset` returns it to `auto` with every other feature. Use `--reset` for a factory reset that ignores all prior state (mutually exclusive with `--plugin`). **Gate level wizard step.** `shouldRunGateLevelStep` gates the machine gate level question with the shared predicate `shouldRunPromptedWizardStep` in `prompt-io.ts`, keyed on `modePromptShown`, never on the mode name. The compliance and tracker steps hold the same table in their own predicates, and issue #554 moves them onto the shared one. Advanced (the `--advanced` flag, a re-init with no mode flag, or Advanced chosen at the Setup-mode prompt) always runs it, and Recommended runs it only when the Setup-mode prompt actually ran, so `--recommended` and every non-TTY invocation stay promptless: they keep the stored `features.gateLevel`, and a first install records none, so `standard` applies at read time. The select offers `full`, `standard` and `lean` with a one-line effect each. It starts on the stored level on a re-init, on `standard` on a first install, after `--reset` and when the stored level cannot be read, and on `full` when the stored value is malformed or `null` (the level every reader gives it). Accepting the prompt as shown keeps a valid level. Over a malformed or `null` value it writes `full` in its place, and the level that applies does not change. A promptless init never defaults, narrows or heals a stored value. A malformed stored value shows as `invalid (manifest.json; reads as full)`, the words `devflow gates` uses. The Recommended settings note has a `Gate level:` row. **The `--gate-level` flag and the summary.** `devflow init --gate-level ` sets the level on every path with no prompt (`hasCliOverride` short-circuits the gate). It is parsed at the boundary, before `--hud-only` or any other write. An unknown value exits 1 and names the valid levels. A missing value exits 1 with Commander's `argument missing` error, which names the levels. `--hud-only --gate-level` exits 1 because `--hud-only` writes no level. The seed stays raw (`FeatureSeed.gateLevel`): only `--gate-level` or the wizard answer replaces it. The result goes into the same manifest write, to the same field `devflow gates --set` writes. The post-install summary shows the level the manifest on disk now holds (D-INIT-REAL-OUTCOME). It adds ` (was X)` when the run changes the level that applies, where X is the level that applied before. A kept level, a malformed value written back as stored and an unreadable prior get no note. If the manifest write fails, the summary warns that init could not save the manifest, so the gate level did not change. Init never writes the personal `gateLevel` in `.devflow/config.json`, which still wins in its repository. **Gate level over a manifest init cannot use.** `readManifest` reads a manifest it rejects (valid JSON with a `features` object in which a field is missing or mistyped, or a leading byte-order mark) as no manifest, so the seed holds no level for it. The full init and `--hud-only` then read the raw file (`readStoredGateLevel`), and `carriedGateLevel` decides the level that the run carries. A promptless init and `--hud-only` keep a stored `features.gateLevel` exactly as it is, a malformed value and `null` included, and the summary warns that init kept it while it replaced the manifest. When the prompt runs, the answer is the level: the prompt starts on the stored level and names where it comes from, and accepting a malformed or `null` value writes `full`. A level that `--gate-level` or the prompt sets is a choice, even when it equals the stored one, so the warning does not print. A manifest that init cannot read has no level to keep. It is corrupt or not JSON, it is not a JSON object with a `features` object, it is not a regular file, it stores a level that nests too deep to write back as JSON, or it is over 1 MiB and also one that `readManifest` rejects. The prompt then shows `Current setting: unknown` and starts on `standard`. A promptless run records no key and warns that it could not read the stored level, that `standard` (the machine default) applies, and that `devflow gates --set ` sets it again. `devflow gates --status` words its warning for each of the two cases. `--reset` removes the stored level in both cases. It reads the raw level for the summary only: `--reset` over a rejected manifest that stored `full` prints `Gate level: standard (default) (was full)` and no kept-level warning. **CLAUDE.md import audit (D-CLAUDE-MD-IMPORT-AUDIT).** After the install, on both paths, init audits the `@path` imports of the Claude directory's `CLAUDE.md` and, inside a git repository that is not HOME, of the repository toplevel's `CLAUDE.md`, `.claude/CLAUDE.md` and `CLAUDE.local.md`, and prints what is flagged as one note: an import over 10,000 bytes, or a root whose import chain totals over 40,000 bytes. The Recommended summary note prints before the install runs and the Advanced path prints no end-of-wizard summary, so the audit is neither's row; both reach the one call site (`claudeMdAuditStep`, the same lines the SessionStart hook shows in its `systemMessage`). A path that is not printable ASCII is shown as `` with its size. Nothing is printed when nothing is flagged, and a failure is at most one degraded line with the exit code unchanged. Init then records the stamp `~/.devflow/.claude-md-audit` (examined paths and the keys it printed, earlier keys kept), so the first SessionStart afterwards does not repeat the finding; the write needs `~/.devflow` to exist and refuses a symlinked or non-regular stamp path. `devflow uninstall` removes the stamp. **Curation data move (3.8).** After the legacy hook sweep and before the manifest persists, init moves the curation data of each project it finds and of the repository where it runs, but never of HOME. It starts the work for up to 16 projects at a time. The order is: the global tuning file `~/.devflow/learning.json` becomes `curation.json` (when both names exist, the new one wins, the old one stays and init logs one line), then the project folders move, then a backup merge runs for each project that has a `.devflow/learning.backup-*` folder. Init prints one notice when at least one project moved, and one line for each busy, refused or failed project, after the install warnings. A project outcome never changes the exit code. A rerun finishes a move that stopped, because each step checks the state it finds. The contract is in the Curation data move paragraph of `docs/reference/architecture.md`. Init also writes `features.curation` and the mirror key `features.learning` to the manifest, and it removes the hook files `learning-lock` and `lib/learning-store.cjs`. ## One Install Location `devflow init` installs machine-wide only: Claude Code assets go to `$CLAUDE_CONFIG_DIR` when it is an absolute path, else `~/.claude` (D-CLAUDE-CONFIG-DIR), and machine state goes to `~/.devflow`, which `DEVFLOW_DIR` no longer relocates (D-ONE-HOME). `--scope` is retired and hidden from `--help`: `--scope user` is exactly the no-flag install, and `--scope local` exits 1 before writing anything, pointing at `devflow uninstall --scope local` to remove an old project-local install (D-SCOPE-RETIRED). The manifest keeps its `scope` field for downgrade safety: every write records `user`, and a legacy `local` or missing value reads with every feature intact (D-MANIFEST-SCOPE-PINNED). Every install also stamps the language focuses its effective selection installs into the installed `code-review.md` (one fixed-prefix line, `(none)` as shipped), and `devflow uninstall --plugin` re-stamps it from the plugins that remain (D-LANGUAGE-FOCUS-STAMP); a curation-variant converge keeps the stamp it finds.