[Feature Request] Auto-generate session summaries on /compact command and context limits
๐ฏ Problem
When Claude Code sessions end or reach context limits, valuable work context is
lost. Users must manually request session summaries before closing (usually forgets), leading to
frustration and lost productivity when starting new sessions.
## ๐ Proposed Solution
Add automated session summary generation that triggers on /compact command or
context limits, creating timestamped files like
SESSION-SUMMARY-2025-08-31-1430.md with:
- Session metadata and work completed
- File locations and key decisions
- Current state and next steps
- Automatic CLAUDE.md references
## ๐ผ User Impact
- Seamless continuity between sessions
- Better documentation of AI-assisted development
- Reduced frustration with context limits
- Enhanced professional development workflows
## ๐ง Implementation Ideas
Built-in Feature Integration
Extend the existing /compact command to auto-generate session summaries before
compaction:
// Enhanced /compact command flow
async function compactCommand() {
// 1. Generate session summary before compaction
const summary = await generateSessionSummary();
const filename = SESSION-SUMMARY-${getTimestamp()}.md;
await writeFile(filename, summary);
// 2. Update project context files
await updateClaudeConfig(filename);
// 3. Proceed with normal compaction
await compactConversation();
// 4. Notify user
console.log(โ
Session summary saved: ${filename});
}
Add new /session-summary command for manual generation:
async function sessionSummaryCommand(args) {
const template = args.template || 'standard';
const summary = await generateSessionSummary(template);
const filename = SESSION-SUMMARY-${getTimestamp()}.md;
await writeFile(filename, summary);
return Session summary created: ${filename};
}
Configuration system:
session_summary:
auto_generate: true # Auto-generate on /compact
auto_on_context_limit: true # Generate when context limit reached
location: "./" # Save to project root directory
update_claude_md: true # Auto-update CLAUDE.md references
template: "standard" # Default summary format
include_file_changes: true # Track modified files
max_length: 2000 # Word limit for summaries
Smart session analysis:
async function generateSessionSummary(template = 'standard') {
return {
metadata: {
date: new Date().toISOString().split('T')[0],
duration: estimateSessionDuration(),
contextLength: getCurrentTokenCount(),
claudeModel: getModelVersion()
},
objective: extractMainObjective(), // Analyze early conversation
workCompleted: analyzeFileOperations(), // Track created/modified files
keyDecisions: extractDecisionPoints(), // Identify important choices
currentState: assessProjectState(), // What's working/broken
nextSteps: generateActionItems(), // Based on incomplete work
fileLocations: getImportantFilePaths() // Critical file references
};
}
Automatic project integration:
// Auto-update project context files
async function updateProjectContext(summaryFilename) {
// Update CLAUDE.md with session reference
if (fileExists('CLAUDE.md')) {
const reference = ## ๐ Recent Session: ${getDate()}\n**Summary**:;
${summaryFilename}\n
await appendToFile('CLAUDE.md', reference);
}
// Optional: commit to git if repository detected
if (fileExists('.git/config')) {
await gitAdd(summaryFilename);
await gitCommit(Add session summary: ${summaryFilename});
}
}
User experience:
User: /compact
Claude: "Generating session summary... โ
Session summary saved: SESSION-SUMMARY-2025-08-31-1430.md
Updated CLAUDE.md with session reference.
Compacting conversation..."
// Or when context limit reached:
Claude: "Context limit reached. Saving session summary...
Summary: SESSION-SUMMARY-2025-08-31-1430.md โ
Compacting to continue..."
Benefits of this approach:
- Seamless integration with existing /compact workflow
- Zero learning curve - works automatically with current commands
- Configurable - users can customize behavior via settings
- Project-aware - automatically integrates with CLAUDE.md and git
- Backwards compatible - doesn't break existing /compact functionality
## ๐ Business Value
This addresses a fundamental UX issue and would differentiate Claude Code from
other AI coding tools by making it more suitable for serious development work.
---
*Created from real user pain point - happy to provide more details or test
implementations!*
This issue has 8 comments on GitHub. Read the full discussion on GitHub โ