Code Verification Skill
Verify code against requirements using a main agent / sub-agent loop with structured feedback and automatic retry.
Workflow Overview
Copy this checklist and track progress:
Code Verification Progress:
- [ ] Step 1: Parse verification instructions
- [ ] Step 2: Pre-flight validation
- [ ] Step 3: Verification loop (per instruction)
- [ ] Step 4: Fix attempts (if failed)
- [ ] Step 5: Update checklist with results
- [ ] Step 6: Generate verification report
- [ ] Step 7: Log results to verification-log.jsonl
Step 1: Parse Verification Instructions
Extract each verification instruction into a discrete, testable item:
- ID: Unique identifier (e.g.,
V-001)
- Instruction: The requirement text
- Test approach: How to verify (file inspection, run tests, lint, type check, etc.)
- Files involved: Which files to examine
- Requires Browser: Whether the instruction needs Playwright MCP verification
- Auto-detect from keywords: UI, render, display, visible, hidden, show, hide, click, hover, focus, blur, scroll, DOM, element, component, layout, responsive, style, CSS, color, font, screenshot, visual, appearance, console, error, warning, log, network, request, response, accessibility, a11y, ARIA, animation, transition, loading, performance
- Mark as:
browser: true or browser: false
- Browser Verification Type (if
browser: true):
DOM_INSPECTION - Element presence, visibility, content via accessibility tree snapshots
SCREENSHOT - Visual appearance, layout verification
CONSOLE - Browser console errors, warnings, logs
NETWORK - API requests, responses, status codes (via network interception)
PERFORMANCE - Load times, Core Web Vitals (via tracing)
ACCESSIBILITY - ARIA attributes, semantic HTML, accessibility tree analysis
Step 2: Pre-flight Validation
Before the verification loop, confirm each instruction is testable:
- Instruction is specific and unambiguous
- Success criteria are clear
- Required files/resources exist
Flag untestable instructions immediately rather than attempting verification.
Browser-Specific Pre-Flight
For instructions with browser: true:
HTTP-First Check (before browser tools)
Many "browser" criteria can be satisfied with a simple HTTP check. Before
launching browser tools, evaluate if the criterion only requires:
- Page accessibility (HTTP 200 status)
- API response validation
- Redirect verification
- Basic content presence
Attempt HTTP verification first using curl:
# Page loads check
curl -sf "{devServer.url}{route}" -o /dev/null && echo "PASS" || echo "FAIL"
# Response contains text
curl -s "{url}" | grep -q "{expected}" && echo "PASS" || echo "FAIL"
# API returns expected status
curl -sf -o /dev/null -w "%{http_code}" "{url}"
Curl error handling:
- Use
-m 10 (10-second timeout) to prevent hanging on unresponsive services
- If curl returns exit code 7 (connection refused): dev server may not be running
- If curl returns exit code 28 (timeout): service is slow or unreachable
- On any curl failure, fall through to browser verification (do not mark as FAIL yet)
If HTTP check passes AND criterion does NOT explicitly require:
- DOM element inspection (selector, visibility)
- Visual appearance verification
- User interaction simulation
- Console log inspection
- Network timing/performance
Then: Mark as PASS (HTTP-first), skip browser verification.
Otherwise: Continue to browser tool fallback chain.
Check browser tool availability (fallback chain)
- Try tools in order: ExecuteAutomation Playwright → Browser MCP → Microsoft Playwright → Chrome DevTools
- Use first available tool for browser verification
If NO tools available (SOFT BLOCK):
Before marking as BLOCKED, attempt HTTP fallback for any remaining criteria.
EXECUTE these commands via Bash tool (substitute actual URLs):
- Page loading:
curl -sf {url}
- API responses:
curl -s {url} | jq .
- Redirects:
curl -sI {url}
Only mark as BLOCKED if both browser tools AND HTTP fallback are insufficient.
If still blocked after HTTP fallback:
- Display warning:
⚠️ NO BROWSER TOOLS AVAILABLE
This verification includes browser-based criteria but no browser
MCP tools are available, and HTTP fallback is insufficient.
Criteria requiring DOM/visual inspection:
- {list criteria that truly need browser}
Options:
1. Continue anyway (these criteria become manual verification)
2. Stop and configure browser tools first
- Use AskUserQuestion to let user choose:
- "Continue with manual verification" → Mark browser instructions as BLOCKED, continue with non-browser criteria
- "Stop to configure tools" → Halt verification, provide setup instructions
Verify dev server is running (if browser tools available)
- Check if configured dev server URL responds (e.g.,
http://localhost:3000)
- If not running, attempt to start using the configured dev server command
- Wait for configured startup time before proceeding
- If unable to start, mark as BLOCKED: "Dev server not accessible at {URL}"
Confirm target route exists (if browser tools available)
- Navigate to the page specified in the instruction using the selected browser tool
- If 404 or error, mark as BLOCKED: "Target route not found: {route}"
Step 3: Sub-Agent Verification Protocol
Spawn a sub-agent to verify each instruction. The sub-agent MUST return structured output:
VERIFICATION RESULT
-------------------
Instruction ID: [ID]
Status: PASS | FAIL | BLOCKED
Location: [file:line or "N/A"]
Severity: BLOCKING | MINOR
Finding: [What was found]
Expected: [What was expected]
Suggested Fix: [Specific fix recommendation]
Sub-agent rules:
- Check ONLY the specific instruction assigned
- Do not attempt fixes—report findings only
- Be precise about location (file, line number, function name)
- Distinguish between blocking failures and minor issues
Browser-Enhanced Verification Output
For instructions with browser: true, the sub-agent MUST use Playwright MCP and return:
BROWSER VERIFICATION RESULT
---------------------------
Instruction ID: [ID]
Status: PASS | FAIL | BLOCKED
Type: DOM | VISUAL | CONSOLE | NETWORK | PERFORMANCE | ACCESSIBILITY
URL: [URL] | Viewport: [width]x[height]
Finding: [What was observed]
Expected: [What was expected]
Details: [Type-specific information]
- DOM: selector, found, visible, content
- Visual: screenshot path, description
- Console: errors, warnings, logs
- Network: endpoint, method, status, response summary
- Performance: load time, LCP, FID, CLS
- Accessibility: ARIA, semantic HTML, contrast, keyboard nav
Suggested Fix: [Specific fix recommendation]
Browser Sub-Agent Rules
In addition to standard sub-agent rules, browser verification sub-agents MUST:
- Start with an accessibility tree snapshot (
browser_snapshot) of the initial state
- Use stable selectors (prefer
data-testid over complex CSS paths, or use accessibility tree element refs)
- Wait for dynamic content to load before inspecting (
browser_wait_for_text or browser_wait)
- Capture console output before and after actions
- Take screenshots (
browser_screenshot) when verifying visual appearance
- Test at default viewport unless criterion specifies responsive/mobile (use
browser_resize to change)
Step 4: Main Agent Fix Protocol
When sub-agent reports FAIL:
- Review the finding - Understand what failed and why
- Check fix history - Do not repeat a previously attempted fix
- Apply targeted fix - Make the minimum change to address the issue
- Log the attempt - Record what was changed
Fix attempt tracking
Maintain a fix log per instruction:
FIX LOG: [Instruction ID]
--------------------------
Attempt 1: [Description of change] → [Result]
Attempt 2: [Description of change] → [Result]
...
Strategy escalation
- Attempts 1-2: Direct fix based on sub-agent suggestion
- Attempt 3: Try alternative approach
- Attempts 4-5: Broaden scope, consider architectural changes
If the same failure pattern repeats twice, explicitly try a different strategy.
After applying fix, re-verify the specific criterion:
- Re-run the sub-agent check for the failed criterion only
- If still failing after 2 fix attempts, mark as FAIL with evidence from both attempts
- Do NOT re-run all criteria — only the failing one
Browser-Specific Fix Strategies
| Failure Type |
Common Fixes |
| DOM/Visibility |
Conditional rendering, CSS display/visibility, z-index, prop passing |
| Console errors |
JS exceptions, missing mocks, env vars, CORS |
| Network |
Endpoint URLs, auth headers, payload format, CORS config |
| Visual |
CSS cascade, responsive breakpoints, font loading |
| Performance |
Bundle size, image optimization, lazy loading, render-blocking |
| Accessibility |
ARIA attributes, color contrast, heading hierarchy, keyboard handlers |
Step 5: Exit Conditions
Exit the verification loop when ANY condition is met:
| Condition |
Action |
| Sub-agent reports PASS |
✅ Check off instruction |
| 5 attempts exhausted |
❌ Mark failed with notes |
| Same failure 3+ times |
⚠️ Exit early, flag for review |
| Fix introduces regression |
⚠️ Revert, flag for review |
| Issue is MINOR severity |
⚠️ Note and continue |
Step 6: Regression Check
After each fix attempt, verify:
- The targeted instruction (primary check)
- Any previously-passing related instructions (regression check)
If a fix breaks something else, revert and note the conflict.
Browser Regression Checks
After each browser-related fix, verify no regressions in: console errors, visual appearance, performance metrics, accessibility. If regression detected, capture before/after state and log in fix history.
Step 7: Generate Verification Report
After all instructions are processed:
VERIFICATION REPORT
===================
Total Instructions: [N]
Passed: [N] ✅
Failed: [N] ❌
Needs Review: [N] ⚠️
DETAILS
-------
[V-001] ✅ [Instruction summary]
[V-002] ❌ [Instruction summary]
- Failed after 5 attempts
- Last error: [description]
- Attempts: [brief log]
[V-003] ⚠️ [Instruction summary]
- Flagged: Repeated same failure pattern
- Recommendation: [suggestion]
AUDIT TRAIL
-----------
[Timestamp] V-001: Verified PASS on first check
[Timestamp] V-002: Attempt 1 - Changed X → FAIL
[Timestamp] V-002: Attempt 2 - Changed Y → FAIL
...
BROWSER VERIFICATION (if applicable)
------------------------------------
Browser Checks: [passed]/[total] | Blocked: [N]
Playwright: Available | Unavailable
Dev Server: [URL] | Not Running
Issues Found:
- [V-XXX] {type}: {description}
Screenshots: [list of captured files]
Example
Given a checklist:
[ ] All functions have docstrings
[ ] No unused imports
[ ] Tests pass with >80% coverage
Workflow execution:
- Parse into V-001, V-002, V-003
- Pre-flight confirms all are testable
- Sub-agent checks V-001 → FAIL (missing docstring in
utils.py:45)
- Main agent adds docstring
- Sub-agent re-checks → PASS
- Continue to V-002...
- Final report shows 3/3 passed
Key Principles
- Structured feedback: Sub-agent always returns actionable, located findings
- No repeated fixes: Track what was tried to avoid loops
- Early exit: Don't burn attempts on unfixable issues
- Regression awareness: Fixes shouldn't break other things
- Audit everything: The journey matters for debugging
1---2name: code-verification3description: Multi-agent code verification workflow using a main agent and sub-agent loop. Use when verifying code against requirements, acceptance criteria, or quality standards. Triggers on requests to verify, validate, or check code against specifications, checklists, or instructions.4---5
6# Code Verification Skill
7
8Verify code against requirements using a main agent / sub-agent loop with structured feedback and automatic retry.
9
10## Workflow Overview
11
12Copy this checklist and track progress:
13
14```
15Code Verification Progress:
16- [ ] Step 1: Parse verification instructions
17- [ ] Step 2: Pre-flight validation
18- [ ] Step 3: Verification loop (per instruction)
19- [ ] Step 4: Fix attempts (if failed)
20- [ ] Step 5: Update checklist with results
21- [ ] Step 6: Generate verification report
22- [ ] Step 7: Log results to verification-log.jsonl
23```
24
25## Step 1: Parse Verification Instructions
26
27Extract each verification instruction into a discrete, testable item:
28
29- **ID**: Unique identifier (e.g., `V-001`)
30- **Instruction**: The requirement text
31- **Test approach**: How to verify (file inspection, run tests, lint, type check, etc.)
32- **Files involved**: Which files to examine
33- **Requires Browser**: Whether the instruction needs Playwright MCP verification
34 - Auto-detect from keywords: UI, render, display, visible, hidden, show, hide, click, hover, focus, blur, scroll, DOM, element, component, layout, responsive, style, CSS, color, font, screenshot, visual, appearance, console, error, warning, log, network, request, response, accessibility, a11y, ARIA, animation, transition, loading, performance
35 - Mark as: `browser: true` or `browser: false`
36- **Browser Verification Type** (if `browser: true`):
37 - `DOM_INSPECTION` - Element presence, visibility, content via accessibility tree snapshots
38 - `SCREENSHOT` - Visual appearance, layout verification
39 - `CONSOLE` - Browser console errors, warnings, logs
40 - `NETWORK` - API requests, responses, status codes (via network interception)
41 - `PERFORMANCE` - Load times, Core Web Vitals (via tracing)
42 - `ACCESSIBILITY` - ARIA attributes, semantic HTML, accessibility tree analysis
43
44## Step 2: Pre-flight Validation
45
46Before the verification loop, confirm each instruction is testable:
47
48- Instruction is specific and unambiguous
49- Success criteria are clear
50- Required files/resources exist
51
52Flag untestable instructions immediately rather than attempting verification.
53
54### Browser-Specific Pre-Flight
55
56For instructions with `browser: true`:
57
581. **HTTP-First Check (before browser tools)**
59
60 Many "browser" criteria can be satisfied with a simple HTTP check. Before
61 launching browser tools, evaluate if the criterion only requires:
62 - Page accessibility (HTTP 200 status)
63 - API response validation
64 - Redirect verification
65 - Basic content presence
66
67 **Attempt HTTP verification first using curl:**
68 ```bash
69 # Page loads check
70 curl -sf "{devServer.url}{route}" -o /dev/null && echo "PASS" || echo "FAIL"
71
72 # Response contains text
73 curl -s "{url}" | grep -q "{expected}" && echo "PASS" || echo "FAIL"
74
75 # API returns expected status
76 curl -sf -o /dev/null -w "%{http_code}" "{url}"
77 ```
78
79 **Curl error handling:**
80 - Use `-m 10` (10-second timeout) to prevent hanging on unresponsive services
81 - If curl returns exit code 7 (connection refused): dev server may not be running
82 - If curl returns exit code 28 (timeout): service is slow or unreachable
83 - On any curl failure, fall through to browser verification (do not mark as FAIL yet)
84
85 **If HTTP check passes AND criterion does NOT explicitly require:**
86 - DOM element inspection (selector, visibility)
87 - Visual appearance verification
88 - User interaction simulation
89 - Console log inspection
90 - Network timing/performance
91
92 **Then:** Mark as PASS (HTTP-first), skip browser verification.
93
94 **Otherwise:** Continue to browser tool fallback chain.
95
962. **Check browser tool availability (fallback chain)**
97 - Try tools in order: ExecuteAutomation Playwright → Browser MCP → Microsoft Playwright → Chrome DevTools
98 - Use first available tool for browser verification
99
100 **If NO tools available (SOFT BLOCK):**
101
102 Before marking as BLOCKED, attempt HTTP fallback for any remaining criteria.
103 **EXECUTE these commands** via Bash tool (substitute actual URLs):
104 - Page loading: `curl -sf {url}`
105 - API responses: `curl -s {url} | jq .`
106 - Redirects: `curl -sI {url}`
107
108 Only mark as BLOCKED if both browser tools AND HTTP fallback are insufficient.
109
110 If still blocked after HTTP fallback:
111 - Display warning:
112 ```
113 ⚠️ NO BROWSER TOOLS AVAILABLE
114
115 This verification includes browser-based criteria but no browser
116 MCP tools are available, and HTTP fallback is insufficient.
117
118 Criteria requiring DOM/visual inspection:
119 - {list criteria that truly need browser}
120
121 Options:
122 1. Continue anyway (these criteria become manual verification)
123 2. Stop and configure browser tools first
124 ```
125 - Use AskUserQuestion to let user choose:
126 - "Continue with manual verification" → Mark browser instructions as BLOCKED, continue with non-browser criteria
127 - "Stop to configure tools" → Halt verification, provide setup instructions
128
1292. **Verify dev server is running** (if browser tools available)
130 - Check if configured dev server URL responds (e.g., `http://localhost:3000`)
131 - If not running, attempt to start using the configured dev server command
132 - Wait for configured startup time before proceeding
133 - If unable to start, mark as BLOCKED: "Dev server not accessible at {URL}"
134
1353. **Confirm target route exists** (if browser tools available)
136 - Navigate to the page specified in the instruction using the selected browser tool
137 - If 404 or error, mark as BLOCKED: "Target route not found: {route}"
138
139## Step 3: Sub-Agent Verification Protocol
140
141Spawn a sub-agent to verify each instruction. The sub-agent MUST return structured output:
142
143```
144VERIFICATION RESULT
145-------------------
146Instruction ID: [ID]
147Status: PASS | FAIL | BLOCKED
148Location: [file:line or "N/A"]
149Severity: BLOCKING | MINOR
150Finding: [What was found]
151Expected: [What was expected]
152Suggested Fix: [Specific fix recommendation]
153```
154
155Sub-agent rules:
156- Check ONLY the specific instruction assigned
157- Do not attempt fixes—report findings only
158- Be precise about location (file, line number, function name)
159- Distinguish between blocking failures and minor issues
160
161### Browser-Enhanced Verification Output
162
163For instructions with `browser: true`, the sub-agent MUST use Playwright MCP and return:
164
165```
166BROWSER VERIFICATION RESULT
167---------------------------
168Instruction ID: [ID]
169Status: PASS | FAIL | BLOCKED
170Type: DOM | VISUAL | CONSOLE | NETWORK | PERFORMANCE | ACCESSIBILITY
171URL: [URL] | Viewport: [width]x[height]
172
173Finding: [What was observed]
174Expected: [What was expected]
175
176Details: [Type-specific information]
177 - DOM: selector, found, visible, content
178 - Visual: screenshot path, description
179 - Console: errors, warnings, logs
180 - Network: endpoint, method, status, response summary
181 - Performance: load time, LCP, FID, CLS
182 - Accessibility: ARIA, semantic HTML, contrast, keyboard nav
183
184Suggested Fix: [Specific fix recommendation]
185```
186
187#### Browser Sub-Agent Rules
188
189In addition to standard sub-agent rules, browser verification sub-agents MUST:
190- Start with an accessibility tree snapshot (`browser_snapshot`) of the initial state
191- Use stable selectors (prefer `data-testid` over complex CSS paths, or use accessibility tree element refs)
192- Wait for dynamic content to load before inspecting (`browser_wait_for_text` or `browser_wait`)
193- Capture console output before and after actions
194- Take screenshots (`browser_screenshot`) when verifying visual appearance
195- Test at default viewport unless criterion specifies responsive/mobile (use `browser_resize` to change)
196
197## Step 4: Main Agent Fix Protocol
198
199When sub-agent reports FAIL:
200
2011. **Review the finding** - Understand what failed and why
2022. **Check fix history** - Do not repeat a previously attempted fix
2033. **Apply targeted fix** - Make the minimum change to address the issue
2044. **Log the attempt** - Record what was changed
205
206### Fix attempt tracking
207
208Maintain a fix log per instruction:
209
210```
211FIX LOG: [Instruction ID]
212--------------------------
213Attempt 1: [Description of change] → [Result]
214Attempt 2: [Description of change] → [Result]
215...
216```
217
218### Strategy escalation
219
220- Attempts 1-2: Direct fix based on sub-agent suggestion
221- Attempt 3: Try alternative approach
222- Attempts 4-5: Broaden scope, consider architectural changes
223
224If the same failure pattern repeats twice, explicitly try a different strategy.
225
226**After applying fix, re-verify the specific criterion:**
2271. Re-run the sub-agent check for the failed criterion only
2282. If still failing after 2 fix attempts, mark as FAIL with evidence from both attempts
2293. Do NOT re-run all criteria — only the failing one
230
231### Browser-Specific Fix Strategies
232
233| Failure Type | Common Fixes |
234|--------------|--------------|
235| **DOM/Visibility** | Conditional rendering, CSS display/visibility, z-index, prop passing |
236| **Console errors** | JS exceptions, missing mocks, env vars, CORS |
237| **Network** | Endpoint URLs, auth headers, payload format, CORS config |
238| **Visual** | CSS cascade, responsive breakpoints, font loading |
239| **Performance** | Bundle size, image optimization, lazy loading, render-blocking |
240| **Accessibility** | ARIA attributes, color contrast, heading hierarchy, keyboard handlers |
241
242## Step 5: Exit Conditions
243
244Exit the verification loop when ANY condition is met:
245
246| Condition | Action |
247|-----------|--------|
248| Sub-agent reports PASS | ✅ Check off instruction |
249| 5 attempts exhausted | ❌ Mark failed with notes |
250| Same failure 3+ times | ⚠️ Exit early, flag for review |
251| Fix introduces regression | ⚠️ Revert, flag for review |
252| Issue is MINOR severity | ⚠️ Note and continue |
253
254## Step 6: Regression Check
255
256After each fix attempt, verify:
257
258- The targeted instruction (primary check)
259- Any previously-passing related instructions (regression check)
260
261If a fix breaks something else, revert and note the conflict.
262
263### Browser Regression Checks
264
265After each browser-related fix, verify no regressions in: console errors, visual appearance, performance metrics, accessibility. If regression detected, capture before/after state and log in fix history.
266
267## Step 7: Generate Verification Report
268
269After all instructions are processed:
270
271```
272VERIFICATION REPORT
273===================
274Total Instructions: [N]
275Passed: [N] ✅
276Failed: [N] ❌
277Needs Review: [N] ⚠️
278
279DETAILS
280-------
281[V-001] ✅ [Instruction summary]
282[V-002] ❌ [Instruction summary]
283 - Failed after 5 attempts
284 - Last error: [description]
285 - Attempts: [brief log]
286[V-003] ⚠️ [Instruction summary]
287 - Flagged: Repeated same failure pattern
288 - Recommendation: [suggestion]
289
290AUDIT TRAIL
291-----------
292[Timestamp] V-001: Verified PASS on first check
293[Timestamp] V-002: Attempt 1 - Changed X → FAIL
294[Timestamp] V-002: Attempt 2 - Changed Y → FAIL
295...
296
297BROWSER VERIFICATION (if applicable)
298------------------------------------
299Browser Checks: [passed]/[total] | Blocked: [N]
300Playwright: Available | Unavailable
301Dev Server: [URL] | Not Running
302
303Issues Found:
304- [V-XXX] {type}: {description}
305
306Screenshots: [list of captured files]
307```
308
309## Example
310
311Given a checklist:
312```
313[ ] All functions have docstrings
314[ ] No unused imports
315[ ] Tests pass with >80% coverage
316```
317
318Workflow execution:
3191. Parse into V-001, V-002, V-003
3202. Pre-flight confirms all are testable
3213. Sub-agent checks V-001 → FAIL (missing docstring in `utils.py:45`)
3224. Main agent adds docstring
3235. Sub-agent re-checks → PASS
3246. Continue to V-002...
3257. Final report shows 3/3 passed
326
327## Key Principles
328
329- **Structured feedback**: Sub-agent always returns actionable, located findings
330- **No repeated fixes**: Track what was tried to avoid loops
331- **Early exit**: Don't burn attempts on unfixable issues
332- **Regression awareness**: Fixes shouldn't break other things
333- **Audit everything**: The journey matters for debugging