This prompt is designed for platform engineers and tech leads who need to reconstruct the architectural decision history of an existing codebase. The primary job-to-be-done is onboarding: when new developers join a team, they need to understand not just what the code does, but why specific architectural choices were made. This prompt automates the discovery of that rationale by scanning repository artifacts—commit messages, pull request discussions, design documents, code comments, and configuration files—to identify decisions and produce structured Architecture Decision Records (ADRs). It is a forensic tool for extracting institutional knowledge that was never formally documented.
Prompt
Architecture Decision Record Extraction Prompt Template

When to Use This Prompt
Understand the job-to-be-done, the ideal user, the required context, and the boundaries for the Architecture Decision Record Extraction prompt.
Use this prompt when you have a repository with a meaningful history of changes and discussions but lack formal ADRs. The prompt requires access to a rich context: a codebase with a non-trivial git log, pull request threads with substantive debate, inline code comments that explain workarounds or trade-offs, and design documents stored in the repository. The output is a set of structured ADRs, each containing a title, context, decision, consequences, and a list of traceable source references (e.g., commit SHAs, PR numbers, file paths with line annotations). This traceability is the core value proposition—every architectural claim must be grounded in evidence, not inferred from thin air. Do not use this prompt for greenfield projects where no decisions have been made yet, or for generating aspirational ADRs from scratch without repository evidence. It is also unsuitable for repositories with squashed git histories or those that lack any form of design discussion in their artifacts.
Before running this prompt, ensure you have assembled the repository context into a format the model can consume. This typically means providing a concatenated dump of relevant git log entries, PR descriptions, markdown design docs, and key configuration files. The prompt works best when you constrain the scope to a specific architectural domain (e.g., database choices, API design, or service boundaries) rather than asking it to extract every decision from the entire codebase at once. After generation, every ADR must pass a human review step where a senior engineer verifies that the cited sources actually support the stated decision and rationale. The next step is to integrate these generated ADRs into your project's docs/decisions/ directory and treat them as living documents that can be refined as new context emerges.
Use Case Fit
Where the Architecture Decision Record extraction prompt works, where it fails, and what you need before running it.
Strong Fit: Retroactive Decision Capture
Use when: your team has a history of pull request discussions, design doc comments, and commit messages that contain architectural rationale, but no formal ADRs exist. Guardrail: the prompt works best when source material includes explicit trade-off discussion. Run a coverage check first to confirm enough signal exists in the repository.
Poor Fit: Greenfield Projects Without History
Avoid when: the repository has fewer than 50 commits, no design documents, and no pull request discussions. The prompt extracts decisions from evidence; it cannot invent decisions that were never discussed. Guardrail: use the forward-looking ADR generation prompt instead, which helps teams write new decisions with structured rationale.
Required Inputs: Source Material Inventory
What you need: commit history with messages, closed pull request discussions, design documents in the repository, code comments referencing architectural intent, and issue tracker exports if available. Guardrail: create a source manifest before running extraction. Missing sources produce thin ADRs with low evidence scores. The eval step should flag ADRs with fewer than two source references.
Operational Risk: Fabricated Rationale
What to watch: the model may invent plausible-sounding rationale that does not appear in any source document. This is the highest-risk failure mode for retrospective ADRs. Guardrail: every generated ADR must include source references with commit hashes, PR numbers, or document sections. Run the evidence-grounding eval before accepting any output. Flag and discard ADRs where rationale cannot be traced to a source.
Operational Risk: Stale or Superseded Decisions
What to watch: the prompt may extract a decision that was later reversed or superseded, producing an ADR that contradicts current architecture. Guardrail: cross-reference extracted decisions against current code structure. If the code no longer matches the decision, mark the ADR as superseded with a pointer to the replacement decision or the commit that reversed it.
Boundary: Not a Replacement for Human Review
What to watch: teams may treat auto-generated ADRs as authoritative without human verification. Guardrail: every extracted ADR must go through a human approval step before merging into the ADR repository. The reviewer should confirm that the decision, context, and consequences match their understanding and that source references are valid. Add an approval field to the output schema.
Copy-Ready Prompt Template
A ready-to-use prompt template for extracting structured Architecture Decision Records from repository context, including commit history, PR discussions, and design docs.
This prompt template is designed to be pasted directly into your AI coding agent or LLM workflow. It instructs the model to act as a software architect analyzing a repository to retroactively produce Architecture Decision Records (ADRs). The template uses square-bracket placeholders that you must replace with actual values before execution. The core job is to transform unstructured signals—commit messages, pull request discussions, code comments, and design documents—into a structured, traceable decision log.
markdownYou are a senior software architect tasked with extracting Architecture Decision Records (ADRs) from a repository's history and context. Your goal is to produce a set of structured, evidence-backed ADRs that explain the key technical decisions made in this codebase. ## Input Context You will be provided with the following repository context. Analyze it carefully to identify architectural decisions. - **Repository Summary:** [REPOSITORY_SUMMARY] - **Relevant Commit History:** [COMMIT_HISTORY] - **Pull Request Discussions:** [PR_DISCUSSIONS] - **Design Document Excerpts:** [DESIGN_DOC_EXCERPTS] - **Key Code Comments/Annotations:** [CODE_COMMENTS] ## Output Schema For each distinct architectural decision you identify, generate a JSON object conforming to this schema. Return a JSON array of these objects. { "adrs": [ { "title": "string (concise decision title)", "status": "string (proposed | accepted | deprecated | superseded)", "context": "string (the problem, forces, and constraints that led to this decision)", "decision": "string (the specific architectural choice that was made)", "consequences": "string (the resulting context, both positive and negative)", "evidence": [ { "source_type": "string (commit | pr_discussion | design_doc | code_comment)", "source_reference": "string (e.g., commit hash, PR number, file path and line)", "excerpt": "string (the direct quote or summary of the evidence)" } ] } ] } ## Constraints - [CONSTRAINTS] - Only create an ADR if you have sufficient evidence from the provided context. Do not fabricate decisions. - If a decision is clearly documented but its status is ambiguous, default to "accepted" and note the ambiguity in the consequences. - Link every ADR to at least one piece of concrete evidence. - If no architectural decisions can be reliably extracted, return an empty `adrs` array.
To adapt this template, start by populating the [REPOSITORY_SUMMARY] and other context placeholders with data pulled from your actual repository. The [CONSTRAINTS] placeholder is critical for tailoring the output; for example, you might add constraints like Focus only on decisions related to data persistence and API design or Ignore decisions made before 2023-01-01. After running the prompt, you must validate the output by checking that each evidence.source_reference is a real, verifiable link to a commit, file, or PR in your repository. For high-stakes documentation, a human architect should review the generated ADRs for accuracy and completeness before they are committed to the project's decision log.
Prompt Variables
Required and optional inputs for the Architecture Decision Record extraction prompt. Each placeholder must be populated with concrete repository context before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[REPOSITORY_CONTEXT] | Raw source material for ADR extraction: commit messages, PR discussions, design doc fragments, code comments, and README sections | git log --oneline v1.0..v2.0; PR #342 discussion thread; /docs/decisions/0001-use-postgres.md | Must contain at least one decision point. Null not allowed. Validate minimum token length > 200. If empty, abort extraction and request input. |
[DECISION_TIMEFRAME] | Date range or commit range bounding the decisions to extract, preventing extraction of outdated or irrelevant history | 2024-01-01..2024-06-30; commits between tag v2.0 and v3.0; last 90 days | Optional. If null, extract from full repository history. Validate date format as ISO 8601 or git revision range. Warn if range spans > 2 years without explicit override. |
[ADR_TEMPLATE] | Target structure for each extracted decision record, defining required sections and field names | Context, Decision, Consequences, Alternatives Considered, Source References, Status, Date | Must include at minimum: Decision, Context, and Source References. Validate against schema before extraction. If missing required fields, use default template: Context, Decision, Consequences, Sources. |
[SOURCE_GROUNDING_LEVEL] | Controls how strictly extracted claims must be linked to specific source evidence in the repository context | strict; moderate; minimal | Default: strict. Strict requires line-level or comment-level citation for every decision claim. Moderate allows section-level citation. Minimal allows file-level citation. Validate enum match. If unrecognized, default to strict. |
[OUTPUT_SCHEMA] | Expected JSON or Markdown schema for each ADR record, defining field types, required fields, and array structures | {"type": "object", "properties": {"title": {"type": "string"}, "status": {"enum": ["proposed", "accepted", "deprecated", "superseded"]}}, "required": ["title", "status", "decision", "sources"]} | Must be valid JSON Schema or explicit field list. Validate parseable schema before extraction. If null, output as structured Markdown with H2 sections. Reject malformed schemas and request correction. |
[EXISTING_ADRS] | Previously documented decisions to avoid duplication and to detect superseding or conflicting decisions | Existing /docs/adr/ directory contents; JSON array of prior ADR titles and dates | Optional. If provided, cross-reference extracted decisions against existing records. Flag duplicates with confidence > 0.8. Detect superseded decisions and mark status accordingly. If null, skip deduplication. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score for including an extracted decision in output; decisions below threshold are flagged for human review | 0.7; 0.85 | Default: 0.7. Range 0.0-1.0. Validate numeric parse. Decisions below threshold go to review queue with source excerpts. If threshold > 0.9, warn that recall may drop significantly. |
[MAX_ADRS] | Upper limit on number of ADRs to extract in a single run, preventing unbounded output from large repositories | 10; 25; null | Default: 15. Validate integer > 0. If null, extract all decisions above confidence threshold. If repository context contains > 50 candidate decisions, require explicit override to proceed without limit. |
Implementation Harness Notes
How to wire the ADR extraction prompt into an application or workflow with validation, retries, and human review.
This prompt is designed to be called programmatically as part of a documentation pipeline, not as a one-off chat interaction. The implementation harness should treat each ADR extraction as a batch job: gather the required context from the repository, assemble the prompt, call the model, validate the output, and store the result. Because ADRs are durable engineering records, the harness must enforce evidence grounding and decision traceability before any output is accepted into the documentation repository.
The harness should assemble the [REPOSITORY_CONTEXT] input from multiple sources: commit messages filtered by architectural keywords (e.g., 'refactor', 'extract', 'introduce pattern'), pull request descriptions and comments from merged PRs, design document fragments from /docs or /rfcs, and inline code comments near module boundaries. Use a retrieval step to gather relevant context before prompt assembly. For model choice, prefer a model with strong reasoning and long-context handling (e.g., Claude 3.5 Sonnet or GPT-4o). Set temperature low (0.0–0.2) to maximize factual consistency. The output must conform to the [OUTPUT_SCHEMA] defined in the prompt template—validate this structurally before accepting the response. If the model returns malformed JSON or missing required fields, retry once with a repair prompt that includes the validation error message. After structural validation, run evidence-grounding checks: for each ADR, verify that the source_references field contains actual commit hashes, file paths, or PR numbers that exist in the repository. Flag any ADR where the decision field cannot be traced to at least one concrete source reference.
Store validated ADRs in a version-controlled directory (e.g., /docs/adr/) with a naming convention like ADR-{NNN}-{slug}.md. Log every extraction run with the prompt version, model used, input context hash, validation results, and any human review flags. For high-risk architectural decisions—those involving security boundaries, data integrity, or system contracts—require human approval before the ADR is merged. The harness should create a draft PR with the generated ADRs and request review from a designated architecture owner. Avoid fully automated merging of ADRs without review; the prompt extracts and structures evidence, but architectural judgment about correctness and completeness remains a human responsibility.
Expected Output Contract
Fields, format, and validation rules for each extracted Architecture Decision Record. Use this contract to build a post-processing validator or structured output schema.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
adr_id | string (slug) | Must match pattern | |
title | string | Must be a single sentence under 120 characters. Must not be identical to any other ADR title in the output. | |
status | enum | Must be one of: | |
context | string | Must contain at least one explicit reference to a source file path, commit hash, or PR number. Minimum 50 characters. | |
decision | string | Must describe a concrete action or choice. Must not be a restatement of the context. Minimum 30 characters. | |
consequences | array of strings | Must contain at least one item. Each item must be a distinct positive, negative, or neutral consequence. No empty strings allowed. | |
source_references | array of objects | Each object must have | |
superseded_by | string or null | Required when status is |
Common Failure Modes
What breaks first when extracting architecture decision records from repository context and how to guard against it.
Hallucinated Decisions
What to watch: The model invents ADRs that don't exist, fabricates decision dates, or attributes choices to non-existent discussions. This happens when the prompt treats sparse or ambiguous signals as definitive evidence. Guardrail: Require explicit source citations for every ADR field. If a decision, date, or rationale cannot be linked to a commit SHA, PR comment, or design doc section, the output must mark it as uncertain or omit it entirely.
Missing Context from Siloed Sources
What to watch: The model extracts decisions from code comments but misses the PR discussion that explains why. Or it reads a design doc but ignores the commit history that shows the decision was later reversed. Partial context produces misleading ADRs. Guardrail: Cross-reference multiple source types (commits, PRs, docs, config changes) before finalizing a decision record. Flag ADRs where only one source type was available and surface the evidence gap to the reviewer.
Temporal Confusion
What to watch: The model misorders decisions, treats a superseded decision as current, or fails to recognize that a later commit reversed an earlier choice. ADRs become historically inaccurate and mislead future readers. Guardrail: Sort evidence by timestamp before extraction. Require the model to check for reversal signals (revert commits, deprecation comments, updated docs) and produce a status field that distinguishes accepted, superseded, and deprecated decisions.
Rationale Fabrication
What to watch: The model generates plausible-sounding rationale that wasn't actually discussed. It fills gaps with generic reasoning like 'chosen for performance' or 'selected for team familiarity' without evidence. Guardrail: Require rationale to be quoted or closely paraphrased from source material. Add a rationale_source field that points to the exact comment, commit message, or document paragraph. If no rationale exists in the sources, output rationale: "not documented" rather than inventing one.
Over-Extraction from Code Patterns
What to watch: The model treats every architectural pattern it finds in code as an explicit decision. A singleton usage becomes 'Team decided to use Singleton pattern' when it may have been an unconsidered default or legacy code. Guardrail: Distinguish between decisions explicitly discussed in design artifacts and patterns inferred from code alone. Add an evidence_strength field with values like explicit (documented decision), inferred (pattern observed in code), and uncertain. Flag all inferred ADRs for human review.
Context Window Truncation
What to watch: Large repositories with extensive commit histories, long PR discussions, and multiple design docs exceed the model's context window. The model silently drops evidence and produces incomplete or incorrect ADRs. Guardrail: Chunk repository context by time period, module, or decision topic before extraction. Process each chunk independently and merge results with deduplication logic. Log which sources were included and which were truncated so reviewers can assess completeness.
Evaluation Rubric
Criteria for testing Architecture Decision Record extraction quality before production deployment. Each row defines a pass standard, failure signal, and test method to validate that extracted ADRs are grounded, traceable, and complete.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Evidence Grounding | Every decision claim cites at least one source reference from commit messages, PR discussions, or design docs | Decision statements lack source references or cite fabricated evidence | Automated check: extract all citation markers and verify each resolves to an actual file path or commit SHA in the repository |
Decision Traceability | Each ADR includes context, decision, and consequences sections with non-empty content | Missing sections or placeholder text in any required ADR field | Schema validation: parse output against ADR template schema and reject records with empty required fields |
Source Accuracy | Quoted or paraphrased source material matches the original text within 95% similarity threshold | Hallucinated rationale that contradicts actual commit messages or design doc content | Spot-check sample: compare 5 extracted ADR claims against original source files using string similarity or manual review |
Option Coverage | At least two alternatives considered are documented with pros and cons when source evidence supports them | Single-option ADRs when source discussions show multiple alternatives were debated | Count check: verify alternatives_considered array length >= 2 when source PR or design doc contains comparison language |
Stakeholder Attribution | Decision authors and approvers are extracted from commit authors or PR participants when identifiable | Anonymous decisions with no author attribution despite available git blame data | Field presence check: author field populated when git log shows clear authorship for related commits |
Temporal Accuracy | Decision date matches the timestamp of the relevant commit or PR merge within a 24-hour window | Decision date set to extraction date rather than original decision date | Timestamp comparison: compare extracted date against git log date for cited commit SHA |
Consequence Completeness | Positive and negative consequences are documented when source material mentions trade-offs or follow-up work | Only positive consequences listed when source material explicitly mentions drawbacks or technical debt | Sentiment check: scan source references for negative-sentiment phrases and verify they appear in consequences section |
Cross-Reference Integrity | Related ADRs are linked when source material references prior decisions or follow-up ADRs | Broken or missing cross-references to ADRs that exist in the repository | Link validation: resolve all related ADR references against actual ADR files in the repository and flag 404s |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet) and minimal validation. Accept the first output that parses as valid JSON. Skip evidence-linking checks and source-reference verification.
Simplify the output schema to only require title, status, context, decision, and consequences. Drop alternatives_considered and source_references fields.
Prompt modification
codeExtract architecture decisions from [REPOSITORY_CONTEXT]. Return JSON array with fields: title, status, context, decision, consequences.
Watch for
- Fabricated decisions not present in source material
- Missing context that makes decisions unintelligible
- Overly generic decisions that could apply to any codebase
- No distinction between actual decisions and aspirational comments

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us