Check an Edit Before Writing It
evaluate_change_setPreview code-quality, design-smell and layer-violation findings a proposed edit would introduce, in memory, before writing it. Returns pass, warn or block from the session baseline.
Instructions
Advisory policy gate: which code-quality / design-smell / layer-violation findings would this edit INTRODUCE? Ask BEFORE writing it. Cheapest form - the edit you are about to make anyway: changes: [{filePath, oldText, newText}], the snippet being replaced and what it becomes (the shape an editor takes). The full file is rebuilt here from the analyzed document, so the payload is the size of the CHANGE, not of the file, and 'operation' defaults to 'modify'. oldText must occur EXACTLY ONCE - a missing or ambiguous anchor is an error, never a silently different edit; line endings are reconciled for you; an empty newText deletes the snippet. Full-text form still works and is required for add/delete: {filePath, operation: 'modify'|'add'|'delete', newContent}. Findings are a delta against the current session, so pre-existing debt is never blamed. The changeset is applied as an in-memory Roslyn overlay (NO disk write, the session is untouched) and the amended solution is re-analyzed. Verdict: pass / warn / block. Policy: 'block_on_critical' (default) | 'block_on_warning' | 'advisory' (an unknown policy is rejected, not silently treated as advisory). Advisory only - an MCP tool cannot block; the real blocking gate is the CLI '--fail-on'. The findings delta honors the session's explicit layer profile (analyze_solution(layerProfile) / sidecar) and its resolved test-detection profile on both sides; pass dbPath to also use that DB's active QualityProfile (producer thresholds + toggles) and its configured default layer profile (per-solution > app-global; the explicit session profile still wins) - same semantics as list_insights, so the gate judges by the same configured thresholds as the CLI gate. apply_change_set is out of scope. Pass absolute file paths matching the analyzed documents.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dbPath | No | Optional path to an AIContextBuilder SQLite DB. When set, producer thresholds + toggles come from that DB's active QualityProfile AND its configured default layer profile (per-solution > app-global) drives the layer-violation analysis on BOTH delta sides (an explicit analyze_solution(layerProfile) wins); omit to fall back to the server's default config DB (the GUI's, if the server resolved one), else the default profile + session axes, and the layer profile to the config DB the session was analysed against - the one its renders read. | |
| policy | No | Policy: 'block_on_critical' (default) | 'block_on_warning' | 'advisory'. | |
| changes | Yes | The proposed file changes. Per change: filePath (absolute), plus EITHER the anchor patch oldText + newText (preferred - 'operation' may be omitted, it defaults to 'modify') OR the full new file text newContent with operation 'modify'/'add' ('delete' takes neither). | |
| sessionId | Yes | The session_id returned by analyze_solution (the baseline). Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use. |