Offline ADR creation and templates
The default filename remains NNNN-kebab-case.md. Repository configuration may opt into unnumbered, adr-prefix, or numeric:1..9 through filename-policy. adr-guard new uses that policy for new files and never renames existing ADRs. Run check first to identify collisions or ambiguous stable identities before a manual migration.
Português (Brasil) · README · Custom template contract · AI template integration
Version availability:
newand optional template-awaredraftare available in published CLI/container releases starting with v1.1.0; older 1.0.x tools do not offer them. Install or update the stable .NET Tool, or use a published release image. The published GitHub Action@v1supportscheck,index, and opt-inreview;newand AI-assisteddraftremain CLI/direct-container workflows.
Structured visual creation and editing are implemented for the CLI 1.7.0 line and require a separately versioned compatible VS Code extension. Confirm publication of both artifacts before relying on the visual forms; implementation in this branch does not make them available in NuGet or the Visual Studio Marketplace.
Native MADR 4.0 generation is available in published CLI 1.11.0 packages and images. Canonical generation remains the default.
Quick start — no AI, account, API key, or network required
Section titled “Quick start — no AI, account, API key, or network required”Run from the repository root with v1.1.0 or newer of the published adr-guard command installed or on your PATH. The destination directory must already exist. The default template is minimal and the default guidance culture is en-US.
mkdir -p docs/adradr-guard new docs/adr --title "Adopt Redis"adr-guard check docs/adradr-guard index docs/adrThe first command writes docs/adr/NNNN-adopt-redis.md, where NNNN is the next available ID after the highest existing ID, not the first gap. On an empty directory this is 0001-adopt-redis.md. new does not update docs/adr/README.md; check validates the ADR set and index creates or refreshes its deterministic README only after validation. index does not overwrite ADR files. Re-running new with the same title after a successful creation allocates a new ID; concurrent creators of the same title sharing the same preview path instead produce an explicit conflict, never a silent overwrite.
Choose Minimal, Extended, Custom, or MADR 4.0
Section titled “Choose Minimal, Extended, Custom, or MADR 4.0”adr-guard new docs/adr --title "Adopt Redis" --template minimal --culture en-USadr-guard new docs/adr --title "Adotar Redis" --template extended --culture pt-BRadr-guard new docs/adr --title "Adopt Cache" --template-file docs/examples/templates/team.en-US.md --culture en-USadr-guard new docs/adr --title "Try Redis" --template extended --previewadr-guard new docs/adr --title "Try Redis" --template extended --dry-runadr-guard new docs/madr --title "Adopt PostgreSQL" --adr-format madr-4adr-guard new docs/madr --title "Adopt a queue" --adr-format madr-4 --template extended --previewOnly minimal and extended are built-in names (case-sensitive). minimal creates the canonical Context, Decision, Consequences sections; extended also adds decision drivers, alternatives, rationale, consequences, risks, and references. --culture controls instructional prose only and accepts en-US or pt-BR. Even in Portuguese, the canonical Markdown section names Status, Context, Decision, Consequences and the generated status Proposed remain in English so the existing validator can read them.
--adr-format madr-4 selects the native MADR renderer. Its minimal template emits Context and Problem Statement, Considered Options, and Decision Outcome; extended adds the supported optional MADR sections. The fixed front matter is status: "proposed", never approval. An explicit format overrides repository adr-format; omitting both preserves canonical output. Custom templates remain canonical-only and cannot be combined with MADR generation.
A custom source is one explicitly selected local UTF-8 .md file, at most 65,536 bytes (64 KiB including an optional UTF-8 BOM). Relative --template-file paths resolve from the directory where the command is launched, not from docs/adr. Put reusable templates outside the ADR destination so check does not interpret them as candidate ADR files. An explicit --template and --template-file are mutually exclusive, even when --template minimal is specified. Files are never discovered recursively. Missing, inaccessible, oversized, malformed, or non-UTF-8 files are rejected before an ADR is saved. See the exact custom file grammar and placeholder rules and a ready-to-copy custom template.
Both --preview and --dry-run calculate the prospective path, validate, and print the full candidate Markdown without creating a file, index, temporary artifact, or ID reservation. A later write may receive a different ID if someone else creates an ADR in the meantime. The destination directory itself must already exist. The renderer always leaves editable guidance rather than pretending to have made a complete architectural decision.
Validated example outputs
Section titled “Validated example outputs”These examples are actual validator-compliant starting drafts, with instructional text deliberately left for the author to replace. Each example lives in a separate directory to avoid duplicate IDs:
- Minimal, English:
0001-adopt-redis.md - Extended, Portuguese guidance:
0001-adotar-redis.md - Custom, English:
0001-adopt-cache.mdfromteam.en-US.md - Custom, Portuguese:
0001-adotar-cache.mdfromteam.pt-BR.md - MADR 4.0, English:
0001-adopt-postgresql.md - MADR 4.0, Portuguese guidance:
0001-adotar-postgresql.md
adr-guard check docs/examples/generated/minimaladr-guard check docs/examples/generated/extendedadr-guard check docs/examples/generated/customadr-guard check docs/examples/generated/custom-pt-BRadr-guard check docs/examples/generated/madr-4 --adr-format madr-4adr-guard check docs/examples/generated/madr-4-pt-BR --adr-format madr-4The repository contract test generates the six examples independently with the installed packaged tool, compares their content byte-for-byte and runs these validation commands. Do not place all samples in the same ADR directory: they each use ID 0001 intentionally.
Custom source grammar and placeholders
Section titled “Custom source grammar and placeholders”A template starts with # {{title}}, followed by a ## Status section whose whole body is {{status}} or Proposed, then nonempty ## Context, ## Decision, and ## Consequences sections. Optional additional literal level-two headings are permitted, but must not collide with required headings. The renderer owns the one H1 title, canonical section headings and Proposed. Templates do not contain executable code.
Recognized exact case-sensitive placeholders: {{title}} (escaped single-line title), {{id}} (four digits), {{status}} (always Proposed), {{context}}, {{decision}}, {{consequences}}, {{guidance-context}}, {{guidance-decision}}, and {{guidance-consequences}}. For offline new, AI content placeholders resolve to empty strings; localized guidance and editable notes supply nonempty sections. The three AI content values are filled only when a separately invoked, explicitly configured template-enabled draft returns them.
Unknown or malformed placeholder syntax, duplicate structural headings and attempted status overrides fail validation. Substitutions occur once, never as shell commands, interpreted expressions or recursive templates. The template does not control the output directory or filename.
Visual-form adapter contract
Section titled “Visual-form adapter contract”adr-guard new <directory> --form is a bounded integration contract for trusted UI adapters, implemented for CLI 1.7.0. It is not an interactive terminal form: it reads one schema 1.0 JSON document from stdin and writes one schema 1.0 JSON response on stdout. Its describe, preview, and create operations support only the native minimal and extended templates. Preview uses the same renderer as creation but never writes or reserves an ID; create reallocates and persists atomically. A configured template-file is reported as incompatible so the adapter can offer the traditional flow without silently changing templates.
The JSON envelope remains schema 1.0; --adr-format stays outside the payload. MADR reuses published IDs for existing clients: required context, optionsConsidered, and decision map to the three required MADR sections; extended adds optional decisionDrivers, consequences, and references (More Information). Distinct form fields for Confirmation or detailed option analysis require a future schema version; traditional extended generation already includes their editable guidance.
Requests use schemaVersion and operation; preview and create also require title plus the string-valued fields object returned by the description, while describe accepts no non-null form content. Responses contain schemaVersion, operation, template (name, compatible, optional reason, and ordered fields), written, and optional path/markdown. Unknown/duplicate properties, unsupported field IDs, NULs, excessive depth/size, missing required fields, and schema versions other than 1.0 fail closed. Form content is never accepted in command-line arguments or operational logs.
{"schemaVersion":"1.0","operation":"preview","title":"Adopt a queue","fields":{"context":"...","decision":"...","consequences":"..."}}The separately versioned VS Code extension uses this contract for guided creation. Structured editing uses adr-guard edit <file> --form with load and save: it supports canonical and MADR 4.0 documents, preserves untouched Markdown, and rejects stale saves by comparing the fingerprint returned by load. See the CLI reference for the exact creation and editing messages, response fields, validation behavior, and exit codes. Use traditional new --title for direct terminal use and for custom templates.
Rendering and newline compatibility
Section titled “Rendering and newline compatibility”Template-rendered output (new and draft with --template/--template-file) uses deterministic LF (\n) on Linux, Windows, and macOS. The legacy draft path without a template intentionally preserves the contract published before this roadmap, including the host-native Environment.NewLine. This exception avoids a silent byte-for-byte change to the existing workflow while keeping the new template contract reproducible across platforms.
Concurrent writing, safety, and errors
Section titled “Concurrent writing, safety, and errors”The same creation path is shared between offline new and AI draft: cooperating writers running as the same OS user on the same host serialize ID allocation under a cross-session named mutex whose identity resolves directory symlink aliases and case aliases on Windows/macOS; the selected template is re-rendered with the final allocated ID while holding that lock, validated, written to a temporary file and atomically promoted without overwriting a destination. Failure/cancellation cleans up temporary files; retry may reuse an uncommitted ID. External non-cooperating writers and different hosts sharing the same filesystem require additional coordination.
The public exit-code contract is 0 success, 1 ADR validation failure, 2 invalid CLI usage (e.g., conflicting template options, unknown template/culture, missing title), 3 operational error (e.g., missing ADR directory, absent/malformed template file, I/O, ID exhaustion or cancellation). Existing invalid ADRs cause code 1 and no new file. On a successful creation, the canonical status is Proposed and MADR metadata is proposed, never automatic architectural approval; a reviewer must replace instructional text and check the reasoning and trade-offs before accepting a decision. ADR Guard validates structure, not technical merit.
Optional AI-assisted draft and distributions
Section titled “Optional AI-assisted draft and distributions”The existing unselected draft behavior, .NET culture handling and provider contract remain intact. You may select --template minimal|extended or --template-file on draft when you intentionally use an AI provider. Template content, guidance and file paths remain local and are not sent to the provider: the provider receives the required --context, each explicitly selected --context-file, and parsed existing ADR context only with --include-existing-adrs. The usual context limits, provider authentication/endpoint requirements, and human review still apply; draft --preview calls the provider but does not persist an ADR. See provider/privacy examples and constraints.
NuGet.org and GitHub Packages distribute the .NET Tool. Both GHCR (ghcr.io/rodri-oliveira-dev/adr-guard) and Docker Hub (rodrigodotnet/adr-guard) distribute the versioned CLI image: run offline new with a writable mount of the ADR directory and no AI credentials; run AI draft only with intentionally supplied credentials and context. See container examples. The published GitHub Action rodri-oliveira-dev/adr-guard@v1 supports check, index, and opt-in review; neither new nor draft is an Action command.