Inferensys

Prompt

Code Smell Severity Triage Prompt

A practical prompt playbook for using Code Smell Severity Triage Prompt in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for the Code Smell Severity Triage Prompt.

This prompt is for tech leads, platform engineers, and senior developers who receive a high volume of findings from multiple static analysis tools, linters, and AI code reviewers. The core job-to-be-done is turning an unstructured, noisy, and often duplicative list of detected code smells into a single, severity-ranked, and deduplicated triage report that a team can act on immediately. The ideal user is someone who owns code quality for a repository or service and needs to decide what must be fixed before merge, what can be deferred to a backlog, and what is likely a false positive that should be suppressed. Required context includes the raw list of findings from one or more detectors, the relevant code snippets or file paths, and a team-defined severity rubric that calibrates what 'critical,' 'high,' 'medium,' and 'low' mean in their specific codebase.

Do not use this prompt when you have only one detector's output with fewer than five findings—a simpler deduplication or direct review is more efficient. Do not use it for real-time security vulnerability triage where exploitability requires immediate human security engineer judgment; this prompt prioritizes maintainability and code health risks, not active threat response. Avoid using it when the team has no agreed-upon severity rubric, as the model will default to generic heuristics that may not match your risk tolerance. The prompt is designed for batch triage of 10–200 findings; for larger volumes, split the input into logical groups by component or detector to stay within context windows and maintain ranking quality.

Before using this prompt, ensure you have a calibrated severity rubric documented and included in the [RUBRIC] placeholder. Without it, the model will make reasonable but potentially misaligned severity calls. After receiving the triage report, always spot-check the top 3 critical findings and a random sample of false-positive flags against your own judgment. This prompt reduces triage time, not replaces engineering judgment. If your team lacks a rubric, run the prompt once with a generic severity scale, review the output with the team, and use that calibration session to define your own thresholds before integrating this into an automated CI pipeline.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Understand the operational boundaries before wiring it into a CI pipeline or review workflow.

01

Good Fit: Multi-Detector Triage Pipelines

Use when: You have output from multiple static analysis tools, linters, or smell detectors and need a single deduplicated, severity-ranked report. Guardrail: Always pass the raw detector output plus the team's severity rubric as [CONTEXT] to prevent the model from inventing its own priority scheme.

02

Bad Fit: Single-Linter Output or Trivial Diffs

Avoid when: The input is a single linter's output with fewer than five findings, or the diff is trivial. The triage overhead outweighs the benefit. Guardrail: Implement a pre-check that counts findings and bypasses the prompt if the count is below a configurable threshold.

03

Required Inputs: Findings List and Severity Rubric

Risk: The model hallucinates severity or invents false positives if it only sees raw code without detector context. Guardrail: The prompt requires a structured [FINDINGS_LIST] and a [SEVERITY_RUBRIC] defining what constitutes Critical, High, Medium, and Low for your team. Missing either should abort the workflow.

04

Operational Risk: Silent Deduplication Errors

Risk: The model incorrectly merges two distinct findings into one, or splits one finding into two, corrupting the triage count. Guardrail: Add a post-processing validation step that compares the count of unique input findings against the count of output items, flagging any discrepancy for human review.

05

Operational Risk: False Positive Flagging Drift

Risk: The model marks a real finding as a false positive because it misinterprets the code's intent, causing a vulnerability or regression to be silently ignored. Guardrail: Any finding flagged as a false positive must include a required [EVIDENCE] field quoting the specific code lines that justify the dismissal. Findings without evidence are escalated.

06

Calibration Requirement: Team-Specific Rubric Alignment

Risk: The model applies a generic severity heuristic that doesn't match your team's risk tolerance, causing alert fatigue or missed critical issues. Guardrail: Run a calibration batch weekly using five known historical findings with agreed-upon severities. Compare model output to expected labels and flag drift before the prompt reaches production PRs.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for triaging code smell severity across multiple detectors.

This prompt template is designed to take a raw list of code smells from one or more detection tools and produce a severity-ranked, deduplicated triage report. It is built for tech leads and platform teams who need to turn a noisy stream of findings into a clear, actionable queue. The template uses square-bracket placeholders for all variable inputs, making it safe to drop into a prompt management system, a CI/CD pipeline, or an internal review tool. Before using it, ensure you have defined your team's severity rubric and have a representative set of examples to calibrate the model's judgment against your own standards.

text
You are a senior software engineer and code review lead responsible for triaging code smell findings.

Your task is to analyze a list of detected code smells and produce a severity-ranked, deduplicated triage report.

## INPUT

[FINDINGS_LIST]

## CONTEXT

- Repository: [REPO_NAME]
- Branch/PR: [BRANCH_OR_PR_ID]
- Team Severity Rubric: [SEVERITY_RUBRIC]
- Known False Positive Patterns: [FALSE_POSITIVE_PATTERNS]
- Deferral Candidates (low-risk patterns to suppress): [DEFERRAL_PATTERNS]

## OUTPUT SCHEMA

Return a JSON object with the following structure:
{
  "report_id": "string",
  "generated_at": "ISO8601 timestamp",
  "summary": {
    "total_findings": "number",
    "after_dedup": "number",
    "critical": "number",
    "high": "number",
    "medium": "number",
    "low": "number",
    "false_positives_flagged": "number",
    "deferred": "number"
  },
  "findings": [
    {
      "id": "string",
      "original_ids": ["string"],
      "category": "string",
      "file": "string",
      "line_range": "start-end",
      "description": "string",
      "severity": "critical|high|medium|low",
      "rationale": "string explaining severity assignment against rubric",
      "action": "fix_now|fix_in_pr|fix_this_sprint|backlog|defer|false_positive",
      "deduplicated_from": ["string"],
      "false_positive_confidence": "number 0-1 if action is false_positive, else null",
      "refactoring_hint": "string or null"
    }
  ],
  "deferral_candidates": [
    {
      "id": "string",
      "reason": "string explaining why deferred"
    }
  ],
  "false_positive_flags": [
    {
      "id": "string",
      "confidence": "number 0-1",
      "explanation": "string"
    }
  ]
}

## CONSTRAINTS

1. Deduplicate findings that refer to the same root cause, even if reported by different detectors. Keep the most specific instance and note merged IDs.
2. Assign severity strictly according to the provided [SEVERITY_RUBRIC]. Do not upgrade severity because a finding "feels" important.
3. Flag a finding as a false positive only if it matches a pattern in [FALSE_POSITIVE_PATTERNS] or if you can articulate a clear, code-specific reason. Include a confidence score.
4. Defer findings that match [DEFERRAL_PATTERNS] and explain why.
5. For every finding with action "fix_now" or "fix_in_pr", provide a concrete refactoring hint.
6. If the input contains more than [MAX_FINDINGS] findings, prioritize the most severe and note truncation in the summary.
7. Do not invent findings. Only triage what is in [FINDINGS_LIST].

## EXAMPLES

[FEW_SHOT_EXAMPLES]

## RISK LEVEL

[RISK_LEVEL]

To adapt this template, start by replacing the placeholders with your actual data. The [FINDINGS_LIST] should be a structured JSON array of smell objects from your detectors. The [SEVERITY_RUBRIC] is critical—paste your team's written definitions for critical, high, medium, and low severity directly into the prompt so the model calibrates against your standards rather than its own defaults. The [FEW_SHOT_EXAMPLES] placeholder should contain at least three worked examples showing correct severity assignment, deduplication decisions, and false positive handling for your codebase. If you are integrating this into a CI pipeline, consider setting [RISK_LEVEL] to "high" to enforce stricter validation and require human review for all critical findings before the report is accepted. For lower-risk internal tools, you can relax this to "medium" and allow automated routing of low-severity items directly to the backlog.

Before deploying this prompt, validate its output against a golden dataset of at least 20 pre-triaged findings that represent your team's actual severity distribution. Run the prompt and compare the model's severity assignments, deduplication choices, and false positive flags against your expected results. Pay special attention to borderline cases where severity could reasonably be argued either way—these are where the model is most likely to drift from your team's norms. If you observe more than 15% disagreement on severity assignments, refine your rubric text or add more few-shot examples until the model aligns. For production use, log every triage report with the model version, prompt hash, and input finding count so you can trace any quality regressions back to prompt or model changes.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Code Smell Severity Triage Prompt. Each placeholder must be populated before the prompt is assembled and sent. Validation notes describe how to verify the input is well-formed before execution.

PlaceholderPurposeExampleValidation Notes

[SMELL_LIST]

Raw list of detected code smells from one or more detectors, each with a file path, line range, detector name, and detector-provided severity

detector: sonarqube, file: src/auth/login.ts:42-48, rule: no-hardcoded-credentials, severity: blocker

Parse check: each entry must have file, line range, detector, and rule fields. Null allowed: false. Empty list triggers no-op response.

[SEVERITY_RUBRIC]

Team-defined severity definitions mapping severity labels to impact, exploitability, and urgency criteria

CRITICAL: user-facing data loss or security breach possible. HIGH: degraded functionality with workaround. MEDIUM: maintainability risk. LOW: style preference.

Schema check: must contain at least three severity levels with impact descriptions. Missing rubric triggers fallback to default severity mapping with a warning.

[TEAM_CONTEXT]

Team ownership area, codebase domain, and known acceptable patterns to reduce false positives

Team: Identity Platform. Domain: auth, session management. Acceptable patterns: hardcoded test credentials in test/ directory only.

Parse check: must include team name and at least one acceptable pattern or domain constraint. Null allowed: true. When null, false positive rate may increase.

[DEFERRAL_POLICY]

Criteria for deferring a finding to a later sprint or backlog, including acceptable risk thresholds

Defer if: severity LOW and not in hot-path code. Never defer: CRITICAL or HIGH severity.

Schema check: must include at least one deferral condition and one never-defer condition. Missing policy triggers conservative no-deferral default.

[FALSE_POSITIVE_INDICATORS]

Known patterns, directories, or annotations that signal a finding is likely a false positive

Files in test/ or mock/ directories. Annotations: @SuppressWarnings, // NOSONAR. Detector: eslint-plugin-testing-library in test files.

Parse check: each indicator must specify a scope (file pattern, annotation, or detector). Null allowed: true. When null, false positive flagging relies on model judgment alone.

[OUTPUT_SCHEMA]

Expected JSON schema for the triage report including required fields, enums, and array constraints

{"findings": [{"id": string, "severity": CRITICAL|HIGH|MEDIUM|LOW, "action": FIX_NOW|FIX_SOON|DEFER|FALSE_POSITIVE, "rationale": string}]}

Schema check: must be valid JSON Schema or TypeScript interface. Required fields: id, severity, action, rationale. Enum values must match rubric and deferral policy.

[CALIBRATION_EXAMPLES]

Few-shot examples of correctly triaged findings matching the team's severity rubric and deferral policy

Input: hardcoded API key in src/prod/config.ts. Output: severity CRITICAL, action FIX_NOW, rationale: production credential exposure.

Count check: at least 2 examples covering different severity levels and action types. Each example must have input finding and expected output triage decision. Null allowed: false.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Code Smell Severity Triage Prompt into a production code review pipeline.

This prompt is designed to sit downstream of one or more smell detectors—linters, static analyzers, or other LLM-based detection prompts. It expects a pre-parsed list of findings as input, not raw code. The implementation harness must therefore collect, normalize, and deduplicate findings from multiple sources before invoking the triage prompt. A typical integration point is a CI/CD pipeline step that runs after all detection jobs complete, aggregating their JSON output into a single [FINDINGS_LIST] payload. The harness should enforce a common finding schema (file, line, detector, smell_type, description) across all upstream detectors to ensure the triage prompt receives consistent input.

Validation and retry logic is critical because the triage output drives human review queues and automated merge gates. The harness must validate the model's JSON response against the expected [OUTPUT_SCHEMA]—a list of triaged findings each containing severity, category, action, rationale, and dedup_group fields. If validation fails, retry once with the validation error message appended to the prompt as a correction hint. If the retry also fails, log the raw output and escalate to a human triage lead rather than silently proceeding. For high-risk repositories (infrastructure, security, payments), configure the harness to require explicit human approval on all severity: critical findings before the report is published to the review queue.

Model choice and context window considerations: The triage task requires reasoning across multiple findings to identify duplicates, rank severity relative to other findings, and detect false positive patterns. Use a model with strong reasoning capabilities (GPT-4o, Claude 3.5 Sonnet, or equivalent). The input finding list can grow large in monorepos or broad scans; if the serialized [FINDINGS_LIST] exceeds roughly 60% of the model's context window, split findings by directory or module and run parallel triage passes, then merge results with a final deduplication pass. Logging should capture the prompt version, input finding count, output finding count, validation status, retry count, and any severity distribution shifts for observability into triage quality over time.

Tool integration is optional but powerful. If your review system supports it, expose a publish_triage_report tool that the model can call with the structured output, rather than relying solely on text completion. This reduces parsing errors and lets the harness enforce the schema at the tool-call boundary. For teams using RAG, you can inject a [TEAM_RUBRIC] containing historical severity calibration examples and team-specific false-positive patterns retrieved from past triage decisions. This grounds the model's judgment in your team's actual standards rather than generic severity heuristics. What to avoid: Do not use this prompt on raw code without upstream detection—it will hallucinate findings. Do not skip the deduplication step across detectors before invoking triage, or you will waste context window on redundant entries. Do not treat the triage output as final for critical-path code without human review of the top severity items.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the required fields, types, and validation rules for the triage report JSON object. Use this contract to build post-processing validators, schema checks, and retry logic before the output reaches a downstream system or human reviewer.

Field or ElementType or FormatRequiredValidation Rule

triage_report

object

Top-level key must be an object. Schema check: reject if missing or not an object.

triage_report.generated_at

string (ISO 8601)

Must parse as valid ISO 8601 datetime. Reject if unparseable or missing.

triage_report.severity_rubric_version

string

Must match the [RUBRIC_VERSION] placeholder value exactly. Reject on mismatch.

triage_report.findings

array

Must be an array. Reject if null or empty. Warn if length differs from input smell count by more than 20%.

triage_report.findings[].original_id

string

Must match an id from the [SMELL_LIST] input. Reject if id not found in input set.

triage_report.findings[].severity

string (enum)

Must be one of: 'critical', 'high', 'medium', 'low', 'false_positive'. Reject on unknown value.

triage_report.findings[].action

string (enum)

Must be one of: 'fix_now', 'fix_in_sprint', 'defer', 'ignore'. Reject on unknown value.

triage_report.findings[].rationale

string

Must be non-empty string. Warn if fewer than 20 characters. Must not contain unresolved placeholders.

PRACTICAL GUARDRAILS

Common Failure Modes

When triaging code smells at scale, these failures degrade trust faster than any single misclassification. Each card pairs a common failure with a concrete guardrail you can implement before the prompt reaches production.

01

Severity Inflation Under Ambiguity

What to watch: The model defaults to HIGH severity when a smell's impact depends on runtime context it cannot see, producing alarm fatigue and eroding reviewer trust. Guardrail: Add a [CONFIDENCE] field to the output schema and require the model to mark any finding as TENTATIVE when context is missing. Route TENTATIVE findings to a separate review queue instead of blocking CI.

02

Duplicate Findings Across Detectors

What to watch: Multiple upstream detectors flag the same root cause with different names, producing a triage list that appears to have 12 findings when only 4 distinct issues exist. Guardrail: Include a deduplication step in the prompt that groups findings by file, line range, and root cause before assigning severity. Require the output to list merged findings with source detector references.

03

False Positive Cascades in Generated Code

What to watch: The model flags smells in generated, vendored, or third-party code that the team never intends to modify, wasting review cycles on untouchable files. Guardrail: Add an [EXCLUDE_PATTERNS] variable for file paths and a prompt rule that marks findings in excluded paths as SUPPRESSED with automatic justification rather than omitting them silently.

04

Rubric Drift Across Reviewers

What to watch: The model's severity assignments shift when different team members use the prompt because the severity rubric is implicit rather than explicit, causing inconsistent triage across sprints. Guardrail: Embed the team's severity rubric directly in the prompt as a [SEVERITY_RUBRIC] variable with concrete examples for each level. Run calibration checks against a golden set of 10 findings before each prompt version release.

05

Action Item Vagueness

What to watch: The model produces action items like 'consider refactoring' or 'review this pattern' that lack enough specificity for a developer to act without re-investigating the finding from scratch. Guardrail: Require each action item to include a concrete before/after code snippet or a specific file-line reference with the exact change needed. Add a validator that rejects action items shorter than 50 characters.

06

Context Window Truncation on Large Diffs

What to watch: When a PR contains many files or a large diff, the model silently drops findings from later files because the input exceeds the context window, producing a triage report that looks complete but misses entire modules. Guardrail: Implement a pre-flight chunking strategy that splits large diffs by file or module, runs triage independently per chunk, and merges results. Add a [FILES_PROCESSED] field to the output so reviewers can verify coverage.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Code Smell Severity Triage Prompt before integrating it into a CI/CD pipeline or code review workflow. Each criterion targets a specific failure mode observed in severity triage prompts.

CriterionPass StandardFailure SignalTest Method

Severity Calibration

Severity labels match the team-defined rubric in [SEVERITY_RUBRIC] for at least 90% of test cases

Output uses generic High/Medium/Low labels that do not map to the provided rubric definitions

Run 20 pre-labeled smell examples through the prompt and compare severity assignments to ground truth

Deduplication Accuracy

True duplicates are merged into a single finding with a combined line reference; distinct smells are kept separate

The same smell appears multiple times with slightly different wording or line ranges that overlap by more than 50%

Inject 5 duplicate smell descriptions with varying wording and verify the output contains exactly 5 unique findings

False Positive Flagging

At least 80% of intentionally injected false positives are flagged with a confidence score below the [CONFIDENCE_THRESHOLD]

Known false positives appear in the triage report without a low-confidence or deferral flag

Insert 3 known false positive patterns from the team's historical review data and check for deferral or flag markers

Action Item Specificity

Every action item references a specific file, line range, and concrete fix direction

Action items contain vague directives like 'refactor this' or 'improve error handling' without code-level guidance

Parse the output JSON and validate that each action item object has non-null file, line_start, line_end, and suggestion fields

Output Schema Compliance

Output is valid JSON matching the [OUTPUT_SCHEMA] with all required fields present

Output is missing required fields, contains extra top-level keys, or uses incorrect types for severity or confidence values

Validate output against the JSON Schema definition using a schema validator; reject if validation fails

Deferral Rationale Quality

Deferred items include a specific reason tied to the deferral criteria in [DEFERRAL_CRITERIA]

Deferred items have generic reasons like 'low priority' or 'not important' without referencing the criteria

Check that every deferred finding's rationale field contains a substring match against at least one deferral criterion from the prompt

Confidence Score Consistency

Confidence scores correlate with explanation detail and evidence grounding; high-confidence findings cite specific code patterns

High confidence scores appear on findings with vague or missing evidence, or low scores appear on well-grounded findings

Sample 10 findings and have a human reviewer rate explanation quality on a 1-5 scale; correlation with confidence scores should exceed 0.7

Token Budget Adherence

Output does not exceed the [MAX_OUTPUT_TOKENS] limit and prioritizes high-severity findings when truncation is needed

Output is truncated mid-sentence or omits high-severity findings while including low-priority deferral candidates

Set a low token limit in the test harness and verify that the output is complete, valid JSON, and contains all Critical and High findings before any Low findings

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a simple JSON output expectation. Remove strict schema enforcement and calibration checks. Focus on getting a ranked list with severity and rationale.

Prompt modification

Remove the [SEVERITY_RUBRIC] and [CALIBRATION_EXAMPLES] placeholders. Replace with inline guidance: "Rate each smell as Critical, High, Medium, or Low based on the likelihood it causes a production incident."

Watch for

  • Inconsistent severity labels across runs
  • Missing deduplication when the same smell appears in multiple detectors
  • Over-flagging style nits as High severity
Prasad Kumkar

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.