sdd-forge 0.1.0-alpha.24 → 0.1.0-alpha.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,23 +2,23 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/sdd-forge.svg)](https://www.npmjs.com/package/sdd-forge)
4
4
 
5
- > **Alpha:** This tool is currently in alpha. The API, command structure, and configuration format may change without notice. Please avoid using it in production environments.
5
+ > **Alpha:** This tool is currently in alpha. APIs, command structure, and configuration formats may change without notice. Not recommended for production use.
6
6
 
7
- **A CLI tool that automatically generates and maintains project documentation using source code analysis + AI.**
7
+ **A CLI tool that automatically generates and maintains project documentation via source code analysis + AI.**
8
8
 
9
9
  Statically analyzes your codebase and combines templates with AI to auto-generate `docs/`.
10
10
  The Spec-Driven Development (SDD) workflow also automates documentation updates when adding features or making changes.
11
11
 
12
12
  ## Features
13
13
 
14
- - **Zero dependencies** — Runs on Node.js 18+ only. No npm package dependencies.
15
- - **Automatic source code analysis** — Statically analyzes controllers, models, routes, and config files to extract structural data.
16
- - **AI document generation** — AI automatically expands `{{text}}` directives in templates.
17
- - **Template inheritance** — Four-layer inheritance (base → arch → preset → project-local) for flexible customization.
18
- - **SDD workflow** — Manage the development cycle of spec → gate → implementation → forge → review with simple commands.
19
- - **Multilingual support** — Automatically generate documentation in multiple languages via translate / generate modes.
20
- - **AI agent integration** — Compatible with Claude Code (skills) and Codex CLI.
21
- - **Multi-preset** — Supports Node.js CLI / CakePHP2 / Laravel / Symfony.
14
+ - **Zero dependencies** — Runs on Node.js 18+ only. No npm packages required
15
+ - **Automatic source analysis** — Statically analyzes controllers, models, routes, and config files to extract structural data
16
+ - **AI document generation** — AI automatically expands `{{text}}` directives in templates
17
+ - **Template inheritance** — Four-layer inheritance (base → arch → preset → project-local) for full customization
18
+ - **SDD workflow** — Manage the spec → gate → implement → forge → review development cycle with commands
19
+ - **Multi-language support** — Auto-generate documentation in multiple languages via translate / generate modes
20
+ - **AI agent integration** — Supports Claude Code (skills) and Codex CLI
21
+ - **Multi-preset** — Supports Node.js CLI / CakePHP2 / Laravel / Symfony
22
22
 
23
23
  ## Quick Start
24
24
 
@@ -41,13 +41,13 @@ pnpm add -g {{data: project.name("")}}sdd-forge{{/data}}
41
41
  # 1. Register your project (interactive wizard)
42
42
  {{data: project.name("")}}sdd-forge{{/data}} setup
43
43
 
44
- # 2. Generate all documentation at once (scan → init → data → text → readme → agents → translate)
44
+ # 2. Generate all documentation (scan → init → data → text → readme → agents → translate)
45
45
  {{data: project.name("")}}sdd-forge{{/data}} build
46
46
  </pre>
47
47
 
48
- This is all it takes to generate `docs/` and `README.md`.
48
+ This generates `docs/` and `README.md` in one step.
49
49
 
50
- ## Command Reference
50
+ ## Commands
51
51
 
52
52
  ### Document Generation
53
53
 
@@ -57,12 +57,12 @@ This is all it takes to generate `docs/` and `README.md`.
57
57
  | `build` | Run the full document generation pipeline |
58
58
  | `scan` | Analyze source code → `analysis.json` |
59
59
  | `init` | Initialize `docs/` from templates |
60
- | `data` | Resolve `{{data}}` directives with analyzed data |
60
+ | `data` | Resolve `{{data}}` directives with analysis data |
61
61
  | `text` | Resolve `{{text}}` directives with AI |
62
62
  | `readme` | Auto-generate `README.md` from `docs/` |
63
63
  | `forge` | Iteratively improve documentation with AI |
64
64
  | `review` | Check documentation quality |
65
- | `translate` | Multilingual translation (default language → others) |
65
+ | `translate` | Multi-language translation (default language → others) |
66
66
  | `upgrade` | Update preset templates to the latest version |
67
67
 
68
68
  ### SDD Workflow
@@ -81,16 +81,16 @@ This is all it takes to generate `docs/` and `README.md`.
81
81
  |---|---|
82
82
  | `default` | Set the default project |
83
83
  | `presets` | List available presets |
84
- | `help` | Show command list |
84
+ | `help` | Display command list |
85
85
 
86
86
  ## SDD Workflow
87
87
 
88
- The flow for adding features or making changes:
88
+ The feature addition / change flow:
89
89
 
90
90
  ```
91
- spec Create a spec (feature branch + spec.md)
91
+ spec Create spec (feature branch + spec.md)
92
92
 
93
- gate Spec gate check (PASS when no unresolved items)
93
+ gate Spec gate check (PASS when no open questions)
94
94
 
95
95
  implement Write code after gate PASS
96
96
 
@@ -112,7 +112,7 @@ Run the SDD workflow with skills:
112
112
 
113
113
  #### Codex CLI
114
114
 
115
- Run the workflow from a prompt:
115
+ Run the workflow from prompts:
116
116
 
117
117
  ```
118
118
  $sdd-flow-start — Start spec creation → gate → implementation
@@ -121,7 +121,7 @@ $sdd-flow-close — Finish with forge → review → commit → merge
121
121
 
122
122
  ## Configuration
123
123
 
124
- Running `sdd-forge setup` generates `.sdd-forge/config.json`.
124
+ `sdd-forge setup` generates `.sdd-forge/config.json`.
125
125
 
126
126
  ```jsonc
127
127
  {
@@ -149,9 +149,9 @@ You can add project-specific templates and data sources:
149
149
  <!-- {{data: docs.chapters("Chapter|Overview")}} -->
150
150
  | Chapter | Overview |
151
151
  | --- | --- |
152
- | [01. System Overview](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/01_overview.md) | This chapter provides a high-level view of `sdd-forge`, a Node.js CLI tool that automates documentation generation th… |
153
- | [02. CLI Command Reference](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/02_cli_commands.md) | This chapter documents all 17 subcommands available in `sdd-forge`, organized across three dispatcher layers (`docs.j… |
154
- | [03. Configuration and Customization](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/03_configuration.md) | This chapter covers the configuration files and customization options available in sdd-forge, including project setti… |
152
+ | [01. System Overview](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/01_overview.md) | This chapter provides a structural overview of sdd-forge, a Node.js CLI tool that automates documentation generation … |
153
+ | [02. CLI Command Reference](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/02_cli_commands.md) | This chapter covers all 18 subcommands available in `sdd-forge`, organized into documentation generation commands (ro… |
154
+ | [03. Configuration and Customization](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/03_configuration.md) | This chapter covers all configuration files used by sdd-forge, the full range of options available in `.sdd-forge/con… |
155
155
  | [04. Internal Design](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/04_internal_design.md) | |
156
156
  <!-- {{/data}} -->
157
157
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  <!-- {{text: Write a 1-2 sentence overview of this chapter. Include the project's architecture and whether it integrates with external systems.}} -->
6
6
 
7
- This chapter provides a high-level view of `sdd-forge`, a Node.js CLI tool that automates documentation generation through source code analysis and drives feature development via a Spec-Driven Development (SDD) workflow. The tool integrates with externally configured AI agents (such as Claude CLI) to produce and refine project documentation, while relying solely on Node.js built-in modules for all other operations.
7
+ This chapter provides a structural overview of sdd-forge, a Node.js CLI tool that automates documentation generation through source code analysis and drives feature development via a Spec-Driven Development (SDD) workflow. The tool follows a three-layer command dispatch architecture and integrates with external AI agents (such as Claude CLI) to generate and refine documentation text.
8
8
 
9
9
  ## Content
10
10
 
@@ -14,35 +14,61 @@ This chapter provides a high-level view of `sdd-forge`, a Node.js CLI tool that
14
14
 
15
15
  ```mermaid
16
16
  flowchart TD
17
- User([User / CI]) -->|CLI invocation| Entry[sdd-forge.js\nEntry Point]
18
-
19
- Entry -->|docs subcommands| DocsDispatcher[docs.js\nDispatcher]
20
- Entry -->|spec / gate| SpecDispatcher[spec.js\nDispatcher]
21
- Entry -->|flow| Flow[flow.js\nSDD Flow Runner]
22
- Entry -->|presets| Presets[presets-cmd.js]
23
- Entry -->|help| Help[help.js]
24
-
25
- DocsDispatcher --> Scan[scan\nSource Analysis]
26
- DocsDispatcher --> Data[data\nDirective Resolver]
27
- DocsDispatcher --> Text[text\nAI Text Fill]
28
- DocsDispatcher --> Forge[forge\nDocs Refinement]
29
- DocsDispatcher --> Review[review\nQuality Check]
30
- DocsDispatcher --> Readme[readme\nREADME Generator]
31
-
32
- SpecDispatcher --> SpecInit[spec init\nSpec Creation]
33
- SpecDispatcher --> Gate[gate\nGate Check]
34
-
35
- Scan -->|analysis.json\nsummary.json| OutputDir[.sdd-forge/output/]
36
- Data -->|reads| OutputDir
37
- Text -->|reads| OutputDir
38
- Forge -->|reads| OutputDir
39
-
40
- Text -->|prompt| AgentLib[lib/agent.js\nAI Agent Caller]
41
- Forge -->|prompt| AgentLib
42
- Review -->|prompt| AgentLib
43
- AgentLib -->|configured command| ExternalAI([External AI Agent\ne.g. Claude CLI])
44
-
45
- OutputDir -->|resolved directives| DocsDir[docs/\nGenerated Documentation]
17
+ User["User (CLI)"]
18
+
19
+ subgraph Entry["Entry Layer"]
20
+ SDF["sdd-forge.js\n(Entry Point)"]
21
+ end
22
+
23
+ subgraph Dispatch["Dispatcher Layer"]
24
+ DOCS["docs.js"]
25
+ SPEC["spec.js"]
26
+ FLOW["flow.js"]
27
+ HELP["help.js"]
28
+ end
29
+
30
+ subgraph Commands["Command Layer"]
31
+ SCAN["scan"]
32
+ DATA["data"]
33
+ TEXT["text"]
34
+ FORGE["forge"]
35
+ REVIEW["review"]
36
+ SPEC_INIT["spec init"]
37
+ GATE["gate"]
38
+ OTHER["readme / agents / changelog / …"]
39
+ end
40
+
41
+ subgraph Lib["Core Libraries"]
42
+ AGENT["agent.js\n(AI Agent Caller)"]
43
+ CONFIG["config.js\n(Config & Paths)"]
44
+ SCANNER["scanner.js\n(Source Analyzer)"]
45
+ PARSER["directive-parser.js"]
46
+ end
47
+
48
+ subgraph Storage["File System"]
49
+ SRC["Source Code\n(project root)"]
50
+ ANALYSIS[".sdd-forge/output/\nanalysis.json / summary.json"]
51
+ DOCFILES["docs/*.md\n(generated docs)"]
52
+ SPECS["specs/NNN-xxx/spec.md"]
53
+ CFGFILE[".sdd-forge/config.json"]
54
+ end
55
+
56
+ AI["External AI Agent\n(e.g. Claude CLI)"]
57
+
58
+ User --> SDF
59
+ SDF --> DOCS & SPEC & FLOW & HELP
60
+ DOCS --> SCAN & DATA & TEXT & FORGE & REVIEW & OTHER
61
+ SPEC --> SPEC_INIT & GATE
62
+ SCAN --> SCANNER --> SRC
63
+ SCANNER --> ANALYSIS
64
+ DATA --> PARSER --> DOCFILES
65
+ TEXT --> AGENT --> AI
66
+ FORGE --> AGENT
67
+ REVIEW --> AGENT
68
+ AGENT --> DOCFILES
69
+ CONFIG --> CFGFILE
70
+ SPEC_INIT --> SPECS
71
+ GATE --> SPECS
46
72
  ```
47
73
 
48
74
  ### Component Responsibilities
@@ -51,17 +77,17 @@ flowchart TD
51
77
 
52
78
  | Component | Location | Responsibility | Input | Output |
53
79
  |---|---|---|---|---|
54
- | CLI Entry Point | `src/sdd-forge.js` | Parses top-level subcommand and resolves project context via environment variables | CLI arguments, `.sdd-forge/projects.json` | Routes to dispatcher with `SDD_SOURCE_ROOT` / `SDD_WORK_ROOT` set |
55
- | Docs Dispatcher | `src/docs.js` | Routes docs-related subcommands (`build`, `scan`, `data`, `text`, `forge`, `review`, etc.) | Subcommand string | Delegates to `src/docs/commands/*.js` |
56
- | Spec Dispatcher | `src/spec.js` | Routes spec-related subcommands (`spec`, `gate`) | Subcommand string | Delegates to `src/specs/commands/*.js` |
57
- | Scanner | `src/docs/lib/scanner.js` | Traverses source files and extracts structural information (PHP, JS, YAML) | Source root path, scan config | `.sdd-forge/output/analysis.json`, `summary.json` |
58
- | Directive Parser | `src/docs/lib/directive-parser.js` | Parses `{{data}}`, `{{text}}`, `@block`, and `@extends` directives in Markdown templates | Markdown template files | Parsed directive AST |
59
- | Data Resolver | `src/docs/lib/resolver-factory.js` | Resolves `{{data}}` directives by binding analysis data to named data sources | Parsed directives, `analysis.json` | Rendered Markdown sections |
60
- | AI Agent Caller | `src/lib/agent.js` | Executes configured external AI agent commands synchronously or asynchronously | Prompt string, agent config | AI-generated text streamed or returned as string |
61
- | Config Manager | `src/lib/config.js` | Loads and validates `.sdd-forge/config.json`; manages context and path resolution | `.sdd-forge/` directory | Typed config object, resolved paths |
62
- | Flow State Manager | `src/lib/flow-state.js` | Persists and retrieves SDD workflow state (current spec, branch, worktree info) | Work root path, state object | `.sdd-forge/current-spec` JSON file |
63
- | Preset System | `src/lib/presets.js` | Auto-discovers `preset.json` files under `src/presets/` and registers available project types | `src/presets/` directory tree | `PRESETS` constant used across all consumers |
64
- | SDD Flow Runner | `src/flow.js` | Orchestrates the full SDD cycle (spec gate implement forge → review) automatically | `--request` argument, flow state | Sequential command execution with user interaction |
80
+ | CLI Entry Point | `src/sdd-forge.js` | Resolves project context; routes subcommands to the appropriate dispatcher | CLI arguments, env vars (`SDD_SOURCE_ROOT`, `SDD_WORK_ROOT`) | Dispatched command execution |
81
+ | Docs Dispatcher | `src/docs.js` | Routes `build`, `scan`, `init`, `data`, `text`, `forge`, `review`, and related subcommands | Subcommand name + flags | Delegates to `docs/commands/*.js` |
82
+ | Spec Dispatcher | `src/spec.js` | Routes `spec` and `gate` subcommands | Subcommand name + flags | Delegates to `specs/commands/*.js` |
83
+ | SDD Flow Runner | `src/flow.js` | Automates the full SDD cycle end-to-end | `--request` prompt string | Orchestrated spec gate implement forge review sequence |
84
+ | Source Scanner | `src/docs/lib/scanner.js` | Parses project source files; extracts modules, routes, and structure | Source root directory | `.sdd-forge/output/analysis.json`, `summary.json` |
85
+ | Directive Parser | `src/docs/lib/directive-parser.js` | Parses `{{data}}` and `{{text}}` directives in Markdown templates | `.md` template files | Directive AST for resolvers |
86
+ | Data Resolver | `src/docs/lib/resolver-factory.js` | Injects structured analysis data into `{{data}}` directives | `analysis.json`, directive AST | Resolved Markdown sections |
87
+ | AI Agent Caller | `src/lib/agent.js` | Invokes external AI agent processes synchronously or asynchronously | Prompt string, agent config | AI-generated text (stdout) |
88
+ | Config Manager | `src/lib/config.js` | Loads and validates `.sdd-forge/config.json`; resolves standard paths | `.sdd-forge/` directory | Typed config object, file paths |
89
+ | Spec Gate | `src/specs/commands/gate.js` | Validates a spec against pre/post implementation checklists | `spec.md` path, `--phase` flag | PASS / FAIL report |
90
+ | Forge Engine | `src/docs/commands/forge.js` | Iteratively improves `docs/` by prompting the AI agent | Change summary prompt, `spec.md` path | Updated `docs/*.md` files |
65
91
 
66
92
  ### External Integrations
67
93
 
@@ -69,22 +95,21 @@ flowchart TD
69
95
 
70
96
  | System | Purpose | Connection Method | Configuration |
71
97
  |---|---|---|---|
72
- | AI Agent (e.g. Claude CLI) | Generates and refines documentation text, performs quality review, and evaluates spec gate checks | Spawned as a child process via `child_process.execFileSync` (sync) or `spawn` (async) | Defined in `.sdd-forge/config.json` under `providers` and `defaultAgent`; supports `command`, `args`, `timeoutMs`, and `systemPromptFlag` |
73
- | Git | Branch creation, worktree isolation, and repository root resolution for SDD workflows | Invoked via `child_process` shell commands (`git rev-parse`, `git worktree`, etc.) | Resolved automatically from the working directory; worktree support detected via `.git` file presence |
98
+ | AI Agent (e.g. Claude CLI) | Generates and refines documentation text for `{{text}}` directives; drives `forge`, `review`, `agents`, and `text` commands | Spawned as a child process via `execFileSync` (sync) or `spawn` (async streaming) in `src/lib/agent.js` | Defined under `providers` in `.sdd-forge/config.json`; selected by `defaultAgent` key |
74
99
 
75
- `sdd-forge` has no network-based external dependencies. All integrations are process-level and operate entirely within the local development environment.
100
+ The AI agent is the only external integration. All other operations — file scanning, directive parsing, template merging, spec management — rely exclusively on Node.js built-in modules (`fs`, `path`, `child_process`, `os`). The agent command, arguments, timeout, and system-prompt delivery method (`--system-prompt` or `--system-prompt-file`) are all configurable per project.
76
101
 
77
102
  ### Environment Differences
78
103
 
79
104
  <!-- {{text: Describe the configuration differences across environments (local/staging/production).}} -->
80
105
 
81
- `sdd-forge` is a local developer CLI tool and does not have traditional deployment environments (staging, production). Configuration is driven entirely by `.sdd-forge/config.json` in each project's working directory.
106
+ As a local CLI tool, sdd-forge does not have distinct deployment environments in the traditional sense. Configuration differences are instead expressed through per-project `.sdd-forge/config.json` settings and environment variables.
82
107
 
83
- | Aspect | Local Development | CI / Automated Pipeline |
84
- |---|---|---|
85
- | Agent invocation | Interactive; supports streaming output callbacks for live feedback | Non-interactive; `callAgentAsync()` with `stdin: "ignore"` to prevent hangs |
86
- | `CLAUDECODE` env var | May be set if running inside Claude Code | Must be unset before spawning AI agent subprocess (handled automatically by `agent.js`) |
87
- | Project context | Resolved via `.sdd-forge/projects.json` `default` entry or `--project` flag | Set explicitly via `SDD_SOURCE_ROOT` and `SDD_WORK_ROOT` environment variables |
88
- | AI agent timeout | Defaults: 120 s / 180 s / 300 s depending on command | Same defaults apply; increase via `config.limits.designTimeoutMs` if needed |
89
- | Concurrency | Default 5 parallel file processes; tunable via `config.limits.concurrency` | Same; reduce if CPU-constrained in CI runners |
90
- | Output language | Controlled by `config.output.default` and `config.lang` | Same; no environment-specific overrides exist |
108
+ | Aspect | Local Development | CI / Automated Pipeline | Multi-Project Setup |
109
+ |---|---|---|---|
110
+ | Project resolution | Interactive; `--project` flag or `.sdd-forge/projects.json` `default` key | `SDD_SOURCE_ROOT` and `SDD_WORK_ROOT` env vars set explicitly per job | `.sdd-forge/projects.json` registers named projects; `--project <name>` selects the target |
111
+ | AI agent | Configured via `providers` + `defaultAgent` in `config.json`; runs interactively | Same config; `stdin: "ignore"` prevents CLI hang in non-TTY environments (`callAgentAsync`) | Each project carries its own `config.json` with independent agent settings |
112
+ | Language / output | `lang` and `output.languages` control CLI language and doc output locale | Same config values apply; no separate override mechanism | Per-project `config.json` allows different languages per project |
113
+ | Concurrency | `limits.concurrency` (default: 5) controls parallel file processing | Can be raised for faster execution on high-core machines | Independently tunable per project |
114
+ | Timeouts | `limits.designTimeoutMs` / per-provider `timeoutMs` | Should be increased for slow CI agents; default constants: 120 s / 180 s / 300 s | Configurable per project |
115
+ ```
@@ -4,7 +4,7 @@
4
4
 
5
5
  <!-- {{text: Write a 1–2 sentence overview of this chapter. Cover the total number of commands, whether global options exist, and the subcommand structure.}} -->
6
6
 
7
- This chapter documents all 17 subcommands available in `sdd-forge`, organized across three dispatcher layers (`docs.js`, `spec.js`, and direct commands). Each subcommand is accessible via `sdd-forge <subcommand>`, with a small set of global options applying across the CLI.
7
+ This chapter covers all 18 subcommands available in `sdd-forge`, organized into documentation generation commands (routed through `docs.js`), spec workflow commands (routed through `spec.js`), and directly executed commands (`flow`, `presets`). All commands share a common set of global options, and most require a resolved project context before execution.
8
8
 
9
9
  ## Contents
10
10
 
@@ -14,42 +14,44 @@ This chapter documents all 17 subcommands available in `sdd-forge`, organized ac
14
14
 
15
15
  | Command | Description | Key Options |
16
16
  |---|---|---|
17
- | `build` | Run the full documentation pipeline: `scan → init → data → text → readme → agents → translate` | `--project` |
18
- | `scan` | Analyze source code and output `analysis.json` and `summary.json` | `--project` |
19
- | `init` | Initialize `docs/` from preset templates | `--project`, `--preset` |
20
- | `data` | Resolve `{{data}}` directives using analysis results | `--project` |
21
- | `text` | Resolve `{{text}}` directives using AI agents | `--project`, `--agent`, `--file` |
22
- | `readme` | Auto-generate `README.md` from docs content | `--project` |
23
- | `forge` | Iteratively improve docs with AI | `--prompt`, `--spec`, `--project` |
24
- | `review` | Run a quality check on generated docs | `--project` |
25
- | `changelog` | Generate `change_log.md` from accumulated specs | `--project` |
26
- | `agents` | Update `AGENTS.md` (SDD template + PROJECT section) | `--sdd`, `--project`, `--dry-run` |
27
- | `translate` | Translate docs into additional output languages | `--lang`, `--force`, `--dry-run` |
28
- | `upgrade` | Update SDD-managed doc templates to the latest version | `--project` |
29
- | `setup` | Register a project and generate `.sdd-forge/config.json` | — |
30
- | `default` | Set or display the default project | — |
31
- | `spec` | Initialize a new spec file and feature branch | `--title`, `--no-branch` |
32
- | `gate` | Run a gate check against a spec file | `--spec`, `--phase` |
33
- | `flow` | Automatically execute the full SDD flow for a given request | `--request` |
34
- | `presets` | List or inspect available project type presets | — |
35
- | `help` | Display available subcommands and usage information | |
17
+ | `build` | Runs the full documentation pipeline (`scan → init → data → text → readme → agents → translate`) in one step | `--project` |
18
+ | `scan` | Analyzes source code and writes `analysis.json` and `summary.json` | `--project` |
19
+ | `init` | Initializes `docs/` from preset templates | `--project` |
20
+ | `data` | Resolves `{{data: ...}}` directives using analysis output | `--project` |
21
+ | `text` | Resolves `{{text: ...}}` directives using the configured AI agent | `--file`, `--agent`, `--project` |
22
+ | `readme` | Auto-generates `README.md` from docs content via AI | `--project` |
23
+ | `forge` | Iteratively improves docs using AI, guided by a prompt | `--prompt`, `--spec`, `--project` |
24
+ | `review` | Runs an AI quality check on docs and reports PASS/FAIL | `--project` |
25
+ | `changelog` | Generates `change_log.md` from all spec files under `specs/` | `--project` |
26
+ | `agents` | Updates `AGENTS.md` with the latest SDD template and PROJECT section | `--sdd`, `--project-only`, `--dry-run` |
27
+ | `translate` | Translates docs into additional output languages defined in config | `--lang`, `--force`, `--dry-run` |
28
+ | `upgrade` | Updates SDD-managed template sections to match the installed package version | `--project` |
29
+ | `setup` | Registers a project and generates initial `.sdd-forge/config.json` | — |
30
+ | `default` | Sets or displays the default project in `projects.json` | — |
31
+ | `spec` | Creates a new spec file and optionally a feature branch | `--title`, `--no-branch` |
32
+ | `gate` | Validates a spec against acceptance criteria before or after implementation | `--spec`, `--phase` |
33
+ | `flow` | Automates the full SDD flow from a natural-language request | `--request` |
34
+ | `presets` | Lists all bundled project type presets | — |
35
+ | `help` | Displays available subcommands and descriptions | `-h`, `--help` |
36
36
 
37
37
  ### Global Options
38
38
 
39
39
  <!-- {{text: List global options common to all commands in a table format. Include --project, --help/-h, and --version/-v/-V. Also note that setup, default, help, and presets skip project context resolution.}} -->
40
40
 
41
- | Option | Alias | Description |
41
+ | Option | Aliases | Description |
42
42
  |---|---|---|
43
- | `--project <name>` | — | Specify the target project by name, as registered in `.sdd-forge/projects.json`. Overrides the `default` project setting. |
44
- | `--help` | `-h` | Display usage information for the CLI or a specific subcommand. |
45
- | `--version` | `-v`, `-V` | Print the installed `sdd-forge` version (read from `package.json`). |
43
+ | `--project <name>` | — | Specifies the target project by name, as registered in `.sdd-forge/projects.json`. When omitted, the project marked as `default` in `projects.json` is used. |
44
+ | `--help` | `-h` | Prints the help text for the given subcommand and exits. |
45
+ | `--version` | `-v`, `-V` | Prints the current `sdd-forge` version from `package.json` and exits. |
46
46
 
47
- > **Note:** The `setup`, `default`, `help`, and `presets` subcommands skip project context resolution entirely. They do not require a registered project and will not read `.sdd-forge/config.json` or set `SDD_SOURCE_ROOT` / `SDD_WORK_ROOT`.
47
+ > **Note:** The `setup`, `default`, `help`, and `presets` commands skip project context resolution entirely. They do not require a registered project and ignore the `--project` flag.
48
48
 
49
49
  ### Command Details
50
50
 
51
51
  <!-- {{text: Describe the usage, options, and examples for each command in detail. Create a #### subsection for each command. For the build pipeline, list all steps: scan → init → data → text → readme → agents → translate. The translate command has --lang, --force, and --dry-run options.}} -->
52
52
 
53
+ Each command below is documented with its purpose, available options, and representative usage examples. Commands that involve AI generation require a valid `defaultAgent` or `providers` entry in `.sdd-forge/config.json`. Commands that modify files on disk always operate within the resolved project's `docs/` directory unless otherwise noted.
54
+
53
55
  #### build
54
56
 
55
57
  Runs the complete documentation generation pipeline in a single step. The pipeline executes the following stages in order: `scan → init → data → text → readme → agents → translate`. This is the standard entry point for first-time setup or full regeneration of project docs.
@@ -252,19 +254,17 @@ sdd-forge -h
252
254
 
253
255
  <!-- {{text: Describe exit code definitions (0=success, 1=general error, etc.) and the rules for stdout/stderr usage in a table format. Include the fact that gate and review PASS/FAIL results are printed to stdout.}} -->
254
256
 
255
- **Exit Codes**
256
-
257
- | Code | Meaning |
257
+ | Exit Code | Meaning |
258
258
  |---|---|
259
259
  | `0` | Command completed successfully |
260
- | `1` | General error (misconfiguration, missing required argument, unexpected failure) |
261
- | `2` | Validation failure used by `gate` when one or more checks FAIL, and by `review` when the quality check does not PASS |
260
+ | `1` | General error (missing required option, file not found, configuration invalid, etc.) |
261
+ | `2` | Gate or review check failed (FAIL result reported; see stdout for details) |
262
262
 
263
- **stdout / stderr Rules**
263
+ **stdout / stderr usage:**
264
264
 
265
265
  | Stream | Content |
266
266
  |---|---|
267
- | `stdout` | Primary command output: generated text, rendered tables, `gate` PASS/FAIL check results, `review` PASS/FAIL results, `--dry-run` previews |
268
- | `stderr` | Diagnostic messages: progress indicators, warnings, error details, AI agent invocation logs |
267
+ | `stdout` | Primary command output: generated text, rendered tables, PASS/FAIL results from `gate` and `review`, dry-run previews |
268
+ | `stderr` | Progress indicators, warnings, debug information, and error messages |
269
269
 
270
- > `gate` and `review` always print their PASS/FAIL verdict and per-item results to `stdout`, making them suitable for use in CI pipelines where stdout is captured and evaluated by automated tooling.
270
+ `gate` and `review` always print their PASS/FAIL verdict and per-item check results to **stdout**, making them suitable for capture in CI pipelines. Error messages describing why a command could not run (missing config, invalid arguments, etc.) are written to **stderr** and do not appear in captured stdout.
@@ -4,7 +4,7 @@
4
4
 
5
5
  <!-- {{text: Describe the overview of this chapter in 1-2 sentences. Cover the types of configuration files, the range of configurable options, and customization points.}} -->
6
6
 
7
- This chapter covers the configuration files and customization options available in sdd-forge, including project settings, AI provider definitions, document style controls, and multi-project management. Understanding these options allows you to tailor the tool's behavior to your team's workflow, language preferences, and existing AI infrastructure.
7
+ This chapter covers all configuration files used by sdd-forge, the full range of options available in `.sdd-forge/config.json`, and the customization points for AI providers, document style, project type, merge strategy, and concurrency.
8
8
 
9
9
  ## Contents
10
10
 
@@ -12,41 +12,41 @@ This chapter covers the configuration files and customization options available
12
12
 
13
13
  <!-- {{text: List all configuration files loaded by this tool in a table, including their locations and roles. Main files: .sdd-forge/config.json (project settings), .sdd-forge/context.json (project context), .sdd-forge/projects.json (multi-project management), .sdd-forge/current-spec (SDD flow state), .sdd-forge/output/analysis.json (analysis results), .sdd-forge/output/summary.json (lightweight version for AI).}} -->
14
14
 
15
- All configuration and generated state files are stored under the `.sdd-forge/` directory at the working root of your project. The table below lists each file, its location, and its purpose.
15
+ All configuration and state files are stored under the `.sdd-forge/` directory at the working root of your project.
16
16
 
17
17
  | File | Location | Role |
18
18
  |---|---|---|
19
- | `config.json` | `.sdd-forge/config.json` | Primary project configuration. Defines output languages, project type, AI providers, document style, and workflow settings. Required before most commands can run. |
20
- | `context.json` | `.sdd-forge/context.json` | Free-form project context string passed to AI agents as supplementary background information. Takes priority over `textFill.projectContext` in `config.json`. |
21
- | `projects.json` | `.sdd-forge/projects.json` | Multi-project registry. Created by `sdd-forge setup`. Maps project names to their source and working root paths. |
22
- | `current-spec` | `.sdd-forge/current-spec` | JSON file tracking the active SDD flow state, including the spec path, base branch, and feature branch. Deleted at flow completion. |
23
- | `analysis.json` | `.sdd-forge/output/analysis.json` | Full source code analysis result produced by `sdd-forge scan`. Stored in compact JSON (no indentation). |
24
- | `summary.json` | `.sdd-forge/output/summary.json` | Lightweight version of `analysis.json` optimized for AI input. Used in preference to `analysis.json` by commands such as `forge`, `agents`, and `init`. |
19
+ | `config.json` | `.sdd-forge/config.json` | Primary project configuration. Defines output languages, project type, AI agent settings, document style, and workflow options. Validated on load. |
20
+ | `context.json` | `.sdd-forge/context.json` | Free-form project context string passed to AI during text generation. Takes priority over `textFill.projectContext` in `config.json`. |
21
+ | `projects.json` | `.sdd-forge/projects.json` | Multi-project registry. Maps project names to their source and work root paths. Generated by `sdd-forge setup`. |
22
+ | `current-spec` | `.sdd-forge/current-spec` | JSON file tracking the active SDD flow state, including spec path, base branch, feature branch, and worktree information. Deleted on flow completion. |
23
+ | `analysis.json` | `.sdd-forge/output/analysis.json` | Full source code analysis result produced by `sdd-forge scan`. Stored without indentation for compact output. |
24
+ | `summary.json` | `.sdd-forge/output/summary.json` | Lightweight version of `analysis.json` optimized for AI consumption. Used in preference to `analysis.json` wherever available. |
25
25
 
26
26
  ### Configuration Reference
27
27
 
28
28
  <!-- {{text: Describe all fields in .sdd-forge/config.json in a table format. Include field name, whether required, type, default value, and description. Main fields: output.languages (output language list), output.default (default language), output.mode (translate/generate), lang (CLI operating language), type (project type), documentStyle (purpose/tone/customInstruction), textFill (projectContext/preamblePatterns), defaultAgent, providers (AI agent definitions), flow.merge (squash/ff-only/merge), limits (concurrency/designTimeoutMs).}} -->
29
29
 
30
- The following table describes every supported field in `.sdd-forge/config.json`. Fields marked **Required** must be present for the tool to operate correctly.
30
+ The table below describes every supported field in `.sdd-forge/config.json`.
31
31
 
32
32
  | Field | Required | Type | Default | Description |
33
33
  |---|---|---|---|---|
34
- | `output.languages` | ✅ | `string[]` | — | List of output languages for generated documentation (e.g., `["ja"]`, `["en", "ja"]`). |
35
- | `output.default` | ✅ | `string` | — | The primary language used when generating documentation (e.g., `"ja"`). |
36
- | `output.mode` | — | `"translate"` \| `"generate"` | `"translate"` | How non-default languages are produced. `translate` derives them from the default-language output; `generate` produces them independently. |
37
- | `lang` | ✅ | `string` | — | Operating language for the CLI, AGENTS.md, skill prompts, and spec files (e.g., `"ja"`, `"en"`). |
38
- | `type` | ✅ | `string` | — | Project type identifier that selects the matching preset (e.g., `"webapp/cakephp2"`, `"cli/node-cli"`). |
39
- | `uiLang` | — | `"en"` \| `"ja"` | — | Language used for CLI interface messages. |
40
- | `documentStyle.purpose` | — | `string` | — | Describes the intended audience and purpose of the generated documentation. |
41
- | `documentStyle.tone` | — | `"polite"` \| `"formal"` \| `"casual"` | — | Controls the writing style applied by the AI when generating documentation text. |
42
- | `documentStyle.customInstruction` | — | `string` | — | Additional free-form instructions passed to the AI agent during text generation. |
43
- | `textFill.projectContext` | — | `string` | — | A brief description of the project used as supplementary context for AI generation. Overridden by `context.json` if present. |
44
- | `textFill.preamblePatterns` | — | `object[]` | — | Patterns used to strip unwanted preamble text from LLM output before it is written to documentation files. |
45
- | `defaultAgent` | — | `string` | — | The key name of the AI provider defined in `providers` to use when no explicit `--agent` flag is given. |
46
- | `providers` | — | `object` | — | A map of named AI agent definitions. Each entry specifies `command`, `args`, optional `timeoutMs`, and `systemPromptFlag`. |
47
- | `flow.merge` | — | `"squash"` \| `"ff-only"` \| `"merge"` | `"squash"` | Git merge strategy applied when closing an SDD flow and merging the feature branch back to the base branch. |
48
- | `limits.concurrency` | — | `number` | `5` | Number of files processed in parallel during documentation generation. |
49
- | `limits.designTimeoutMs` | — | `number` | — | Maximum time in milliseconds allowed for a single AI agent call before it is considered timed out. |
34
+ | `output.languages` | ✅ | `string[]` | — | List of output languages for generated docs (e.g., `["ja"]`, `["en", "ja"]`). |
35
+ | `output.default` | ✅ | `string` | — | The primary output language used when generating documents. |
36
+ | `output.mode` | — | `"translate"` \| `"generate"` | `"translate"` | How non-default languages are produced: `translate` uses the default output as source; `generate` calls AI independently. |
37
+ | `lang` | ✅ | `string` | — | Operating language for the CLI, AGENTS.md, skill prompts, and spec files. |
38
+ | `type` | ✅ | `string` | — | Project type that selects the active preset (e.g., `"cli/node-cli"`, `"webapp/cakephp2"`). |
39
+ | `uiLang` | — | `"en"` \| `"ja"` | — | Language for sdd-forge's own UI messages. |
40
+ | `documentStyle.purpose` | — | `string` | — | A short description of the document's intended audience or purpose, passed to AI during generation. |
41
+ | `documentStyle.tone` | — | `"polite"` \| `"formal"` \| `"casual"` | — | Writing tone applied to AI-generated text sections. |
42
+ | `documentStyle.customInstruction` | — | `string` | — | Additional freeform instruction appended to AI prompts for every text generation task. |
43
+ | `textFill.projectContext` | — | `string` | — | Project overview text supplied to AI. Overridden by `context.json` when that file exists. |
44
+ | `textFill.preamblePatterns` | — | `object[]` | — | Patterns used to strip LLM-generated preamble text from AI responses before inserting into docs. |
45
+ | `defaultAgent` | — | `string` | — | Name of the AI provider entry (from `providers`) used when no agent is explicitly specified. |
46
+ | `providers` | — | `object` | — | Map of named AI agent definitions. Each entry specifies `command`, `args`, optional `timeoutMs`, and `systemPromptFlag`. |
47
+ | `flow.merge` | — | `"squash"` \| `"ff-only"` \| `"merge"` | `"squash"` | Git merge strategy applied when closing an SDD flow. |
48
+ | `limits.concurrency` | — | `number` | `5` | Maximum number of files processed in parallel during document generation. |
49
+ | `limits.designTimeoutMs` | — | `number` | — | Timeout in milliseconds for AI agent calls during document generation. |
50
50
 
51
51
  ### Customization Points
52
52
 
@@ -54,7 +54,7 @@ The following table describes every supported field in `.sdd-forge/config.json`.
54
54
 
55
55
  **1. AI Provider Settings**
56
56
 
57
- The `providers` field lets you register one or more AI agents and control how sdd-forge invokes them. Each provider entry specifies the executable command, the argument list (use `{{PROMPT}}` as a placeholder for the prompt if omitted it is appended automatically), an optional timeout, and how the system prompt is passed.
57
+ The `providers` field defines one or more named AI agents. Each entry specifies the executable command, argument list, an optional timeout, and how system prompts are passed. Use `defaultAgent` to select which provider is active by default.
58
58
 
59
59
  ```json
60
60
  {
@@ -62,7 +62,7 @@ The `providers` field lets you register one or more AI agents and control how sd
62
62
  "providers": {
63
63
  "claude": {
64
64
  "command": "claude",
65
- "args": ["--model", "claude-opus-4-5", "-p", "{{PROMPT}}"],
65
+ "args": ["--model", "claude-opus-4-5", "{{PROMPT}}"],
66
66
  "timeoutMs": 180000,
67
67
  "systemPromptFlag": "--system-prompt"
68
68
  }
@@ -70,23 +70,25 @@ The `providers` field lets you register one or more AI agents and control how sd
70
70
  }
71
71
  ```
72
72
 
73
+ The `{{PROMPT}}` placeholder in `args` marks where the generated prompt is injected. If omitted, the prompt is appended at the end of the argument list. Set `systemPromptFlag` to `"--system-prompt-file"` when the agent expects a file path rather than an inline string.
74
+
73
75
  **2. Document Style**
74
76
 
75
- The `documentStyle` block shapes the tone and focus of every AI-generated text section. Set `purpose` to describe who will read the documentation, `tone` to control formality, and `customInstruction` to pass any project-specific writing rules directly to the AI.
77
+ The `documentStyle` field controls the tone and purpose of AI-generated documentation. Use `customInstruction` to enforce project-specific writing conventions.
76
78
 
77
79
  ```json
78
80
  {
79
81
  "documentStyle": {
80
- "purpose": "Internal reference for backend engineers onboarding to the project",
82
+ "purpose": "Internal reference for backend engineers",
81
83
  "tone": "formal",
82
- "customInstruction": "Always use active voice and avoid passive constructions."
84
+ "customInstruction": "Always include code examples for each API method."
83
85
  }
84
86
  }
85
87
  ```
86
88
 
87
89
  **3. Preset Selection**
88
90
 
89
- The `type` field selects the preset that determines which source files are scanned and which documentation template structure is applied. Choose the value that best matches your project's architecture.
91
+ The `type` field selects the preset that determines which source files are scanned and which document chapters are generated. Choose the value that best matches your project's architecture.
90
92
 
91
93
  ```json
92
94
  {
@@ -94,11 +96,11 @@ The `type` field selects the preset that determines which source files are scann
94
96
  }
95
97
  ```
96
98
 
97
- Available preset keys include `webapp/cakephp2`, `webapp/laravel`, `webapp/symfony`, and `cli/node-cli`. Use `sdd-forge presets` to list all available options.
99
+ Available built-in values include `"cli/node-cli"`, `"webapp/cakephp2"`, `"webapp/laravel"`, and `"webapp/symfony"`. Refer to the preset list for the full set of supported aliases.
98
100
 
99
101
  **4. Merge Strategy**
100
102
 
101
- The `flow.merge` field controls how feature branches are integrated into the base branch at the end of an SDD workflow. `squash` (the default) combines all commits into one clean commit; `ff-only` requires a linear history; `merge` creates a standard merge commit.
103
+ The `flow.merge` field controls how feature branches are merged into the base branch at the end of an SDD flow.
102
104
 
103
105
  ```json
104
106
  {
@@ -108,14 +110,17 @@ The `flow.merge` field controls how feature branches are integrated into the bas
108
110
  }
109
111
  ```
110
112
 
113
+ Use `"squash"` to condense all feature commits into one, `"ff-only"` for a linear history without a merge commit, or `"merge"` for a standard merge commit.
114
+
111
115
  **5. Concurrency**
112
116
 
113
- The `limits.concurrency` field sets the number of source files processed in parallel during documentation generation. Increase this value on machines with sufficient resources to speed up large codebases, or decrease it to reduce memory pressure.
117
+ Adjust `limits.concurrency` to control how many files are processed in parallel during document generation. Lower this value if AI rate limits are being hit; raise it to speed up generation on large codebases.
114
118
 
115
119
  ```json
116
120
  {
117
121
  "limits": {
118
- "concurrency": 10
122
+ "concurrency": 3,
123
+ "designTimeoutMs": 240000
119
124
  }
120
125
  }
121
126
  ```
@@ -124,10 +129,8 @@ The `limits.concurrency` field sets the number of source files processed in para
124
129
 
125
130
  <!-- {{text: List the environment variables referenced by the tool and their purposes in a table. SDD_SOURCE_ROOT (source code root), SDD_WORK_ROOT (working root, location of .sdd-forge/), CLAUDECODE (internal variable removed to prevent Claude CLI hangs).}} -->
126
131
 
127
- The following environment variables influence the behavior of sdd-forge at runtime. They are typically set automatically by the tool itself during command execution, but can also be specified manually when integrating sdd-forge into scripts or CI pipelines.
128
-
129
- | Variable | Direction | Description |
130
- |---|---|---|
131
- | `SDD_SOURCE_ROOT` | Input | Absolute path to the root of the source code being analyzed. When set, overrides the path resolved from `projects.json` or the current working directory. |
132
- | `SDD_WORK_ROOT` | Input | Absolute path to the working root — the directory that contains `.sdd-forge/`. When set, all config, output, and state files are read from and written to this location. |
133
- | `CLAUDECODE` | Internal | An environment variable that sdd-forge actively **removes** before spawning AI agent processes. This prevents the Claude CLI from entering an interactive mode and hanging when standard input is closed. |
132
+ | Variable | Purpose |
133
+ |---|---|
134
+ | `SDD_SOURCE_ROOT` | Absolute path to the source code root being analyzed. When set, overrides the path resolved from `git rev-parse` or the current working directory. |
135
+ | `SDD_WORK_ROOT` | Absolute path to the working root, i.e., the directory containing `.sdd-forge/`. When set, takes priority over the git-resolved root. |
136
+ | `CLAUDECODE` | An internal variable that sdd-forge actively removes from the environment before spawning AI agent processes. This prevents the Claude CLI from hanging when launched as a child process. |