This prompt is designed for test architects and SDETs who need to convert a known module dependency graph and a set of recent code changes into a defensible, risk-prioritized test execution order. The core job-to-be-done is reducing the feedback loop for propagation failures: when module A changes, you need to know whether to run tests for module A first, or if downstream module B carries a higher risk of a transitive break. Use this when you have a structured representation of your system's dependencies (e.g., a JSON or DOT graph), a list of modified modules from a diff or changelist, and a mapping of test suites to the modules they cover. The prompt's value is in making the prioritization rationale explicit and auditable, not just producing a list of tests.
Prompt
Dependency Graph Impact Analysis Prompt for Test Prioritization

When to Use This Prompt
Defines the ideal scenario, required inputs, and boundaries for using the dependency graph impact analysis prompt to prioritize test execution.
This prompt is most effective inside a risk-based test selection workflow where a human or an automated system will review the reasoning before committing to a reduced test suite. You should not use this prompt when you lack a reliable dependency graph, when the graph is too coarse (e.g., only top-level services without internal module boundaries), or when test-to-module mappings are incomplete. It is also not a replacement for a full CI/CD pipeline that runs all tests on a merge to main; it is a tool for pre-merge or pre-release risk assessment where execution time is constrained and you must justify which tests to skip. The prompt assumes you can provide the dependency graph as structured data—if your architecture is undocumented, invest in generating that graph first through static analysis or build tooling before applying this prompt.
Before using this prompt, ensure you have defined a maximum transitive depth for impact analysis. Without a depth limit, a change in a leaf utility module can theoretically propagate to every test in the system, making the output useless. A typical starting point is a depth of 2 or 3, which you can tune based on your system's coupling characteristics. Also, prepare a validation step for circular dependencies: the prompt includes instructions for handling them, but you should verify that the model's resolution matches your architectural reality. Finally, treat the output as a recommendation, not an automated gate. In high-risk domains like finance or healthcare, always require a human to sign off on any skipped tests, and log the prompt's rationale alongside the final execution order for auditability.
Use Case Fit
Where the Dependency Graph Impact Analysis Prompt works well and where it introduces risk. Use these cards to decide if this prompt fits your test prioritization workflow.
Strong Fit: Monorepo with Explicit Build Graphs
Use when: your repository has a machine-readable dependency graph (Bazel, Nx, Turborepo, or Gradle). The prompt can trace upstream changes to downstream test targets with high precision. Guardrail: always provide the dependency graph as structured input, not as a natural-language description of the architecture.
Poor Fit: Dynamic or Runtime Dependency Injection
Avoid when: dependencies are resolved at runtime through DI containers, service locators, or plugin systems that are invisible to static analysis. The prompt will miss critical propagation paths. Guardrail: supplement with runtime trace data or service-mesh call graphs before using this prompt for test selection.
Required Input: Version-Anchored Dependency Graph
Risk: stale or incomplete dependency data produces false-negative test exclusions. Guardrail: the dependency graph must be version-anchored to the exact commit or release under test. Automate graph extraction in CI and pass it as a structured adjacency list or JSON payload alongside the change list.
Operational Risk: Circular Dependency Handling
Risk: circular dependencies cause infinite propagation or arbitrary cutoff in impact analysis, leading to unpredictable test scope. Guardrail: preprocess the graph to detect and break cycles before passing it to the prompt. Include a circular_dependencies field in the input and require the prompt to flag any cycle it encounters in its reasoning.
Operational Risk: Transitive Depth Explosion
Risk: deep transitive dependencies can cause the prompt to recommend running the entire test suite, defeating the purpose of impact analysis. Guardrail: set an explicit max_transitive_depth parameter (typically 2-3) and require the prompt to report when it truncates propagation. Pair with a risk-weighted fallback for truncated paths.
Poor Fit: Greenfield Projects Without Test History
Avoid when: the codebase has no historical test failure data or flakiness records to calibrate risk weights. The prompt will rely solely on structural proximity, which can over-prioritize low-risk modules. Guardrail: start with a simpler change-based selection prompt until you have at least 3-4 release cycles of test execution history to feed as calibration data.
Copy-Ready Prompt Template
A copy-ready prompt template for analyzing a module dependency graph and producing a risk-prioritized test execution order.
This prompt template is the core instruction set you will send to the model. It is designed to be self-contained: paste it into your AI system, replace the square-bracket placeholders with your actual data, and run it. The template forces the model to reason about upstream change propagation, circular dependencies, and transitive impact depth before producing a ranked test list. It also requires explicit validation rules and a structured output schema, making the result auditable and machine-readable.
textYou are a test architect analyzing a software module dependency graph to prioritize regression tests after a code change. Your goal is to produce a risk-prioritized test execution order based on upstream change propagation risk. ## INPUT - Dependency Graph: [DEPENDENCY_GRAPH] - Changed Modules: [CHANGED_MODULES] - Available Test Suites: [TEST_SUITES] - Historical Failure Data (optional): [FAILURE_DATA] - Max Transitive Depth: [MAX_DEPTH] ## CONSTRAINTS - Handle circular dependencies by treating the cycle as a single risk unit and flagging it. - Do not exceed the specified Max Transitive Depth when tracing impact. - If a module has no tests, flag it as an untested risk. - Justify every prioritization decision with a specific dependency path. ## OUTPUT_SCHEMA Return a JSON object with the following structure: { "analysis_summary": "string", "circular_dependencies_detected": [ { "cycle": ["module_a", "module_b"], "risk_note": "string" } ], "untested_modules": ["module_x"], "prioritized_test_order": [ { "rank": 1, "test_suite": "string", "target_module": "string", "risk_score": 0.0-1.0, "rationale": "string (include dependency path)", "transitive_depth": 0 } ], "validation_notes": ["string"] } ## INSTRUCTIONS 1. Parse the dependency graph and identify all modules directly or transitively dependent on the changed modules, up to the Max Transitive Depth. 2. For each affected module, calculate a risk score based on: proximity to the change, historical failure rate (if provided), and the number of dependent modules. 3. Map affected modules to the available test suites. 4. Sort test suites by risk score in descending order. 5. Validate your output: check for missing dependencies, depth limit violations, and circular dependency handling. 6. Return the JSON.
To adapt this template, replace the placeholders with your real data. [DEPENDENCY_GRAPH] should be a structured representation of your modules and their dependencies—a JSON adjacency list, a Mermaid diagram, or a simple A -> B, B -> C text format. [CHANGED_MODULES] is a list of module names that were modified. [TEST_SUITES] is a mapping of test suites to the modules they cover. [MAX_DEPTH] is an integer (e.g., 3) that limits how far the model traces transitive dependencies to prevent analysis paralysis on very large graphs. If you have historical failure data from your test management system, include it in [FAILURE_DATA] to improve risk scoring accuracy.
Before integrating this prompt into a CI/CD pipeline, test it against a known, small dependency graph where you can manually verify the expected output. Pay close attention to how the model handles cycles and depth limits—these are the most common failure points. For high-risk releases, always have a test architect review the prioritized list before execution begins. The structured JSON output is designed to be consumed by a downstream test runner, so validate the schema strictly before automation.
Prompt Variables
Required inputs for the Dependency Graph Impact Analysis Prompt. Each placeholder must be populated before execution to ensure reliable test prioritization.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[DEPENDENCY_GRAPH] | Machine-readable representation of module dependencies and their relationships | JSON adjacency list: {"auth": ["db", "cache"], "db": [], "cache": []} | Must be valid JSON. Reject if circular references exceed [MAX_CIRCULAR_DEPTH]. Validate all node IDs are non-empty strings. |
[CHANGE_LIST] | Set of modified modules, files, or components that triggered the analysis | ["src/auth/login.py", "src/auth/session.py"] | Must be a non-empty array. Each entry must match a node in [DEPENDENCY_GRAPH]. Reject if no matches found. |
[TEST_CATALOG] | Inventory of available tests with module coverage mappings and historical metadata | JSON array with test_id, covered_modules, avg_duration_ms, last_failure_date | Must include test_id and covered_modules fields. Validate that covered_modules references exist in [DEPENDENCY_GRAPH]. Null last_failure_date allowed for new tests. |
[MAX_TRANSITIVE_DEPTH] | Maximum number of dependency hops to traverse for impact propagation | 3 | Must be a positive integer between 1 and 10. Higher values increase analysis scope and runtime. Default to 3 if not specified. |
[RISK_WEIGHTS] | Weighting factors for change type, historical failure rate, and dependency distance | {"direct_change": 1.0, "transitive_depth_penalty": 0.5, "historical_failure_multiplier": 1.5} | Must be valid JSON with numeric values. All weights must be non-negative. Validate that direct_change weight is highest. Reject if all weights are zero. |
[CIRCULAR_DEPENDENCY_POLICY] | Instruction for handling cycles in the dependency graph | break_at_lowest_degree_node | Must be one of: break_at_lowest_degree_node, treat_as_single_component, fail_with_error, ignore_and_log. Default to break_at_lowest_degree_node if not specified. |
[OUTPUT_SCHEMA] | Expected structure for the prioritized test execution order | JSON schema with fields: prioritized_tests (array), skipped_tests (array), risk_scores (object), rationale_summary (string) | Must be a valid JSON Schema or TypeScript interface definition. Required fields: prioritized_tests, skipped_tests, risk_scores. Reject if schema allows ambiguous test ordering. |
[TIME_BUDGET_MS] | Optional hard constraint on total estimated test execution time in milliseconds | 600000 | Must be null or a positive integer. When set, the prompt must select tests that fit within this budget and flag any high-risk tests that exceed it. Validate that budget exceeds minimum single-test duration. |
Implementation Harness Notes
How to wire the dependency graph impact analysis prompt into a test prioritization pipeline with validation, retries, and audit logging.
The dependency graph impact analysis prompt is designed to be called programmatically within a CI/CD or test orchestration pipeline, not as a one-off chat interaction. The application layer is responsible for assembling the dependency graph, the change list, and the test catalog before invoking the model. The prompt expects these structured inputs and returns a prioritized test list with risk justifications. The harness must validate the output against the known test inventory to prevent hallucinated test IDs, enforce the transitive impact depth limit, and flag any circular dependency claims that contradict the input graph.
Wire the prompt into your pipeline by first constructing a JSON payload containing the [DEPENDENCY_GRAPH] (nodes and directed edges), [CHANGED_MODULES] (list of modified components), [TEST_CATALOG] (all available tests with their module coverage), and [CONSTRAINTS] (max depth, time budget, risk thresholds). After receiving the model response, run a strict post-processing validator: (1) confirm every recommended test ID exists in the input catalog, (2) verify that the transitive_depth field for each test does not exceed the configured limit, (3) check that no circular dependency is claimed unless it is present in the input graph, and (4) ensure the output conforms to the expected JSON schema. If validation fails, retry once with a repair prompt that includes the specific validation errors. If the retry also fails, log the failure, fall back to a rule-based selection (e.g., all tests for changed modules plus one hop), and alert the on-call channel.
Model choice matters here. Use a model with strong structured output capabilities and a large context window if your dependency graph is extensive. For production, prefer a model that supports strict JSON mode or function calling to reduce parsing errors. Log every invocation with the input graph hash, change list, model version, raw output, validation results, and final test execution order. This audit trail is essential for post-incident review and for tuning the prompt's risk thresholds over time. Avoid using this prompt for real-time commit-gate decisions without a human review escape hatch for high-risk releases where the blast radius exceeds a pre-defined threshold.
Expected Output Contract
Defines the required fields, types, and validation rules for the dependency graph impact analysis output. Use this contract to parse, validate, and integrate the model response into a test execution pipeline.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
test_plan_id | string (UUID v4) | Must match regex for UUID v4. Reject if missing or malformed. | |
analysis_timestamp | string (ISO 8601) | Must parse as valid ISO 8601 datetime. Must be within 5 minutes of system clock. | |
source_change_description | string | Must be non-empty and contain a summary of the analyzed change. Max 500 chars. | |
dependency_graph_summary | object | Must contain 'nodes' (array of strings) and 'edges' (array of [source, target] tuples). Node count must be >= 1. | |
prioritized_test_suites | array of objects | Array must not be empty. Each object must have 'suite_name' (string), 'priority_rank' (integer >= 1), and 'risk_score' (float 0.0-1.0). Ranks must be sequential and unique. | |
circular_dependency_warnings | array of strings | If present, each string must describe a detected cycle (e.g., 'Cycle: A->B->C->A'). Null or empty array is allowed if no cycles found. | |
transitive_impact_depth | integer | Must be >= 1 and <= [MAX_DEPTH]. Represents the maximum depth of dependency traversal performed. | |
skipped_modules | array of strings | If present, each entry must match a module name in the dependency graph. Must include a 'skip_reason' in a parallel 'skip_reasons' array of equal length. |
Common Failure Modes
Dependency graph impact analysis is powerful but brittle. These are the most common ways the prompt fails in production and how to prevent each one before it affects a release cycle.
Circular Dependency Infinite Loops
What to watch: The model follows a circular dependency chain (A→B→C→A) and produces an unbounded or nonsensical propagation depth. This inflates risk scores and prioritizes everything as critical. Guardrail: Pre-process the dependency graph to detect cycles before sending it to the prompt. Include a hard max_depth constraint in [CONSTRAINTS] and instruct the model to mark circular paths as 'CYCLE_DETECTED' with a depth limit stop reason.
Transitive Dependency Explosion
What to watch: A change in a low-level utility module causes the model to flag hundreds of downstream tests as high-priority, defeating the purpose of risk-based selection. The output becomes a full test suite rerun. Guardrail: Set an explicit transitive_depth_limit (e.g., 3) in the prompt. Require the model to distinguish between 'direct dependents' and 'deep transitive dependents' with diminishing risk weights per hop. Validate that the output list size is a fraction of the total suite.
Ignoring Interface vs. Implementation Changes
What to watch: The model treats all code changes as equal risk. A whitespace change in a core module gets the same priority as a signature change, leading to over-testing of trivial diffs. Guardrail: Include a change_type classification step in the prompt (SIGNATURE, LOGIC, CONFIG, DOCS, REFACTOR). Instruct the model to deprioritize or skip tests for changes classified as DOCS or non-semantic REFACTOR unless static analysis shows otherwise.
Stale Dependency Graph Blindness
What to watch: The prompt receives an outdated dependency graph that doesn't reflect recent refactors, causing it to recommend tests for modules that no longer depend on the changed code, or miss newly coupled modules. Guardrail: Add a graph_generated_at timestamp field to the input. Instruct the model to flag any change file whose last modification date is newer than the graph timestamp with a 'STALE_GRAPH_RISK' warning. Automate graph regeneration as a pre-prompt CI step.
Test History Blindness and False Negatives
What to watch: The model relies solely on structural dependencies and ignores historical failure data. A module with a clean dependency path but a history of flaky failures gets deprioritized, leading to escaped defects. Guardrail: Augment the prompt input with a historical_flakiness_score and recent_failure_count per test suite. Add a rule that any test with a flakiness score above a threshold is automatically promoted to the priority list regardless of dependency distance.
Unbounded Output and Missing Rationale
What to watch: The model returns a flat list of prioritized tests without explaining why each was selected, making the output unauditable for release governance. Engineers override the AI recommendation because they don't trust it. Guardrail: Enforce a strict [OUTPUT_SCHEMA] that requires a rationale field per test entry, citing the specific dependency path and risk factor. Include a confidence_score (0-1) per recommendation. Reject outputs that lack rationale during validation.
Evaluation Rubric
Criteria for evaluating the quality and safety of a dependency graph impact analysis prompt output before integrating it into a CI/CD or release pipeline.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Dependency Traceability | Every prioritized test is explicitly linked to an upstream module change via a documented dependency path. | A test appears in the list with no clear path to a changed module, or the path references a non-existent module. | Spot-check 5 prioritized tests; verify each has a valid path in the dependency graph provided in [DEPENDENCY_GRAPH]. |
Circular Dependency Handling | Circular dependencies are detected, flagged, and do not cause infinite loops or missing transitive impact. | Output contains a stack overflow pattern, hangs, or omits all modules within a circular cluster. | Inject a known circular dependency into [DEPENDENCY_GRAPH]; confirm output includes a warning and still produces a finite, complete list. |
Transitive Depth Limit Enforcement | Impact analysis respects the [MAX_TRANSITIVE_DEPTH] constraint; no test is justified by a dependency chain longer than the limit. | A test is prioritized based on a dependency chain of length N+1 when [MAX_TRANSITIVE_DEPTH] is set to N. | Set [MAX_TRANSITIVE_DEPTH]=2; verify no rationale string references a path with more than 2 hops. |
Risk Score Calibration | Risk scores are monotonically related to the number of changed upstream dependents and historical failure rate from [HISTORICAL_FAILURE_DATA]. | A module with zero changed dependents and zero historical failures receives a higher risk score than a module with multiple changed dependents. | Provide a controlled [CHANGE_LIST] with known impact; verify the rank order of risk scores matches expected propagation logic. |
Output Schema Compliance | Output strictly matches [OUTPUT_SCHEMA] with all required fields present and correctly typed. | Output is missing a required field like 'rationale' or 'estimated_runtime', or a field contains a string instead of a number. | Validate output with a JSON Schema validator against [OUTPUT_SCHEMA]; reject on any schema violation. |
Skip Rationale Completeness | Every skipped or de-prioritized test suite includes a specific, auditable reason, not a generic statement. | A skipped test entry contains rationale like 'low risk' without referencing specific modules or data. | Parse the 'skipped_tests' array; assert each entry's 'rationale' field contains at least one reference to a module name or data point from [INPUT]. |
Hallucinated Module Reference | All referenced modules, files, or test suites exist in the provided [DEPENDENCY_GRAPH] or [TEST_CATALOG]. | Output references a module or test suite name not present in any input artifact. | Extract all module and test suite names from the output; diff against the set of names in [DEPENDENCY_GRAPH] and [TEST_CATALOG]; flag any extras. |
Execution Time Budget Adherence | The sum of 'estimated_runtime' for all recommended tests does not exceed the [TIME_BUDGET] by more than 10%. | Total estimated runtime exceeds [TIME_BUDGET] by more than 10% without an explicit override flag. | Sum the 'estimated_runtime' field across all non-skipped test entries; assert total <= [TIME_BUDGET] * 1.1. |
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
Add strict JSON output schema with required fields: test_order, rationale, risk_score, transitive_depth, circular_dependency_warnings. Include validation rules for max depth, cycle detection, and change-to-test traceability. Wire into CI/CD with graph input from build tools (e.g., madge, dependency-cruiser).
code[SYSTEM] You are a test prioritization engine. Output ONLY valid JSON matching [OUTPUT_SCHEMA]. Max transitive depth: [MAX_DEPTH]. Handle circular dependencies by [CYCLE_STRATEGY]. [INPUT] Dependency graph: [GRAPH_JSON] Changed modules: [CHANGED_MODULES] Test-to-module mapping: [TEST_MAP]
Watch for
- Silent format drift when models omit optional schema fields
- Large graphs exceeding context windows; chunk by subgraph
- Missing human review gate for high-risk module changes
- Stale test-to-module mappings producing false positives

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