OctiAI

Categories

Minimal Safe Fix Plan — CI Failure Template

A Markdown template that converts failing CI logs, failing tests, and implicated diffs into a minimal, low-risk repair: unified-diff patch, tests, risk analysis, rollback steps,...

What You'll Get

How to Use

Provide exact failing artifacts

For high-quality, actionable fixes, include the exact failing test command and output, the implicated git unified diff, and the minimal repo path context. If timeboxed, set constraints (e.g., no large refactor, backport target branches) so the assistant recommends only safe, local changes.

Works Best With

Works best with concise, complete CI failure artifacts and small, targeted diffs

Prompt Template


# Developer Productivity Prompt Blueprint (use EXACT section order)

## Goal
- Produce a minimal, safe fix plan for a failing CI job: determine root cause, produce ranked hypotheses, provide a reproducible checklist, propose an exact patch (unified-diff style), list tests to add/update, estimate risks and rollback/mitigation steps, and produce a PR checklist for reviewers.

## Inputs
- Code snippets, failing test output, CI job logs, implicated diff, repo/file paths, runtime/environment details, and constraints (for example: no large refactor, timebox).
- If any of the following are missing, ask for them before proceeding: failing test command and exact failing output, the implicated diff (git unified diff), minimal repro steps or sample input, the repository path or file list to change, and the tech stack.
- Required input placeholders to include in the copy-paste prompt below: 
  - {{tech_stack}}
  - {{ci_failure_log}}
  - {{implicated_diff}}
  - {{repo_context}}
  - {{constraints}}

## Prompt
Copy-paste the following prompt exactly into your LLM or automation tool. Replace only the placeholder blocks with the corresponding artifacts.

You are an expert software engineer focused on minimal-risk bug fixes. Given the provided CI failure artifacts, produce an engineering-grade repair: hypotheses, diagnosis, minimal patch, tests, risk analysis, rollback, and a reviewer checklist.

Inputs:
- Tech stack: {{tech_stack}}
- CI failure log and failing test output: {{ci_failure_log}}
- Implicated diff (unified diff / git patch that likely introduced regression): {{implicated_diff}}
- Repo context (relevant file paths, failing test names, and where to place patches): {{repo_context}}
- Constraints and non-goals: {{constraints}}

Deliverables required (strictly follow the output format described below):
1) Assumptions and Unknowns — list any missing facts needed to be 100% certain; for each, state a minimal action to resolve it.
2) Likely root causes — produce 3-5 ranked hypotheses (highest confidence first). For each hypothesis include: evidence from logs/diff, probability (%) and why.
3) Repro checklist — exact commands, environment variables, and steps to reproduce locally and in CI (one-liner commands where possible).
4) Fix plan — ordered step-by-step plan for a minimal patch that restores passing CI with no behavioral regression. Include acceptance criteria for each step.
5) Patch suggestions — provide exact code changes as a unified diff (git-style patch). For each changed file include a brief comment (1-2 sentences) explaining the change and why it’s minimal and safe.
6) Tests to add/update — list specific test files and precise test cases to add or change. For each test include the exact test assertion intent, fixtures or mocks, and expected outputs. Include an estimate of coverage impact.
7) Verification checklist — automated and manual checks required to validate the fix (unit tests, integration tests, smoke tests, performance quick-checks).
8) Risk assessment & rollback — list potential risks introduced by the patch, severity and likelihood, and an explicit rollback/migration mitigation plan (including git commands and feature-flagging if applicable).
9) PR reviewer checklist — an itemized checklist for reviewers (correctness, security, performance, style, tests, deployment notes).
10) Time and complexity estimate — approximate LOC changed, CI minutes added/removed, and estimated review + merge time.

Formatting and guardrails (must be followed):
- Output the patch as a unified diff that can be applied with git apply or git am. Provide file paths relative to repo root provided in {{repo_context}}.
- Keep changes minimal: prefer one small targeted change over a refactor. If a refactor is proposed, explicitly mark it out-of-scope unless {{constraints}} allow.
- Do not assume any unseen files or implicit behavior. If you need to read additional files, list them under Assumptions/Unknowns.
- For any external library or dependency change, include exact version bump and rationale.
- Include explicit commands to run locally and CI steps to verify (for example: run npm test -- -t "name", pytest path::test_name, docker-compose up --build && curl).
- Where applicable, include a short note about why the fix is safe for backport to previous release branches.
- If the fix touches security-sensitive code, include a minimal threat-model check and a suggested sec-review approver tag.

Produce the entire deliverable as structured sections that exactly match the Output Format below.

## Output Format
Output:
  1) Assumptions/Unknowns
  2) Likely root causes (ranked)
  3) Fix plan (steps)
  4) Patch suggestions
  5) Test/verification checklist

Ensure each numbered section is present and clearly labeled. Use bullet points and short, imperative sentences. Provide the unified-diff block under section 4.

## Guardrails
- Do not assume unseen files.
- Prefer minimal diffs; avoid scope creep.
- Do not introduce breaking API/behavioral changes unless explicitly allowed in {{constraints}}.
- Do not remove tests; update or add tests to preserve coverage.
- When in doubt, prefer a localized guard (input validation, default values, try/catch) over large structural changes.
- Explicitly flag any workaround that is temporary and include a remediation ticket recommendation.

## Examples
- Mini example (root-cause + minimal fix excerpt):
  - Root cause: A recent change in handler A converted a timestamp string to a Number, causing NaN in edge case where header X is missing.
  - Minimal fix excerpt (unified-diff):
    --- a/src/handlers/timeHandler.js
    +++ b/src/handlers/timeHandler.js
    @@ -12,7 +12,9 @@
     const ts = req.headers['x-timestamp'];
    -const t = Number(ts);
    +const t = ts ? Number(ts) : Date.now();
    +// If header omitted, fallback to server clock to avoid NaN downstream
     
  - Test to add: in tests/timeHandler.test.js add a case where request has no x-timestamp header and assert no crash and valid Date.now() range.

Variables

Usage Notes

Not for

Do not include

Minimal Safe Fix Plan — CI Failure Template

Turn CI job failures, failing test output, and the implicated diff into an engineer-ready minimal fix: ranked hypotheses, repro steps, unified-diff patch, tests to add/update, risk & rollback plan, and a reviewer checklist.

Turn this into a working asset in minutes.

Import into Workspace to auto-fill variables, adapt output style, and iterate with OctiAI's prompt editor.

What you'll get

Output format

Markdown

Best used when

Avoid when

Sign in to save, like, or rate this prompt.

Made for

What to fill in

Use the guidance below to complete each placeholder with the right level of detail.

Tech Stack

Provide the key details needed for this variable.

Ci Failure Log

Provide the key details needed for this variable.

Implicated Diff

Provide the key details needed for this variable.

Repo Context

Provide the key details needed for this variable.

Constraints

Provide the key details needed for this variable.

Rules

Canonical Examples

Input: Node.js (Jest) CI failing: unit test 'formatDate handles null' started failing after a recent commit that removed a fallback in src/utils/formatDate.js. Tech stack: Node 14, Jest. Implicated diff provided.

Loading result...

Failed to load output.


--- a/src/utils/formatDate.js
+++ b/src/utils/formatDate.js
@@ -1,7 +1,9 @@
-exports.formatDate = (d) => new Date(d).toISOString();
+exports.formatDate = (d) => {
+  const ts = d || Date.now();
+  return new Date(ts).toISOString();
+};

Why it works: This example is small, constrained, and shows a classic regression where a missing default leads to an exception/NaN. The prompt yields a ranked hypothesis list, exact repro commands, a minimal one-line guarded fix, a unified diff patch that can be applied with git apply, and precise tests to add/update.

Input: Python Flask integration test times out in CI. Tech stack: Python 3.9, Flask, Redis cache. Implicated diff removed tenant prefix from cache key generation in src/cache/key.py leading to cache collisions/misses and extra DB queries; failing integration test 'test_user_profile_cached' times out (>5s).

Loading result...

Failed to load output.


--- a/src/cache/key.py
+++ b/src/cache/key.py
@@ -1,6 +1,8 @@
-def make_cache_key(user_id, tenant_id=None):
-    return f"user:{user_id}"
+def make_cache_key(user_id, tenant_id='global'):
+    # Reintroduce tenant namespacing to avoid cross-tenant collisions and cache misses
+    return f"user:{tenant_id}:{user_id}"

Why it works: This example demonstrates diagnosing a performance/flakiness regression caused by a small change in cache key construction. The blueprint produces ranked hypotheses (cache miss vs. test timeout), an exact repro command, a targeted patch to restore tenant namespacing, tests to add, and a rollback plan. It stays minimal and avoids refactors.

Works Best With

Works best with concise, complete CI failure artifacts and small, targeted diffs