Create Automated Verification Loops for Long-Running Coding Agents

Generate a deterministic shell pipeline that combines linting, isolated unit testing, and diff-budget monitoring to validate AI agent code changes.

Agent prompt for Claude Code and Cursor

Prompt

Prompt
You are a Senior DevOps Engineer specializing in autonomous coding agent safety. Your task is to write a single-line shell pipeline that verifies changes made by an AI coding agent. The pipeline must: 1. Run a linter and fail if exit code is non-zero. 2. Execute a specific unit test suite in an isolated environment. 3. Calculate the line count of the git diff and fail if it exceeds a threshold. 4. Output a clear Pass or Fail status. 5. Include no placeholders and use standard tools like grep, wc, and exit codes. Please ask me these 3 questions first and wait for my response: 1. What programming language and linter are you using? 2. What is the command to run your isolated test suite? 3. What is the maximum number of lines allowed in a single diff? This is for technical system configuration only.

Example output

Example for: a Python project using flake8 and pytest with a 50-line diff limit.

Verification Pipeline

flake8 . && pytest tests/isolated_suite.py && test $(git diff --shortstat | awk '{print $4 + $6}') -lt 50 && echo "Pass" || (echo "Fail" && exit 1)

Explanation of Pipeline Components
  1. flake8 .: Runs the linting suite. The && operator ensures the pipeline stops immediately if linting fails.
  2. pytest tests/isolated_suite.py: Executes the specific test battery. Only proceeds if all tests pass.
  3. git diff --shortstat | awk '{print $4 + $6}': Calculates total insertions and deletions. The -lt 50 check enforces the diff budget.
  4. echo "Pass" || (echo "Fail" && exit 1): Provides a clear final status and returns a non-zero exit code to the parent process if any step fails.
Implementation Notes
  • The diff budget check assumes a clean working directory relative to the last commit.
  • Ensure the environment has the necessary dependencies installed before running this script.
  • This command can be added directly to a .pre-commit-config.yaml or a standalone bash script for CI integration.
Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Forces a strict exit-code dependency chain to prevent faulty code from reaching production.
  • Combines static analysis, dynamic testing, and volume control in a single command line.
  • Eliminates ambiguity by requiring clear binary Pass or Fail output.

Use this prompt when configuring pre-commit hooks or CI/CD pipelines to ensure AI-generated code meets quality standards before deployment. Supported in Claude Code, Cursor, and terminal environments.

Common edits

  • Adjust the awk field indices if your git diff output format varies across environments.
  • Add a flag to ignore specific directories in the linter step using --exclude.

Reuse it: Use in a workflowAdapt in the builder

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

AI Coding AgentsClaude Code

Design a Sandbox Security Policy for Autonomous Coding Agents

Generate a rigorous security policy for autonomous agents to define allowed shell commands, file access boundaries, and network restrictions.

AI Coding AgentsClaude Code

Generate Reproducible Bug Fix Specs for Coding Agents

Get a standalone reproduction test script and a precise technical plan to fix a bug, ensuring your AI agent stays focused and avoids unnecessary file changes.

AI Coding AgentsClaude Code

Audit PR Git Diffs for Scope Creep and Churn

Reviews git diff statistics and patch files to immediately flag out-of-scope edits, accidental whitespace formatting churn, and unrequested dependency updates.

AI Coding AgentsClaude Code

Safe Refactor With Characterization Tests and Small Commits

Get a refactor split into small commits, each with its test result, after characterization tests pin what the code does today, plus a list of suspected bugs left unfixed.

AI Coding AgentsClaude Code

Audit AI Code Diffs for Performance Regressions

This prompt scans code changes for silent performance killers like N+1 queries, unindexed filters, and memory leaks before you merge them.