Skip to main content
VertaaUX Docs

suggest_fix

Generate AI-powered code patches for accessibility and UX findings

suggest_fix

Generate AI-powered code patches to fix accessibility and UX issues. This is the key remediation tool that provides actionable fixes with confidence scores.

Description

The suggest_fix tool analyzes a finding and generates a code patch that resolves the issue. It returns a search/replace pattern that can be applied to your source code.

This is the "aha moment" tool - getting AI-suggested fixes from natural language requests is what makes the MCP integration powerful.

Parameters

ParameterTypeRequiredDescription
finding_idstringrequiredSingle finding ID to fix
audit_idstringrequiredParent audit containing the finding
finding_idsstring[]optionalArray of finding IDs for batch fixes
file_contentstringoptionalSource code content for more accurate patches
file_pathstringoptionalPath to the file being fixed (for context)

Response

type
properties

Confidence Levels

LevelPercentageMeaningAction
HIGH80-100%Safe to applyApply directly
MEDIUM50-79%Likely correctReview before applying
LOW0-49%Significant changesCareful manual review required

Even HIGH confidence fixes should be tested. AI suggestions are not guaranteed to be perfect.

Example Conversations

Single Fix

"Suggest a fix for finding fnd_xyz789"

suggest_fix({
  finding_id: "fnd_xyz789",
  audit_id: "aud_abc123"
})

Fix with Source Context

"Suggest a fix for this button issue. Here's my Button.tsx file: [code]"

Providing file content improves patch accuracy:

suggest_fix({
  finding_id: "fnd_xyz789",
  audit_id: "aud_abc123",
  file_content: "// Your Button.tsx content...",
  file_path: "src/components/Button.tsx"
})

Batch Fixes

"Fix all critical findings from the last audit"

suggest_fix({
  audit_id: "aud_abc123",
  finding_ids: ["fnd_001", "fnd_002", "fnd_003"]
})

Returns an array of patches.

Natural Language Request

"The audit found a missing alt text issue. Can you fix it?"

Claude will identify the relevant finding and call suggest_fix automatically.

Applying Patches

Manual Application

  1. Find the search string in your code
  2. Replace with the replace string
  3. Verify the change works

Search/Replace Pattern

The patch uses a literal search/replace model:

// Original (search)
<button onClick={handleSubmit}>
  <Icon name="check" />
</button>

// Fixed (replace)
<button onClick={handleSubmit} aria-label="Submit form">
  <Icon name="check" />
</button>

Editor Integration

Most editors support find/replace:

  • VS Code: Ctrl/Cmd + H
  • Cursor: Ctrl/Cmd + H
  • Vim: :%s/search/replace/g

Example Patches

Button Accessibility

// Search
<button onClick={handleClick}>
  <TrashIcon />
</button>

// Replace
<button onClick={handleClick} aria-label="Delete item">
  <TrashIcon />
</button>

Confidence: HIGH (92%) Explanation: Icon-only buttons need aria-label for screen readers.

Color Contrast

/* Search */
.hero-text {
  color: #999999;
}

/* Replace */
.hero-text {
  color: #595959;
}

Confidence: HIGH (88%) Explanation: Changed color to meet 4.5:1 contrast ratio.

Missing Form Label

// Search
<input
  type="email"
  placeholder="Enter your email"
/>

// Replace
<label>
  <span className="sr-only">Email address</span>
  <input
    type="email"
    placeholder="Enter your email"
  />
</label>

Confidence: MEDIUM (72%) Explanation: Added programmatic label association. Review the sr-only class implementation.

When needs_human_review is True

The needs_human_review flag indicates:

  • Complex changes affecting multiple elements
  • Changes that might affect functionality
  • Framework-specific patterns that need verification
  • Low confidence fixes

When true, carefully review:

  1. The suggested change makes sense
  2. It doesn't break existing functionality
  3. It follows your project's patterns

Verification

After applying a fix:

  1. Run the hint: Use the verification_hint (e.g., test with screen reader)
  2. Re-audit: Run audit_url again to confirm the issue is resolved
  3. Test functionality: Ensure the element still works correctly

Workflow

Complete fix workflow:

1. audit_url → Get audit ID
2. get_findings → Find issues
3. explain_finding → Understand (optional)
4. suggest_fix → Get patch
5. Apply patch manually or use generate_pr
6. audit_url → Verify fix worked

Was this page helpful?

On this page