Plan: Surface All 4 Remediation Prompts in the UI + Fix CLAUDE.md Consolidation
Context
Two tasks:
Show all 4 prompts per remediation: The user wants to inspect the full prompts sent to the AI for each phase (error plan, error execution, suggestion plan, suggestion execution). Currently the UI only shows the plan responses (AI output), not the prompts (AI input). Phases 2 & 4 execution prompts are also silently stripped before being saved to the database.
Fix CLAUDE.md conflict persisting after remediation impact evaluation: When the suggestion execution AI (Phase 4) modifies CLAUDE.md, the final fullPatch captures that state instead of @AGENTS.md. The impact evaluation then re-finds the conflict. Fix: re-apply consolidation after Phase 4, before captureGitDiff().
serializeRemediation() / updateCompletedRemediation() — stop stripping; add to planData:
typescript
if (result.errorFixStats?.prompt) planData.errorFixPrompt = result.errorFixStats.prompt;
if (result.suggestionEnrichStats?.prompt) planData.suggestionEnrichPrompt = result.suggestionEnrichStats.prompt;
Add 4 collapsible prompt sections (using the existing CollapsiblePlanSection component), grouped logically near the existing plan response sections:
code
[Errors section]
→ "Error Fix Plan Prompt" (errorPlanPrompt) — NEW
→ "Error Fix Plan" (errorPlan) — already shown
→ "Error Fix Execution Prompt" (errorFixPrompt) — NEW
[Suggestions section]
→ "Suggestion Plan Prompt" (suggestionPlanPrompt) — NEW
→ "Suggestion Enrichment Plan" (suggestionPlan) — already shown
→ "Suggestion Execution Prompt" (suggestionEnrichPrompt) — NEW
Use the existing CollapsiblePlanSection component for each. No new component needed.
Part 2: Fix CLAUDE.md Consolidation in fullPatch
Change
src/shared/remediation/engine.ts — add re-consolidation between Phase 4 completion (line ~624) and captureGitDiff() (line ~628):
typescript
// Re-consolidate to ensure AI hasn't overwritten CLAUDE.md during phases 2/4
if (colocatedPairs.length > 0) {
await consolidateColocatedFiles(workDir, colocatedPairs);
}
consolidateColocatedFiles() already skips pairs where CLAUDE.md is already @AGENTS.md, so this is a no-op when AI behaved correctly.
Run a full remediation via bun run dev; open the remediation card in the UI and verify all 4 prompt sections appear (collapsible)
Confirm prompts are long-form text (matching what buildErrorPlanPrompt() / buildSuggestionExecutionPrompt() generate)
For the CLAUDE.md fix: run a remediation on a repo with conflicting files, then "Evaluate Impact" — confirm no conflict issue in the result
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/cedricteyton/.REDACTED.jsonl
Assistant
Now let me read the RemediationHistoryCard and the engine.ts around the consolidation area:
Assistant
Now I have a clear picture. Let me implement all 4 changes in parallel:
Assistant
Now stop stripping the execution prompts in saveRemediation() and add them to planData:
Assistant
Now add the 4 CollapsiblePlanSection entries to RemediationHistoryCard.tsx:
Assistant
Now fix the CLAUDE.md re-consolidation in engine.ts. Let me look at the exact context around line 624:
Assistant
Now run tests:
Assistant
All 1309 tests pass. Now run lint:
Assistant
All tests pass and lint is clean. Let me mark all tasks complete:
Assistant
Done. Here's a summary of all changes made:
Part 1 — Surface all 4 prompts:
src/api/db/remediation-repository.ts: Added errorFixPrompt and suggestionEnrichPrompt fields to IRemediationPlanData. In saveRemediation(), instead of silently dropping the execution prompts, they're now extracted from result.errorFixStats.prompt and result.suggestionEnrichStats.prompt and stored in planData.
frontend/src/types/remediation.ts: Added errorFixPrompt and suggestionEnrichPrompt to the PlanData interface.
frontend/src/components/RemediationHistoryCard.tsx: Added 4 CollapsiblePlanSection entries in this order: Error Fix Plan Prompt → Error Fix Plan → Error Fix Execution Prompt → Suggestion Plan Prompt → Suggestion Enrichment Plan → Suggestion Execution Prompt.
Part 2 — Fix CLAUDE.md re-consolidation:
src/shared/remediation/engine.ts: Added a call to consolidateColocatedFiles(workDir, colocatedPairs) after Phase 4 completes and before captureGitDiff(). This ensures that if the AI wrote new content to CLAUDE.md during execution phases, it gets re-consolidated back to @AGENTS.md before the final diff is captured.
User
Verification
Run bun run test — no existing tests should break
Run bun run lint — no lint errors
Run a full remediation via bun run dev; open the remediation card in the UI and verify all 4 prompt sections appear (collapsible)
Confirm prompts are long-form text (matching what buildErrorPlanPrompt() / buildSuggestionExecutionPrompt() generate)
For the CLAUDE.md fix: run a remediation on a repo with conflicting files, then "Evaluate Impact" — confirm no conflict issue in the result
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/cedricteyton/.REDACTED.jsonl
src/shared/remediation/engine.ts — add re-consolidation between Phase 4 completion (line ~624) and captureGitDiff() (line ~628):
typescript
// Re-consolidate to ensure AI hasn't overwritten CLAUDE.md during phases 2/4
if (colocatedPairs.length > 0) {
await consolidateColocatedFiles(workDir, colocatedPairs);
}
consolidateColocatedFiles() already skips pairs where CLAUDE.md is already @AGENTS.md, so this is a no-op when AI behaved correctly.
serializeRemediation() / updateCompletedRemediation() — stop stripping; add to planData:
typescript
if (result.errorFixStats?.prompt) planData.errorFixPrompt = result.errorFixStats.prompt;
if (result.suggestionEnrichStats?.prompt) planData.suggestionEnrichPrompt = result.suggestionEnrichStats.prompt;