This prompt is designed for a specific job: transforming a user's natural language question about software architecture into a retrieval-optimized query for a RAG system. The ideal user is a developer or architect asking 'should we use X or Y for Z?' or 'what are the trade-offs of pattern A vs. pattern B?'. The required context is a knowledge base containing structured decision rationale, such as Architecture Decision Records (ADRs), design docs, RFCs, and trade-off analyses. The core value is bridging the gap between a conversational question and the precise, consequence-focused language found in these internal documents.
Prompt
Architecture Decision Intent Query Rewrite Prompt Template

When to Use This Prompt
Learn when to deploy the Architecture Decision Intent Query Rewrite Prompt and when to choose a different tool.
You should use this prompt when your retrieval system needs to surface documents that explain the why behind a choice, not just the what. For example, a user question like 'Is PostgreSQL a good fit for our event-sourcing system?' requires a query that retrieves ADRs discussing database selection, consequences of event sourcing, and rejected alternatives like Kafka or MongoDB. A naive keyword or vector search for 'PostgreSQL event sourcing' will likely return API references or generic blog posts. This prompt detects the architectural evaluation intent and generates a query like 'architectural decision record for database selection in event-sourcing systems, including trade-offs, consequences, and rejected alternatives for PostgreSQL, Kafka, and MongoDB'.
Do not use this prompt for general Q&A over code documentation, API references, or runbook procedures. It is specifically tuned for the language of architectural choice and consequence. If a user asks 'How do I create a table in PostgreSQL?', this prompt is the wrong tool; a procedural intent rewrite or a direct RAG query over documentation would be more appropriate. Using this prompt for non-architectural questions will likely produce an over-engineered query that retrieves irrelevant decision records, leading to poor answer quality and wasted context.
Before integrating this prompt, verify that your knowledge base actually contains the type of documents it's designed to retrieve. If your indexed corpus consists mostly of code comments, API specs, and playbooks, the rewritten queries will not improve retrieval. The next step is to review the prompt template and adapt the architectural concern tags to match your team's specific terminology, such as 'design doc', 'RFC', or 'trade-off memo'.
Use Case Fit
Where the Architecture Decision Intent Query Rewrite prompt works and where it introduces risk. Use these cards to decide if this prompt fits your retrieval pipeline before integrating it.
Good Fit: Structured Decision Records
Use when: your knowledge base contains Architecture Decision Records (ADRs), design docs, or RFCs with explicit sections for context, options, and consequences. Why: the prompt's trade-off and consequence tags map directly to these document structures, improving retrieval precision.
Bad Fit: Greenfield Brainstorming
Avoid when: the user is exploring ideas without a concrete decision to evaluate. Risk: the prompt forces a comparative frame onto open-ended exploration, producing queries that retrieve structured trade-off analyses when the user needs broad inspiration or reference architectures. Guardrail: route to a general retrieval prompt first; only apply this rewrite when decision language is detected.
Required Inputs
Requires: a user query containing explicit or implicit comparison language, option enumeration, or trade-off vocabulary. Minimum signal: phrases like 'should we use,' 'trade-offs,' 'pros and cons,' or naming two or more technologies. Guardrail: if no architectural entities are detected, return the original query unchanged rather than forcing a decision frame onto a factual lookup.
Operational Risk: False Decision Framing
What to watch: the prompt may rewrite a factual question as a decision query. Example: 'What is Kubernetes?' becomes a query for Kubernetes trade-off analyses. Guardrail: add an intent confidence threshold. If the decision intent score is below 0.7, fall back to factual lookup rewriting. Log overrides for review.
Operational Risk: Missing Entity Extraction
What to watch: the prompt fails to extract all technologies or options being compared, producing a query that retrieves analysis for only one option. Guardrail: validate that the rewritten query contains all entities from the original. If entities are dropped, generate parallel queries for each missing option and merge results.
Pipeline Placement
Use when: this prompt sits after intent classification and before retrieval execution in a RAG pipeline. Do not use: as the only query rewrite step. Pair with synonym expansion and metadata filter extraction for production retrieval quality. Guardrail: always run entity normalization before this prompt so technology names are canonical before decision framing is applied.
Copy-Ready Prompt Template
A copy-paste template for rewriting user queries to retrieve architecture decision records, trade-off analyses, and design pattern documentation.
This template is designed to be placed in your system prompt or a query rewriting module within a RAG pipeline. Its job is to detect when a user is evaluating architectural choices and transform their natural language question into a retrieval-optimized query. The output includes the rewritten query string and a set of architectural concern tags that you can use as metadata filters against a vector or hybrid search index containing Architecture Decision Records (ADRs), design docs, and RFCs.
textYou are a query rewriting agent for a software architecture knowledge base. Your task is to detect when a user's question indicates they are evaluating an architectural choice, comparing design options, or seeking trade-off analysis. If the intent is architectural decision-making, rewrite the query to maximize retrieval of Architecture Decision Records (ADRs), design pattern documentation, trade-off analyses, and technical RFCs. If the intent is not architectural, return the original query unchanged. ### INPUT User Query: [USER_QUERY] ### OUTPUT SCHEMA Return a valid JSON object with the following fields: { "intent": "architecture_decision" | "other", "rewritten_query": "string", "architectural_concerns": ["string"], "reasoning": "string" } ### REWRITING RULES 1. Expand acronyms and normalize architectural terminology (e.g., 'k8s' -> 'Kubernetes', 'event-driven' -> 'event-driven architecture'). 2. Include synonyms for key concepts: 'ADR', 'decision record', 'design rationale', 'trade-off', 'consequence', 'alternative considered'. 3. Extract and append explicit architectural quality attributes as keywords: scalability, availability, consistency, latency, maintainability, cost, security, deployability. 4. If the query mentions specific technologies, frameworks, or patterns, include their canonical names and common alternatives. 5. Preserve all original constraints and context from the user query. ### ARCHITECTURAL CONCERN TAGS Select from the following controlled vocabulary based on the query content: - scalability - availability - performance - security - maintainability - cost - consistency - durability - latency - deployability - observability - testability - interoperability - data_management - integration_pattern - migration_strategy ### CONSTRAINTS - Do not hallucinate technologies or constraints not present in the original query. - If the query is ambiguous about architectural intent, default to 'other' and return the original query. - The rewritten query must be self-contained and not rely on external conversation context.
To adapt this template, replace [USER_QUERY] with your application's actual user input variable. If your knowledge base uses a different taxonomy for architectural concerns, update the controlled vocabulary list to match your internal tags. For production use, wrap the JSON output in a validation step that confirms the rewritten_query is non-empty and the architectural_concerns array contains only allowed tags. If the model returns "intent": "other", bypass the architecture-specific retrieval index and fall back to your general-purpose search. Always log the reasoning field for debugging false positives where non-architectural queries are misclassified.
Prompt Variables
Required inputs for the Architecture Decision Intent Query Rewrite prompt. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to verify the input is well-formed before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[USER_QUERY] | The raw user question that may contain an architecture decision intent | Should we use a monolith or microservices for our new e-commerce platform? | Non-empty string required. Reject null or whitespace-only input. Minimum 10 characters recommended for intent detection. |
[DOMAIN_CONTEXT] | Optional description of the system domain, tech stack, or organizational constraints | E-commerce platform, team of 12 engineers, AWS infrastructure, Java/Spring ecosystem | Null allowed. If provided, must be a non-empty string. Validate that context does not exceed 500 tokens to avoid diluting the query rewrite. |
[ARCHITECTURE_TAXONOMY] | List of architectural concern categories the system should detect and tag | ["scalability", "fault-tolerance", "data-consistency", "deployment-complexity", "cost-efficiency", "team-structure"] | Must be a valid JSON array of strings. Minimum 3 categories. Reject if array is empty or contains duplicate entries. Each tag should be lowercase with hyphens for spaces. |
[DECISION_RECORD_CORPUS_DESCRIPTION] | Brief description of the architecture decision record corpus being searched | Internal ADR repository with 200+ records covering service boundaries, data storage, and integration patterns | Non-empty string required. Should describe corpus scope and document types. Used to guide query formulation toward available evidence. |
[OUTPUT_SCHEMA] | Expected JSON structure for the rewritten query and metadata | {"rewritten_query": "string", "architectural_concerns": ["string"], "decision_framing": "string", "retrieval_strategy": "string"} | Must be a valid JSON Schema or example object. Validate parseable JSON. Required fields: rewritten_query, architectural_concerns. Optional: decision_framing, retrieval_strategy, confidence. |
[MAX_CONCERN_TAGS] | Upper limit on the number of architectural concern tags to output | 5 | Must be a positive integer between 1 and 10. Default to 5 if not specified. Prevents tag explosion on ambiguous queries. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score required to proceed with automated retrieval without human review | 0.7 | Must be a float between 0.0 and 1.0. If model confidence falls below this threshold, route to human clarification queue. Default 0.7 if not specified. |
Implementation Harness Notes
How to wire the Architecture Decision Intent Query Rewrite prompt into a production RAG pipeline with validation, logging, and fallback strategies.
This prompt is designed as a pre-retrieval transformation step in a software architecture RAG system. It should sit between the user's raw query and the retrieval engine, intercepting natural language questions about architectural choices and rewriting them to target architecture decision records (ADRs), trade-off analyses, and design pattern documentation. The harness must treat this prompt as a structured transformation function: natural language in, a JSON object containing rewritten_query and architectural_concern_tags out. Do not expose the rewritten query to the end user unless you are building a debug or transparency panel. The output is a retrieval artifact, not a user-facing answer.
Wire this prompt into your application as a synchronous pre-retrieval call. Use a model with strong JSON mode or structured output support (e.g., GPT-4o, Claude 3.5 Sonnet) and enforce the output schema at the API level rather than relying solely on the prompt's format instructions. The expected output shape is: {"rewritten_query": "string", "architectural_concern_tags": ["string", ...], "intent_confidence": 0.0-1.0, "requires_clarification": false}. After receiving the output, validate that rewritten_query is non-empty and semantically distinct from the input (a simple string equality or Levenshtein distance check can catch no-op rewrites). If requires_clarification is true or intent_confidence falls below a configurable threshold (start with 0.7), route to a human clarification step or surface a disambiguation question to the user rather than executing a low-confidence retrieval. Log every rewrite alongside the original query, the detected intent, the confidence score, and the final retrieval metrics for offline evaluation.
For retrieval execution, use the rewritten_query as the primary search string and append the architectural_concern_tags as metadata filters or boosted terms depending on your search backend. If you are using a hybrid vector and keyword index, send the rewritten query to both and apply the concern tags as keyword boosts or filter clauses. Common failure modes to monitor: the prompt may produce a rewritten query that is too narrow and misses relevant ADRs, or it may over-generalize and retrieve design pattern documentation that lacks decision rationale. Mitigate this by implementing a post-retrieval check that scans returned documents for structured decision fields (e.g., 'Decision', 'Rationale', 'Consequences', 'Alternatives Considered'). If fewer than a minimum number of documents contain these fields, fall back to a broader retrieval strategy or append the original query as a secondary retrieval pass. Do not use this prompt for real-time chat where latency must be under 200ms; the rewrite step adds a full model inference round-trip and is best suited for asynchronous or slightly delayed retrieval workflows where decision quality outweighs sub-second response times.
Before shipping, build a regression test suite with 20-30 labeled examples covering clear architecture decision queries ('Should we use event sourcing or CQRS?'), ambiguous queries ('What's the best database?'), and non-architecture queries ('How do I write a for loop?'). Measure rewrite relevance, tag accuracy, and downstream retrieval precision against a golden ADR corpus. Run these tests on every prompt version change. In production, set up a feedback loop: when users rate retrieved documents as unhelpful, capture the original query, the rewritten query, and the retrieved document IDs for periodic prompt tuning. Avoid the temptation to chain multiple intent-detection prompts sequentially; if you need to detect architecture intent alongside other intents, use a single multi-class classification prompt rather than running this prompt in parallel with other intent detectors and then selecting the highest-confidence result.
Expected Output Contract
Defines the structure, types, and validation rules for the output of the Architecture Decision Intent Query Rewrite Prompt. Use this contract to build a parser and validator in your application harness before the rewritten query is sent to the retrieval system.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
rewritten_query | string | Must be non-empty. Must differ from [ORIGINAL_QUERY] in at least one token. Must contain architecture-specific terms (e.g., trade-off, pattern, decision, ADR). | |
architectural_concern_tags | array of strings | Must contain at least one tag. Each tag must be a lowercase string from a predefined taxonomy (e.g., 'scalability', 'maintainability', 'cost', 'performance', 'security'). No free-form tags allowed. | |
detected_intent | string | Must exactly equal 'architecture_decision'. Any other value is a failure and should trigger a fallback or human review. | |
intent_confidence | number | Must be a float between 0.0 and 1.0. If below 0.8, the harness should log a warning and may route for human clarification before retrieval. | |
target_document_types | array of strings | Must be a non-empty array. Allowed values are 'architecture_decision_record', 'design_doc', 'tradeoff_analysis', 'pattern_catalog'. Any other value is invalid. | |
requires_human_review | boolean | Must be true if intent_confidence < 0.8 or if the original query contains high-risk architectural terms (e.g., 'critical', 'outage', 'security breach'). Otherwise false. | |
fallback_query | string or null | If intent_confidence < 0.8, this field must be a non-empty string representing a broader, non-intent-specific query. Otherwise, it must be null. |
Common Failure Modes
When rewriting architecture decision queries, these failures degrade retrieval quality and downstream answer accuracy. Each card identifies a specific failure pattern and a concrete guardrail to prevent it.
Intent Misclassification: Comparison Detected as Factual Lookup
What to watch: The model classifies 'Should we use PostgreSQL or MongoDB for this workload?' as a factual lookup instead of a comparison intent. The rewritten query retrieves general documentation rather than trade-off analyses and decision records. Guardrail: Add a few-shot example in the prompt template that explicitly maps architecture comparison phrasing ('vs', 'or', 'trade-offs', 'which is better') to the comparison intent class. Validate intent classification against a golden set of 20+ architecture decision queries before deployment.
Entity Dropping During Query Rewrite
What to watch: The original query mentions specific technologies, patterns, or constraints ('event sourcing with Kafka for audit logging'), but the rewritten query drops critical entities and becomes generic ('event sourcing patterns'). Retrieved documents miss the technology-specific trade-off analysis. Guardrail: Implement a pre-rewrite entity extraction step that identifies architecture-specific terms (technologies, patterns, quality attributes). After rewrite, verify all extracted entities appear in the rewritten query. Log and flag rewrites where entity recall drops below 100%.
Over-Narrowing to a Single Architecture Style
What to watch: The model detects 'microservices' in the query and rewrites it to retrieve only microservices content, even though the user is evaluating whether microservices is appropriate. The retrieval excludes monolith decomposition patterns, modular monolith references, and hybrid approaches that the decision requires. Guardrail: Include an explicit instruction in the prompt template: 'When the user is evaluating an architectural choice, include alternative patterns in the rewritten query. Do not assume the mentioned approach is the correct one.' Test with queries that mention one pattern but require multi-pattern retrieval.
Missing Quality Attribute Constraints
What to watch: A query like 'How should we design for high availability in a multi-region deployment?' gets rewritten as 'multi-region deployment patterns' without preserving the availability constraint. Retrieved documents cover general multi-region setups but miss the availability-specific trade-offs (consistency vs. latency, failover strategies). Guardrail: Extract quality attributes (availability, consistency, latency, scalability, security, maintainability) from the original query as explicit metadata tags. Append these tags to the rewritten query or use them as required filter constraints in the retrieval step.
Context Window Starvation from Over-Expansion
What to watch: The rewrite expands a concise architecture question into a verbose paragraph with multiple synonym expansions, related concepts, and speculative constraints. The expanded query consumes excessive tokens in the retrieval embedding step and dilutes semantic precision. Guardrail: Set a maximum token budget for rewritten queries (e.g., 2-3x the original query length). If the rewrite exceeds the budget, truncate to the highest-salience terms. Log expansion ratio metrics and alert when average expansion exceeds 3x in production.
Temporal Context Loss in Decision Record Retrieval
What to watch: The user asks 'What was the rationale for choosing gRPC in 2023?' and the rewrite drops the temporal constraint, retrieving all gRPC decision records regardless of date. The retrieved context includes outdated decisions that contradict the current architecture state. Guardrail: Extract explicit and implicit temporal references from the original query. If a date, year, or relative time expression is present, preserve it as a metadata filter in the rewritten query output. Test with queries containing 'last year', 'Q3', '2022', and 'recently' to verify temporal constraint preservation.
Evaluation Rubric
Use this rubric to test the Architecture Decision Intent Query Rewrite prompt before deploying it to production. Each criterion targets a specific failure mode common in intent-driven retrieval for software architecture RAG systems.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Intent Classification Accuracy | Correctly classifies the query as 'architecture_decision' when the user is evaluating trade-offs, comparing patterns, or selecting a design approach. | Misclassifies the query as 'factual_lookup', 'procedural', or 'summarization' when the user is clearly weighing architectural options. | Run a golden set of 20 architecture decision queries and 20 non-decision queries. Measure precision and recall for the 'architecture_decision' label. Pass threshold: F1 >= 0.90. |
Architectural Concern Tag Extraction | Extracts relevant architectural concern tags (e.g., 'scalability', 'consistency', 'latency', 'coupling') that match the decision dimensions implied by the query. | Returns generic tags like 'architecture' or misses critical quality attributes explicitly mentioned in the user query. Returns tags for concerns not present in the query. | Compare extracted tags against a human-labeled set of concern tags for 15 test queries. Require recall >= 0.85 and precision >= 0.80 on concern tag extraction. |
Rewritten Query Retrieval Relevance | The rewritten query retrieves documents containing structured decision rationale, trade-off analysis, or ADR content when executed against the target architecture knowledge base. | The rewritten query retrieves API reference docs, tutorials, or generic definitions instead of decision records and trade-off analyses. | Execute the rewritten query against the production retrieval index. Have a domain expert rate the top-5 retrieved documents as 'relevant to architecture decision-making' on a 3-point scale. Require NDCG@5 >= 0.80. |
Entity and Technology Name Preservation | Preserves specific technology names, framework references, and architectural pattern names from the original query in the rewritten output. | Drops or replaces specific technology names (e.g., 'Kafka' becomes 'message queue') causing retrieval to miss version-specific or technology-specific ADRs. | Use a set of 10 queries containing explicit technology names. Check exact string match for each technology entity in the rewritten query. Require 100% preservation of proper noun entities. |
Decision Dimension Coverage | The rewritten query expands to cover multiple decision dimensions when the user query implies trade-offs (e.g., cost vs performance, consistency vs availability). | The rewritten query narrows to a single dimension, losing the comparative or trade-off structure of the original user intent. | For 10 queries with explicit or implicit trade-offs, verify that the rewritten query contains terms for all dimensions. Require >= 90% dimension coverage rate. |
Output Schema Compliance | Returns valid JSON matching the defined output schema with all required fields present and correctly typed. | Returns malformed JSON, missing required fields, or fields with incorrect types (e.g., array instead of string for 'rewritten_query'). | Validate output against the JSON schema using a programmatic validator. Run 50 test cases. Require 100% schema compliance. Any schema violation is a hard failure. |
Confidence Score Calibration | Assigns a confidence score >= 0.80 when the intent is unambiguously 'architecture_decision' and <= 0.50 when the query is clearly not about architectural decisions. | Assigns high confidence to non-decision queries or low confidence to clear architecture decision queries, causing incorrect routing or unnecessary clarification prompts. | Plot confidence scores against actual intent labels for 100 labeled queries. Calculate Expected Calibration Error (ECE). Require ECE <= 0.10. Visually inspect the reliability diagram for systematic overconfidence. |
Abstention on Non-Architecture Queries | Returns a low confidence score and an empty or null rewritten_query when the input is not an architecture decision query (e.g., a coding syntax question or a general conversation). | Forcefully rewrites non-architecture queries into architecture decision queries, polluting retrieval with irrelevant results. | Submit 20 non-architecture queries (code examples, general chat, factual definitions). Require that >= 90% have confidence <= 0.40 and produce either a null rewritten_query or an explicit 'not_applicable' flag. |
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 and minimal post-processing. Focus on getting the rewritten query and architectural concern tags correct before adding retrieval logic.
Prompt modification
- Remove strict output schema requirements; accept a paragraph with the rewritten query and tags inline.
- Drop the
[CONFIDENCE_THRESHOLD]gate; always return a rewrite. - Use a simple system prompt: "You are an architecture decision analyst. Rewrite the user's question to retrieve architecture decision records and trade-off analyses."
Watch for
- The model inventing ADR titles or decision outcomes instead of rewriting for retrieval.
- Missing architectural concern tags when the user question is vague.
- Overly narrow rewrites that drop context the user implied but didn't state explicitly.

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