[FEATURE] Pre-Compact Auto-Save and Improved Summarization

Resolved 💬 5 comments Opened Dec 6, 2025 by EMarkODell Closed Feb 27, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Problem Statement

Currently, Claude Code's auto-compact feature creates summaries that omit critical debugging information, including:

  • Error messages and stack traces
  • Failed attempts and why they failed
  • Problem-solving iterations
  • Complete context of what was tried
  • Temporary variables and intermediate results

User Impact

When users search conversation history for past errors or debugging sessions, they find information has "vanished." This:

  1. Breaks debugging workflows - Cannot review what went wrong previously
  2. Causes repeated mistakes - AI may repeat failed approaches it doesn't remember
  3. Blocks learning - Users cannot learn from documented failures
  4. Erodes trust - Information disappears without warning or explanation
  5. No user control - Cannot prevent, delay, or preview compaction

Current Behavior

  • User sees brief notification: "Conversation compacted · ctrl+o for history"
  • Compaction happens automatically at token limits (~180K-200K tokens)
  • Summary omits errors, debugging context, and failed attempts
  • No advance warning or ability to save before compaction
  • No way to recover lost information

---

Proposed Solution

Proposed Solutions

Priority 1: Pre-Compact Auto-Save (CRITICAL)

Implement automatic /save_claude before every auto-compact operation.

Implementation:

1. When token usage approaches compact threshold (e.g., 175K tokens)
2. Automatically trigger: /save_claude
3. Wait for save to complete
4. Then proceed with auto-compact
5. Notify user: "Conversation saved before compacting"

Benefits:

  • ✅ Preserves complete transcript including all errors/debugging
  • ✅ No user action required
  • ✅ Backward compatible - existing saves continue to work
  • ✅ Minimal performance impact
  • ✅ Simple implementation

Alternative: Configurable Hook

{
  "hooks": {
    "beforeCompact": {
      "command": "~/AI_claude/hist/.save_conversation.sh",
      "timeout": 5000
    }
  }
}

This allows users to customize pre-compact behavior.

---

Priority 2: Richer Summaries (HIGH)

Preserve debugging context in auto-compact summaries.

Include in summaries:

  • ✅ Error messages with full stack traces
  • ✅ Failed attempts and why they failed
  • ✅ Debugging iterations and solutions
  • ✅ Warnings and edge cases discovered
  • ✅ Performance issues identified
  • ✅ Unresolved problems/blockers

Current summary format (simplified):


Summary:
User requested feature X.
Assistant implemented feature X.
Tests passed.

Improved summary format:

Summary:
User requested feature X.
Assistant implemented feature X.

Initial approach failed with error: [full error]
Reason: [explanation]

Second approach succeeded with changes:
- [specific changes]

Tests passed after fixing:
- [test failure details]
- [solution applied]

Unresolved issues:
- [open problems]

---

Priority 3: Compaction Preview (MEDIUM)

Show users what will be lost before compacting.

UI Flow:

Token limit approaching (180K/200K)

Options:
[1] Compact now (show preview of what will be summarized)
[2] Save full transcript first, then compact
[3] Continue without compacting (may affect performance)

Preview:
- 47 error messages will be summarized
- 12 failed attempts will be condensed
- 200+ lines of debugging output will be reduced

Benefits:

  • Users make informed decisions
  • Can save important sessions manually first
  • Transparency builds trust

---

Priority 4: Manual Compaction Control (LOW)

Allow users to trigger compaction manually.

Commands:

/compact              # Compact now
/compact preview      # Show what would be compacted
/compact disable      # Disable auto-compact (with warnings)
/compact force        # Force compact even if below threshold

Use cases:

  • User wants to compact at a logical stopping point
  • User knows next task will need full context
  • User wants to start fresh after debugging

---

Priority 5: Full Transcript Preservation (LOW)

Keep complete uncompacted history in background storage.

Implementation:

  • Auto-save full transcript to .claude/cache/full_history/
  • Summaries used for active context
  • Full history available via: /history full
  • Configurable retention (7 days, 30 days, forever)

Benefits:

  • No information ever lost
  • Users can retrieve any past detail
  • Debugging history always available

---

Alternative Solutions

_No response_

Priority

High - Significant impact on productivity

Feature Category

CLI commands and flags

Use Case Example

Use Case Example

Current Behavior (Problematic)

Session 1: User debugging HTM encoding bug
- Tried approach A: Failed with error X
- Tried approach B: Failed with error Y
- Tried approach C: Success!

[Auto-compact happens]

Session 2: User wants to review why A and B failed
- Searches transcript: "error X" → NO RESULTS
- Searches transcript: "approach A" → NO RESULTS
- Information lost, user confused

Proposed Behavior (Fixed)

Session 1: User debugging HTM encoding bug
- Tried approach A: Failed with error X
- Tried approach B: Failed with error Y
- Tried approach C: Success!

[Token limit reached: 178K tokens]
→ Auto-save triggered: ~/AI_claude/hist/2025-12-06_14-30-00.txt
→ Saved 178K tokens, 2.1 MB
→ Creating summary (preserving errors and failures)
→ Auto-compact complete

Session 2: User wants to review why A and B failed
- Searches transcript: "error X" → FOUND in summary
- OR opens saved file: ~/AI_claude/hist/2025-12-06_14-30-00.txt
- Complete information preserved

Additional Context

Feature Request: Pre-Compact Auto-Save and Improved Summarization

Date: 2025-12-06
Product: Claude Code CLI
Priority: High - UX/Trust Issue
Category: Conversation Management

---

Summary

Request automatic conversation saving before auto-compact and improved summarization that preserves debugging context and error history.

---

Problem Statement

Currently, Claude Code's auto-compact feature creates summaries that omit critical debugging information, including:

  • Error messages and stack traces
  • Failed attempts and why they failed
  • Problem-solving iterations
  • Complete context of what was tried
  • Temporary variables and intermediate results

User Impact

When users search conversation history for past errors or debugging sessions, they find information has "vanished." This:

  1. Breaks debugging workflows - Cannot review what went wrong previously
  2. Causes repeated mistakes - AI may repeat failed approaches it doesn't remember
  3. Blocks learning - Users cannot learn from documented failures
  4. Erodes trust - Information disappears without warning or explanation
  5. No user control - Cannot prevent, delay, or preview compaction

Current Behavior

  • User sees brief notification: "Conversation compacted · ctrl+o for history"
  • Compaction happens automatically at token limits (~180K-200K tokens)
  • Summary omits errors, debugging context, and failed attempts
  • No advance warning or ability to save before compaction
  • No way to recover lost information

---

Proposed Solutions

Priority 1: Pre-Compact Auto-Save (CRITICAL)

Implement automatic /save_claude before every auto-compact operation.

Implementation:

1. When token usage approaches compact threshold (e.g., 175K tokens)
2. Automatically trigger: /save_claude
3. Wait for save to complete
4. Then proceed with auto-compact
5. Notify user: "Conversation saved before compacting"

Benefits:

  • ✅ Preserves complete transcript including all errors/debugging
  • ✅ No user action required
  • ✅ Backward compatible - existing saves continue to work
  • ✅ Minimal performance impact
  • ✅ Simple implementation

Alternative: Configurable Hook

{
  "hooks": {
    "beforeCompact": {
      "command": "~/AI_claude/hist/.save_conversation.sh",
      "timeout": 5000
    }
  }
}

This allows users to customize pre-compact behavior.

---

Priority 2: Richer Summaries (HIGH)

Preserve debugging context in auto-compact summaries.

Include in summaries:

  • ✅ Error messages with full stack traces
  • ✅ Failed attempts and why they failed
  • ✅ Debugging iterations and solutions
  • ✅ Warnings and edge cases discovered
  • ✅ Performance issues identified
  • ✅ Unresolved problems/blockers

Current summary format (simplified):

Summary:
User requested feature X.
Assistant implemented feature X.
Tests passed.

Improved summary format:

Summary:
User requested feature X.
Assistant implemented feature X.

Initial approach failed with error: [full error]
Reason: [explanation]

Second approach succeeded with changes:
- [specific changes]

Tests passed after fixing:
- [test failure details]
- [solution applied]

Unresolved issues:
- [open problems]

---

Priority 3: Compaction Preview (MEDIUM)

Show users what will be lost before compacting.

UI Flow:

Token limit approaching (180K/200K)

Options:
[1] Compact now (show preview of what will be summarized)
[2] Save full transcript first, then compact
[3] Continue without compacting (may affect performance)

Preview:
- 47 error messages will be summarized
- 12 failed attempts will be condensed
- 200+ lines of debugging output will be reduced

Benefits:

  • Users make informed decisions
  • Can save important sessions manually first
  • Transparency builds trust

---

Priority 4: Manual Compaction Control (LOW)

Allow users to trigger compaction manually.

Commands:

/compact              # Compact now
/compact preview      # Show what would be compacted
/compact disable      # Disable auto-compact (with warnings)
/compact force        # Force compact even if below threshold

Use cases:

  • User wants to compact at a logical stopping point
  • User knows next task will need full context
  • User wants to start fresh after debugging

---

Priority 5: Full Transcript Preservation (LOW)

Keep complete uncompacted history in background storage.

Implementation:

  • Auto-save full transcript to .claude/cache/full_history/
  • Summaries used for active context
  • Full history available via: /history full
  • Configurable retention (7 days, 30 days, forever)

Benefits:

  • No information ever lost
  • Users can retrieve any past detail
  • Debugging history always available

---

Use Case Example

Current Behavior (Problematic)

Session 1: User debugging HTM encoding bug
- Tried approach A: Failed with error X
- Tried approach B: Failed with error Y
- Tried approach C: Success!

[Auto-compact happens]

Session 2: User wants to review why A and B failed
- Searches transcript: "error X" → NO RESULTS
- Searches transcript: "approach A" → NO RESULTS
- Information lost, user confused

Proposed Behavior (Fixed)

Session 1: User debugging HTM encoding bug
- Tried approach A: Failed with error X
- Tried approach B: Failed with error Y
- Tried approach C: Success!

[Token limit reached: 178K tokens]
→ Auto-save triggered: ~/AI_claude/hist/2025-12-06_14-30-00.txt
→ Saved 178K tokens, 2.1 MB
→ Creating summary (preserving errors and failures)
→ Auto-compact complete

Session 2: User wants to review why A and B failed
- Searches transcript: "error X" → FOUND in summary
- OR opens saved file: ~/AI_claude/hist/2025-12-06_14-30-00.txt
- Complete information preserved

---

Technical Requirements

Pre-Compact Auto-Save

Required:

  • Hook into compaction trigger (before summarization)
  • Call existing /save_claude functionality
  • Handle save failures gracefully
  • Notify user of save location
  • Continue with compact after save

Estimated complexity: Low (1-2 days)
Estimated risk: Low (uses existing save mechanism)

Improved Summaries

Required:

  • Modify summarization prompt to preserve:
  • Error messages (full text)
  • Failed attempts (with reasons)
  • Debugging iterations
  • Unresolved issues
  • Increase summary budget for error context
  • Add structured sections (Errors, Warnings, Unresolved)

Estimated complexity: Medium (3-5 days)
Estimated risk: Medium (requires prompt tuning)

---

Success Metrics

Measure improvement by:

  1. User Trust
  • % of users who report "lost information" issues
  • Target: Reduce by 90%
  1. Debugging Efficiency
  • Time to find past error information
  • Target: < 30 seconds (vs. "not found" currently)
  1. Repeated Mistakes
  • Instances where AI repeats previously failed approach
  • Target: Reduce by 80%
  1. Manual Saves
  • Frequency of manual /save_claude commands
  • Target: Reduce by 50% (automation replaces manual)

---

Alternatives Considered

1. Larger Context Window

Pros: Delays compaction
Cons: Higher cost, doesn't solve fundamental issue
Verdict: Not sufficient alone

2. User-Only Manual Saves

Pros: Simple, already exists
Cons: Relies on user remembering, easy to forget
Verdict: Insufficient - users forget or don't know when to save

3. External Transcript Logging

Pros: Complete preservation
Cons: Users must configure separately, extra complexity
Verdict: Good supplement but not replacement for auto-save

4. No Compaction (Unlimited Context)

Pros: No information loss
Cons: Technically infeasible, extremely expensive
Verdict: Not realistic

---

Backward Compatibility

All proposed changes are backward compatible:

  • ✅ Pre-compact save uses existing /save_claude infrastructure
  • ✅ Improved summaries enhance (don't replace) existing format
  • ✅ Manual controls are additive (new commands)
  • ✅ Full preservation is opt-in configuration
  • ✅ No breaking changes to existing workflows

---

Implementation Priority

Phase 1 (MVP): Pre-Compact Auto-Save

  • Impact: High - Solves 80% of the problem
  • Effort: Low - Uses existing save mechanism
  • Timeline: 1-2 weeks

Phase 2: Improved Summaries

  • Impact: Medium - Better immediate context
  • Effort: Medium - Requires prompt engineering
  • Timeline: 3-4 weeks

Phase 3: Preview & Control

  • Impact: Medium - Better UX
  • Effort: Medium - New UI components
  • Timeline: 4-6 weeks

Phase 4: Full Preservation

  • Impact: Low - Nice-to-have for power users
  • Effort: High - Storage, retrieval, UI
  • Timeline: 2-3 months

---

User Feedback

Actual user quote:

"this may explain why so often when I go looking back in the transcript, stuff seems to have vanished ... most notably every time 'you' make an 'error' or something does not work as expected ... which is a HUUUUUUUUUUUUUUUUUUUGE bug to me ... this is a MAJOR problem"

Pain points identified:

  • Information disappears without warning
  • Cannot review past errors
  • Cannot learn from documented failures
  • Erodes trust in the tool
  • No control or visibility into compaction

---

Request

Please implement Priority 1 (Pre-Compact Auto-Save) as soon as possible. This single change would dramatically improve user trust and debugging workflows.

Minimal viable implementation:

def auto_compact():
    if token_count > COMPACT_THRESHOLD:
        # NEW: Save before compacting
        save_result = execute_slash_command("/save_claude")
        notify_user(f"Conversation saved: {save_result.path}")

        # Existing: Proceed with compact
        summary = create_summary()
        replace_history_with_summary(summary)
        notify_user("Conversation compacted · ctrl+o for history")

Estimated effort: 1-2 days
Impact: Solves critical user trust issue
Risk: Low (uses existing tested save mechanism)

---

Contact

For questions or discussion about this feature request:

---

Thank you for considering this request. This feature would significantly improve the Claude Code debugging experience and user trust.

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗