Patch Verification
Overview
A patch that crashes or introduces bugs at runtime is worse than no patch
at all. Every patch must pass thorough verification before being committed.
Only fix what would actually crash or produce incorrect behavior — do
NOT change the patch's intent.
When to Use
After applying ANY patch type (capability or steering).
Verification Procedure
Step 1: Review the Diff
git diff
- Does the diff match your intent? No unintended changes?
- Are there leftover debug statements, commented-out code, or TODOs?
- Are there any files modified that should not have been changed?
Step 2: Syntax and Import Check
For every modified Python file:
python3 -m py_compile <modified_file>
python3 -c "import <modified_module>"
- No
SyntaxError, IndentationError, or TabError
- No
ImportError or ModuleNotFoundError
- No
NameError from undefined variables or functions at module level
Step 3: Docstring Integrity
Docstrings are the agent's only interface to tools — errors here directly
cause agent failures.
- No placeholder values (
[...], {...}, <placeholder>) — these crash
downstream parsers
- All examples use concrete, valid values
- Parameter names in the docstring match the actual method signature
- Return value description matches what the implementation actually returns
- No stale documentation from copy-paste (e.g., wrong tool name, wrong
parameter list from another method)
- No literal escape sequences (
\n, \t, etc.) used to represent
multi-line examples or formatting inside docstrings — these produce
actual control characters in the parsed string and can cause
SyntaxError or silently corrupt the docstring text. Use triple-quoted
strings with real newlines instead
Step 4: Template String Safety
If the patch modifies any string that uses .format() or f-string
interpolation:
- Every
{placeholder} has a corresponding .format() argument
- No extra or missing placeholders from copy-paste
- No unescaped curly braces in literal text (use
{{ and }} to escape)
- No cross-file contamination between template variables
Step 5: Hook JSON Validation
If the patch modifies hook configuration:
python3 -c "import json; json.load(open('<hook_file>'))"
Step 6: Logic and Correctness
Read each modified function/method end-to-end and verify:
- Control flow: No unreachable code, no missing return statements,
no infinite loops
- Edge cases: Does the code handle empty inputs, None values, missing
keys, and boundary conditions?
- Type consistency: Are function arguments and return values used
consistently with their expected types?
- Variable scope: No shadowed variables, no use-before-assignment,
no stale references to renamed variables
- Side effects: Does the change unintentionally modify shared state,
global variables, or mutable default arguments?
- Dependencies: If the modified function is called by other modules,
verify the signature change is backward-compatible (e.g., new parameters
have defaults)
Step 7: Integration Check
- If a new tool was added, verify it is discoverable by the agent
(registered, decorated, or configured correctly per the codebase's
conventions)
- If a tool signature changed, verify all existing callers pass the
correct arguments
- If prompt text was modified, verify the complete prompt still renders
correctly (no broken concatenation, no missing sections)
Step 8: Preserve Intent
After all verification, re-read git diff one final time:
- Only fix runtime crash or correctness issues found during verification
- Do NOT remove functionality or change patch behavior
- Do NOT alter logic beyond what prevents crashes or bugs
1---2name: patch-verification-23description: "Use after applying any patch to thoroughly verify the agent codebase has no bugs — checks syntax, imports, runtime behavior, docstrings, templates, hooks, and logical correctness"4metadata:5 source: https://skillmd.com/skills/microsoft/patch-verification-26---78# Patch Verification910## Overview1112A patch that crashes or introduces bugs at runtime is worse than no patch13at all. Every patch must pass thorough verification before being committed.1415**Only fix what would actually crash or produce incorrect behavior — do16NOT change the patch's intent.**1718## When to Use1920After applying ANY patch type (capability or steering).2122## Verification Procedure2324### Step 1: Review the Diff2526```bash27git diff28```2930- Does the diff match your intent? No unintended changes?31- Are there leftover debug statements, commented-out code, or TODOs?32- Are there any files modified that should not have been changed?3334### Step 2: Syntax and Import Check3536For every modified Python file:3738```bash39python3 -m py_compile <modified_file>40python3 -c "import <modified_module>"41```4243- No `SyntaxError`, `IndentationError`, or `TabError`44- No `ImportError` or `ModuleNotFoundError`45- No `NameError` from undefined variables or functions at module level4647### Step 3: Docstring Integrity4849Docstrings are the agent's only interface to tools — errors here directly50cause agent failures.5152- No placeholder values (`[...]`, `{...}`, `<placeholder>`) — these crash53 downstream parsers54- All examples use concrete, valid values55- Parameter names in the docstring match the actual method signature56- Return value description matches what the implementation actually returns57- No stale documentation from copy-paste (e.g., wrong tool name, wrong58 parameter list from another method)59- No literal escape sequences (`\n`, `\t`, etc.) used to represent60 multi-line examples or formatting inside docstrings — these produce61 actual control characters in the parsed string and can cause62 `SyntaxError` or silently corrupt the docstring text. Use triple-quoted63 strings with real newlines instead6465### Step 4: Template String Safety6667If the patch modifies any string that uses `.format()` or f-string68interpolation:6970- Every `{placeholder}` has a corresponding `.format()` argument71- No extra or missing placeholders from copy-paste72- No unescaped curly braces in literal text (use `{{` and `}}` to escape)73- No cross-file contamination between template variables7475### Step 5: Hook JSON Validation7677If the patch modifies hook configuration:7879```bash80python3 -c "import json; json.load(open('<hook_file>'))"81```8283- Valid JSON syntax (no trailing commas, unquoted keys, etc.)84- Correct schema structure (hooks array with matcher + handler entries)85- Each matcher regex compiles without error:86 ```bash87 python3 -c "import re; re.compile('<matcher_value>')"88 ```89- Handler type matches the expected type for the hook category90 (e.g., `"reminder"` for PreToolUse hooks)91- Each handler has non-blank text content9293### Step 6: Logic and Correctness9495Read each modified function/method end-to-end and verify:9697- **Control flow**: No unreachable code, no missing return statements,98 no infinite loops99- **Edge cases**: Does the code handle empty inputs, None values, missing100 keys, and boundary conditions?101- **Type consistency**: Are function arguments and return values used102 consistently with their expected types?103- **Variable scope**: No shadowed variables, no use-before-assignment,104 no stale references to renamed variables105- **Side effects**: Does the change unintentionally modify shared state,106 global variables, or mutable default arguments?107- **Dependencies**: If the modified function is called by other modules,108 verify the signature change is backward-compatible (e.g., new parameters109 have defaults)110111### Step 7: Integration Check112113- If a new tool was added, verify it is discoverable by the agent114 (registered, decorated, or configured correctly per the codebase's115 conventions)116- If a tool signature changed, verify all existing callers pass the117 correct arguments118- If prompt text was modified, verify the complete prompt still renders119 correctly (no broken concatenation, no missing sections)120121### Step 8: Preserve Intent122123After all verification, re-read `git diff` one final time:124125- Only fix runtime crash or correctness issues found during verification126- Do NOT remove functionality or change patch behavior127- Do NOT alter logic beyond what prevents crashes or bugs